@anji-dashing/dam-solution-v2 5.8.173

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (259) hide show
  1. package/README.md +53 -0
  2. package/build/AssetType/AddFieldProperties.d.ts +10 -0
  3. package/build/AssetType/AddFieldProperties.js +359 -0
  4. package/build/AssetType/AssetTemplatesTable.d.ts +10 -0
  5. package/build/AssetType/AssetTemplatesTable.js +172 -0
  6. package/build/AssetType/CreateAssetTemplate.d.ts +3 -0
  7. package/build/AssetType/CreateAssetTemplate.js +70 -0
  8. package/build/AssetType/CreateOrEditAssetTemplate.d.ts +1 -0
  9. package/build/AssetType/CreateOrEditAssetTemplate.js +100 -0
  10. package/build/AssetType/DraggedField.d.ts +14 -0
  11. package/build/AssetType/DraggedField.js +58 -0
  12. package/build/AssetType/EditAssetTemplate.d.ts +5 -0
  13. package/build/AssetType/EditAssetTemplate.js +257 -0
  14. package/build/AssetType/FieldsSection.d.ts +14 -0
  15. package/build/AssetType/FieldsSection.js +268 -0
  16. package/build/AssetType/assetTemplatesContainer.d.ts +2 -0
  17. package/build/AssetType/assetTemplatesContainer.js +71 -0
  18. package/build/AssetType/fieldProperties/DateField.d.ts +5 -0
  19. package/build/AssetType/fieldProperties/DateField.js +23 -0
  20. package/build/AssetType/fieldProperties/NumberField.d.ts +5 -0
  21. package/build/AssetType/fieldProperties/NumberField.js +91 -0
  22. package/build/AssetType/fieldProperties/OptionsField.d.ts +6 -0
  23. package/build/AssetType/fieldProperties/OptionsField.js +55 -0
  24. package/build/AssetType/fieldProperties/TextField.d.ts +5 -0
  25. package/build/AssetType/fieldProperties/TextField.js +92 -0
  26. package/build/AssetType/index.d.ts +11 -0
  27. package/build/AssetType/index.js +25 -0
  28. package/build/AssetType/routes.d.ts +3 -0
  29. package/build/AssetType/routes.js +17 -0
  30. package/build/BookView/ProductDescription.d.ts +4 -0
  31. package/build/BookView/ProductDescription.js +20 -0
  32. package/build/BookView/bookDetail.d.ts +4 -0
  33. package/build/BookView/bookDetail.js +106 -0
  34. package/build/BookView/bookInfo.d.ts +4 -0
  35. package/build/BookView/bookInfo.js +17 -0
  36. package/build/BookView/description.d.ts +4 -0
  37. package/build/BookView/description.js +5 -0
  38. package/build/BookView/index.d.ts +10 -0
  39. package/build/BookView/index.js +23 -0
  40. package/build/CreateClient/CreateClientBtn.d.ts +14 -0
  41. package/build/CreateClient/CreateClientBtn.js +54 -0
  42. package/build/CreateClient/CreateClientForm.d.ts +15 -0
  43. package/build/CreateClient/CreateClientForm.js +347 -0
  44. package/build/CreateClient/index.d.ts +20 -0
  45. package/build/CreateClient/index.js +18 -0
  46. package/build/ImagePicker/MetaFieldOptions.d.ts +14 -0
  47. package/build/ImagePicker/MetaFieldOptions.js +75 -0
  48. package/build/ImagePicker/TestImagePickerModal.d.ts +8 -0
  49. package/build/ImagePicker/TestImagePickerModal.js +72 -0
  50. package/build/ImagePicker/TestImgFromMetaData.d.ts +7 -0
  51. package/build/ImagePicker/TestImgFromMetaData.js +82 -0
  52. package/build/ImagePicker/imagePickerComponent.d.ts +6 -0
  53. package/build/ImagePicker/imagePickerComponent.js +63 -0
  54. package/build/ImagePicker/index.d.ts +13 -0
  55. package/build/ImagePicker/index.js +24 -0
  56. package/build/ImagePicker/routes.d.ts +6 -0
  57. package/build/ImagePicker/routes.js +17 -0
  58. package/build/ImagePickerFilters/ImagePickerFiltersComponent.d.ts +8 -0
  59. package/build/ImagePickerFilters/ImagePickerFiltersComponent.js +223 -0
  60. package/build/ImagePickerFilters/index.d.ts +12 -0
  61. package/build/ImagePickerFilters/index.js +19 -0
  62. package/build/MyDrive/ActionBar.d.ts +8 -0
  63. package/build/MyDrive/ActionBar.js +190 -0
  64. package/build/MyDrive/AddDrive.d.ts +5 -0
  65. package/build/MyDrive/AddDrive.js +189 -0
  66. package/build/MyDrive/AddFolder.d.ts +11 -0
  67. package/build/MyDrive/AddFolder.js +165 -0
  68. package/build/MyDrive/BreadCrumbList.d.ts +10 -0
  69. package/build/MyDrive/BreadCrumbList.js +81 -0
  70. package/build/MyDrive/BulkUploadModal.d.ts +2 -0
  71. package/build/MyDrive/BulkUploadModal.js +324 -0
  72. package/build/MyDrive/DriveContainer.d.ts +14 -0
  73. package/build/MyDrive/DriveContainer.js +343 -0
  74. package/build/MyDrive/FileDownloadHistory.d.ts +7 -0
  75. package/build/MyDrive/FileDownloadHistory.js +107 -0
  76. package/build/MyDrive/FileMenuOptions.d.ts +11 -0
  77. package/build/MyDrive/FileMenuOptions.js +450 -0
  78. package/build/MyDrive/FilesGridView.d.ts +9 -0
  79. package/build/MyDrive/FilesGridView.js +25 -0
  80. package/build/MyDrive/FolderGridView.d.ts +20 -0
  81. package/build/MyDrive/FolderGridView.js +95 -0
  82. package/build/MyDrive/FolderListView.d.ts +26 -0
  83. package/build/MyDrive/FolderListView.js +226 -0
  84. package/build/MyDrive/FolderMenuOptions.d.ts +5 -0
  85. package/build/MyDrive/FolderMenuOptions.js +350 -0
  86. package/build/MyDrive/FolderTree.d.ts +8 -0
  87. package/build/MyDrive/FolderTree.js +479 -0
  88. package/build/MyDrive/ImageEditor/EditImage.d.ts +6 -0
  89. package/build/MyDrive/ImageEditor/EditImage.js +97 -0
  90. package/build/MyDrive/ImageEditor/EditImageModal.d.ts +8 -0
  91. package/build/MyDrive/ImageEditor/EditImageModal.js +30 -0
  92. package/build/MyDrive/ImageEditor/TuiImageEditor.d.ts +10 -0
  93. package/build/MyDrive/ImageEditor/TuiImageEditor.js +99 -0
  94. package/build/MyDrive/ImagePickerBreadCrumbList.d.ts +8 -0
  95. package/build/MyDrive/ImagePickerBreadCrumbList.js +35 -0
  96. package/build/MyDrive/ImagePickerDrive.d.ts +1 -0
  97. package/build/MyDrive/ImagePickerDrive.js +41 -0
  98. package/build/MyDrive/MyDriveMainContainer.d.ts +6 -0
  99. package/build/MyDrive/MyDriveMainContainer.js +63 -0
  100. package/build/MyDrive/SearchFilter.d.ts +8 -0
  101. package/build/MyDrive/SearchFilter.js +73 -0
  102. package/build/MyDrive/ShareBtn.d.ts +5 -0
  103. package/build/MyDrive/ShareBtn.js +19 -0
  104. package/build/MyDrive/ToggleView.d.ts +4 -0
  105. package/build/MyDrive/ToggleView.js +12 -0
  106. package/build/MyDrive/UploadStatusModal.d.ts +12 -0
  107. package/build/MyDrive/UploadStatusModal.js +52 -0
  108. package/build/MyDrive/fileDetails/CommentEntity.d.ts +8 -0
  109. package/build/MyDrive/fileDetails/CommentEntity.js +102 -0
  110. package/build/MyDrive/fileDetails/Comments.d.ts +6 -0
  111. package/build/MyDrive/fileDetails/Comments.js +65 -0
  112. package/build/MyDrive/fileDetails/Compliance.d.ts +2 -0
  113. package/build/MyDrive/fileDetails/Compliance.js +18 -0
  114. package/build/MyDrive/fileDetails/CreateComment.d.ts +7 -0
  115. package/build/MyDrive/fileDetails/CreateComment.js +48 -0
  116. package/build/MyDrive/fileDetails/Editor.d.ts +6 -0
  117. package/build/MyDrive/fileDetails/Editor.js +55 -0
  118. package/build/MyDrive/fileDetails/EmojiPicker.d.ts +5 -0
  119. package/build/MyDrive/fileDetails/EmojiPicker.js +6 -0
  120. package/build/MyDrive/fileDetails/FileDetails.d.ts +11 -0
  121. package/build/MyDrive/fileDetails/FileDetails.js +125 -0
  122. package/build/MyDrive/fileDetails/FileHeader.d.ts +7 -0
  123. package/build/MyDrive/fileDetails/FileHeader.js +27 -0
  124. package/build/MyDrive/fileDetails/FileViewer.d.ts +10 -0
  125. package/build/MyDrive/fileDetails/FileViewer.js +17 -0
  126. package/build/MyDrive/fileDetails/ImageOptions.d.ts +2 -0
  127. package/build/MyDrive/fileDetails/ImageOptions.js +44 -0
  128. package/build/MyDrive/fileDetails/ImageViewer.d.ts +6 -0
  129. package/build/MyDrive/fileDetails/ImageViewer.js +16 -0
  130. package/build/MyDrive/fileDetails/ManageFile.d.ts +7 -0
  131. package/build/MyDrive/fileDetails/ManageFile.js +34 -0
  132. package/build/MyDrive/fileDetails/MetaForm.d.ts +15 -0
  133. package/build/MyDrive/fileDetails/MetaForm.js +199 -0
  134. package/build/MyDrive/fileDetails/Metadata.d.ts +8 -0
  135. package/build/MyDrive/fileDetails/Metadata.js +52 -0
  136. package/build/MyDrive/fileDetails/PdfOptions.d.ts +9 -0
  137. package/build/MyDrive/fileDetails/PdfOptions.js +35 -0
  138. package/build/MyDrive/fileDetails/PdfViewer.d.ts +8 -0
  139. package/build/MyDrive/fileDetails/PdfViewer.js +18 -0
  140. package/build/MyDrive/fileDetails/Previewdetails.d.ts +10 -0
  141. package/build/MyDrive/fileDetails/Previewdetails.js +53 -0
  142. package/build/MyDrive/fileDetails/VideoPlayer.d.ts +4 -0
  143. package/build/MyDrive/fileDetails/VideoPlayer.js +21 -0
  144. package/build/MyDrive/files/AssetSelectionFormItem.d.ts +7 -0
  145. package/build/MyDrive/files/AssetSelectionFormItem.js +14 -0
  146. package/build/MyDrive/files/FolderTabs.d.ts +6 -0
  147. package/build/MyDrive/files/FolderTabs.js +90 -0
  148. package/build/MyDrive/files/MapFile.d.ts +9 -0
  149. package/build/MyDrive/files/MapFile.js +239 -0
  150. package/build/MyDrive/files/MoveToAnotherFolder.d.ts +9 -0
  151. package/build/MyDrive/files/MoveToAnotherFolder.js +67 -0
  152. package/build/MyDrive/filesListView.d.ts +2 -0
  153. package/build/MyDrive/filesListView.js +57 -0
  154. package/build/MyDrive/index.d.ts +16 -0
  155. package/build/MyDrive/index.js +50 -0
  156. package/build/MyDrive/routes.d.ts +10 -0
  157. package/build/MyDrive/routes.js +12 -0
  158. package/build/PenView/PenDetails.d.ts +4 -0
  159. package/build/PenView/PenDetails.js +114 -0
  160. package/build/PenView/ProductDescription.d.ts +5 -0
  161. package/build/PenView/ProductDescription.js +51 -0
  162. package/build/PenView/index.d.ts +10 -0
  163. package/build/PenView/index.js +23 -0
  164. package/build/RefreshKey/RefreshKeyBtn.d.ts +1 -0
  165. package/build/RefreshKey/RefreshKeyBtn.js +42 -0
  166. package/build/RefreshKey/index.d.ts +9 -0
  167. package/build/RefreshKey/index.js +23 -0
  168. package/build/ShoesView/ProductDescription.d.ts +4 -0
  169. package/build/ShoesView/ProductDescription.js +25 -0
  170. package/build/ShoesView/ShoeDetails.d.ts +4 -0
  171. package/build/ShoesView/ShoeDetails.js +96 -0
  172. package/build/ShoesView/index.d.ts +10 -0
  173. package/build/ShoesView/index.js +23 -0
  174. package/build/common/Button.d.ts +2 -0
  175. package/build/common/Button.js +18 -0
  176. package/build/common/CustomElements.d.ts +98 -0
  177. package/build/common/CustomElements.js +77 -0
  178. package/build/common/LoadMoreItems.d.ts +7 -0
  179. package/build/common/LoadMoreItems.js +33 -0
  180. package/build/common/RenderFormItem.d.ts +42 -0
  181. package/build/common/RenderFormItem.js +98 -0
  182. package/build/common/RenderThumnail.d.ts +7 -0
  183. package/build/common/RenderThumnail.js +6 -0
  184. package/build/common/deleteModal.d.ts +1 -0
  185. package/build/common/deleteModal.js +12 -0
  186. package/build/common/folders/TypeAndDateFilters.d.ts +13 -0
  187. package/build/common/folders/TypeAndDateFilters.js +66 -0
  188. package/build/common/folders/getFolderOrFileIcon.d.ts +2 -0
  189. package/build/common/folders/getFolderOrFileIcon.js +41 -0
  190. package/build/common/loader/CustomLoader.d.ts +7 -0
  191. package/build/common/loader/CustomLoader.js +8 -0
  192. package/build/common/loader/loader.d.ts +1 -0
  193. package/build/common/loader/loader.js +6 -0
  194. package/build/common/notifications.d.ts +2 -0
  195. package/build/common/notifications.js +30 -0
  196. package/build/common/steps.d.ts +4 -0
  197. package/build/common/steps.js +7 -0
  198. package/build/hocs/AppProvider.d.ts +3 -0
  199. package/build/hocs/AppProvider.js +11 -0
  200. package/build/hocs/DamConfigContext.d.ts +2 -0
  201. package/build/hocs/DamConfigContext.js +153 -0
  202. package/build/hocs/ThemeContext.d.ts +15 -0
  203. package/build/hocs/ThemeContext.js +131 -0
  204. package/build/hocs/ToastProvider.d.ts +2 -0
  205. package/build/hocs/ToastProvider.js +6 -0
  206. package/build/hocs/appConstants.d.ts +124 -0
  207. package/build/hocs/appConstants.js +211 -0
  208. package/build/hocs/configureAxios.d.ts +2 -0
  209. package/build/hocs/configureAxios.js +65 -0
  210. package/build/hocs/helpers.d.ts +17 -0
  211. package/build/hocs/helpers.js +201 -0
  212. package/build/index.d.ts +12 -0
  213. package/build/index.js +12 -0
  214. package/build/react-query/hooks/brand-hooks.d.ts +3 -0
  215. package/build/react-query/hooks/brand-hooks.js +10 -0
  216. package/build/react-query/hooks/folder-hooks.d.ts +7 -0
  217. package/build/react-query/hooks/folder-hooks.js +119 -0
  218. package/build/react-query/services/brand-services.d.ts +4 -0
  219. package/build/react-query/services/brand-services.js +41 -0
  220. package/build/react-query/services/file-services.d.ts +43 -0
  221. package/build/react-query/services/file-services.js +69 -0
  222. package/build/react-query/services/folder-services.d.ts +46 -0
  223. package/build/react-query/services/folder-services.js +87 -0
  224. package/build/react-query/services/image-picker-services.d.ts +5 -0
  225. package/build/react-query/services/image-picker-services.js +47 -0
  226. package/build/settings/InviteTeamModal.d.ts +12 -0
  227. package/build/settings/InviteTeamModal.js +174 -0
  228. package/build/settings/UpdateInvitationAccessType.d.ts +9 -0
  229. package/build/settings/UpdateInvitationAccessType.js +96 -0
  230. package/build/settings/getUserAvatar.d.ts +7 -0
  231. package/build/settings/getUserAvatar.js +11 -0
  232. package/build/style.css +1 -0
  233. package/build/types/assetType.d.ts +8 -0
  234. package/build/types/assetType.js +1 -0
  235. package/build/ui/pageTitle.d.ts +3 -0
  236. package/build/ui/pageTitle.js +4 -0
  237. package/build/utilities/FoldersContext.d.ts +16 -0
  238. package/build/utilities/FoldersContext.js +15 -0
  239. package/build/utilities/NavigatorProvider.d.ts +2 -0
  240. package/build/utilities/NavigatorProvider.js +10 -0
  241. package/build/utilities/constants/apiUrls.d.ts +97 -0
  242. package/build/utilities/constants/apiUrls.js +117 -0
  243. package/build/utilities/constants/imageUrls.d.ts +6 -0
  244. package/build/utilities/constants/imageUrls.js +6 -0
  245. package/build/utilities/constants/interface.d.ts +371 -0
  246. package/build/utilities/constants/interface.js +142 -0
  247. package/build/utilities/constants/messages.d.ts +55 -0
  248. package/build/utilities/constants/messages.js +55 -0
  249. package/build/utilities/constants/queryKeys.d.ts +16 -0
  250. package/build/utilities/constants/queryKeys.js +33 -0
  251. package/build/utilities/constants/routes.d.ts +22 -0
  252. package/build/utilities/constants/routes.js +22 -0
  253. package/build/utilities/helpers/validators.d.ts +12 -0
  254. package/build/utilities/helpers/validators.js +89 -0
  255. package/build/utilities/useAppNavigate.d.ts +2 -0
  256. package/build/utilities/useAppNavigate.js +35 -0
  257. package/build/utilities/useAppParams.d.ts +8 -0
  258. package/build/utilities/useAppParams.js +72 -0
  259. package/package.json +93 -0
