@bindu-dashing/dam-solution-v2 5.8.6

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 +9 -0
  3. package/build/AssetType/AddFieldProperties.js +197 -0
  4. package/build/AssetType/AssetTemplatesTable.d.ts +10 -0
  5. package/build/AssetType/AssetTemplatesTable.js +153 -0
  6. package/build/AssetType/CreateAssetTemplate.d.ts +3 -0
  7. package/build/AssetType/CreateAssetTemplate.js +68 -0
  8. package/build/AssetType/CreateOrEditAssetTemplate.d.ts +1 -0
  9. package/build/AssetType/CreateOrEditAssetTemplate.js +77 -0
  10. package/build/AssetType/DraggedField.d.ts +14 -0
  11. package/build/AssetType/DraggedField.js +40 -0
  12. package/build/AssetType/EditAssetTemplate.d.ts +5 -0
  13. package/build/AssetType/EditAssetTemplate.js +179 -0
  14. package/build/AssetType/FieldsSection.d.ts +14 -0
  15. package/build/AssetType/FieldsSection.js +239 -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 +24 -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 +8 -0
  41. package/build/CreateClient/CreateClientBtn.js +12 -0
  42. package/build/CreateClient/CreateClientForm.d.ts +9 -0
  43. package/build/CreateClient/CreateClientForm.js +165 -0
  44. package/build/CreateClient/index.d.ts +14 -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 +61 -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 +6 -0
  63. package/build/MyDrive/ActionBar.js +165 -0
  64. package/build/MyDrive/AddDrive.d.ts +3 -0
  65. package/build/MyDrive/AddDrive.js +169 -0
  66. package/build/MyDrive/AddFolder.d.ts +10 -0
  67. package/build/MyDrive/AddFolder.js +150 -0
  68. package/build/MyDrive/BreadCrumbList.d.ts +9 -0
  69. package/build/MyDrive/BreadCrumbList.js +86 -0
  70. package/build/MyDrive/BulkUploadModal.d.ts +2 -0
  71. package/build/MyDrive/BulkUploadModal.js +279 -0
  72. package/build/MyDrive/DriveContainer.d.ts +13 -0
  73. package/build/MyDrive/DriveContainer.js +276 -0
  74. package/build/MyDrive/FileDownloadHistory.d.ts +7 -0
  75. package/build/MyDrive/FileDownloadHistory.js +94 -0
  76. package/build/MyDrive/FileMenuOptions.d.ts +11 -0
  77. package/build/MyDrive/FileMenuOptions.js +397 -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 +19 -0
  81. package/build/MyDrive/FolderGridView.js +91 -0
  82. package/build/MyDrive/FolderListView.d.ts +25 -0
  83. package/build/MyDrive/FolderListView.js +188 -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 +342 -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 +1 -0
  99. package/build/MyDrive/MyDriveMainContainer.js +32 -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 +40 -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 +10 -0
  121. package/build/MyDrive/fileDetails/FileDetails.js +78 -0
  122. package/build/MyDrive/fileDetails/FileHeader.d.ts +7 -0
  123. package/build/MyDrive/fileDetails/FileHeader.js +25 -0
  124. package/build/MyDrive/fileDetails/FileViewer.d.ts +10 -0
  125. package/build/MyDrive/fileDetails/FileViewer.js +31 -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 +5 -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 +195 -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 +9 -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 +83 -0
  148. package/build/MyDrive/files/MapFile.d.ts +8 -0
  149. package/build/MyDrive/files/MapFile.js +217 -0
  150. package/build/MyDrive/files/MoveToAnotherFolder.d.ts +9 -0
  151. package/build/MyDrive/files/MoveToAnotherFolder.js +53 -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 +10 -0
  155. package/build/MyDrive/index.js +35 -0
  156. package/build/MyDrive/routes.d.ts +7 -0
  157. package/build/MyDrive/routes.js +17 -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 +10 -0
  187. package/build/common/folders/TypeAndDateFilters.js +59 -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 +108 -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 +15 -0
  211. package/build/hocs/helpers.js +177 -0
  212. package/build/index.d.ts +11 -0
  213. package/build/index.js +11 -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 +3 -0
  219. package/build/react-query/services/brand-services.js +30 -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 +44 -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 +48 -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 +14 -0
  238. package/build/utilities/FoldersContext.js +10 -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 +95 -0
  242. package/build/utilities/constants/apiUrls.js +115 -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 +54 -0
  248. package/build/utilities/constants/messages.js +54 -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 +19 -0
  257. package/build/utilities/useAppParams.d.ts +6 -0
  258. package/build/utilities/useAppParams.js +27 -0
  259. package/package.json +93 -0
