@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
@@ -0,0 +1,5 @@
1
+ import { AssetTemplateEntity, InputTypeEntity } from "../utilities/constants/interface";
2
+ export default function EditAssetTemplate({ assetTemplate, inputTypes, }: {
3
+ inputTypes: InputTypeEntity[];
4
+ assetTemplate: AssetTemplateEntity;
5
+ }): JSX.Element;
@@ -0,0 +1,179 @@
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 { Tabs, Typography } from "antd";
13
+ import { useEffect, useMemo, useState } from "react";
14
+ import { IoMdClose } from "react-icons/io";
15
+ // import "../../styles/styles.assetTemplates.scss";
16
+ import { FiSave, FiEdit2 } from "react-icons/fi";
17
+ import AddWidgets from "./FieldsSection";
18
+ import { InputSupportedTypes, InputTypes, NotificationStatus, } from "../utilities/constants/interface";
19
+ import { find, get, includes, map } from "lodash";
20
+ import CustomButton from "../common/Button";
21
+ import { showNotification } from "../common/notifications";
22
+ import { SOMETHING_WENT_WRONG, UPDATE_SUCCESS, } from "../utilities/constants/messages";
23
+ import { FETCH_ASSET_URL } from "../utilities/constants/apiUrls";
24
+ import { ASSETS_SCREEN } from "../utilities/constants/routes";
25
+ import { useDamConfig } from "../hocs/DamConfigContext";
26
+ import { createApiClient } from "../hocs/configureAxios";
27
+ import useAppNavigate from "../utilities/useAppNavigate";
28
+ import useAppParams from "../utilities/useAppParams";
29
+ const { Paragraph } = Typography;
30
+ const IoMdCloseIcon = IoMdClose;
31
+ const FiEdit2Icon = FiEdit2;
32
+ const FiSaveIcon = FiSave;
33
+ export default function EditAssetTemplate({ assetTemplate, inputTypes, }) {
34
+ const { id } = useAppParams();
35
+ const navigate = useAppNavigate();
36
+ const damConfig = useDamConfig();
37
+ const api = useMemo(() => createApiClient(damConfig), [damConfig]);
38
+ const [state, setState] = useState({
39
+ name: get(assetTemplate, "name", ""),
40
+ currentFieldIndex: null,
41
+ fields: get(assetTemplate, "metadataFields", []),
42
+ loading: false,
43
+ showOutputFormat: false,
44
+ imagePickerOutputFormat: get(assetTemplate, "imagePickerOutputFormat", []),
45
+ imagePickerOutputFormatError: false,
46
+ activeTab: "1",
47
+ });
48
+ useEffect(() => {
49
+ setState((prevState) => {
50
+ return Object.assign(Object.assign({}, prevState), { name: get(assetTemplate, "name", ""), fields: get(assetTemplate, "metadataFields", []), imagePickerOutputFormat: get(assetTemplate, "imagePickerOutputFormat", []) });
51
+ });
52
+ }, [assetTemplate]);
53
+ const { name, currentFieldIndex, fields, loading, showOutputFormat, imagePickerOutputFormat, imagePickerOutputFormatError, } = state;
54
+ const transformInputTypePayload = (updatedValues, field, mapId) => {
55
+ const supportedTypes = get(field, "supportedTypes", []);
56
+ const inputTypeSettings = {};
57
+ supportedTypes.forEach((type) => {
58
+ const defaultName = get(type, "defaultName");
59
+ const valueType = get(type, "valueType");
60
+ const typeValue = get(updatedValues, ["inputTypeSettings", defaultName]);
61
+ if (valueType === "boolean") {
62
+ inputTypeSettings[defaultName] = typeValue === true;
63
+ }
64
+ if (includes([
65
+ InputSupportedTypes.CHARACTER_LIMIT,
66
+ InputSupportedTypes.REGEX,
67
+ InputSupportedTypes.VALUE_RANGE,
68
+ InputSupportedTypes.ALLOW_TIME,
69
+ ], defaultName)) {
70
+ if (get(typeValue, "allow")) {
71
+ inputTypeSettings[defaultName] = typeValue;
72
+ }
73
+ else {
74
+ inputTypeSettings[defaultName] = { allow: false };
75
+ }
76
+ }
77
+ });
78
+ const payload = {
79
+ name: get(updatedValues, "name"),
80
+ placeholder: get(updatedValues, "placeholder"),
81
+ isMandatory: get(updatedValues, "isMandatory", false),
82
+ inputTypeSettings,
83
+ label: get(field, "label", get(field, "name", "")),
84
+ defaultName: get(field, "defaultName"),
85
+ mapId,
86
+ defaultValue: get(updatedValues, "defaultValue"),
87
+ };
88
+ if (get(updatedValues, "_id", null)) {
89
+ payload["_id"] = get(updatedValues, "_id");
90
+ }
91
+ if (includes([InputTypes.CHECKBOX, InputTypes.RADIO, InputTypes.SELECT], get(field, "defaultName"))) {
92
+ payload["options"] = get(updatedValues, "options", []);
93
+ }
94
+ return payload;
95
+ };
96
+ const validateImagePickerOutputFormat = () => {
97
+ const filteredOutput = imagePickerOutputFormat.filter((item) => item.required);
98
+ return filteredOutput.reduce((acc, curr, index) => {
99
+ if (index !== filteredOutput.length - 1 && !curr.separator) {
100
+ acc = true;
101
+ }
102
+ return acc;
103
+ }, false);
104
+ };
105
+ const handleSaveTemplate = () => __awaiter(this, void 0, void 0, function* () {
106
+ const imagePickerOutputFormatHasErrors = validateImagePickerOutputFormat();
107
+ if (!imagePickerOutputFormatHasErrors) {
108
+ setState((prevState) => (Object.assign(Object.assign({}, prevState), { loading: true })));
109
+ try {
110
+ const response = yield api.put(FETCH_ASSET_URL.replace(":assetId", id), {
111
+ name: name,
112
+ metadataFields: map(fields, (field) => {
113
+ const currentInputType = find(inputTypes, (input) => get(field, "defaultName") === get(input, "defaultName"));
114
+ return transformInputTypePayload(field, currentInputType, get(field, "mapId", ""));
115
+ }),
116
+ imagePickerOutputFormat: imagePickerOutputFormat.map((field) => {
117
+ const finalField = {
118
+ name: field.name,
119
+ placeholder: field.placeholder,
120
+ label: field.label,
121
+ defaultName: field.defaultName,
122
+ required: field.required,
123
+ separator: field.separator,
124
+ mapId: field.mapId,
125
+ };
126
+ if (field._id) {
127
+ finalField["_id"] = field._id;
128
+ }
129
+ return finalField;
130
+ }),
131
+ });
132
+ navigate(ASSETS_SCREEN);
133
+ showNotification(get(response, "data.message", UPDATE_SUCCESS), NotificationStatus.SUCCESS);
134
+ }
135
+ catch (error) {
136
+ showNotification(get(error, "message", SOMETHING_WENT_WRONG), NotificationStatus.ERROR);
137
+ }
138
+ finally {
139
+ setState((prevState) => (Object.assign(Object.assign({}, prevState), { loading: false })));
140
+ }
141
+ }
142
+ else {
143
+ setState((prevState) => (Object.assign(Object.assign({}, prevState), { imagePickerOutputFormatError: true })));
144
+ }
145
+ });
146
+ const toggleShowOutputFormat = () => {
147
+ const hasErrors = validateImagePickerOutputFormat();
148
+ setState((prevState) => (Object.assign(Object.assign({}, prevState), { showOutputFormat: !prevState.showOutputFormat, imagePickerOutputFormatError: hasErrors })));
149
+ };
150
+ const tabs = [
151
+ {
152
+ key: "1",
153
+ label: "Fields",
154
+ children: (_jsx(AddWidgets, { name: name, inputTypes: inputTypes, transformInputTypePayload: transformInputTypePayload, currentFieldIndex: currentFieldIndex, setState: setState, fields: fields, imagePickerOutputFormat: imagePickerOutputFormat, setCurrentFieldIndex: (value) => setState((prevState) => (Object.assign(Object.assign({}, prevState), { currentFieldIndex: value }))), showOutputFormat: false })),
155
+ },
156
+ {
157
+ key: "2",
158
+ label: "Image picker output format",
159
+ disabled: fields.length === 0,
160
+ children: (_jsx(AddWidgets, { name: name, inputTypes: inputTypes, transformInputTypePayload: transformInputTypePayload, currentFieldIndex: currentFieldIndex, setState: setState, fields: fields, imagePickerOutputFormat: imagePickerOutputFormat, setCurrentFieldIndex: (value) => setState((prevState) => (Object.assign(Object.assign({}, prevState), { currentFieldIndex: value }))), showOutputFormat: true })),
161
+ },
162
+ ];
163
+ // console.log("edit asset template", fields, imagePickerOutputFormat);
164
+ return (_jsx(_Fragment, { children: _jsx(Tabs, { items: tabs, tabBarStyle: {
165
+ background: "white",
166
+ display: "flex",
167
+ justifyContent: "center",
168
+ alignItems: "center",
169
+ marginBottom: 0,
170
+ }, centered: true, tabBarExtraContent: {
171
+ left: (_jsxs("div", { className: "md-lib-flex md-lib-items-center md-lib-border-b md-lib-p-3 md-lib-border-borderColor dark:md-lib-border-darkBorderColor dark:md-lib-bg-darkPrimary md-lib-bg-white", children: [_jsx(IoMdCloseIcon, { size: ICON_SIZE, onClick: () => navigate(ASSETS_SCREEN), className: "md-lib-cursor-pointer" }), _jsx(Paragraph, { className: "md-lib-text-xl md-lib-border-l md-lib-pl-4 md-lib-ml-4 md-lib-asset-template-title", style: { marginBottom: "0px !important" }, editable: {
172
+ onChange: (val) => setState((prevState) => (Object.assign(Object.assign({}, prevState), { name: val }))),
173
+ icon: _jsx(FiEdit2Icon, { size: 15, className: "md-lib-ml-2" }),
174
+ }, children: name })] })),
175
+ right: (_jsxs("div", { className: "md-lib-flex md-lib-items-center md-lib-gap-2 md-lib-ml-auto", children: [imagePickerOutputFormatError && (_jsx("p", { className: "md-lib-text-sm md-lib-text-red-500", children: "Please fix the errors in the Image Picker Output format" })), _jsx(CustomButton, { label: "Cancel", onClick: () => navigate(ASSETS_SCREEN) }), _jsx(CustomButton, { label: "Save", type: currentFieldIndex !== null ? "default" : "primary", icon: _jsx(FiSaveIcon, {}), disabled: currentFieldIndex !== null, onClick: handleSaveTemplate, loading: loading })] })),
176
+ }, onChange: (key) => setState((prevState) => {
177
+ return Object.assign(Object.assign({}, prevState), { activeTab: key, currentFieldIndex: key === "2" ? null : prevState.currentFieldIndex });
178
+ }) }) }));
179
+ }
@@ -0,0 +1,14 @@
1
+ import { SetStateAction } from "react";
2
+ import { InputTypeEntity } from "../utilities/constants/interface";
3
+ export declare const getWidgetIcon: (defaultName: string) => import("react-icons").IconType | null;
4
+ export default function FieldsSection({ name, inputTypes, transformInputTypePayload, currentFieldIndex, setCurrentFieldIndex, fields, setState, showOutputFormat, imagePickerOutputFormat, }: {
5
+ name: string;
6
+ inputTypes: InputTypeEntity[];
7
+ transformInputTypePayload: (values: any, field: InputTypeEntity, mapId: string) => void;
8
+ currentFieldIndex: number | null;
9
+ setCurrentFieldIndex: (value: number | null) => void;
10
+ fields: InputTypeEntity[];
11
+ setState: React.Dispatch<SetStateAction<any>>;
12
+ showOutputFormat: boolean;
13
+ imagePickerOutputFormat: InputTypeEntity[];
14
+ }): JSX.Element;
@@ -0,0 +1,239 @@
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 { Typography } from "antd";
13
+ import { useMemo, useState } from "react";
14
+ import { DragDropContext, Droppable, Draggable } from "react-beautiful-dnd";
15
+ import DraggedField from "./DraggedField";
16
+ import AddFieldProperties from "./AddFieldProperties";
17
+ import { InputTypes, NotificationStatus, } from "../utilities/constants/interface";
18
+ import { filter, find, first, get, isEqual, map, reduce, toNumber, uniqueId, } from "lodash";
19
+ import { CiCalendarDate, CiLink, CiText } from "react-icons/ci";
20
+ import { BsTextParagraph } from "react-icons/bs";
21
+ import { RiNumbersLine } from "react-icons/ri";
22
+ import { MdOutlineDateRange, MdOutlineGroup } from "react-icons/md";
23
+ import { GoSingleSelect } from "react-icons/go";
24
+ import { IoIosRadioButtonOff } from "react-icons/io";
25
+ import { IoCheckboxOutline } from "react-icons/io5";
26
+ import { FaRegUser } from "react-icons/fa";
27
+ import { showNotification } from "../common/notifications";
28
+ import { DELETE_CONFIRMATION_MESSAGE, DELETE_MESSAGE_DESCRIPTION, DELETE_OK_TEXT, DELETE_SUCCESS, INPUT_SETTINGS_VALIDATION_ERROR, INPUT_SETTINGS_VALIDATION_ERROR_AT_SWITCH_INPUT, SOMETHING_WENT_WRONG, } from "../utilities/constants/messages";
29
+ import { getInputTypeValidationErrors } from "../utilities/helpers/validators";
30
+ import { DELETE_ASSET_FIELD_URL } from "../utilities/constants/apiUrls";
31
+ import { DeleteConfirmationModal } from "../common/CustomElements";
32
+ import { createApiClient } from "../hocs/configureAxios";
33
+ import { useDamConfig } from "../hocs/DamConfigContext";
34
+ import { EMPTY_ASSET_TEMPLATE_WIDGETS_URL } from "../utilities/constants/imageUrls";
35
+ import _ from "lodash";
36
+ import useAppParams from "../utilities/useAppParams";
37
+ export const getWidgetIcon = (defaultName) => {
38
+ switch (defaultName.toUpperCase()) {
39
+ case InputTypes.TEXT:
40
+ return CiText;
41
+ case InputTypes.PARAGRAPH:
42
+ return BsTextParagraph;
43
+ case InputTypes.NUMBERS:
44
+ return RiNumbersLine;
45
+ case InputTypes.DATE:
46
+ return CiCalendarDate;
47
+ case InputTypes.DATE_RANGE:
48
+ return MdOutlineDateRange;
49
+ case InputTypes.SELECT:
50
+ return GoSingleSelect;
51
+ case InputTypes.LINK:
52
+ return CiLink;
53
+ case InputTypes.RADIO:
54
+ return IoIosRadioButtonOff;
55
+ case InputTypes.CHECKBOX:
56
+ return IoCheckboxOutline;
57
+ case InputTypes.PERSON:
58
+ return FaRegUser;
59
+ case InputTypes.TEAM:
60
+ return MdOutlineGroup;
61
+ default:
62
+ return null;
63
+ }
64
+ };
65
+ export default function FieldsSection({ name, inputTypes, transformInputTypePayload, currentFieldIndex, setCurrentFieldIndex, fields, setState, showOutputFormat, imagePickerOutputFormat, }) {
66
+ const { id } = useAppParams();
67
+ const [fieldState, setFieldState] = useState({
68
+ showConfirmModal: false,
69
+ selectedField: null,
70
+ loading: false,
71
+ });
72
+ const { showConfirmModal, selectedField, loading } = fieldState;
73
+ const damConfig = useDamConfig();
74
+ const api = useMemo(() => createApiClient(damConfig), [damConfig]);
75
+ const toggleConfirmModal = (field = null) => {
76
+ setFieldState((prevState) => (Object.assign(Object.assign({}, prevState), { showConfirmModal: !prevState.showConfirmModal, selectedField: field, loading: false })));
77
+ };
78
+ const onDragEnd = (result) => {
79
+ const source = get(result, "source");
80
+ const destination = get(result, "destination");
81
+ if (!destination)
82
+ return;
83
+ if (get(source, "droppableId") === "droppable1" &&
84
+ get(destination, "droppableId") === "droppable1")
85
+ return;
86
+ if (isEqual(source, "droppable2") && isEqual(destination, "droppable1"))
87
+ return;
88
+ if (get(source, "droppableId") === get(destination, "droppableId") &&
89
+ get(fields, "length", 0) > 0) {
90
+ const reorderedFields = showOutputFormat
91
+ ? [...imagePickerOutputFormat]
92
+ : [...fields];
93
+ const [moved] = reorderedFields.splice(get(source, "index"), 1);
94
+ reorderedFields.splice(get(destination, "index"), 0, moved);
95
+ setState((prevState) => (Object.assign(Object.assign({}, prevState), { fields: showOutputFormat ? fields : reorderedFields, imagePickerOutputFormat: showOutputFormat
96
+ ? reorderedFields
97
+ : imagePickerOutputFormat })));
98
+ }
99
+ else {
100
+ const draggedWidget = find(inputTypes, (type) => get(type, "_id") === get(result, "draggableId"));
101
+ if (draggedWidget) {
102
+ const maxIdField = reduce(fields, (prev, curr) => {
103
+ return toNumber(get(curr, "_id")) > toNumber(get(prev, "_id"))
104
+ ? curr
105
+ : prev;
106
+ }, first(fields) || { _id: "0" });
107
+ const newWidget = Object.assign(Object.assign({}, draggedWidget), { label: get(draggedWidget, "name", ""), _id: null, mapId: uniqueId() });
108
+ const reorderedFields = [...fields];
109
+ const imagePickerOutputFormatFields = [...imagePickerOutputFormat];
110
+ reorderedFields.splice(get(destination, "index"), 0, newWidget);
111
+ imagePickerOutputFormatFields.splice(get(destination, "index"), 0, Object.assign(Object.assign({}, newWidget), { required: false, separator: "" }));
112
+ setState((prevState) => (Object.assign(Object.assign({}, prevState), { fields: reorderedFields, currentFieldIndex: get(destination, "index", null), imagePickerOutputFormat: imagePickerOutputFormatFields })));
113
+ }
114
+ }
115
+ };
116
+ const onAddLabel = (id, value) => {
117
+ const updatedFields = map(fields, (field) => {
118
+ if (get(field, "_id") === id) {
119
+ return Object.assign(Object.assign({}, field), { label: value });
120
+ }
121
+ return field;
122
+ });
123
+ const updatedImagePickerOutputFormat = map(imagePickerOutputFormat, (field) => {
124
+ if (get(field, "_id") === id) {
125
+ return Object.assign(Object.assign({}, field), { label: value });
126
+ }
127
+ return field;
128
+ });
129
+ setState((prevState) => (Object.assign(Object.assign({}, prevState), { fields: updatedFields, imagePickerOutputFormat: updatedImagePickerOutputFormat })));
130
+ };
131
+ const onUpdateOutputFormat = (id, key, value) => {
132
+ // console.log(id, key, value, "onUpdateOutputFormat");
133
+ const updatedImagePickerOutputFormat = map(imagePickerOutputFormat, (field, index) => {
134
+ if (index === id) {
135
+ return Object.assign(Object.assign({}, field), { [key]: value });
136
+ }
137
+ return field;
138
+ });
139
+ setState((prevState) => (Object.assign(Object.assign({}, prevState), { imagePickerOutputFormat: updatedImagePickerOutputFormat })));
140
+ };
141
+ // console.log(imagePickerOutputFormat, "imagePickerOutputFormat", fields);
142
+ const onDeleteField = (ind) => {
143
+ const currentField = fields.find((field, index) => index === ind);
144
+ const updatedFields = filter(fields, (field, index) => index !== ind);
145
+ const deleteField = find(fields, (field, index) => index === ind);
146
+ const updatedImagePickerOutputFormat = filter(imagePickerOutputFormat, (field, index) => get(currentField, "mapId") !== get(field, "mapId"));
147
+ if (get(deleteField, "_id")) {
148
+ toggleConfirmModal(deleteField);
149
+ }
150
+ else {
151
+ setState((prevState) => (Object.assign(Object.assign({}, prevState), { fields: updatedFields, currentFieldIndex: null, imagePickerOutputFormat: updatedImagePickerOutputFormat })));
152
+ }
153
+ };
154
+ const onDeleteExistedField = () => __awaiter(this, void 0, void 0, function* () {
155
+ setFieldState((prevState) => (Object.assign(Object.assign({}, prevState), { loading: true })));
156
+ try {
157
+ const response = yield api.delete(DELETE_ASSET_FIELD_URL.replace(":assetId", id).replace(":id", get(selectedField, "_id")));
158
+ const updatedFields = filter(fields, (field, index) => get(field, "_id") !== get(selectedField, "_id"));
159
+ const updatedImagePickerOutputFormat = filter(imagePickerOutputFormat, (field, index) => get(field, "mapId") !== get(selectedField, "mapId"));
160
+ setState((prevState) => (Object.assign(Object.assign({}, prevState), { fields: updatedFields, currentFieldIndex: null, imagePickerOutputFormat: updatedImagePickerOutputFormat })));
161
+ toggleConfirmModal();
162
+ showNotification(get(response, "data.message", DELETE_SUCCESS), NotificationStatus.SUCCESS);
163
+ }
164
+ catch (error) {
165
+ setFieldState((prevState) => (Object.assign(Object.assign({}, prevState), { loading: false })));
166
+ showNotification(get(error, "message", SOMETHING_WENT_WRONG), NotificationStatus.ERROR);
167
+ }
168
+ });
169
+ const currentField = useMemo(() => {
170
+ return find(fields, (field, index) => index === currentFieldIndex);
171
+ }, [currentFieldIndex, fields]);
172
+ const currentInputType = useMemo(() => {
173
+ return find(inputTypes, (input) => get(currentField, "defaultName") === get(input, "defaultName"));
174
+ }, [inputTypes, currentField]);
175
+ const onUpdateField = (updatedValues, existedField, index) => {
176
+ const currentField = index || index == 0 ? (fields === null || fields === void 0 ? void 0 : fields[index]) || null : null;
177
+ const data = transformInputTypePayload(updatedValues, existedField, get(currentField, "mapId", ""));
178
+ const updatedFields = map(fields, (field, i) => {
179
+ if (i === index) {
180
+ return data;
181
+ }
182
+ return field;
183
+ });
184
+ // console.log("imagepicker", imagePickerOutputFormat);
185
+ const updatedImagePickerOutputFormat = map(imagePickerOutputFormat, (field, i) => {
186
+ if (currentField &&
187
+ get(field, "mapId") &&
188
+ get(currentField, "mapId") === get(field, "mapId")) {
189
+ return Object.assign(Object.assign({}, field), { name: get(data, "name"), label: get(data, "label"), placeholder: get(data, "placeholder"), defaultName: get(data, "defaultName") });
190
+ }
191
+ return field;
192
+ });
193
+ setState((prevState) => (Object.assign(Object.assign({}, prevState), { fields: updatedFields, imagePickerOutputFormat: updatedImagePickerOutputFormat })));
194
+ };
195
+ const getFormattedValue = (data) => {
196
+ const sortedData = _.sortBy(data, "order");
197
+ const value = sortedData === null || sortedData === void 0 ? void 0 : sortedData.reduce((acc, field) => {
198
+ if (field === null || field === void 0 ? void 0 : field.required) {
199
+ // if (field?.name !== "File Url") {
200
+ acc = acc + (field === null || field === void 0 ? void 0 : field.name);
201
+ if (field === null || field === void 0 ? void 0 : field.separator) {
202
+ acc = acc + (field === null || field === void 0 ? void 0 : field.separator);
203
+ }
204
+ // }
205
+ }
206
+ return acc;
207
+ }, "");
208
+ return value;
209
+ };
210
+ // console.log("imagepicker output format", imagePickerOutputFormat);
211
+ return (_jsxs(_Fragment, { children: [" ", _jsx(DragDropContext, { onDragEnd: currentFieldIndex === null || showOutputFormat
212
+ ? onDragEnd
213
+ : () => {
214
+ !showOutputFormat &&
215
+ showNotification(INPUT_SETTINGS_VALIDATION_ERROR, NotificationStatus.WARN);
216
+ }, children: _jsxs("div", { className: `md-lib-grid ${showOutputFormat ? "md-lib-grid-cols-1" : "md-lib-grid-cols-4"} ${showOutputFormat ? "md-lib-h-screen" : ""}`, children: [showOutputFormat && (_jsxs("div", { className: "md-lib-p-8", children: [_jsx("p", { className: "md-lib-text-sm md-lib-text-orange-500", children: "Note: Please ensure that all required fields has separators" }), _jsxs("div", { className: "md-lib-flex md-lib-items-center md-lib-gap-2", children: [_jsx("p", { className: "md-lib-text-sm md-lib-font-semibold", children: "Sample File Format: " }), _jsx("pre", { children: getFormattedValue(imagePickerOutputFormat) })] })] })), !showOutputFormat && (_jsx(Droppable, { droppableId: "droppable1", children: (provided) => (_jsxs("div", Object.assign({}, provided.droppableProps, { ref: provided.innerRef, children: [_jsxs("div", { className: "md-lib-p-3 md-lib-col-span-1 md-lib-border-r dark:md-lib-border-darkBorderColor dark:md-lib-bg-darkPrimary", children: [_jsx(Typography.Title, { level: 4, children: "Form Widgets" }), _jsx("p", { className: "md-lib-text-sm md-lib-description md-lib-mb-3", children: "Drag and drop form elements in additional section" }), map(inputTypes, (type, index) => {
217
+ const IconComponent = getWidgetIcon(get(type, "defaultName"));
218
+ return (_jsx(Draggable, { draggableId: get(type, "_id"), index: index, children: (provided) => (_jsxs("div", Object.assign({ className: "md-lib-flex md-lib-items-center md-lib-gap-2 md-lib-bg-white dark:md-lib-bg-darkPrimaryHoverColor md-lib-p-3 md-lib-mb-2 md-lib-rounded", ref: provided.innerRef }, provided.draggableProps, provided.dragHandleProps, { children: [IconComponent && (_jsx(IconComponent, { size: ICON_SIZE })), _jsx("p", { children: get(type, "name") })] }))) }, get(type, "_id")));
219
+ })] }), provided.placeholder] }))) })), _jsx("div", { className: `${!!currentField && !showOutputFormat ? "md-lib-col-span-2" : "md-lib-col-span-3"} dark:md-lib-bg-darkPrimary`, children: _jsx(Droppable, { droppableId: "droppable2", children: (provided) => (_jsxs("div", Object.assign({}, provided.droppableProps, { ref: provided.innerRef, className: "md-lib-bg-white dark:md-lib-bg-darkPrimaryHoverColor md-lib-rounded-[20px] md-lib-my-4 md-lib-mx-8", children: [_jsx("p", { className: "md-lib-text-xl md-lib-border-b md-lib-p-3 md-lib-asset-template-title md-lib-truncate", children: name }), _jsx("div", { className: "md-lib-p-4", children: get(fields, "length") === 0 ? (_jsxs("div", { className: "md-lib-flex md-lib-flex-col md-lib-items-center md-lib-justify-center", children: [_jsx("img", { src: EMPTY_ASSET_TEMPLATE_WIDGETS_URL, alt: "Empty Asset Template Widgets", width: 250, height: 250 }), _jsx("p", { className: "md-lib-text-sm md-lib-description md-lib-mt-2", children: "Drag fields to create form" })] })) : (map(showOutputFormat ? imagePickerOutputFormat : fields, (field, index) => (_jsx(Draggable, { draggableId: `${(field === null || field === void 0 ? void 0 : field._id)
220
+ ? `selected-${get(field, "_id")}`
221
+ : `selected-${index}`}`, index: index, children: (provided) => (_jsx("div", Object.assign({ ref: provided.innerRef }, provided.draggableProps, { children: _jsx(DraggedField, { provided: provided, field: field, outputFormatField: imagePickerOutputFormat === null || imagePickerOutputFormat === void 0 ? void 0 : imagePickerOutputFormat[index], onAddLabel: onAddLabel, onDeleteField: onDeleteField, onUpdateOutputFormat: onUpdateOutputFormat, setCurrentFieldIndex: (val) => __awaiter(this, void 0, void 0, function* () {
222
+ if (currentFieldIndex === null) {
223
+ setCurrentFieldIndex(val);
224
+ return;
225
+ }
226
+ const field = currentField;
227
+ const currentInputType = find(inputTypes, (input) => get(field, "defaultName") ===
228
+ get(input, "defaultName"));
229
+ const validationErrors = getInputTypeValidationErrors(field, currentInputType);
230
+ if (validationErrors.length > 0 &&
231
+ !showOutputFormat) {
232
+ showNotification(INPUT_SETTINGS_VALIDATION_ERROR_AT_SWITCH_INPUT, NotificationStatus.WARN);
233
+ return;
234
+ }
235
+ setCurrentFieldIndex(val);
236
+ }), currentFieldIndex: currentFieldIndex, index: index, showOutputFormat: showOutputFormat }) }))) }, `${(field === null || field === void 0 ? void 0 : field._id)
237
+ ? `selected-${get(field, "_id")}`
238
+ : `selected-${index}`}`)))) }), provided.placeholder] }))) }) }), !!currentField && !showOutputFormat && (_jsx("div", { className: "md-lib-col-span-1 md-lib-bg-white dark:md-lib-bg-darkPrimaryHoverColor", children: _jsx(AddFieldProperties, { field: currentField, index: currentFieldIndex, setCurrentFieldIndex: (val) => setCurrentFieldIndex(val), onUpdateField: (updatedValues, field, index) => onUpdateField(updatedValues, field, index), currentInputType: currentInputType, allFields: fields }) }))] }) }), showConfirmModal && (_jsx(DeleteConfirmationModal, { showDeleteModal: showConfirmModal, toggleDeleteModal: toggleConfirmModal, okText: DELETE_OK_TEXT, onOk: onDeleteExistedField, loading: loading, description: DELETE_CONFIRMATION_MESSAGE.replace(":action", "Delete").replace(":entity", `${get(selectedField, "name", "this field")}`), subHeading: DELETE_MESSAGE_DESCRIPTION }))] }));
239
+ }
@@ -0,0 +1,2 @@
1
+ declare function AssetTemplatesContainer(): JSX.Element;
2
+ export default AssetTemplatesContainer;
@@ -0,0 +1,71 @@
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 { useEffect, useMemo, useState } from "react";
12
+ import { get, includes } from "lodash";
13
+ import { DEFAULT_PAGE } from "../hocs/appConstants";
14
+ import AssetTemplatesTable from "./AssetTemplatesTable";
15
+ import { NotificationStatus, SortOrders, } from "../utilities/constants/interface";
16
+ import { showNotification } from "../common/notifications";
17
+ import { SOMETHING_WENT_WRONG } from "../utilities/constants/messages";
18
+ import { FETCH_ASSETS_URL } from "../utilities/constants/apiUrls";
19
+ import { useDamConfig } from "../hocs/DamConfigContext";
20
+ import PageTitle from "../ui/pageTitle";
21
+ import CreateAssetTemplate from "./CreateAssetTemplate";
22
+ import { NOT_FOUND_IMAGE_URL } from "../utilities/constants/imageUrls";
23
+ import { createApiClient } from "../hocs/configureAxios";
24
+ import { addQueryParams } from "../hocs/helpers";
25
+ import Loader from "../common/loader/loader";
26
+ function AssetTemplatesContainer() {
27
+ const damConfig = useDamConfig();
28
+ const api = useMemo(() => createApiClient(damConfig), [damConfig]);
29
+ const [state, setState] = useState({
30
+ loading: false,
31
+ totalCount: 0,
32
+ totalPages: 0,
33
+ assetTemplates: [],
34
+ filters: {
35
+ sortBy: "createdAt",
36
+ sortOrder: SortOrders.DESCEND,
37
+ page: DEFAULT_PAGE,
38
+ name: "",
39
+ },
40
+ });
41
+ const { loading, totalCount, totalPages, assetTemplates, filters } = state;
42
+ const { brand } = damConfig;
43
+ useEffect(() => {
44
+ if (brand) {
45
+ onFetchAssetTemplates({});
46
+ }
47
+ }, [brand]);
48
+ const onFetchAssetTemplates = (...args_1) => __awaiter(this, [...args_1], void 0, function* (params = {}) {
49
+ setState((prev) => (Object.assign(Object.assign({}, prev), { loading: true })));
50
+ Object.keys(params).forEach((key) => {
51
+ if (includes(["name"], key) && params[key] && params[key].length > 2) {
52
+ return;
53
+ }
54
+ if (params[key] === undefined ||
55
+ params[key] === "" ||
56
+ params[key] === null) {
57
+ delete params[key];
58
+ }
59
+ });
60
+ try {
61
+ const response = yield api.get(`${FETCH_ASSETS_URL.replace(":brandId", get(brand, "_id"))}?${addQueryParams(params)}`);
62
+ setState((prev) => (Object.assign(Object.assign({}, prev), { assetTemplates: get(response, "data.data", []), totalCount: get(response, "data.total"), totalPages: get(response, "data.totalPages"), filters: params, loading: false })));
63
+ }
64
+ catch (error) {
65
+ showNotification(get(error, "message", SOMETHING_WENT_WRONG), NotificationStatus.ERROR);
66
+ setState((prev) => (Object.assign(Object.assign({}, prev), { loading: false })));
67
+ }
68
+ });
69
+ return (_jsx("div", { className: "md-lib-p-4", children: loading ? (_jsx(Loader, {})) : (_jsxs(_Fragment, { children: [_jsxs("div", { className: "md-lib-flex md-lib-items-center", children: [_jsx(PageTitle, { label: "Assets Templates" }), get(assetTemplates, "length") > 0 && (_jsx("div", { className: "md-lib-ml-auto md-lib-hidden md:md-lib-block", children: _jsx(CreateAssetTemplate, { label: "Create" }) }))] }), (get(assetTemplates, "length") > 0 || Object.keys(filters).length > 0) ? (_jsx("div", { className: "md-lib-mt-4", children: _jsx(AssetTemplatesTable, { assetTemplates: assetTemplates, totalCount: totalCount, totalPages: totalPages, onFetchAssetTemplates: onFetchAssetTemplates, filters: filters, loading: loading }) })) : (_jsxs("div", { className: "md-lib-flex md-lib-flex-col md-lib-items-center md-lib-justify-center", children: [_jsx("img", { src: NOT_FOUND_IMAGE_URL, alt: "Not Found", width: 300, height: 300 }), _jsx("p", { className: "md-lib-mt-3 md-lib-text-sm md-lib-font-semibold", children: "No ticket template has been created yet" }), _jsx("div", { className: "md-lib-mt-4 md-lib-hidden md:md-lib-block", children: _jsx(CreateAssetTemplate, { label: "Add Template" }) })] }))] })) }));
70
+ }
71
+ export default AssetTemplatesContainer;
@@ -0,0 +1,5 @@
1
+ import { InputTypeEntity, InputTypeSupportedTypeEntity } from "../../utilities/constants/interface";
2
+ export default function DateField({ field, supportedTypes, }: {
3
+ field: InputTypeEntity;
4
+ supportedTypes: InputTypeSupportedTypeEntity[];
5
+ }): JSX.Element;
@@ -0,0 +1,23 @@
1
+ import { jsx as _jsx, jsxs as _jsxs, Fragment as _Fragment } from "react/jsx-runtime";
2
+ import { InputSupportedTypes, } from "../../utilities/constants/interface";
3
+ import { Col, Form, Row, Switch } from "antd";
4
+ import { get, isEqual, find, map } from "lodash";
5
+ import { useEffect, useState } from "react";
6
+ export default function DateField({ field, supportedTypes, }) {
7
+ const [allowTimeEnabled, setAllowTimeEnabled] = useState(false);
8
+ useEffect(() => {
9
+ const timeSupport = find(supportedTypes, (s) => get(s, "defaultName") === InputSupportedTypes.ALLOW_TIME);
10
+ setAllowTimeEnabled(!!timeSupport);
11
+ }, [supportedTypes]);
12
+ return (_jsx(_Fragment, { children: map(supportedTypes, (type) => {
13
+ const defaultName = get(type, "defaultName");
14
+ const name = get(type, "name");
15
+ const valueType = get(type, "valueType");
16
+ const id = get(type, "_id");
17
+ if (isEqual(defaultName, InputSupportedTypes.ALLOW_TIME) &&
18
+ isEqual(valueType, "boolean")) {
19
+ return (_jsxs(Row, { className: "md-lib-flex md-lib-items-center", children: [_jsx(Col, { span: 12, children: name }), _jsx(Col, { span: 12, push: 8, children: _jsx(Form.Item, { name: ["inputTypeSettings", defaultName, "allow"], className: "md-lib-mb-0", valuePropName: "checked", children: _jsx(Switch, { onChange: (val) => setAllowTimeEnabled(val) }) }) })] }, id));
20
+ }
21
+ return null;
22
+ }) }));
23
+ }
@@ -0,0 +1,5 @@
1
+ import { InputTypeEntity, InputTypeSupportedTypeEntity } from "../../utilities/constants/interface";
2
+ export default function NumberField({ field, supportedTypes, }: {
3
+ field: InputTypeEntity;
4
+ supportedTypes: InputTypeSupportedTypeEntity[];
5
+ }): JSX.Element;