@@ -0,0 +1,347 @@
1
+ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
2
+ function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
3
+ return new (P || (P = Promise))(function (resolve, reject) {
4
+ function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
5
+ function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
6
+ function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
7
+ step((generator = generator.apply(thisArg, _arguments || [])).next());
8
+ });
9
+ };
10
+ import { jsx as _jsx, jsxs as _jsxs, Fragment as _Fragment } from "react/jsx-runtime";
11
+ import { Button, Checkbox, Drawer, Form, Input, Select, Typography } from "antd";
12
+ import { useEffect, useMemo, useState } from "react";
13
+ import { ACCESS_TYPES, DAM_LOCATION_TYPES } from "../hocs/appConstants";
14
+ import { useDamConfig } from "../hocs/DamConfigContext";
15
+ import { CREATE_SUB_BRAND, FETCH_BRAND_USING_SUBDOMAIN, USER_LOGIN } from "../utilities/constants/apiUrls";
16
+ import axios from "axios";
17
+ import { createApiClient } from "../hocs/configureAxios";
18
+ import { getBaseUrl } from "../hocs/helpers";
19
+ import { CREATE_SUCCESS, SOMETHING_WENT_WRONG, } from "../utilities/constants/messages";
20
+ import { NotificationStatus } from "../utilities/constants/interface";
21
+ import { showNotification } from "../common/notifications";
22
+ import { get } from "lodash";
23
+ const CreateClientForm = ({ teamsApi, username, password, toggleShow, onSuccess, clientSubdomain, existingClientData, }) => {
24
+ const damConfig = useDamConfig();
25
+ const { appType } = damConfig;
26
+ const [loading, setLoading] = useState(false);
27
+ const [fetchingClientData, setFetchingClientData] = useState(false);
28
+ const [damLocationType, setDamLocationType] = useState("external");
29
+ const [filteredTeams, setFilteredTeams] = useState([]);
30
+ const [clientData, setClientData] = useState(null);
31
+ const [teamsFetched, setTeamsFetched] = useState(false);
32
+ const [authToken, setAuthToken] = useState(null);
33
+ const [brandIdForUpdate, setBrandIdForUpdate] = useState(null);
34
+ const api = useMemo(() => createApiClient(damConfig), [damConfig]);
35
+ const [form] = Form.useForm();
36
+ const isEditMode = !!existingClientData;
37
+ const onChangeDamLocationType = (e) => {
38
+ setDamLocationType(e);
39
+ form.setFieldValue("dam_location_details", { type: e });
40
+ };
41
+ // Fetch client data when editing
42
+ useEffect(() => {
43
+ const fetchClientData = () => __awaiter(void 0, void 0, void 0, function* () {
44
+ var _a, _b, _c, _d;
45
+ if (isEditMode) {
46
+ setFetchingClientData(true);
47
+ try {
48
+ // Validate that we have required credentials
49
+ if (!(existingClientData === null || existingClientData === void 0 ? void 0 : existingClientData.accessKey) || !(existingClientData === null || existingClientData === void 0 ? void 0 : existingClientData.secretKey) || !(existingClientData === null || existingClientData === void 0 ? void 0 : existingClientData.subdomain)) {
50
+ setFetchingClientData(false);
51
+ return;
52
+ }
53
+ let fetchedData;
54
+ let brandId = (existingClientData === null || existingClientData === void 0 ? void 0 : existingClientData.brandId) || "";
55
+ // If brandId is not provided, try to get it from subdomain first
56
+ if (!(existingClientData === null || existingClientData === void 0 ? void 0 : existingClientData.brandId) && (existingClientData === null || existingClientData === void 0 ? void 0 : existingClientData.subdomain)) {
57
+ try {
58
+ const subdomainResponse = yield api.get(`${FETCH_BRAND_USING_SUBDOMAIN}?subdomain=${existingClientData.subdomain}`);
59
+ const subdomainData = get(subdomainResponse, "data.data", {});
60
+ const extractedBrandId = get(subdomainData, "_id");
61
+ if (extractedBrandId) {
62
+ brandId = extractedBrandId;
63
+ }
64
+ }
65
+ catch (subdomainError) {
66
+ // Failed to fetch by subdomain, continue with empty brandId
67
+ }
68
+ }
69
+ // Step 1: Call login API first with access and secret keys
70
+ const baseUrl = getBaseUrl(appType);
71
+ const loginPayload = {
72
+ accessKey: existingClientData.accessKey,
73
+ secretKey: existingClientData.secretKey,
74
+ subdomain: existingClientData.subdomain,
75
+ teams: [brandId] // Use brandId as team ID
76
+ };
77
+ let token;
78
+ let loginBrandId = brandId;
79
+ try {
80
+ const loginResponse = yield axios.post(`${baseUrl}${USER_LOGIN}`, loginPayload, {
81
+ headers: {
82
+ 'Content-Type': 'application/json',
83
+ 'accept': 'application/json, text/plain, */*'
84
+ }
85
+ });
86
+ token = (_b = (_a = loginResponse === null || loginResponse === void 0 ? void 0 : loginResponse.data) === null || _a === void 0 ? void 0 : _a.data) === null || _b === void 0 ? void 0 : _b.access_token;
87
+ const loginBrandData = (_d = (_c = loginResponse === null || loginResponse === void 0 ? void 0 : loginResponse.data) === null || _c === void 0 ? void 0 : _c.data) === null || _d === void 0 ? void 0 : _d.brand;
88
+ loginBrandId = (loginBrandData === null || loginBrandData === void 0 ? void 0 : loginBrandData._id) || brandId;
89
+ if (!token) {
90
+ setFetchingClientData(false);
91
+ return;
92
+ }
93
+ // Store token and brandId for use in update API
94
+ setAuthToken(token);
95
+ setBrandIdForUpdate(loginBrandId);
96
+ }
97
+ catch (loginError) {
98
+ setFetchingClientData(false);
99
+ return;
100
+ }
101
+ // Step 2: Call brands/details API with the token (only after login succeeds)
102
+ try {
103
+ const brandDetailsResponse = yield axios.get(`${baseUrl}/brands/details/${loginBrandId}`, {
104
+ headers: {
105
+ 'Authorization': `Bearer ${token}`,
106
+ 'accept': 'application/json, text/plain, */*'
107
+ }
108
+ });
109
+ fetchedData = get(brandDetailsResponse, "data.data", {});
110
+ }
111
+ catch (brandDetailsError) {
112
+ // If brand details fetch fails, still set subdomain
113
+ if (existingClientData === null || existingClientData === void 0 ? void 0 : existingClientData.subdomain) {
114
+ form.setFieldValue("subdomain", existingClientData.subdomain);
115
+ }
116
+ setFetchingClientData(false);
117
+ return;
118
+ }
119
+ // Store client data in state
120
+ setClientData(fetchedData);
121
+ setTeamsFetched(false); // Reset teams fetched flag when new client data is loaded
122
+ // Populate form with existing client data
123
+ if (fetchedData && Object.keys(fetchedData).length > 0) {
124
+ const damLocationDetails = get(fetchedData, "damLocationDetails", {});
125
+ const locationType = get(damLocationDetails, "locationType", "");
126
+ // Set DAM location type state first
127
+ if (locationType === "EXTERNAL") {
128
+ setDamLocationType("external");
129
+ }
130
+ else if (locationType === "INTERNAL") {
131
+ setDamLocationType("internal");
132
+ }
133
+ else {
134
+ setDamLocationType("external"); // default
135
+ }
136
+ }
137
+ }
138
+ catch (error) {
139
+ // If fetch fails, still set subdomain
140
+ if (existingClientData === null || existingClientData === void 0 ? void 0 : existingClientData.subdomain) {
141
+ form.setFieldValue("subdomain", existingClientData.subdomain);
142
+ }
143
+ }
144
+ finally {
145
+ setFetchingClientData(false);
146
+ }
147
+ }
148
+ else if (clientSubdomain) {
149
+ form.setFieldValue("subdomain", clientSubdomain);
150
+ }
151
+ });
152
+ fetchClientData();
153
+ }, [isEditMode, existingClientData === null || existingClientData === void 0 ? void 0 : existingClientData.brandId, existingClientData === null || existingClientData === void 0 ? void 0 : existingClientData.subdomain, api, form]);
154
+ const onFinish = (data) => __awaiter(void 0, void 0, void 0, function* () {
155
+ var _a, _b, _c, _d, _e, _f, _g, _h, _j;
156
+ try {
157
+ // Use teamsApiDetails from clientData if available (from API response), otherwise use props
158
+ const teamsApiDetailsFromData = get(clientData, "teamsApiDetails", {});
159
+ const finalTeamsApi = teamsApiDetailsFromData.teamsApi || teamsApi;
160
+ const finalUsername = teamsApiDetailsFromData.username || username;
161
+ const finalPassword = teamsApiDetailsFromData.password || password;
162
+ // Convert adminTeams to strings for API (API expects strings like ["547"] not numbers like [547])
163
+ const adminTeamsAsStrings = Array.isArray(data.adminTeams)
164
+ ? data.adminTeams.map((team) => String(team))
165
+ : [];
166
+ const values = Object.assign(Object.assign({}, data), { adminTeams: adminTeamsAsStrings, showFilePreview: (_a = data.showFilePreview) !== null && _a !== void 0 ? _a : false, accessKey: appType == "reactJs"
167
+ ? process.env.REACT_APP_MIXDRIVE_CLIENT_PARENT_ACCESS_KEY
168
+ : process.env.NEXT_PUBLIC_MIXDRIVE_CLIENT_PARENT_ACCESS_KEY, secretKey: appType == "reactJs"
169
+ ? process.env.REACT_APP_MIXDRIVE_CLIENT_PARENT_SECRET_KEY
170
+ : process.env.NEXT_PUBLIC_MIXDRIVE_CLIENT_PARENT_SECRET_KEY, parentSubdomain: appType == "reactJs"
171
+ ? process.env.REACT_APP_MIXDRIVE_CLIENT_PARENT_SUBDOMAIN
172
+ : process.env.NEXT_PUBLIC_MIXDRIVE_CLIENT_PARENT_SUBDOMAIN, teamsApiDetails: {
173
+ teamsApi: finalTeamsApi,
174
+ username: finalUsername,
175
+ password: finalPassword,
176
+ }, damLocationDetails: damLocationType === "external"
177
+ ? {
178
+ bucket: (_b = data === null || data === void 0 ? void 0 : data.damLocationDetails) === null || _b === void 0 ? void 0 : _b.bucket,
179
+ locationType: "EXTERNAL",
180
+ rootPath: (_c = data === null || data === void 0 ? void 0 : data.damLocationDetails) === null || _c === void 0 ? void 0 : _c.rootPath,
181
+ accessKeyId: (_d = data === null || data === void 0 ? void 0 : data.damLocationDetails) === null || _d === void 0 ? void 0 : _d.accessKeyId,
182
+ secretAccessKey: (_e = data === null || data === void 0 ? void 0 : data.damLocationDetails) === null || _e === void 0 ? void 0 : _e.secretAccessKey,
183
+ url: (_f = data === null || data === void 0 ? void 0 : data.damLocationDetails) === null || _f === void 0 ? void 0 : _f.url,
184
+ region: (_g = data === null || data === void 0 ? void 0 : data.damLocationDetails) === null || _g === void 0 ? void 0 : _g.region,
185
+ }
186
+ : {
187
+ locationType: "INTERNAL",
188
+ rootPath: (_h = data === null || data === void 0 ? void 0 : data.damLocationDetails) === null || _h === void 0 ? void 0 : _h.rootPath,
189
+ } });
190
+ setLoading(true);
191
+ let response;
192
+ const baseUrl = getBaseUrl(appType);
193
+ if (isEditMode && brandIdForUpdate && authToken) {
194
+ // Update existing client: PUT to /brands/{brandId}
195
+ const putResponse = yield axios.put(`${baseUrl}/brands/${brandIdForUpdate}`, values, {
196
+ headers: {
197
+ 'Authorization': `Bearer ${authToken}`,
198
+ 'Content-Type': 'application/json',
199
+ 'accept': 'application/json, text/plain, */*'
200
+ }
201
+ });
202
+ // Extract data from axios response (API returns { data: {...} } or { data: { data: {...} } })
203
+ response = get(putResponse, "data.data", get(putResponse, "data", putResponse));
204
+ }
205
+ else {
206
+ // Create new client: POST to /brands/sub-brand
207
+ response = yield api.post(CREATE_SUB_BRAND, values);
208
+ }
209
+ setLoading(false);
210
+ showNotification((_j = response === null || response === void 0 ? void 0 : response.message) !== null && _j !== void 0 ? _j : (get(response, "message") || CREATE_SUCCESS), NotificationStatus.SUCCESS);
211
+ toggleShow();
212
+ if (onSuccess) {
213
+ onSuccess(response === null || response === void 0 ? void 0 : response.data);
214
+ }
215
+ }
216
+ catch (error) {
217
+ setLoading(false);
218
+ showNotification(get(error, "message", SOMETHING_WENT_WRONG), NotificationStatus.ERROR);
219
+ }
220
+ });
221
+ // Populate form when client data and teams are ready
222
+ useEffect(() => {
223
+ if (clientData && Object.keys(clientData).length > 0) {
224
+ const damLocationDetails = get(clientData, "damLocationDetails", {});
225
+ const locationType = get(damLocationDetails, "locationType", "");
226
+ // Convert adminTeams to numbers if they're strings, to match Select component values
227
+ const adminTeamsData = get(clientData, "adminTeams", []);
228
+ const adminTeamsFormatted = Array.isArray(adminTeamsData)
229
+ ? adminTeamsData.map((team) => {
230
+ const teamNum = typeof team === "string" ? Number(team) : team;
231
+ return teamNum;
232
+ })
233
+ : [];
234
+ form.setFieldsValue({
235
+ name: get(clientData, "name", ""),
236
+ subdomain: get(clientData, "subdomain", (existingClientData === null || existingClientData === void 0 ? void 0 : existingClientData.subdomain) || ""),
237
+ accessTypes: get(clientData, "accessTypes", []),
238
+ adminTeams: adminTeamsFormatted,
239
+ showFilePreview: get(clientData, "showFilePreview", false),
240
+ damLocationDetails: {
241
+ type: locationType === "EXTERNAL" ? "external" : locationType === "INTERNAL" ? "internal" : "external",
242
+ bucket: get(damLocationDetails, "bucket", ""),
243
+ rootPath: get(damLocationDetails, "rootPath", ""),
244
+ accessKeyId: get(damLocationDetails, "accessKeyId", ""),
245
+ secretAccessKey: get(damLocationDetails, "secretAccessKey", ""),
246
+ url: get(damLocationDetails, "url", ""),
247
+ region: get(damLocationDetails, "region", ""),
248
+ },
249
+ });
250
+ }
251
+ }, [clientData, form, existingClientData === null || existingClientData === void 0 ? void 0 : existingClientData.subdomain]);
252
+ // Extract teamsApiDetails from clientData to avoid dependency on entire clientData object
253
+ const teamsApiFromData = useMemo(() => get(clientData, "teamsApiDetails.teamsApi"), [clientData]);
254
+ const usernameFromData = useMemo(() => get(clientData, "teamsApiDetails.username"), [clientData]);
255
+ const passwordFromData = useMemo(() => get(clientData, "teamsApiDetails.password"), [clientData]);
256
+ useEffect(() => {
257
+ // Use teamsApiDetails from clientData if available, otherwise use props
258
+ const finalTeamsApi = teamsApiFromData || teamsApi;
259
+ const finalUsername = usernameFromData || username;
260
+ const finalPassword = passwordFromData || password;
261
+ // Only fetch teams if we have the required credentials and haven't fetched yet
262
+ if (!teamsFetched && finalTeamsApi && finalUsername && finalPassword) {
263
+ fetchTeams(finalTeamsApi, finalUsername, finalPassword);
264
+ setTeamsFetched(true);
265
+ }
266
+ }, [teamsApi, username, password, teamsApiFromData, usernameFromData, passwordFromData, teamsFetched]);
267
+ const fetchTeams = (apiUrl, apiUsername, apiPassword) => __awaiter(void 0, void 0, void 0, function* () {
268
+ var _a, _b;
269
+ try {
270
+ const response = yield axios.get(apiUrl, {
271
+ headers: {
272
+ Authorization: "Basic " + btoa(apiUsername + ":" + apiPassword),
273
+ },
274
+ });
275
+ const options = (_b = (_a = response === null || response === void 0 ? void 0 : response.data) === null || _a === void 0 ? void 0 : _a.data) === null || _b === void 0 ? void 0 : _b.map((team) => {
276
+ return {
277
+ label: (_jsxs(Typography.Text, { style: { display: "flex" }, children: [team === null || team === void 0 ? void 0 : team.id, " ", team === null || team === void 0 ? void 0 : team.name, " ", _jsx("span", { style: { marginLeft: "auto" }, children: team === null || team === void 0 ? void 0 : team.type })] })),
278
+ value: team === null || team === void 0 ? void 0 : team.id,
279
+ key: `${team === null || team === void 0 ? void 0 : team.id} - ${team === null || team === void 0 ? void 0 : team.name} - ${team === null || team === void 0 ? void 0 : team.type}`,
280
+ };
281
+ });
282
+ setFilteredTeams(options);
283
+ }
284
+ catch (err) {
285
+ }
286
+ });
287
+ const shouldShowExternalFields = damLocationType === "external" || isEditMode;
288
+ return (_jsx(Drawer, { open: true, title: isEditMode ? "Edit Client" : "Create Client", onClose: toggleShow, width: 500, maskClosable: false, children: fetchingClientData ? (_jsx("div", { style: { textAlign: "center", padding: "20px" }, children: _jsx(Typography.Text, { children: "Loading client data..." }) })) : (_jsxs(Form, { layout: "vertical", form: form, onFinish: onFinish, children: [_jsx(Form.Item, { label: "Name", name: "name", rules: [
289
+ {
290
+ required: true,
291
+ message: "Name is required",
292
+ },
293
+ ], children: _jsx(Input, { placeholder: "Name" }) }), _jsx(Form.Item, { label: "Access Types", name: "accessTypes", rules: [
294
+ {
295
+ required: true,
296
+ message: "Access type is required",
297
+ },
298
+ ], children: _jsx(Select, { options: ACCESS_TYPES, mode: "multiple", placeholder: "Select Access Type" }) }), _jsx(Form.Item, { label: "Admin Teams", name: "adminTeams", rules: [
299
+ {
300
+ required: true,
301
+ message: "Team Ids is required",
302
+ },
303
+ ], children: _jsx(Select, { showSearch: true, mode: "multiple", placeholder: "Team Ids", options: filteredTeams, optionFilterProp: "key" }) }), _jsxs(Form.Item, { label: "DAM Location Details", name: "damLocationDetails", children: [_jsx(Form.Item, { label: "Type", name: ["damLocationDetails", "type"], rules: [
304
+ {
305
+ required: true,
306
+ message: "Type is required",
307
+ },
308
+ ], children: _jsx(Select, { options: DAM_LOCATION_TYPES, onChange: (e) => {
309
+ onChangeDamLocationType(e);
310
+ }, placeholder: "Type" }) }), _jsx(Form.Item, { label: "Root Path", name: ["damLocationDetails", "rootPath"], rules: [
311
+ {
312
+ required: true,
313
+ message: "Root path is required",
314
+ },
315
+ ], children: _jsx(Input, { placeholder: "Root path" }) }), shouldShowExternalFields && (_jsxs(_Fragment, { children: [_jsx(Form.Item, { label: "Bucket", name: ["damLocationDetails", "bucket"], rules: [
316
+ {
317
+ required: damLocationType === "external",
318
+ message: "Bucket is required",
319
+ },
320
+ ], children: _jsx(Input, { placeholder: "Bucket", disabled: damLocationType === "internal" }) }), _jsx(Form.Item, { label: "Access Key", name: ["damLocationDetails", "accessKeyId"], rules: [
321
+ {
322
+ required: damLocationType === "external",
323
+ message: "Access key is required",
324
+ },
325
+ ], children: _jsx(Input, { placeholder: "Access Key", disabled: damLocationType === "internal" }) }), _jsx(Form.Item, { label: "Secret Access Key", name: ["damLocationDetails", "secretAccessKey"], rules: [
326
+ {
327
+ required: damLocationType === "external",
328
+ message: "Secret Access Key is required",
329
+ },
330
+ ], children: _jsx(Input, { placeholder: "Secret Key", disabled: damLocationType === "internal" }) }), _jsx(Form.Item, { label: "Url", name: ["damLocationDetails", "url"], rules: [
331
+ {
332
+ required: damLocationType === "external",
333
+ message: "Url is required",
334
+ },
335
+ ], children: _jsx(Input, { placeholder: "Url", disabled: damLocationType === "internal" }) }), _jsx(Form.Item, { label: "Region", name: ["damLocationDetails", "region"], rules: [
336
+ {
337
+ required: damLocationType === "external",
338
+ message: "Region is required",
339
+ },
340
+ ], children: _jsx(Input, { placeholder: "Region", disabled: damLocationType === "internal" }) })] }))] }), _jsx(Form.Item, { label: "Subdomain", name: "subdomain", rules: [
341
+ {
342
+ required: true,
343
+ message: "Subdomain is required",
344
+ },
345
+ ], children: _jsx(Input, { placeholder: "Subdomain" }) }), _jsx(Form.Item, { name: "showFilePreview", valuePropName: "checked", initialValue: false, children: _jsx(Checkbox, { children: "Show File Preview Editor" }) }), _jsx(Form.Item, { children: _jsx(Button, { htmlType: "submit", type: "primary", block: true, loading: loading, children: "Submit" }) })] })) }));
346
+ };
347
+ export default CreateClientForm;
@@ -0,0 +1,20 @@
1
+ declare function App(props: {
2
+ accessKey: string;
3
+ secretKey: string;
4
+ subdomain: string;
5
+ clientSubdomain: string;
6
+ teamsApi: string;
7
+ username: string;
8
+ password: string;
9
+ onSuccess: (data: any) => void;
10
+ teamIds: string[] | number[];
11
+ styles: Record<string, any>;
12
+ appType: string;
13
+ existingClientData?: {
14
+ accessKey: string;
15
+ secretKey: string;
16
+ subdomain: string;
17
+ brandId?: string;
18
+ } | null;
19
+ }): JSX.Element;
20
+ export default App;
@@ -0,0 +1,18 @@
1
+ import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
2
+ import { DamConfigProvider } from "../hocs/DamConfigContext";
3
+ import { ThemeProvider } from "../hocs/ThemeContext";
4
+ import { ThemeModes } from "../utilities/constants/interface";
5
+ import CreateClient from "./CreateClientBtn";
6
+ import ToastProvider from "../hocs/ToastProvider";
7
+ function App(props) {
8
+ const config = {
9
+ damAccessKey: props === null || props === void 0 ? void 0 : props.accessKey,
10
+ secretKey: props === null || props === void 0 ? void 0 : props.secretKey,
11
+ subdomain: props === null || props === void 0 ? void 0 : props.subdomain,
12
+ teamIds: props === null || props === void 0 ? void 0 : props.teamIds,
13
+ styles: props === null || props === void 0 ? void 0 : props.styles,
14
+ appType: props === null || props === void 0 ? void 0 : props.appType,
15
+ };
16
+ return (_jsx(DamConfigProvider, { config: config, children: _jsxs(ThemeProvider, { styles: props === null || props === void 0 ? void 0 : props.styles, sessionTheme: ThemeModes.LIGHT, children: [_jsx(CreateClient, { teamsApi: props === null || props === void 0 ? void 0 : props.teamsApi, username: props === null || props === void 0 ? void 0 : props.username, password: props === null || props === void 0 ? void 0 : props.password, clientSubdomain: props === null || props === void 0 ? void 0 : props.clientSubdomain, onSuccess: props === null || props === void 0 ? void 0 : props.onSuccess, existingClientData: props === null || props === void 0 ? void 0 : props.existingClientData }), _jsx(ToastProvider, {})] }) }));
17
+ }
18
+ export default App;
@@ -0,0 +1,14 @@
1
+ import { FormInstance } from "antd";
2
+ import { MetaDataFieldEntity } from "../utilities/constants/interface";
3
+ declare function MetaFieldOptions({ meta, imagePickerId, form, previousMetaFields, index, totalFields, onMetaFieldChange, nextFieldId, allFieldIds, }: {
4
+ meta: MetaDataFieldEntity;
5
+ imagePickerId: string;
6
+ form: FormInstance;
7
+ previousMetaFields: MetaDataFieldEntity[];
8
+ index: number;
9
+ totalFields: number;
10
+ onMetaFieldChange?: (filters: Record<string, any>, index: number) => void;
11
+ nextFieldId?: string;
12
+ allFieldIds: string[];
13
+ }): JSX.Element;
14
+ export default MetaFieldOptions;
@@ -0,0 +1,75 @@
1
+ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
2
+ function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
3
+ return new (P || (P = Promise))(function (resolve, reject) {
4
+ function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
5
+ function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
6
+ function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
7
+ step((generator = generator.apply(thisArg, _arguments || [])).next());
8
+ });
9
+ };
10
+ import { jsx as _jsx } from "react/jsx-runtime";
11
+ import { Form } from "antd";
12
+ import { useEffect, useMemo, useState } from "react";
13
+ import { find, get, map, pick, slice } from "lodash";
14
+ import { FETCH_META_FIELD_OPTIONS_URL } from "../utilities/constants/apiUrls";
15
+ import { InputTypes, NotificationStatus, } from "../utilities/constants/interface";
16
+ import { CustomSelectFormItem } from "../common/RenderFormItem";
17
+ import { showNotification } from "../common/notifications";
18
+ import { SOMETHING_WENT_WRONG } from "../utilities/constants/messages";
19
+ import { useQueryClient } from "react-query";
20
+ import { getCurrentBrandUsers } from "../react-query/hooks/brand-hooks";
21
+ import { useDamConfig } from "../hocs/DamConfigContext";
22
+ import { createApiClient } from "../hocs/configureAxios";
23
+ function MetaFieldOptions({ meta, imagePickerId, form, previousMetaFields, index, totalFields, onMetaFieldChange, nextFieldId, allFieldIds, }) {
24
+ const allFormValues = Form.useWatch([], form);
25
+ const filters = pick(allFormValues, slice(allFieldIds, 0, index));
26
+ const damConfig = useDamConfig();
27
+ const { brand } = damConfig;
28
+ const brandId = get(brand, "_id");
29
+ const queryClient = useQueryClient();
30
+ const users = getCurrentBrandUsers(queryClient, brandId);
31
+ const [state, setState] = useState({
32
+ loading: false,
33
+ options: [],
34
+ });
35
+ const api = useMemo(() => createApiClient(damConfig), [damConfig]);
36
+ const { loading, options } = state;
37
+ const currentValue = Form.useWatch(get(meta, "_id"), form);
38
+ const allValues = Form.useWatch([], form);
39
+ const fetchOptions = (...args_1) => __awaiter(this, [...args_1], void 0, function* (filters = {}) {
40
+ setState((prevState) => (Object.assign(Object.assign({}, prevState), { loading: true })));
41
+ try {
42
+ const payload = {
43
+ distinctValuesKey: get(meta, "_id"),
44
+ filters,
45
+ };
46
+ const response = yield api.put(FETCH_META_FIELD_OPTIONS_URL.replace(":id", imagePickerId), payload);
47
+ setState((prevState) => (Object.assign(Object.assign({}, prevState), { loading: false, options: get(meta, "defaultValue") === InputTypes.PERSON
48
+ ? map(get(response, "data.values"), (id) => {
49
+ const user = find(users, (u) => get(u, "_id") === id);
50
+ return {
51
+ label: get(user, "name", "Unknown"),
52
+ value: get(user, "_id", id),
53
+ };
54
+ })
55
+ : map(get(response, "data.values"), (text) => ({
56
+ label: text,
57
+ value: text,
58
+ })) })));
59
+ }
60
+ catch (err) {
61
+ showNotification(get(err, "message", SOMETHING_WENT_WRONG), NotificationStatus.ERROR);
62
+ setState({ loading: false, options: [] });
63
+ }
64
+ });
65
+ useEffect(() => {
66
+ fetchOptions(filters);
67
+ }, [JSON.stringify(filters)]);
68
+ return (_jsx(CustomSelectFormItem, { name: get(meta, "_id"), label: get(meta, "name"), options: options, loading: loading, onChange: (value) => {
69
+ form.setFieldValue(get(meta, "_id"), value);
70
+ if (typeof onMetaFieldChange === "function") {
71
+ onMetaFieldChange(filters, index);
72
+ }
73
+ } }));
74
+ }
75
+ export default MetaFieldOptions;
@@ -0,0 +1,8 @@
1
+ import { ImagePickerEntity } from "../utilities/constants/interface";
2
+ declare function TestImagePickerModal({ imagePicker, open, toggleModal, setSelectedFile, }: {
3
+ imagePicker: ImagePickerEntity | {};
4
+ open: boolean;
5
+ toggleModal: () => void;
6
+ setSelectedFile: (thumbnailUrl: string, value: string) => void;
7
+ }): JSX.Element;
8
+ export default TestImagePickerModal;
@@ -0,0 +1,72 @@
1
+ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
2
+ function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
3
+ return new (P || (P = Promise))(function (resolve, reject) {
4
+ function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
5
+ function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
6
+ function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
7
+ step((generator = generator.apply(thisArg, _arguments || [])).next());
8
+ });
9
+ };
10
+ import { jsx as _jsx } from "react/jsx-runtime";
11
+ import { Modal } from "antd";
12
+ import { get } from "lodash";
13
+ import DriveContainer from "../MyDrive/DriveContainer";
14
+ import { useEffect, useMemo, useState } from "react";
15
+ import CustomButton from "../common/Button";
16
+ import TestImageFromMetalData from "./TestImgFromMetaData";
17
+ import { getFormattedValue } from "../hocs/helpers";
18
+ import { createApiClient } from "../hocs/configureAxios";
19
+ import { useDamConfig } from "../hocs/DamConfigContext";
20
+ import { FETCH_ASSET_URL, FETCH_SHARED_FILE_URL, } from "../utilities/constants/apiUrls";
21
+ import { FoldersProvider } from "../utilities/FoldersContext";
22
+ function TestImagePickerModal({ imagePicker, open, toggleModal, setSelectedFile, }) {
23
+ const damConfig = useDamConfig();
24
+ const { rootFolderId } = damConfig;
25
+ const pickerFolderId = get(imagePicker, "folderId");
26
+ const [state, setState] = useState({
27
+ parentFolderId: pickerFolderId || rootFolderId || '',
28
+ fileForConfirmation: {},
29
+ });
30
+ const [folders, setFolders] = useState([]);
31
+ const [globalSearch, setGlobalSearch] = useState("");
32
+ const api = useMemo(() => createApiClient(damConfig), [damConfig]);
33
+ useEffect(() => {
34
+ const newFolderId = pickerFolderId || rootFolderId || '';
35
+ if (newFolderId && newFolderId !== state.parentFolderId) {
36
+ setState(prev => (Object.assign(Object.assign({}, prev), { parentFolderId: newFolderId })));
37
+ }
38
+ }, [pickerFolderId, rootFolderId]);
39
+ const { parentFolderId, fileForConfirmation } = state;
40
+ const onSelectFile = () => __awaiter(this, void 0, void 0, function* () {
41
+ // console.log(fileForConfirmation);
42
+ const response = yield api.get(FETCH_SHARED_FILE_URL.replace(":fileId", get(fileForConfirmation, "_id")));
43
+ // console.log(response);
44
+ const fileData = get(response, "data");
45
+ const assetId = get(fileData, "assetId");
46
+ const assetTypeResponse = yield api.get(FETCH_ASSET_URL.replace(":assetId", assetId));
47
+ const imagePickerOutputFormat = get(assetTypeResponse, "data.imagePickerOutputFormat", []);
48
+ const metadataFields = get(assetTypeResponse, "data.metadataFields", []);
49
+ // console.log(imagePickerOutputFormat);
50
+ const formattedOutputFormat = imagePickerOutputFormat.map((field) => {
51
+ // console.log("field", field);
52
+ const metaField = metadataFields.find((item) => (item === null || item === void 0 ? void 0 : item.name) == (field === null || field === void 0 ? void 0 : field.name));
53
+ return Object.assign(Object.assign({}, field), { fieldId: get(metaField, "_id") });
54
+ });
55
+ // console.log(formattedOutputFormat);
56
+ const value = getFormattedValue(formattedOutputFormat, fileForConfirmation === null || fileForConfirmation === void 0 ? void 0 : fileForConfirmation.s3Url, get(fileData, "metadata", {}));
57
+ console.log(value);
58
+ setSelectedFile(fileForConfirmation === null || fileForConfirmation === void 0 ? void 0 : fileForConfirmation.thumbnailUrl, value);
59
+ });
60
+ return (_jsx(Modal, { title: `Test ${get(imagePicker, "name", "Image picker")}`, open: open, onCancel: toggleModal, okText: "Create", maskClosable: false, width: get(imagePicker, "assetId") ? 600 : 1000, footer: get(fileForConfirmation, "thumbnailUrl") ? (_jsx(CustomButton, { type: "primary", label: "Confirm", onClick: () => {
61
+ onSelectFile();
62
+ } }, "confirm")) : null, children: get(imagePicker, "assetId") ? (_jsx(TestImageFromMetalData, { imagePicker: imagePicker, selectedPickerFile: fileForConfirmation, setSelectedFile: (file) => {
63
+ setState((prevState) => (Object.assign(Object.assign({}, prevState), { fileForConfirmation: file })));
64
+ } })) : (_jsx(FoldersProvider, { value: { folders, setFolders, globalSearch }, children: _jsx(DriveContainer, { setSelectedFile: (file, localFile = false) => {
65
+ console.log("local file", file);
66
+ setState((prevState) => (Object.assign(Object.assign({}, prevState), { fileForConfirmation: file })));
67
+ if (localFile) {
68
+ setSelectedFile(get(file, "s3Url", ""), get(file, "thumbnailUrl", ""));
69
+ }
70
+ }, parentFolderId: parentFolderId, setParentFolderId: (id) => setState((prevState) => (Object.assign(Object.assign({}, prevState), { parentFolderId: id, fileForConfirmation: {} }))), pickerFolderId: get(imagePicker, "folderId"), selectedPickerFile: fileForConfirmation, imagePicker: imagePicker, globalSearch: globalSearch, setGlobalSearch: setGlobalSearch }) })) }));
71
+ }
72
+ export default TestImagePickerModal;
@@ -0,0 +1,7 @@
1
+ import { FileEntity, ImagePickerEntity } from "../utilities/constants/interface";
2
+ declare function TestImageFromMetalData({ imagePicker, selectedPickerFile, setSelectedFile, }: {
3
+ imagePicker: ImagePickerEntity;
4
+ selectedPickerFile: FileEntity;
5
+ setSelectedFile: (file: FileEntity) => void;
6
+ }): JSX.Element;
7
+ export default TestImageFromMetalData;