package/README.md ADDED
@@ -0,0 +1,53 @@
1
+ # @veera-dashing/dam-solution-v2
2
+
3
+ ---
4
+
5
+ ## Installation
6
+
7
+ To install the library in your project:
8
+
9
+ ```bash
10
+ npm install @veera-dashing/dam-solution-v2
11
+ # or
12
+ yarn add @veera-dashing/dam-solution-v2
13
+
14
+ ```
15
+
16
+ ## Local Testing
17
+
18
+ To test the library in local before publishing it to npm:
19
+
20
+ In Library
21
+
22
+ ```bash
23
+ npm run build
24
+ npm link
25
+ ```
26
+
27
+ In test project:
28
+
29
+ ```bash
30
+ npm link @veera-dashing/dam-solution-v2
31
+ ```
32
+
33
+ ## Publishing
34
+
35
+ To publish the library to npm:
36
+
37
+ 1. Update the version in package.json
38
+ 2. Next Steps
39
+
40
+ ```bash
41
+ npm run build
42
+ npm publish
43
+
44
+ ```
45
+
46
+ ## Login
47
+
48
+ To login to npm account:
49
+ Before publishing, login to npm account if not already loggedin
50
+
51
+ ```bash
52
+ npm login
53
+ ```
@@ -0,0 +1,9 @@
1
+ import { InputTypeEntity } from "../utilities/constants/interface";
2
+ export default function AddFieldProperties({ field, setCurrentFieldIndex, onUpdateField, currentInputType, index, allFields, }: {
3
+ field: InputTypeEntity | undefined;
4
+ setCurrentFieldIndex: (value: number | null) => void;
5
+ onUpdateField: (updatedValues: any, field: InputTypeEntity, index: number | null) => void;
6
+ currentInputType: InputTypeEntity | undefined;
7
+ index: number | null;
8
+ allFields: InputTypeEntity[];
9
+ }): JSX.Element;
@@ -0,0 +1,197 @@
1
+ import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
2
+ import { Button, Checkbox, Form, Input } from "antd";
3
+ import TextField from "./fieldProperties/TextField";
4
+ import NumberField from "./fieldProperties/NumberField";
5
+ import { useEffect, useState } from "react";
6
+ import DateField from "./fieldProperties/DateField";
7
+ import OptionsField from "./fieldProperties/OptionsField";
8
+ import { InputSupportedTypes, InputTypes, } from "../utilities/constants/interface";
9
+ import { first, get, includes, isArray, nth } from "lodash";
10
+ import { useDamConfig } from "../hocs/DamConfigContext";
11
+ import useAppNavigate from "../utilities/useAppNavigate";
12
+ import { getFormItem } from "../MyDrive/fileDetails/MetaForm";
13
+ import dayjs from "dayjs";
14
+ import { DATE_FORMAT, DATE_WITH_TIME_FORMAT } from "../hocs/appConstants";
15
+ export default function AddFieldProperties({ field, setCurrentFieldIndex, onUpdateField, currentInputType, index, allFields, }) {
16
+ const { styles } = useDamConfig();
17
+ const navigate = useAppNavigate();
18
+ const [defaultValueInput, setDefaultValueInput] = useState("");
19
+ const onUpdate = (values) => {
20
+ const allValues = Object.assign({}, values);
21
+ if (allValues === null || allValues === void 0 ? void 0 : allValues.defaultValue) {
22
+ allValues["defaultValue"] = getFormattedDefaultValue(allValues);
23
+ }
24
+ if (get(field, "_id", null)) {
25
+ allValues["_id"] = get(field, "_id");
26
+ }
27
+ onUpdateField(allValues, currentInputType, index);
28
+ setCurrentFieldIndex(null);
29
+ };
30
+ const [form] = Form.useForm();
31
+ const getFormattedDefaultValue = (values) => {
32
+ const defaultName = get(field, "defaultName");
33
+ const defaultValue = get(values, "defaultValue");
34
+ // console.log("default", defaultValue);
35
+ const allowTime = get(values, `inputTypeSettings.${InputSupportedTypes.ALLOW_TIME}.allow`, false);
36
+ const allowMultiple = get(values, `inputTypeSettings.${InputSupportedTypes.ALLOW_MULTIPLE}`, false);
37
+ switch (defaultName) {
38
+ case InputTypes.DATE_RANGE:
39
+ case InputTypes.DATE:
40
+ const format = allowTime ? DATE_WITH_TIME_FORMAT : DATE_FORMAT;
41
+ if (isArray(defaultValue) && get(defaultValue, "length") === 2) {
42
+ return [
43
+ first(defaultValue)
44
+ ? dayjs(first(defaultValue)).format(format)
45
+ : null,
46
+ nth(defaultValue, 1)
47
+ ? dayjs(nth(defaultValue, 1)).format(format)
48
+ : null,
49
+ ];
50
+ }
51
+ return defaultValue ? dayjs(defaultValue).format(format) : null;
52
+ case InputTypes.CHECKBOX:
53
+ return defaultValue || [];
54
+ case InputTypes.SELECT:
55
+ return allowMultiple ? defaultValue || [] : defaultValue || undefined;
56
+ default:
57
+ return defaultValue;
58
+ }
59
+ };
60
+ const getInitialDefaultValue = (inputTypeSettings) => {
61
+ const defaultName = currentInputType === null || currentInputType === void 0 ? void 0 : currentInputType.defaultName;
62
+ const allowMultiple = get(inputTypeSettings, `${InputSupportedTypes.ALLOW_MULTIPLE}`, false);
63
+ const value = get(field, "defaultValue", "");
64
+ switch (defaultName) {
65
+ case InputTypes.DATE:
66
+ return value ? dayjs(value) : undefined;
67
+ case InputTypes.DATE_RANGE:
68
+ return isArray(value) && get(value, "length") === 2
69
+ ? [dayjs(first(value)), dayjs(nth(value, 1))]
70
+ : undefined;
71
+ case InputTypes.SELECT:
72
+ return allowMultiple ? value || [] : value !== null && value !== void 0 ? value : undefined;
73
+ case InputTypes.CHECKBOX:
74
+ return value || [];
75
+ default:
76
+ return value;
77
+ }
78
+ };
79
+ useEffect(() => {
80
+ form.setFieldsValue(Object.assign(Object.assign({}, field), { defaultValue: getInitialDefaultValue(get(field, "inputTypeSettings", {})) }));
81
+ handleFormValuesChange();
82
+ }, [field, form]);
83
+ // Update defaultValueInput whenever form values change
84
+ const handleFormValuesChange = () => {
85
+ var _a;
86
+ const formValues = form.getFieldsValue(true);
87
+ const defaultName = currentInputType === null || currentInputType === void 0 ? void 0 : currentInputType.defaultName;
88
+ const options = ((_a = formValues.options) === null || _a === void 0 ? void 0 : _a.filter((opt) => (opt === null || opt === void 0 ? void 0 : opt.label) && (opt === null || opt === void 0 ? void 0 : opt.value))) || [];
89
+ const settings = formValues.inputTypeSettings || {};
90
+ const placeholder = formValues.placeholder || "";
91
+ const item = {
92
+ _id: "defaultValue",
93
+ name: "Default Value",
94
+ defaultName,
95
+ options,
96
+ inputTypeSettings: settings,
97
+ placeholder,
98
+ };
99
+ // Add rule: defaultValue must be one of the options when defaultName is SELECT
100
+ let rules = [];
101
+ if ((defaultName === InputTypes.SELECT ||
102
+ defaultName === InputTypes.CHECKBOX ||
103
+ defaultName === InputTypes.RADIO) &&
104
+ options.length > 0) {
105
+ rules.push({
106
+ validator: (_, value) => {
107
+ const allowedValues = options
108
+ .filter((opt) => opt)
109
+ .map((opt) => opt.value);
110
+ if (value === undefined ||
111
+ (Array.isArray(value)
112
+ ? value.every((v) => allowedValues.includes(v))
113
+ : allowedValues.includes(value))) {
114
+ return Promise.resolve();
115
+ }
116
+ return Promise.reject("Default value must be one of the options");
117
+ },
118
+ });
119
+ }
120
+ // Rule for DATE and DATE_RANGE: check time part if allow time is selected
121
+ if ((defaultName === InputTypes.DATE ||
122
+ defaultName === InputTypes.DATE_RANGE) &&
123
+ settings[InputSupportedTypes.ALLOW_TIME] !== undefined) {
124
+ rules.push({
125
+ validator: (_, value) => {
126
+ const allowTime = !!get(settings, `${InputSupportedTypes.ALLOW_TIME}.allow`);
127
+ if (!value)
128
+ return Promise.resolve();
129
+ // For DATE
130
+ if (defaultName === InputTypes.DATE) {
131
+ const hasTime = value && value.hour && typeof value.hour === "function"
132
+ ? value.hour() !== 0 ||
133
+ value.minute() !== 0 ||
134
+ value.second() !== 0
135
+ : false;
136
+ if (allowTime && !hasTime) {
137
+ return Promise.reject("Please select a date with time (hour/minute/second).");
138
+ }
139
+ if (!allowTime && hasTime) {
140
+ return Promise.reject("Time is not allowed. Please select only a date.");
141
+ }
142
+ }
143
+ // For DATE_RANGE
144
+ if (defaultName === InputTypes.DATE_RANGE && Array.isArray(value)) {
145
+ const [start, end] = value;
146
+ const startHasTime = start && start.hour && typeof start.hour === "function"
147
+ ? start.hour() !== 0 ||
148
+ start.minute() !== 0 ||
149
+ start.second() !== 0
150
+ : false;
151
+ const endHasTime = end && end.hour && typeof end.hour === "function"
152
+ ? end.hour() !== 0 || end.minute() !== 0 || end.second() !== 0
153
+ : false;
154
+ if (allowTime && (!startHasTime || !endHasTime)) {
155
+ return Promise.reject("Please select both start and end dates with time.");
156
+ }
157
+ if (!allowTime && (startHasTime || endHasTime)) {
158
+ return Promise.reject("Time is not allowed. Please select only dates.");
159
+ }
160
+ }
161
+ return Promise.resolve();
162
+ },
163
+ });
164
+ }
165
+ // Pass rules to getFormItem
166
+ const defaultValueItem = getFormItem(Object.assign(Object.assign({}, item), { additionalRules: rules }), true);
167
+ setDefaultValueInput(defaultValueItem);
168
+ };
169
+ return (_jsxs("div", { className: "md-lib-p-4", children: [_jsxs("div", { className: "md-lib-flex md-lib-items-center md-lib-gap-2", children: [_jsx("h2", { className: "md-lib-text-xl md-lib-font-semibold", children: "Properties" }), _jsxs("p", { className: "md-lib-ml-auto md-lib-text-sm md-lib-truncate", style: { color: styles === null || styles === void 0 ? void 0 : styles.secondaryTextColor }, children: ["Type: ", get(field, "name", "N/A")] })] }), _jsx("div", { className: "md-lib-mt-4", children: _jsxs(Form, { layout: "vertical", form: form, requiredMark: false, scrollToFirstError: true, onFinish: onUpdate, initialValues: field, onValuesChange: handleFormValuesChange, children: [_jsx(Form.Item, { name: "isMandatory", valuePropName: "checked", children: _jsx(Checkbox, { children: "Marks as mandatory field" }) }), _jsx(Form.Item, { name: "name", label: "Field Name", rules: [
170
+ { required: true, message: "Name is required" },
171
+ {
172
+ validator: (_, value) => {
173
+ if (!value ||
174
+ !allFields.some((f, i) => f.name === value && i !== index)) {
175
+ return Promise.resolve();
176
+ }
177
+ return Promise.reject("Name must be unique");
178
+ },
179
+ },
180
+ ], children: _jsx(Input, { placeholder: "Enter name", className: "md-lib-h-12" }) }), _jsx(Form.Item, { label: "Placeholder", name: "placeholder", rules: [
181
+ {
182
+ required: true,
183
+ message: "Placeholder is required",
184
+ },
185
+ ], children: _jsx(Input, { placeholder: "Enter Field Placeholder", className: "md-lib-h-12" }) }), defaultValueInput, _jsxs("div", { children: [!!get(currentInputType, "supportedTypes.length") && (_jsx("h3", { className: "md-lib-text-md md-lib-font-semibold md-lib-mb-2", children: "Field Validations" })), _jsxs(Form.Item, { name: "field_validations", children: [includes([InputTypes.PARAGRAPH, InputTypes.TEXT, InputTypes.LINK], get(currentInputType, "defaultName")) && (_jsx(TextField, { field: field, supportedTypes: get(currentInputType, "supportedTypes", []) })), get(currentInputType, "defaultName") == InputTypes.NUMBERS && (_jsx(NumberField, { field: field, supportedTypes: get(currentInputType, "supportedTypes", []) })), (get(currentInputType, "defaultName") == InputTypes.DATE ||
186
+ get(currentInputType, "defaultName") ==
187
+ InputTypes.DATE_RANGE) && (_jsx(DateField, { field: field, supportedTypes: get(currentInputType, "supportedTypes", []) })), includes([
188
+ InputTypes.SELECT,
189
+ InputTypes.PERSON,
190
+ InputTypes.TEAM,
191
+ InputTypes.CHECKBOX,
192
+ InputTypes.RADIO,
193
+ ], get(currentInputType, "defaultName")) && (_jsx(OptionsField, { field: field, supportedTypes: get(currentInputType, "supportedTypes", []), currentInputType: currentInputType }))] })] }), _jsxs(Form.Item, { className: "md-lib-flex md-lib-items-center md-lib-justify-end md-lib-absolute md-lib-bottom-0 md-lib-right-0 !md-lib-my-2", children: [_jsx(Button, { color: "primary", variant: "text", onClick: () => {
194
+ setCurrentFieldIndex(null);
195
+ // navigate(ASSETS_SCREEN);
196
+ }, size: "large", children: "Cancel" }), _jsx(Button, { color: "primary", htmlType: "submit", className: "md-lib-ml-2 md-lib-border-primaryColor md-lib-text-primaryColor", size: "large", children: "Update" })] })] }) })] }));
197
+ }
@@ -0,0 +1,10 @@
1
+ import { AssetTemplateEntity } from "../utilities/constants/interface";
2
+ declare function AssetTemplatesTable({ assetTemplates, totalPages, totalCount, filters, onFetchAssetTemplates, loading, }: {
3
+ assetTemplates: AssetTemplateEntity[];
4
+ totalPages: number;
5
+ totalCount: number;
6
+ filters: any;
7
+ onFetchAssetTemplates: (params: any) => void;
8
+ loading: boolean;
9
+ }): JSX.Element;
10
+ export default AssetTemplatesTable;
@@ -0,0 +1,153 @@
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 } from "react/jsx-runtime";
11
+ import { Space, Table, Tooltip, Switch } from "antd";
12
+ import { useMemo, useState } from "react";
13
+ import { get } from "lodash";
14
+ import { APP_DATE_TIME_FORMAT, DEFAULT_PAGE, LOCAL_TIMEZONE, } from "../hocs/appConstants";
15
+ import { NotificationStatus, SortOrders, } from "../utilities/constants/interface";
16
+ import CustomLoader from "../common/loader/CustomLoader";
17
+ import { EditOutlined, DeleteOutlined } from "@ant-design/icons";
18
+ import CustomButton from "../common/Button";
19
+ import { ASSET_TEMPLATE_SCREEN } from "../utilities/constants/routes";
20
+ import moment from "moment-timezone";
21
+ import { DeleteConfirmationModal, RenderTableSearchFilters, RenderTableSelectFilters, } from "../common/CustomElements";
22
+ import { DEACTIVATE_OK_TEXT, DELETE_CONFIRMATION_MESSAGE, DELETE_OK_TEXT, DELETE_SUCCESS, SOMETHING_WENT_WRONG, UPDATE_SUCCESS, } from "../utilities/constants/messages";
23
+ import { showNotification } from "../common/notifications";
24
+ import { FETCH_ASSET_URL } from "../utilities/constants/apiUrls";
25
+ import { useDamConfig } from "../hocs/DamConfigContext";
26
+ import { createApiClient } from "../hocs/configureAxios";
27
+ import useAppNavigate from "../utilities/useAppNavigate";
28
+ function AssetTemplatesTable({ assetTemplates, totalPages, totalCount, filters = {}, onFetchAssetTemplates, loading, }) {
29
+ const [state, setState] = useState({
30
+ showConfirmPopup: false,
31
+ selectedAsset: {},
32
+ actionLoading: false,
33
+ updateAssetId: "",
34
+ });
35
+ const navigate = useAppNavigate();
36
+ const damConfig = useDamConfig();
37
+ const api = useMemo(() => createApiClient(damConfig), [damConfig]);
38
+ const { showConfirmPopup, selectedAsset, actionLoading, updateAssetId } = state;
39
+ const toggleDeletConfirm = (asset = {}, updateAssetId = "") => {
40
+ setState((prevState) => (Object.assign(Object.assign({}, prevState), { selectedAsset: asset, showConfirmPopup: !prevState.showConfirmPopup, actionLoading: false, updateAssetId: updateAssetId })));
41
+ };
42
+ const onDeleteTemplate = () => __awaiter(this, void 0, void 0, function* () {
43
+ setState((prevState) => (Object.assign(Object.assign({}, prevState), { actionLoading: true })));
44
+ try {
45
+ const response = yield api.delete(FETCH_ASSET_URL.replace(":assetId", get(selectedAsset, "_id")));
46
+ onFetchAssetTemplates(Object.assign(Object.assign({}, filters), { page: DEFAULT_PAGE }));
47
+ toggleDeletConfirm();
48
+ showNotification(get(response, "data.message", DELETE_SUCCESS), NotificationStatus.SUCCESS);
49
+ }
50
+ catch (error) {
51
+ setState((prevState) => (Object.assign(Object.assign({}, prevState), { actionLoading: false })));
52
+ showNotification(get(error, "message", SOMETHING_WENT_WRONG), NotificationStatus.ERROR);
53
+ }
54
+ });
55
+ const onUpdateTemplate = (values, assetId) => __awaiter(this, void 0, void 0, function* () {
56
+ setState((prevState) => (Object.assign(Object.assign({}, prevState), { actionLoading: true })));
57
+ try {
58
+ const response = yield api.put(FETCH_ASSET_URL.replace(":assetId", assetId), values);
59
+ onFetchAssetTemplates(filters);
60
+ toggleDeletConfirm();
61
+ showNotification(get(response, "data.message", UPDATE_SUCCESS), NotificationStatus.SUCCESS);
62
+ }
63
+ catch (error) {
64
+ setState((prevState) => (Object.assign(Object.assign({}, prevState), { actionLoading: false })));
65
+ showNotification(get(error, "message", SOMETHING_WENT_WRONG), NotificationStatus.ERROR);
66
+ }
67
+ });
68
+ const getSortOrder = (order) => {
69
+ if (order === SortOrders.ASCEND) {
70
+ return "ascend";
71
+ }
72
+ else if (order === SortOrders.DESCEND) {
73
+ return "descend";
74
+ }
75
+ };
76
+ const columns = [
77
+ {
78
+ title: "Template Name",
79
+ dataIndex: "name",
80
+ key: "templateName",
81
+ sortOrder: filters.sortBy == "name" ? getSortOrder(filters.sortOrder) : undefined,
82
+ filteredValue: filters.name ? [filters.name] : [],
83
+ filterDropdown: ({ setSelectedKeys, selectedKeys, confirm, clearFilters, }) => {
84
+ return (_jsx(RenderTableSearchFilters, { value: selectedKeys[0] || "", onChange: (e) => setSelectedKeys(e.target.value ? [e.target.value] : []), placeholder: "Search name", onPressEnter: confirm, onClick: confirm, onClear: () => {
85
+ clearFilters();
86
+ setSelectedKeys([]);
87
+ confirm();
88
+ } }));
89
+ },
90
+ sorter: true,
91
+ render: (text) => (_jsx("span", { className: "md-lib-text-textColor dark:md-lib-text-darkTextColor md-lib-max-w-[200px] md-lib-truncate md-lib-inline-block md-lib-cursor-default", title: text, children: text })),
92
+ },
93
+ {
94
+ title: "Created at",
95
+ dataIndex: "createdAt",
96
+ key: "createdAt",
97
+ sorter: true,
98
+ sortOrder: filters.sortBy == "createdAt"
99
+ ? getSortOrder(filters.sortOrder)
100
+ : undefined,
101
+ width: 200,
102
+ render: (date) => (_jsx("span", { className: "md-lib-text-secondaryTextColor dark:md-lib-text-darkSecondaryTextColor md-lib-text-sm md-lib-cursor-default", children: moment.utc(date).tz(LOCAL_TIMEZONE).format(APP_DATE_TIME_FORMAT) })),
103
+ },
104
+ {
105
+ title: "Description",
106
+ dataIndex: "description",
107
+ key: "description",
108
+ render: (text) => (_jsx("span", { className: "md-lib-text-secondaryTextColor dark:md-lib-text-darkSecondaryTextColor md-lib-max-w-[240px] md-lib-truncate md-lib-inline-block md-lib-text-sm md-lib-cursor-default", title: text, children: text })),
109
+ },
110
+ {
111
+ title: "Active",
112
+ dataIndex: "isActive",
113
+ key: "isActive",
114
+ align: "center",
115
+ filteredValue: filters.isActive ? filters.isActive : null,
116
+ render: (isActive, record) => (_jsx(Switch, { loading: updateAssetId === get(record, "_id") && actionLoading, checked: isActive, onChange: (checked) => {
117
+ if (isActive) {
118
+ toggleDeletConfirm(record, get(record, "_id"));
119
+ }
120
+ else {
121
+ onUpdateTemplate({ isActive: !isActive }, get(record, "_id"));
122
+ }
123
+ } })),
124
+ filterDropdown: ({ setSelectedKeys, selectedKeys, confirm, clearFilters, }) => (_jsx(RenderTableSelectFilters, { selectedKeys: selectedKeys, onChange: (value) => setSelectedKeys(value), placeholder: "Is active?", onClear: () => {
125
+ clearFilters();
126
+ setSelectedKeys([]);
127
+ confirm();
128
+ }, onClick: confirm })),
129
+ },
130
+ {
131
+ title: "Actions",
132
+ dataIndex: "",
133
+ key: "actions",
134
+ render: (record) => (_jsxs(Space, { children: [_jsx(Tooltip, { title: "Edit Asset template", className: "md-lib-hidden md:md-lib-block", children: _jsx(CustomButton, { icon: _jsx(EditOutlined, { size: 24, className: "md-lib-text-primaryColor" }), size: "large", label: "", className: "md-lib-border-none", onClick: () => navigate(ASSET_TEMPLATE_SCREEN.replace(":id", get(record, "_id"))) }) }), _jsx(Tooltip, { title: "Delete Asset template", placement: "topLeft", children: _jsx(CustomButton, { icon: _jsx(DeleteOutlined, { className: "md-lib-text-dangerColor", size: 24 }), label: "", type: "default", onClick: () => toggleDeletConfirm(record), className: "md-lib-border-none", size: "large" }) })] })),
135
+ },
136
+ ];
137
+ const handleTableChange = (pagination, tableFilters, sorter) => {
138
+ const order = sorter.order === "ascend" ? SortOrders.ASCEND : SortOrders.DESCEND;
139
+ const sortBy = sorter.field;
140
+ const updatedFilters = Object.assign(Object.assign({}, filters), { page: get(pagination, "current"), name: get(tableFilters, "templateName")
141
+ ? get(tableFilters, "templateName[0]")
142
+ : "", isActive: get(tableFilters, "isActive")
143
+ ? get(tableFilters, "isActive")
144
+ : undefined, sortBy: sortBy, sortOrder: order });
145
+ onFetchAssetTemplates(updatedFilters);
146
+ };
147
+ return (_jsxs("div", { className: "md-lib-mt-4", children: [_jsx(Table, { columns: columns, dataSource: assetTemplates, loading: { spinning: loading, indicator: _jsx(CustomLoader, {}) }, className: "assetType-table", pagination: totalPages > 1 ? { showSizeChanger: false, total: totalCount } : false, onChange: handleTableChange, scroll: { x: "100%" } }), _jsx(DeleteConfirmationModal, { showDeleteModal: showConfirmPopup, toggleDeleteModal: toggleDeletConfirm, okText: updateAssetId ? DEACTIVATE_OK_TEXT : DELETE_OK_TEXT, onOk: updateAssetId
148
+ ? () => onUpdateTemplate({ isActive: false }, get(selectedAsset, "_id"))
149
+ : onDeleteTemplate, loading: actionLoading, description: DELETE_CONFIRMATION_MESSAGE.replace(":action", updateAssetId ? "deactivate" : "delete").replace(":entity", `${get(selectedAsset, "name", "this asset template")}`), subHeading: updateAssetId
150
+ ? ""
151
+ : "Deleting this template might result in loosing all the meta data associated with this asset type. This change is irreversible." })] }));
152
+ }
153
+ export default AssetTemplatesTable;
@@ -0,0 +1,3 @@
1
+ export default function CreateAssetTemplate({ label }: {
2
+ label: string;
3
+ }): JSX.Element;
@@ -0,0 +1,68 @@
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 { ICON_SIZE } from "../hocs/appConstants";
12
+ import { Form, Input, Modal } from "antd";
13
+ import { useMemo, useState } from "react";
14
+ import { CiCirclePlus } from "react-icons/ci";
15
+ import CustomButton from "../common/Button";
16
+ import { CustomInputFormItem, CustomTextAreaFormItem, } from "../common/RenderFormItem";
17
+ import { CREATE_SUCCESS, ENTITY_REQUIRED, SOMETHING_WENT_WRONG, } from "../utilities/constants/messages";
18
+ import { showNotification } from "../common/notifications";
19
+ import { NotificationStatus } from "../utilities/constants/interface";
20
+ import { get } from "lodash";
21
+ import { CREATE_ASSETS_URL } from "../utilities/constants/apiUrls";
22
+ import { ASSET_TEMPLATE_SCREEN } from "../utilities/constants/routes";
23
+ import { useDamConfig } from "../hocs/DamConfigContext";
24
+ import { createApiClient } from "../hocs/configureAxios";
25
+ import useAppNavigate from "../utilities/useAppNavigate";
26
+ const CiCirclePlusIcon = CiCirclePlus;
27
+ const { TextArea } = Input;
28
+ export default function CreateAssetTemplate({ label }) {
29
+ const navigate = useAppNavigate();
30
+ const [state, setState] = useState({ open: false, loading: false });
31
+ const { open, loading } = state;
32
+ const damConfig = useDamConfig();
33
+ const [form] = Form.useForm();
34
+ const api = useMemo(() => createApiClient(damConfig), [damConfig]);
35
+ const { brand } = damConfig;
36
+ const handleOk = () => {
37
+ form.validateFields().then((values) => __awaiter(this, void 0, void 0, function* () {
38
+ setState((prevState) => (Object.assign(Object.assign({}, prevState), { loading: true })));
39
+ try {
40
+ const response = yield api.post(CREATE_ASSETS_URL, Object.assign(Object.assign({}, values), { brandId: get(brand, "_id") }));
41
+ // console.log("response", response);
42
+ showNotification(get(response, "data.message", CREATE_SUCCESS), NotificationStatus.SUCCESS);
43
+ toggleModal();
44
+ navigate(ASSET_TEMPLATE_SCREEN.replace(":id", get(response, "data._id")));
45
+ }
46
+ catch (error) {
47
+ setState((prevState) => (Object.assign(Object.assign({}, prevState), { loading: false })));
48
+ showNotification(get(error, "message", SOMETHING_WENT_WRONG), NotificationStatus.ERROR);
49
+ }
50
+ }));
51
+ };
52
+ const toggleModal = () => {
53
+ setState((prevState) => (Object.assign(Object.assign({}, prevState), { open: !prevState.open, loading: false })));
54
+ };
55
+ return (_jsxs(_Fragment, { children: [_jsx(CustomButton, { type: "primary", icon: _jsx(CiCirclePlusIcon, { size: ICON_SIZE }), onClick: toggleModal, size: "large", label: label }), _jsx(Modal, { title: "Create new template", open: open, onCancel: toggleModal, okText: "Create", width: 400, onOk: handleOk, okButtonProps: { loading }, children: _jsxs(Form, { layout: "vertical", form: form,
56
+ // requiredMark={false}
57
+ scrollToFirstError: true, onFinish: handleOk, children: [_jsx(CustomInputFormItem, { label: "Template name", name: "name", rules: [
58
+ {
59
+ required: true,
60
+ message: ENTITY_REQUIRED.replace(":entity", "Name"),
61
+ },
62
+ ], placeholder: "Enter template name", style: { width: "100%" } }), _jsx(CustomTextAreaFormItem, { label: "Template description", name: "description", rules: [
63
+ {
64
+ required: true,
65
+ message: ENTITY_REQUIRED.replace(":entity", "Description"),
66
+ },
67
+ ], placeholder: "Enter template description", style: { width: "100%" }, rows: 3 })] }) })] }));
68
+ }
@@ -0,0 +1 @@
1
+ export default function CreateOrEditAssetTemplate(): JSX.Element;
@@ -0,0 +1,77 @@
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 { useEffect, useMemo, useState } from "react";
12
+ import { FETCH_ASSET_URL, FETCH_INPUT_TYPES_URL, } from "../utilities/constants/apiUrls";
13
+ import { get } from "lodash";
14
+ import EditAssetTemplate from "./EditAssetTemplate";
15
+ import { useDamConfig } from "../hocs/DamConfigContext";
16
+ import { createApiClient } from "../hocs/configureAxios";
17
+ import { useTheme } from "../hocs/ThemeContext";
18
+ import { InputTypes } from "../utilities/constants/interface";
19
+ import Loader from "../common/loader/loader";
20
+ import useAppParams from "../utilities/useAppParams";
21
+ export default function CreateOrEditAssetTemplate() {
22
+ const [state, setState] = useState({
23
+ inputTypesLoading: false,
24
+ templatesDataLoading: false,
25
+ templateData: {},
26
+ inputTypesData: [],
27
+ });
28
+ const damConfig = useDamConfig();
29
+ const { styles } = damConfig;
30
+ const { variables } = useTheme();
31
+ const api = useMemo(() => createApiClient(damConfig), [damConfig]);
32
+ const params = useAppParams();
33
+ useEffect(() => {
34
+ getInputTypesData();
35
+ }, []);
36
+ useEffect(() => {
37
+ getTemplateData();
38
+ }, [params]);
39
+ const getInputTypesData = () => __awaiter(this, void 0, void 0, function* () {
40
+ setState((prevState) => {
41
+ return Object.assign(Object.assign({}, prevState), { inputTypesLoading: true });
42
+ });
43
+ try {
44
+ const response = yield api.get(FETCH_INPUT_TYPES_URL);
45
+ setState((prevState) => {
46
+ var _a;
47
+ return Object.assign(Object.assign({}, prevState), { inputTypesData: (_a = get(response, "data", [])) === null || _a === void 0 ? void 0 : _a.filter((input) => get(input, "defaultName") !== InputTypes.PERSON), inputTypesLoading: false });
48
+ });
49
+ }
50
+ catch (err) {
51
+ console.log("Error while fetching input types", err);
52
+ setState((prevState) => {
53
+ return Object.assign(Object.assign({}, prevState), { inputTypesLoading: false });
54
+ });
55
+ }
56
+ });
57
+ const getTemplateData = () => __awaiter(this, void 0, void 0, function* () {
58
+ setState((prevState) => {
59
+ return Object.assign(Object.assign({}, prevState), { templateData: true });
60
+ });
61
+ try {
62
+ const response = yield api.get(FETCH_ASSET_URL.replace(":assetId", get(params, "id") || ""));
63
+ setState((prevState) => {
64
+ return Object.assign(Object.assign({}, prevState), { templateData: get(response, "data", []), templatesDataLoading: false });
65
+ });
66
+ }
67
+ catch (error) {
68
+ console.log("Error while fetching template data", error);
69
+ setState((prevState) => {
70
+ return Object.assign(Object.assign({}, prevState), { templatesDataLoading: false });
71
+ });
72
+ }
73
+ });
74
+ return (_jsx("div", { className: "md-lib-h-auto", style: {
75
+ backgroundColor: (styles === null || styles === void 0 ? void 0 : styles.secondaryColor) || (variables === null || variables === void 0 ? void 0 : variables.secondaryColor),
76
+ }, children: (state === null || state === void 0 ? void 0 : state.inputTypesLoading) || (state === null || state === void 0 ? void 0 : state.templatesDataLoading) ? (_jsx(Loader, {})) : (_jsx(EditAssetTemplate, { assetTemplate: get(state, "templateData", {}), inputTypes: get(state, "inputTypesData", []) })) }));
77
+ }
@@ -0,0 +1,14 @@
1
+ import { AddFieldNameFunc } from "../types/assetType";
2
+ import { InputTypeEntity } from "../utilities/constants/interface";
3
+ export default function DraggedField({ provided, field, onAddLabel, onDeleteField, setCurrentFieldIndex, currentFieldIndex, index, showOutputFormat, onUpdateOutputFormat, outputFormatField, }: {
4
+ provided: any;
5
+ field: InputTypeEntity;
6
+ onAddLabel: AddFieldNameFunc;
7
+ onDeleteField: (value: number) => void;
8
+ setCurrentFieldIndex: (value: number | null) => void;
9
+ currentFieldIndex: number | null;
10
+ index: number;
11
+ showOutputFormat: boolean;
12
+ onUpdateOutputFormat: (id: number, key: string, value: string | boolean) => void;
13
+ outputFormatField: InputTypeEntity;
14
+ }): JSX.Element;
@@ -0,0 +1,40 @@
1
+ import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
2
+ import { ICON_SIZE } from "../hocs/appConstants";
3
+ import { Checkbox, DatePicker, Input, InputNumber, Radio, Select } from "antd";
4
+ import { MdDragIndicator } from "react-icons/md";
5
+ import { MdOutlineEdit } from "react-icons/md";
6
+ import { IoMdClose } from "react-icons/io";
7
+ import { get } from "lodash";
8
+ import { InputTypes, } from "../utilities/constants/interface";
9
+ import { getWidgetIcon } from "./FieldsSection";
10
+ const { RangePicker } = DatePicker;
11
+ const MdDragIndicatorIcon = MdDragIndicator;
12
+ const MdOutlineEditIcon = MdOutlineEdit;
13
+ const IoMdCloseIcon = IoMdClose;
14
+ export default function DraggedField({ provided, field, onAddLabel, onDeleteField, setCurrentFieldIndex, currentFieldIndex, index, showOutputFormat, onUpdateOutputFormat, outputFormatField, }) {
15
+ // const [fieldName, setFieldName] = useState("");
16
+ // useEffect(() => {
17
+ // const initialName = get(field, "name", "");
18
+ // setFieldName(initialName);
19
+ // }, [field]);
20
+ const defaultName = get(field, "defaultName");
21
+ const id = get(field, "_id");
22
+ const IconComponent = getWidgetIcon(get(field, "defaultName"));
23
+ return (_jsxs("div", { className: `md-lib-flex md-lib-relative md-lib-gap-2 md-lib-border md-lib-h-100 md-lib-rounded-md md-lib-cursor-pointer md-lib-bg-white dark:md-lib-bg-darkPrimaryHoverColor md-lib-mb-2 ${currentFieldIndex === index && !showOutputFormat
24
+ ? "md-lib-border-primaryColor"
25
+ : "md-lib-border-borderColor dark:md-lib-border-darkBorderColor"}`,
26
+ // onBlur={() =>
27
+ // onAddLabel(id, !!fieldName ? fieldName : get(field, "label", ""))
28
+ // }
29
+ onClick: () => {
30
+ if (!showOutputFormat) {
31
+ setCurrentFieldIndex(index);
32
+ }
33
+ }, children: [_jsx("div", Object.assign({
34
+ // style={{ backgroundColor: variables.secondaryColor }}
35
+ className: "md-lib-flex md-lib-items-center md-lib-rounded-s" }, provided.dragHandleProps, { children: _jsx(MdDragIndicatorIcon, { size: ICON_SIZE, className: "md-lib-h-100" }) })), _jsxs("div", { className: "md-lib-flex-1 md-lib-p-2 md-lib-w-100", children: [_jsxs("div", { className: "md-lib-flex md-lib-items-center md-lib-gap-2 md-lib-mb-3", children: [IconComponent && _jsx(IconComponent, {}), _jsx("label", { className: "md-lib-font-semibold", children: get(field, "name", "Field Name") }), !showOutputFormat && (_jsxs("div", { className: `md-lib-flex md-lib-items-center md-lib-gap-2 md-lib-absolute md-lib-right-3 md-lib--top-3 md-lib-border md-lib-bg-white dark:md-lib-bg-darkPrimaryHoverColor md-lib-rounded-md md-lib-p-1 ${currentFieldIndex === index ? "md-lib-border-primaryColor" : "md-lib-hidden"}`, children: [_jsx(MdOutlineEditIcon, { size: ICON_SIZE, className: "md-lib-cursor-pointer", onClick: () => setCurrentFieldIndex(index), "aria-disabled": showOutputFormat }), _jsx(IoMdCloseIcon, { size: ICON_SIZE, className: "md-lib-cursor-pointer", onClick: (e) => {
36
+ e.stopPropagation();
37
+ onDeleteField(index);
38
+ }, "aria-disabled": showOutputFormat })] }))] }), _jsxs("div", { className: "md-lib-flex md-lib-items-center md-lib-gap-2", children: [(defaultName === InputTypes.TEXT || !defaultName) && (_jsx(Input, { placeholder: get(field, "placeholder", ""), style: { width: "100%" }, size: "large", className: "md-lib-pointer-events-none" })), defaultName === InputTypes.PARAGRAPH && (_jsx(Input.TextArea, { rows: 2, placeholder: get(field, "placeholder", ""), style: { width: "100%" }, size: "large", className: "md-lib-pointer-events-none" })), defaultName === InputTypes.NUMBERS && (_jsx(InputNumber, { placeholder: get(field, "placeholder", ""), style: { width: "100%" }, size: "large", className: "md-lib-pointer-events-none" })), defaultName === InputTypes.DATE && (_jsx(DatePicker, { style: { width: "100%" }, size: "large", className: "md-lib-pointer-events-none" })), defaultName === InputTypes.DATE_RANGE && (_jsx(RangePicker, { placeholder: ["Start", "End"], style: { width: "100%" }, size: "large", className: "md-lib-pointer-events-none" })), (defaultName === InputTypes.SELECT ||
39
+ defaultName === InputTypes.TEAM) && (_jsx(Select, { placeholder: get(field, "placeholder", ""), style: { width: "100%" }, size: "large", className: "md-lib-pointer-events-none", disabled: true })), defaultName === InputTypes.LINK && (_jsx(Input, { placeholder: get(field, "placeholder", ""), style: { width: "100%" }, size: "large", className: "md-lib-pointer-events-none" })), defaultName === InputTypes.RADIO && (_jsx(Radio.Group, { options: [], style: { width: "100%" }, size: "large", className: "md-lib-pointer-events-none" })), defaultName === InputTypes.CHECKBOX && (_jsx(Checkbox.Group, { options: [], style: { width: "100%" }, className: "md-lib-pointer-events-none" })), showOutputFormat && (_jsxs("div", { className: "md-lib-flex md-lib-items-center md-lib-gap-2", children: [_jsx(Checkbox, { onChange: (e) => onUpdateOutputFormat(index, "required", e.target.checked), checked: get(outputFormatField, "required", false), children: "Required" }), _jsx(Input, { placeholder: "Separator", value: get(outputFormatField, "separator", ""), onChange: (e) => onUpdateOutputFormat(index, "separator", e.target.value) })] }))] })] })] }));
40
+ }