@antscorp/antsomi-ui 1.3.3-beta.7 → 1.3.3-beta.70

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 (372) hide show
  1. package/es/assets/images/iphone-top-bar.png +0 -0
  2. package/es/assets/images/iphone.png +0 -0
  3. package/es/assets/images/stars_slider.png +0 -0
  4. package/es/components/atoms/Button/index.d.ts +1 -8
  5. package/es/components/atoms/Empty/Empty.d.ts +6 -5
  6. package/es/components/atoms/Empty/Empty.js +7 -1
  7. package/es/components/atoms/Flex/Flex.d.ts +2 -0
  8. package/es/components/atoms/Flex/Flex.js +1 -0
  9. package/es/components/atoms/Flex/index.d.ts +1 -0
  10. package/es/components/atoms/Flex/index.js +1 -0
  11. package/es/components/atoms/Input/Input.d.ts +14 -3
  12. package/es/components/atoms/Input/Input.js +7 -3
  13. package/es/components/atoms/InputDynamic/EditCaretPositioning.d.ts +2 -0
  14. package/es/components/atoms/InputDynamic/EditCaretPositioning.js +89 -0
  15. package/es/components/atoms/InputDynamic/InputDynamic.d.ts +10 -0
  16. package/es/components/atoms/InputDynamic/InputDynamic.js +504 -0
  17. package/es/components/atoms/InputDynamic/PopupShortLink.d.ts +16 -0
  18. package/es/components/atoms/InputDynamic/PopupShortLink.js +85 -0
  19. package/es/components/atoms/InputDynamic/constants.d.ts +71 -0
  20. package/es/components/atoms/InputDynamic/constants.js +71 -0
  21. package/es/components/atoms/InputDynamic/index.d.ts +2 -0
  22. package/es/components/atoms/InputDynamic/index.js +1 -0
  23. package/es/components/atoms/InputDynamic/styled.d.ts +13 -0
  24. package/es/components/atoms/InputDynamic/styled.js +293 -0
  25. package/es/components/atoms/InputDynamic/types.d.ts +110 -0
  26. package/es/components/atoms/InputDynamic/types.js +1 -0
  27. package/es/components/atoms/InputDynamic/utils.d.ts +30 -0
  28. package/es/components/atoms/InputDynamic/utils.js +872 -0
  29. package/es/components/atoms/MobileFrame/MobileFrame.d.ts +4 -0
  30. package/es/components/atoms/MobileFrame/MobileFrame.js +22 -0
  31. package/es/components/atoms/MobileFrame/constants.d.ts +4 -0
  32. package/es/components/atoms/MobileFrame/constants.js +4 -0
  33. package/es/components/atoms/MobileFrame/index.d.ts +2 -0
  34. package/es/components/atoms/MobileFrame/index.js +1 -0
  35. package/es/components/atoms/MobileFrame/styled.d.ts +3 -0
  36. package/es/components/atoms/MobileFrame/styled.js +33 -0
  37. package/es/components/atoms/Pagination/index.d.ts +1 -0
  38. package/es/components/atoms/Popover/Popover.d.ts +1 -1
  39. package/es/components/atoms/Popover/styled.d.ts +1 -1
  40. package/es/components/atoms/PreviewTabs/PreviewTabs.d.ts +7 -0
  41. package/es/components/atoms/PreviewTabs/PreviewTabs.js +67 -0
  42. package/es/components/atoms/PreviewTabs/index.d.ts +2 -0
  43. package/es/components/atoms/PreviewTabs/index.js +1 -0
  44. package/es/components/atoms/PreviewTabs/styled.d.ts +6 -0
  45. package/es/components/atoms/PreviewTabs/styled.js +79 -0
  46. package/es/components/atoms/Progress/Progress.d.ts +1 -1
  47. package/es/components/atoms/Radio/index.d.ts +3 -3
  48. package/es/components/atoms/RateV2/RateV2.d.ts +18 -0
  49. package/es/components/atoms/RateV2/RateV2.js +73 -0
  50. package/es/components/atoms/RateV2/index.d.ts +1 -0
  51. package/es/components/atoms/RateV2/index.js +1 -0
  52. package/es/components/atoms/RequiredLabel/index.d.ts +1 -0
  53. package/es/components/atoms/RequiredLabel/index.js +4 -3
  54. package/es/components/atoms/Slider/index.d.ts +2 -1
  55. package/es/components/atoms/Slider/index.js +7 -14
  56. package/es/components/atoms/SliderV2/index.d.ts +6 -0
  57. package/es/components/atoms/SliderV2/index.js +21 -0
  58. package/es/components/atoms/Space/Space.d.ts +1 -1
  59. package/es/components/atoms/Spin/Spin.d.ts +2 -1
  60. package/es/components/atoms/Spin/styled.d.ts +1 -1
  61. package/es/components/atoms/Statistic/Statistic.d.ts +1 -4
  62. package/es/components/atoms/index.d.ts +8 -0
  63. package/es/components/atoms/index.js +6 -0
  64. package/es/components/common/ConfigProvider/ConfigProvider.js +6 -0
  65. package/es/components/common/ConfigProvider/GlobalStyle.js +281 -27
  66. package/es/components/icons/ArrowGrowIcon.d.ts +2 -1
  67. package/es/components/icons/AudioRecordIcon.d.ts +2 -1
  68. package/es/components/icons/BugIcon.d.ts +2 -1
  69. package/es/components/icons/CameraIcon.d.ts +2 -1
  70. package/es/components/icons/CaptureIcon.d.ts +2 -1
  71. package/es/components/icons/CheckSlimIcon.d.ts +2 -1
  72. package/es/components/icons/CloseIcon.d.ts +2 -1
  73. package/es/components/icons/CommentIcon.d.ts +2 -1
  74. package/es/components/icons/EventIcon.d.ts +2 -1
  75. package/es/components/icons/FreeDrawIcon.d.ts +2 -1
  76. package/es/components/icons/GPTIcon.d.ts +2 -1
  77. package/es/components/icons/GPTIconV2.d.ts +2 -1
  78. package/es/components/icons/GPTIconV3.d.ts +2 -1
  79. package/es/components/icons/HighlightIcon.d.ts +2 -1
  80. package/es/components/icons/IdeaIcon.d.ts +2 -1
  81. package/es/components/icons/InvisibleIcon.d.ts +2 -1
  82. package/es/components/icons/MuteIcon.d.ts +2 -1
  83. package/es/components/icons/OpenUrlIcon.d.ts +2 -1
  84. package/es/components/icons/PauseIcon.d.ts +2 -1
  85. package/es/components/icons/PlaneIcon.d.ts +2 -1
  86. package/es/components/icons/RequestIcon.d.ts +2 -1
  87. package/es/components/icons/StopRecordIcon.d.ts +2 -1
  88. package/es/components/icons/UserIcon.d.ts +2 -1
  89. package/es/components/icons/VerticalDotsIcon.d.ts +2 -1
  90. package/es/components/icons/WarningIcon.d.ts +2 -1
  91. package/es/components/molecules/AddDynamicContent/AddDynamicContent.d.ts +35 -0
  92. package/es/components/molecules/AddDynamicContent/AddDynamicContent.js +1245 -0
  93. package/es/components/molecules/AddDynamicContent/components/DisplayFormat/DisplayFormat.d.ts +12 -0
  94. package/es/components/molecules/AddDynamicContent/components/DisplayFormat/DisplayFormat.js +25 -0
  95. package/es/components/molecules/AddDynamicContent/components/DisplayFormat/index.d.ts +3 -0
  96. package/es/components/molecules/AddDynamicContent/components/DisplayFormat/index.js +3 -0
  97. package/es/components/molecules/AddDynamicContent/components/FormatDatetime/FormatDatetime.d.ts +19 -0
  98. package/es/components/molecules/AddDynamicContent/components/FormatDatetime/FormatDatetime.js +101 -0
  99. package/es/components/molecules/AddDynamicContent/components/FormatDatetime/index.d.ts +1 -0
  100. package/es/components/molecules/AddDynamicContent/components/FormatDatetime/index.js +1 -0
  101. package/es/components/molecules/AddDynamicContent/components/FormatNumber/FormatNumber.d.ts +52 -0
  102. package/es/components/molecules/AddDynamicContent/components/FormatNumber/FormatNumber.js +132 -0
  103. package/es/components/molecules/AddDynamicContent/components/FormatNumber/index.d.ts +1 -0
  104. package/es/components/molecules/AddDynamicContent/components/FormatNumber/index.js +1 -0
  105. package/es/components/molecules/AddDynamicContent/components/index.d.ts +3 -0
  106. package/es/components/molecules/AddDynamicContent/components/index.js +3 -0
  107. package/es/components/molecules/AddDynamicContent/constants.d.ts +101 -0
  108. package/es/components/molecules/AddDynamicContent/constants.js +152 -0
  109. package/es/components/molecules/AddDynamicContent/currencies.json +1523 -0
  110. package/es/components/molecules/AddDynamicContent/index.d.ts +2 -0
  111. package/es/components/molecules/AddDynamicContent/index.js +2 -0
  112. package/es/components/molecules/AddDynamicContent/styled.d.ts +9 -0
  113. package/es/components/molecules/AddDynamicContent/styled.js +18 -0
  114. package/es/components/molecules/AddDynamicContent/types.d.ts +13 -0
  115. package/es/components/molecules/AddDynamicContent/types.js +1 -0
  116. package/es/components/molecules/AddDynamicContent/utils.d.ts +42 -0
  117. package/es/components/molecules/AddDynamicContent/utils.js +398 -0
  118. package/es/components/molecules/CaptureScreen/CaptureScreen.d.ts +2 -1
  119. package/es/components/molecules/CaptureScreen/components/CommentBox/CommentBox.d.ts +2 -1
  120. package/es/components/molecules/CaptureScreen/components/Cursor/Cursor.d.ts +2 -1
  121. package/es/components/molecules/Collapse/Collapse.d.ts +3 -3
  122. package/es/components/molecules/Collapse/Collapse.js +9 -0
  123. package/es/components/molecules/ColorSetting/styled.d.ts +1 -8
  124. package/es/components/molecules/DatePicker/components/AdvancedPicker/AdvancedPicker.d.ts +2 -2
  125. package/es/components/molecules/DatePicker/components/AdvancedPicker/AdvancedPicker.js +260 -113
  126. package/es/components/molecules/DatePicker/components/AdvancedPicker/constants.d.ts +66 -25
  127. package/es/components/molecules/DatePicker/components/AdvancedPicker/constants.js +109 -0
  128. package/es/components/molecules/DatePicker/components/AdvancedPicker/styled.js +48 -4
  129. package/es/components/molecules/DatePicker/components/AdvancedPicker/types.d.ts +22 -0
  130. package/es/components/molecules/DatePicker/components/AdvancedPicker/utils.d.ts +20 -0
  131. package/es/components/molecules/DatePicker/components/AdvancedPicker/utils.js +90 -1
  132. package/es/components/molecules/Drawer/Drawer.d.ts +5 -1
  133. package/es/components/molecules/Drawer/Drawer.js +3 -1
  134. package/es/components/molecules/Drawer/index.d.ts +1 -0
  135. package/es/components/molecules/Form/Form.d.ts +1 -0
  136. package/es/components/molecules/Form/Form.js +1 -0
  137. package/es/components/molecules/Form/index.d.ts +1 -0
  138. package/es/components/molecules/Form/index.js +1 -0
  139. package/es/components/molecules/IconSelection/styled.d.ts +1 -8
  140. package/es/components/molecules/Modal/Modal.d.ts +2 -2
  141. package/es/components/molecules/Modal/index.d.ts +1 -0
  142. package/es/components/molecules/Modal/styled.d.ts +1 -1
  143. package/es/components/molecules/Modal/styled.js +2 -0
  144. package/es/components/molecules/ModalV2/ModalV2.d.ts +5 -0
  145. package/es/components/molecules/ModalV2/ModalV2.js +26 -0
  146. package/es/components/molecules/ModalV2/index.d.ts +2 -0
  147. package/es/components/molecules/ModalV2/index.js +1 -0
  148. package/es/components/molecules/ModalV2/styled.d.ts +7 -0
  149. package/es/components/molecules/ModalV2/styled.js +22 -0
  150. package/es/components/molecules/Popconfirm/Popconfirm.d.ts +1 -1
  151. package/es/components/molecules/PreviewModal/PreviewModal.d.ts +7 -0
  152. package/es/components/molecules/PreviewModal/PreviewModal.js +30 -0
  153. package/es/components/molecules/PreviewModal/index.d.ts +2 -0
  154. package/es/components/molecules/PreviewModal/index.js +1 -0
  155. package/es/components/molecules/PreviewModal/styled.d.ts +4 -0
  156. package/es/components/molecules/PreviewModal/styled.js +39 -0
  157. package/es/components/molecules/ResizeGrid/ResizeGrid.d.ts +3 -0
  158. package/es/components/molecules/ResizeGrid/ResizeGrid.js +728 -0
  159. package/es/components/molecules/ResizeGrid/components/Cell/Cell.d.ts +3 -0
  160. package/es/components/molecules/ResizeGrid/components/Cell/Cell.js +87 -0
  161. package/es/components/molecules/ResizeGrid/components/Cell/index.d.ts +1 -0
  162. package/es/components/molecules/ResizeGrid/components/Cell/index.js +1 -0
  163. package/es/components/molecules/ResizeGrid/components/Cell/styled.d.ts +3 -0
  164. package/es/components/molecules/ResizeGrid/components/Cell/styled.js +80 -0
  165. package/es/components/molecules/ResizeGrid/constant.d.ts +35 -0
  166. package/es/components/molecules/ResizeGrid/constant.js +111 -0
  167. package/es/components/molecules/ResizeGrid/index.d.ts +2 -0
  168. package/es/components/molecules/ResizeGrid/index.js +1 -0
  169. package/es/components/molecules/ResizeGrid/styled.d.ts +10 -0
  170. package/es/components/molecules/ResizeGrid/styled.js +56 -0
  171. package/es/components/molecules/ResizeGrid/types.d.ts +147 -0
  172. package/es/components/molecules/ResizeGrid/types.js +1 -0
  173. package/es/components/molecules/RichMenu/RichMenuBlock/RichMenuBlock.d.ts +12 -0
  174. package/es/components/molecules/RichMenu/RichMenuBlock/RichMenuBlock.js +53 -0
  175. package/es/components/molecules/RichMenu/RichMenuBlock/RichMenuCell/index.d.ts +17 -0
  176. package/es/components/molecules/RichMenu/RichMenuBlock/RichMenuCell/index.js +108 -0
  177. package/es/components/molecules/RichMenu/RichMenuBlock/RichMenuCell/styled.d.ts +20 -0
  178. package/es/components/molecules/RichMenu/RichMenuBlock/RichMenuCell/styled.js +135 -0
  179. package/es/components/molecules/RichMenu/RichMenuBlock/constants.d.ts +2 -0
  180. package/es/components/molecules/RichMenu/RichMenuBlock/constants.js +765 -0
  181. package/es/components/molecules/RichMenu/RichMenuBlock/index.d.ts +3 -0
  182. package/es/components/molecules/RichMenu/RichMenuBlock/index.js +2 -0
  183. package/es/components/molecules/RichMenu/RichMenuBlock/styled.d.ts +9 -0
  184. package/es/components/molecules/RichMenu/RichMenuBlock/styled.js +17 -0
  185. package/es/components/molecules/RichMenu/RichMenuChatBar/RichMenuChatBar.d.ts +10 -0
  186. package/es/components/molecules/RichMenu/RichMenuChatBar/RichMenuChatBar.js +32 -0
  187. package/es/components/molecules/RichMenu/RichMenuChatBar/TypingChat/index.d.ts +6 -0
  188. package/es/components/molecules/RichMenu/RichMenuChatBar/TypingChat/index.js +15 -0
  189. package/es/components/molecules/RichMenu/RichMenuChatBar/TypingChat/styled.d.ts +4 -0
  190. package/es/components/molecules/RichMenu/RichMenuChatBar/TypingChat/styled.js +47 -0
  191. package/es/components/molecules/RichMenu/RichMenuChatBar/index.d.ts +2 -0
  192. package/es/components/molecules/RichMenu/RichMenuChatBar/index.js +1 -0
  193. package/es/components/molecules/RichMenu/RichMenuChatBar/styled.d.ts +9 -0
  194. package/es/components/molecules/RichMenu/RichMenuChatBar/styled.js +37 -0
  195. package/es/components/molecules/RichMenu/RichMenuMobileView/RichMenuMobileView.d.ts +10 -0
  196. package/es/components/molecules/RichMenu/RichMenuMobileView/RichMenuMobileView.js +37 -0
  197. package/es/components/molecules/RichMenu/RichMenuMobileView/index.d.ts +1 -0
  198. package/es/components/molecules/RichMenu/RichMenuMobileView/index.js +1 -0
  199. package/es/components/molecules/RichMenu/RichMenuMobileView/styled.d.ts +6 -0
  200. package/es/components/molecules/RichMenu/RichMenuMobileView/styled.js +20 -0
  201. package/es/components/molecules/RichMenu/index.d.ts +3 -0
  202. package/es/components/molecules/RichMenu/index.js +3 -0
  203. package/es/components/molecules/Select/Select.d.ts +6 -4
  204. package/es/components/molecules/Select/Select.js +23 -2
  205. package/es/components/molecules/Select/Test.d.ts +2 -1
  206. package/es/components/molecules/ShareAccess/ShareAccess.d.ts +3 -0
  207. package/es/components/molecules/ShareAccess/ShareAccess.js +23 -0
  208. package/es/components/molecules/ShareAccess/actions.d.ts +16 -0
  209. package/es/components/molecules/ShareAccess/actions.js +12 -0
  210. package/es/components/molecules/ShareAccess/components/GeneralAccess/GeneralAccess.d.ts +2 -0
  211. package/es/components/molecules/ShareAccess/components/GeneralAccess/GeneralAccess.js +78 -0
  212. package/es/components/molecules/ShareAccess/components/GeneralAccess/index.d.ts +1 -0
  213. package/es/components/molecules/ShareAccess/components/GeneralAccess/index.js +1 -0
  214. package/es/components/molecules/ShareAccess/components/GeneralAccess/styled.d.ts +1 -0
  215. package/es/components/molecules/ShareAccess/components/GeneralAccess/styled.js +57 -0
  216. package/es/components/molecules/ShareAccess/components/LayoutContent/LayoutContent.d.ts +3 -0
  217. package/es/components/molecules/ShareAccess/components/LayoutContent/LayoutContent.js +19 -0
  218. package/es/components/molecules/ShareAccess/components/LayoutContent/index.d.ts +1 -0
  219. package/es/components/molecules/ShareAccess/components/LayoutContent/index.js +1 -0
  220. package/es/components/molecules/ShareAccess/components/LayoutContent/styled.d.ts +1 -0
  221. package/es/components/molecules/ShareAccess/components/LayoutContent/styled.js +7 -0
  222. package/es/components/molecules/ShareAccess/components/ModalTransferOwnerShip/ModalTransferOwnerShip.d.ts +2 -0
  223. package/es/components/molecules/ShareAccess/components/ModalTransferOwnerShip/ModalTransferOwnerShip.js +43 -0
  224. package/es/components/molecules/ShareAccess/components/ModalTransferOwnerShip/index.d.ts +0 -0
  225. package/es/components/molecules/ShareAccess/components/ModalTransferOwnerShip/index.js +1 -0
  226. package/es/components/molecules/ShareAccess/components/ModalTransferOwnerShip/styled.d.ts +7 -0
  227. package/es/components/molecules/ShareAccess/components/ModalTransferOwnerShip/styled.js +18 -0
  228. package/es/components/molecules/ShareAccess/components/PeopleAccess/PeopleAccess.d.ts +5 -0
  229. package/es/components/molecules/ShareAccess/components/PeopleAccess/PeopleAccess.js +97 -0
  230. package/es/components/molecules/ShareAccess/components/PeopleAccess/index.d.ts +1 -0
  231. package/es/components/molecules/ShareAccess/components/PeopleAccess/index.js +1 -0
  232. package/es/components/molecules/ShareAccess/components/PeopleAccess/styled.d.ts +1 -0
  233. package/es/components/molecules/ShareAccess/components/PeopleAccess/styled.js +46 -0
  234. package/es/components/molecules/ShareAccess/components/SearchUser/SearchUser.d.ts +5 -0
  235. package/es/components/molecules/ShareAccess/components/SearchUser/SearchUser.js +73 -0
  236. package/es/components/molecules/ShareAccess/components/SearchUser/index.d.ts +1 -0
  237. package/es/components/molecules/ShareAccess/components/SearchUser/index.js +1 -0
  238. package/es/components/molecules/ShareAccess/components/SearchUser/styled.d.ts +2 -0
  239. package/es/components/molecules/ShareAccess/components/SearchUser/styled.js +29 -0
  240. package/es/components/molecules/ShareAccess/components/index.d.ts +1 -0
  241. package/es/components/molecules/ShareAccess/components/index.js +1 -0
  242. package/es/components/molecules/ShareAccess/constants.d.ts +67 -0
  243. package/es/components/molecules/ShareAccess/constants.js +85 -0
  244. package/es/components/molecules/ShareAccess/context.d.ts +4 -0
  245. package/es/components/molecules/ShareAccess/context.js +3 -0
  246. package/es/components/molecules/ShareAccess/hooks/index.d.ts +1 -0
  247. package/es/components/molecules/ShareAccess/hooks/index.js +1 -0
  248. package/es/components/molecules/ShareAccess/hooks/useShareAccess.d.ts +18 -0
  249. package/es/components/molecules/ShareAccess/hooks/useShareAccess.js +29 -0
  250. package/es/components/molecules/ShareAccess/index.d.ts +4 -0
  251. package/es/components/molecules/ShareAccess/index.js +4 -0
  252. package/es/components/molecules/ShareAccess/reducer.d.ts +2 -0
  253. package/es/components/molecules/ShareAccess/reducer.js +19 -0
  254. package/es/components/molecules/ShareAccess/types.d.ts +54 -0
  255. package/es/components/molecules/ShareAccess/types.js +1 -0
  256. package/es/components/molecules/ShareAccess/utils.d.ts +38 -0
  257. package/es/components/molecules/ShareAccess/utils.js +57 -0
  258. package/es/components/molecules/TreeSelect/TreeSelect.d.ts +4 -5
  259. package/es/components/molecules/UploadImage/MediaIcon.d.ts +2 -1
  260. package/es/components/molecules/UploadImage/MediaThumb.d.ts +11 -0
  261. package/es/components/molecules/UploadImage/MediaThumb.js +31 -0
  262. package/es/components/molecules/UploadImage/index.d.ts +6 -2
  263. package/es/components/molecules/UploadImage/index.js +101 -77
  264. package/es/components/molecules/UploadImage/styled.js +0 -4
  265. package/es/components/molecules/UploadImage/utils.d.ts +3 -0
  266. package/es/components/molecules/UploadImage/utils.js +24 -0
  267. package/es/components/molecules/index.d.ts +10 -3
  268. package/es/components/molecules/index.js +8 -3
  269. package/es/components/organism/Help/styled.d.ts +6 -16
  270. package/es/components/organism/Table/ExplorePivotTable/styled.d.ts +1 -0
  271. package/es/constants/index.d.ts +1 -0
  272. package/es/constants/index.js +1 -0
  273. package/es/constants/queries.d.ts +14 -0
  274. package/es/constants/queries.js +21 -0
  275. package/es/constants/richMenu.d.ts +19 -0
  276. package/es/constants/richMenu.js +19 -0
  277. package/es/constants/storybook.d.ts +7 -1
  278. package/es/constants/storybook.js +12 -0
  279. package/es/constants/theme.js +30 -3
  280. package/es/hooks/index.d.ts +1 -0
  281. package/es/hooks/index.js +1 -0
  282. package/es/hooks/useDebounceCallback.d.ts +1 -0
  283. package/es/hooks/useDebounceCallback.js +5 -0
  284. package/es/hooks/useDebounceV2.d.ts +1 -0
  285. package/es/hooks/useDebounceV2.js +11 -0
  286. package/es/hooks/useDeepCompareEffect.d.ts +1 -0
  287. package/es/hooks/useDeepCompareEffect.js +21 -0
  288. package/es/hooks/useDeepCompareMemo.d.ts +2 -0
  289. package/es/hooks/useDeepCompareMemo.js +21 -0
  290. package/es/hooks/usePrevious.d.ts +2 -0
  291. package/es/hooks/usePrevious.js +9 -0
  292. package/es/locales/en/translation.json +156 -3
  293. package/es/locales/i18n.d.ts +154 -0
  294. package/es/locales/translations.d.ts +153 -0
  295. package/es/locales/vi/translation.json +2 -1
  296. package/es/models/BusinessObject.d.ts +116 -0
  297. package/es/models/BusinessObject.js +113 -0
  298. package/es/models/Currency.d.ts +9 -0
  299. package/es/models/Currency.js +10 -0
  300. package/es/models/CustomFunction.d.ts +19 -0
  301. package/es/models/CustomFunction.js +25 -0
  302. package/es/models/DynamicContentAttribute.d.ts +34 -0
  303. package/es/models/DynamicContentAttribute.js +9 -0
  304. package/es/models/EventTrackingAttribute.d.ts +11 -0
  305. package/es/models/EventTrackingAttribute.js +13 -0
  306. package/es/models/PromotionPool.d.ts +11 -0
  307. package/es/models/PromotionPool.js +12 -0
  308. package/es/models/{SavedImage.d.ts → SavedMedia.d.ts} +5 -5
  309. package/es/models/{SavedImage.js → SavedMedia.js} +3 -3
  310. package/es/queries/BusinessObject/index.d.ts +6 -0
  311. package/es/queries/BusinessObject/index.js +6 -0
  312. package/es/queries/BusinessObject/useGetListAllEvents.d.ts +11 -0
  313. package/es/queries/BusinessObject/useGetListAllEvents.js +14 -0
  314. package/es/queries/BusinessObject/useGetListAttributeBO.d.ts +17 -0
  315. package/es/queries/BusinessObject/useGetListAttributeBO.js +41 -0
  316. package/es/queries/BusinessObject/useGetListBO.d.ts +6 -0
  317. package/es/queries/BusinessObject/useGetListBO.js +19 -0
  318. package/es/queries/BusinessObject/useGetListEventAttr.d.ts +4 -0
  319. package/es/queries/BusinessObject/useGetListEventAttr.js +15 -0
  320. package/es/queries/BusinessObject/useGetListPromotionCodeAttr.d.ts +6 -0
  321. package/es/queries/BusinessObject/useGetListPromotionCodeAttr.js +26 -0
  322. package/es/queries/BusinessObject/useGetListSourceByEvent.d.ts +13 -0
  323. package/es/queries/BusinessObject/useGetListSourceByEvent.js +11 -0
  324. package/es/queries/CustomFunction/index.d.ts +2 -0
  325. package/es/queries/CustomFunction/index.js +2 -0
  326. package/es/queries/CustomFunction/useCustomFunction.d.ts +19 -0
  327. package/es/queries/CustomFunction/useCustomFunction.js +53 -0
  328. package/es/queries/DynamicContentAttribute/index.d.ts +1 -0
  329. package/es/queries/DynamicContentAttribute/index.js +1 -0
  330. package/es/queries/DynamicContentAttribute/useGetDynamicContentAttr.d.ts +10 -0
  331. package/es/queries/DynamicContentAttribute/useGetDynamicContentAttr.js +21 -0
  332. package/es/queries/PromotionPool/index.d.ts +1 -0
  333. package/es/queries/PromotionPool/index.js +1 -0
  334. package/es/queries/PromotionPool/useGetListPromotionPool.d.ts +9 -0
  335. package/es/queries/PromotionPool/useGetListPromotionPool.js +62 -0
  336. package/es/queries/ThirdParty/index.d.ts +1 -0
  337. package/es/queries/ThirdParty/index.js +1 -0
  338. package/es/queries/ThirdParty/useGetEventTrackingAttributes.d.ts +14 -0
  339. package/es/queries/ThirdParty/useGetEventTrackingAttributes.js +15 -0
  340. package/es/queries/configs.d.ts +4 -0
  341. package/es/queries/configs.js +13 -0
  342. package/es/queries/index.d.ts +6 -0
  343. package/es/queries/index.js +6 -0
  344. package/es/services/MediaTemplateDesign/BusinessObject/index.d.ts +8 -0
  345. package/es/services/MediaTemplateDesign/BusinessObject/index.js +100 -0
  346. package/es/services/MediaTemplateDesign/CustomFunction/index.d.ts +15 -0
  347. package/es/services/MediaTemplateDesign/CustomFunction/index.js +135 -0
  348. package/es/services/MediaTemplateDesign/DynamicContentAttribute/index.d.ts +4 -0
  349. package/es/services/MediaTemplateDesign/DynamicContentAttribute/index.js +39 -0
  350. package/es/services/MediaTemplateDesign/ListCurrency/index.d.ts +6 -0
  351. package/es/services/MediaTemplateDesign/ListCurrency/index.js +34 -0
  352. package/es/services/MediaTemplateDesign/PromotionPool/index.d.ts +3 -0
  353. package/es/services/MediaTemplateDesign/PromotionPool/index.js +31 -0
  354. package/es/services/MediaTemplateDesign/UploadFile/index.d.ts +5 -5
  355. package/es/services/MediaTemplateDesign/UploadFile/index.js +36 -19
  356. package/es/services/ThirParty/index.d.ts +8 -0
  357. package/es/services/ThirParty/index.js +26 -0
  358. package/es/services/index.d.ts +14 -5
  359. package/es/services/index.js +45 -1
  360. package/es/test.d.ts +2 -1
  361. package/es/test.js +201 -63
  362. package/es/types/index.d.ts +17 -0
  363. package/es/types/index.js +2 -1
  364. package/es/types/richMenu.d.ts +214 -0
  365. package/es/types/richMenu.js +1 -0
  366. package/es/types/variables.d.ts +2 -0
  367. package/es/types/variables.js +1 -0
  368. package/es/utils/common.d.ts +4 -0
  369. package/es/utils/common.js +21 -0
  370. package/es/utils/handleError.d.ts +32 -2
  371. package/es/utils/handleError.js +42 -4
  372. package/package.json +17 -8
@@ -0,0 +1,1245 @@
1
+ var __rest = (this && this.__rest) || function (s, e) {
2
+ var t = {};
3
+ for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p) && e.indexOf(p) < 0)
4
+ t[p] = s[p];
5
+ if (s != null && typeof Object.getOwnPropertySymbols === "function")
6
+ for (var i = 0, p = Object.getOwnPropertySymbols(s); i < p.length; i++) {
7
+ if (e.indexOf(p[i]) < 0 && Object.prototype.propertyIsEnumerable.call(s, p[i]))
8
+ t[p[i]] = s[p[i]];
9
+ }
10
+ return t;
11
+ };
12
+ /* eslint-disable no-case-declarations */
13
+ /* eslint-disable @typescript-eslint/no-use-before-define */
14
+ // Libraries
15
+ import React, { useCallback, useEffect, useLayoutEffect, useMemo, useState } from 'react';
16
+ import { omit, isEmpty, flatMapDeep, set, get, isNaN } from 'lodash';
17
+ import classnames from 'classnames';
18
+ // Hooks
19
+ import { useDeepCompareEffect, useDeepCompareMemo } from '@antscorp/antsomi-ui/es/hooks';
20
+ // Components
21
+ import { TreeNode } from 'rc-tree-select';
22
+ import { Button, Checkbox, Text, Spin } from '../../atoms';
23
+ import { TreeSelect, Form, Select } from 'antd';
24
+ // Locales
25
+ import { useTranslation } from 'react-i18next';
26
+ import i18nInstance from '@antscorp/antsomi-ui/es/locales/i18n';
27
+ import { translations } from '@antscorp/antsomi-ui/es/locales/translations';
28
+ // Query
29
+ import { useGetDynamicContentAttr, useGetListPromotionPool, useGetListEventAttr, useGetListPromotionCodeAttr, useGetListBO, useGetListAllEvents, useGetListSourceByEvent, useGetListAttributeBO, useGetCustomFunction, useAddSavedCSFunction, useUpdateCSFunction, } from '@antscorp/antsomi-ui/es/queries';
30
+ import { useGetEventTrackingAttributes } from '@antscorp/antsomi-ui/es/queries/ThirdParty';
31
+ // Queries config
32
+ import { queryClientAntsomiUI } from '@antscorp/antsomi-ui/es/queries/configs';
33
+ import { QUERY_KEYS } from '@antscorp/antsomi-ui/es/constants/queries';
34
+ import { dateExample } from './components/FormatDatetime';
35
+ import DisplayFormat from './components/DisplayFormat';
36
+ // Constants
37
+ import { DYNAMIC_CONTENT_SETTING_KEY, DYNAMIC_CONTENT_TYPE, DYNAMIC_CONTENT_ATTR_DF_TYPE, DATA_TYPE, ATTRIBUTE_TYPE, } from './constants';
38
+ // Utils
39
+ import { handleError } from '@antscorp/antsomi-ui/es/utils';
40
+ import { formatDatetimeDF, formatNumberDF, getAvailableAttrs, getStringFormatDateDF, regexCSType, serilizeBOAttr, serializeCSSelectedString, serilizeDynamicContentAttr, serilizeEventAttr, serilizePromotionPool, buildOptionAttrArchive, checkStatusAttr, serializeLabelToCode, buildMappingFields, CUSTOM_TYPE, } from './utils';
41
+ // Style
42
+ import { InputSuggestion, ModalCustom } from './styled';
43
+ const getMembers = (member) => {
44
+ if (!member.children || !member.children.length) {
45
+ return member;
46
+ }
47
+ return [member, member.children];
48
+ };
49
+ const PATH = 'src/components/molecules/AddDynamicContent/AddDynamicContent.tsx';
50
+ const initNumberDFSettings = {
51
+ grouping: ',',
52
+ decimal: '.',
53
+ decimalPlaces: 2,
54
+ isCompact: false,
55
+ currencyCode: 'USD',
56
+ prefixType: 'code',
57
+ };
58
+ const initDatetimeDFSettings = {
59
+ hasDateFormat: true,
60
+ hasTimeFormat: true,
61
+ dateParseOption: 'medium',
62
+ timeParseOption: 'medium',
63
+ dateParseFormat: 'MM/DD/YYYY',
64
+ timeParseFormat: '12hour',
65
+ };
66
+ const defaultDynamicTypes = [...Object.values(DYNAMIC_CONTENT_TYPE)]
67
+ .filter((i) => i.value !== 'bo-settings')
68
+ .sort((a, b) => a.index - b.index);
69
+ const optionDataType = [...Object.values(DATA_TYPE)];
70
+ export const AddDynamicContent = props => {
71
+ //* Props
72
+ const { defaultData = {}, defaultDynamicIndex = 1, visible, showDisplayFormat, showIndex, journeySettings, contentSources, APIConfig, isShowCustomFunction = false, modalTitle, } = props;
73
+ const { accountId, userId, token, domain, slug } = APIConfig;
74
+ const infos = { accountId, userId, token };
75
+ const { onCancel, onOk, additionalAttrProperties = [] } = props;
76
+ const url = useMemo(() => `${domain}${slug}`, [domain, slug]);
77
+ // Hook Queries
78
+ const { mutate: addSavedCSFunction } = useAddSavedCSFunction();
79
+ const { data: customFunction } = useGetCustomFunction({ url }, infos);
80
+ const { mutate: updateCSFunction } = useUpdateCSFunction();
81
+ //* Hooks
82
+ const { i18n } = useTranslation();
83
+ const { t } = i18nInstance;
84
+ //* Selectors
85
+ const { triggerEvent } = journeySettings;
86
+ const [itemTypeId, setItemTypeId] = useState(null);
87
+ // Form states
88
+ const [form] = Form.useForm();
89
+ const selectedDynamicContentType = Form.useWatch(DYNAMIC_CONTENT_SETTING_KEY.DYNAMIC_CONTENT_TYPE, form);
90
+ const selectedAttr = Form.useWatch(DYNAMIC_CONTENT_SETTING_KEY.ATTRIBUTE, form);
91
+ const selectedDFType = Form.useWatch(DYNAMIC_CONTENT_SETTING_KEY.DISPLAY_FORMAT_TYPE, form);
92
+ const selectedEventSource = Form.useWatch(DYNAMIC_CONTENT_SETTING_KEY.EVENT, form);
93
+ const selectedSource = Form.useWatch(DYNAMIC_CONTENT_SETTING_KEY.SOURCE, form);
94
+ const selectedBoIndex = Form.useWatch(DYNAMIC_CONTENT_SETTING_KEY.INDEX, form);
95
+ const [formSubmitDisabled, setFormSubmitDisabled] = useState(true);
96
+ const [saveAsTemplate, setsaveAsTemplate] = useState(false);
97
+ const [hasError, setHasError] = useState({
98
+ [DYNAMIC_CONTENT_SETTING_KEY.EVENT]: false,
99
+ [DYNAMIC_CONTENT_SETTING_KEY.INDEX]: false,
100
+ [DYNAMIC_CONTENT_SETTING_KEY.ATTRIBUTE]: false,
101
+ [DYNAMIC_CONTENT_SETTING_KEY.PROMOTION_POOL]: false,
102
+ [DYNAMIC_CONTENT_SETTING_KEY.SOURCE]: false,
103
+ [DYNAMIC_CONTENT_SETTING_KEY.FUNCTION]: false,
104
+ [DYNAMIC_CONTENT_SETTING_KEY.PERNAME]: false,
105
+ });
106
+ // Queries
107
+ const { data: listBO } = useGetListBO({ url }, infos);
108
+ // defaultSettings
109
+ const [defaultAttrDFSetings, setDefaultAttrDFSetings] = useState(null);
110
+ // Variables
111
+ const [eventActionId, eventCategoryId] = (selectedEventSource === null || selectedEventSource === void 0 ? void 0 : selectedEventSource.split(':').map(Number)) || [];
112
+ // Selection Options states
113
+ const [listDynamicContentTypes, setListDynamicContentTypes] = useState(defaultDynamicTypes);
114
+ const [listCustomerAttributes, setListCustomerAttributes] = useState([]);
115
+ const [listVisitorAttributes, setListVisitorAttributes] = useState([]);
116
+ const [listCustomTemplates, setlistCustomTemplates] = useState([]);
117
+ const [listCustomTemplatesSearch, setlistCustomTemplatesSearch] = useState([]);
118
+ const [searchValue, setSearchValue] = useState('');
119
+ // Expanded keys in tree select
120
+ const [expandedEventAttributes, setExpandedEventAttributes] = useState([]);
121
+ const [isActionArchive, setActionArchive] = useState(false);
122
+ const [errorMessageAttr, setErrorMessageAttr] = useState();
123
+ // Number Display format
124
+ const [showDetailEditDF, setShowDetailEditDF] = useState(false);
125
+ const [formatedAttr, setFormatedAttr] = useState('');
126
+ const [attrDFSettings, setAttrDFSettings] = useState(undefined);
127
+ const [templateName, setTemplateName] = useState('');
128
+ const [attrDFOptions, setAttrDFOptions] = useState([]);
129
+ // Template Custom
130
+ const [templateId, settemplateId] = useState();
131
+ const { data: listBoAttributes = [], isFetching: isFetchingListBoAttr, isError: isErrorBoAttr, } = useGetListAttributeBO({
132
+ url,
133
+ itemTypeIds: itemTypeId ? [itemTypeId] : [],
134
+ options: {
135
+ onSuccess: (data) => {
136
+ setHasError({
137
+ [DYNAMIC_CONTENT_SETTING_KEY.ATTRIBUTE]: false,
138
+ [DYNAMIC_CONTENT_SETTING_KEY.INDEX]: false,
139
+ });
140
+ if (data.length &&
141
+ selectedDynamicContentType &&
142
+ regexCSType.test(selectedDynamicContentType)) {
143
+ if (form.getFieldValue(DYNAMIC_CONTENT_SETTING_KEY.ATTRIBUTE) &&
144
+ form.getFieldValue(DYNAMIC_CONTENT_SETTING_KEY.INDEX))
145
+ return;
146
+ form.setFieldsValue({
147
+ [DYNAMIC_CONTENT_SETTING_KEY.ATTRIBUTE]: data[0],
148
+ [DYNAMIC_CONTENT_SETTING_KEY.INDEX]: defaultDynamicIndex,
149
+ });
150
+ }
151
+ },
152
+ select: (data) => serilizeBOAttr(data, additionalAttrProperties),
153
+ onError: (error) => {
154
+ setHasError({
155
+ [DYNAMIC_CONTENT_SETTING_KEY.ATTRIBUTE]: true,
156
+ [DYNAMIC_CONTENT_SETTING_KEY.INDEX]: true,
157
+ });
158
+ handleError(error, {
159
+ path: PATH,
160
+ name: 'useGetListAttributeBO',
161
+ args: error === null || error === void 0 ? void 0 : error.message,
162
+ });
163
+ },
164
+ enabled: !!itemTypeId,
165
+ },
166
+ }, infos);
167
+ const { data: dynamicContentAttr, isFetching: isFetchingDynamicContentAttr, isError: isErrorDynamicContentAttr, } = useGetDynamicContentAttr({ url }, infos, {
168
+ onSuccess: () => {
169
+ setHasError({
170
+ [DYNAMIC_CONTENT_SETTING_KEY.ATTRIBUTE]: false,
171
+ });
172
+ },
173
+ onError: (error) => {
174
+ setHasError({
175
+ [DYNAMIC_CONTENT_SETTING_KEY.ATTRIBUTE]: true,
176
+ });
177
+ handleError(error, {
178
+ path: PATH,
179
+ name: 'useGetDynamicContentAttr',
180
+ args: error === null || error === void 0 ? void 0 : error.message,
181
+ });
182
+ },
183
+ });
184
+ const { data: listSources, isFetching: isFetchingSourceBO } = useGetListSourceByEvent({
185
+ apiConfig: {
186
+ url,
187
+ },
188
+ infos,
189
+ eventActionId,
190
+ eventCategoryId,
191
+ options: {
192
+ onSuccess: () => {
193
+ setHasError({ [DYNAMIC_CONTENT_SETTING_KEY.SOURCE]: false });
194
+ },
195
+ select: (data) => {
196
+ const { rows } = data || {};
197
+ return rows.map((row) => ({
198
+ label: row.label,
199
+ value: row.value,
200
+ }));
201
+ },
202
+ onError: (error) => {
203
+ setHasError({ [DYNAMIC_CONTENT_SETTING_KEY.SOURCE]: true });
204
+ handleError(error, {
205
+ path: PATH,
206
+ name: 'useGetListSourceBO',
207
+ args: error === null || error === void 0 ? void 0 : error.message,
208
+ });
209
+ },
210
+ },
211
+ });
212
+ const { data: listEvents, isFetching: isFetchingEventBySource } = useGetListAllEvents({
213
+ apiConfig: {
214
+ url,
215
+ },
216
+ infos,
217
+ options: {
218
+ onSuccess: (data) => {
219
+ setHasError({ [DYNAMIC_CONTENT_SETTING_KEY.EVENT]: false });
220
+ if (!isEmpty(data) &&
221
+ selectedDynamicContentType === DYNAMIC_CONTENT_TYPE.EVENT_ATTRIBUTE.value) {
222
+ form.setFieldsValue({
223
+ [DYNAMIC_CONTENT_SETTING_KEY.EVENT]: data[0].value,
224
+ });
225
+ }
226
+ },
227
+ onError: (error) => {
228
+ setHasError({ [DYNAMIC_CONTENT_SETTING_KEY.EVENT]: true });
229
+ handleError(error, {
230
+ path: PATH,
231
+ name: 'useGetListEventBySource',
232
+ args: error === null || error === void 0 ? void 0 : error.message,
233
+ });
234
+ },
235
+ select: (data) => {
236
+ const { rows = [] } = data || {};
237
+ return rows.map((event) => ({
238
+ label: event.label,
239
+ value: `${event.eventActionId}:${event.eventCategoryId}`,
240
+ }));
241
+ },
242
+ },
243
+ });
244
+ const { data: listEventAttributes, isFetching: isFetchingEventAttr, isError: isErrorEventAttr, } = useGetListEventAttr({ url }, infos, selectedEventSource || '', Array.isArray(selectedSource) ? selectedSource.join(',') : selectedSource || '', {
245
+ onSuccess: () => setHasError({ [DYNAMIC_CONTENT_SETTING_KEY.ATTRIBUTE]: false }),
246
+ onError: (error) => {
247
+ setHasError({ [DYNAMIC_CONTENT_SETTING_KEY.ATTRIBUTE]: true });
248
+ handleError(error, {
249
+ path: PATH,
250
+ name: 'useGetListEventAttr',
251
+ args: error === null || error === void 0 ? void 0 : error.message,
252
+ });
253
+ },
254
+ select: (data) => serilizeEventAttr(data, i18n, additionalAttrProperties),
255
+ });
256
+ const { data: listPromotionPools, isFetching: isFetchingPromotionPool } = useGetListPromotionPool({ url }, infos, {
257
+ onSuccess: () => {
258
+ setHasError({
259
+ [DYNAMIC_CONTENT_SETTING_KEY.PROMOTION_POOL]: false,
260
+ });
261
+ },
262
+ select: (data) => serilizePromotionPool(data, additionalAttrProperties),
263
+ onError: (error) => {
264
+ setHasError({ [DYNAMIC_CONTENT_SETTING_KEY.ATTRIBUTE]: true });
265
+ handleError(error, {
266
+ path: PATH,
267
+ name: 'useGetListPromotionPool',
268
+ args: error === null || error === void 0 ? void 0 : error.message,
269
+ });
270
+ },
271
+ });
272
+ const { data: listPromotionCodeAttributes, isFetching: isFetchingPromotionCodeAttr, isError: isErrorListPromotionCodeAttr, } = useGetListPromotionCodeAttr({ url }, infos, {
273
+ onSuccess: () => {
274
+ setHasError({ [DYNAMIC_CONTENT_SETTING_KEY.ATTRIBUTE]: false });
275
+ },
276
+ select: (data) => data
277
+ .filter((attr) => +(attr === null || attr === void 0 ? void 0 : attr.status) === 1)
278
+ .map((attr) => ({
279
+ label: attr.propertyDisplayMultilang[i18n.language] ||
280
+ attr.propertyDisplayMultilang[get(attr, "propertyDisplayMultilang['DEFAULT_LANG']", 'EN')],
281
+ value: attr.itemPropertyName,
282
+ dataType: attr.dataType,
283
+ disabled: parseInt(attr.status) === 4,
284
+ status: attr.status,
285
+ })),
286
+ onError: (error) => {
287
+ setHasError({
288
+ [DYNAMIC_CONTENT_SETTING_KEY.ATTRIBUTE]: true,
289
+ });
290
+ handleError(error, {
291
+ path: PATH,
292
+ name: 'useGetPromotionCodeAttr',
293
+ args: error === null || error === void 0 ? void 0 : error.message,
294
+ });
295
+ },
296
+ });
297
+ const { data: eventTrackingAttributes } = useGetEventTrackingAttributes({
298
+ apiConfig: { url },
299
+ infos,
300
+ eventActionId,
301
+ eventCategoryId,
302
+ });
303
+ // Memo
304
+ const isShowEventIndexField = useDeepCompareMemo(() => {
305
+ if (selectedAttr && selectedDynamicContentType === DYNAMIC_CONTENT_TYPE.EVENT_ATTRIBUTE.value) {
306
+ if (selectedAttr.itemTypeId) {
307
+ return !!get(selectedAttr, 'eventPropertySyntax', '').includes('items');
308
+ }
309
+ return selectedAttr.type === ATTRIBUTE_TYPE.ITEM;
310
+ }
311
+ return false;
312
+ }, [selectedAttr, selectedDynamicContentType, eventTrackingAttributes === null || eventTrackingAttributes === void 0 ? void 0 : eventTrackingAttributes.mainObjects]);
313
+ const itemTypeName = useMemo(() => {
314
+ var _a;
315
+ let draftItemTypeName = '';
316
+ if (itemTypeId) {
317
+ draftItemTypeName = ((_a = listBO === null || listBO === void 0 ? void 0 : listBO.find((bo) => bo.id === itemTypeId)) === null || _a === void 0 ? void 0 : _a.name) || '';
318
+ }
319
+ return draftItemTypeName;
320
+ }, [itemTypeId, listBO]);
321
+ // Add BO settings (if exists) to list Dynamic content Type, or removed from the previous states
322
+ useEffect(() => {
323
+ const temp = [...defaultDynamicTypes];
324
+ contentSources.groups.forEach((g) => {
325
+ if (!g.itemTypeId)
326
+ return;
327
+ temp.push({
328
+ index: temp.length,
329
+ label: `${g.groupName} (${g.itemTypeDisplay})`,
330
+ value: `content-source::${g.groupId}::${g.itemTypeId}`,
331
+ });
332
+ });
333
+ if (isShowCustomFunction) {
334
+ temp.push(Object.assign(Object.assign({}, CUSTOM_TYPE), { index: temp.length }));
335
+ }
336
+ setListDynamicContentTypes(temp);
337
+ }, [contentSources.groups, isShowCustomFunction]);
338
+ useEffect(() => {
339
+ if (Array.isArray(customFunction) && customFunction.length) {
340
+ const temp = [];
341
+ customFunction.forEach(item => {
342
+ temp.push(Object.assign(Object.assign({}, item), { label: item.template_name, value: item.template_name }));
343
+ });
344
+ setlistCustomTemplates(temp);
345
+ }
346
+ }, [customFunction, visible]);
347
+ useDeepCompareEffect(() => {
348
+ if (dynamicContentAttr) {
349
+ const { customer, visitor } = dynamicContentAttr;
350
+ const dynamicContentType = form.getFieldValue(DYNAMIC_CONTENT_SETTING_KEY.DYNAMIC_CONTENT_TYPE);
351
+ const parseCustomers = serilizeDynamicContentAttr(customer, i18n, additionalAttrProperties);
352
+ const parseVisitors = serilizeDynamicContentAttr(visitor, i18n, additionalAttrProperties);
353
+ setListCustomerAttributes(parseCustomers);
354
+ setListVisitorAttributes(parseVisitors);
355
+ if (form.getFieldValue(DYNAMIC_CONTENT_SETTING_KEY.ATTRIBUTE))
356
+ return;
357
+ if (dynamicContentType === DYNAMIC_CONTENT_TYPE.VISITOR_ATTRIBUTE.value) {
358
+ form.setFieldsValue({
359
+ [DYNAMIC_CONTENT_SETTING_KEY.ATTRIBUTE]: getAvailableAttrs(parseVisitors)[0],
360
+ });
361
+ }
362
+ if (dynamicContentType === DYNAMIC_CONTENT_TYPE.CUSTOMER_ATTRIBUTE.value) {
363
+ form.setFieldsValue({
364
+ [DYNAMIC_CONTENT_SETTING_KEY.ATTRIBUTE]: getAvailableAttrs(parseCustomers)[0],
365
+ });
366
+ }
367
+ }
368
+ }, [dynamicContentAttr, form, i18n.language]);
369
+ useDeepCompareEffect(() => {
370
+ if (listSources && selectedDynamicContentType === DYNAMIC_CONTENT_TYPE.EVENT_ATTRIBUTE.value) {
371
+ if (!isEmpty(form.getFieldValue(DYNAMIC_CONTENT_SETTING_KEY.SOURCE)))
372
+ return;
373
+ const defaultValue = listSources[0] ? [listSources[0].value] : [];
374
+ form.setFieldsValue({
375
+ [DYNAMIC_CONTENT_SETTING_KEY.SOURCE]: defaultValue,
376
+ });
377
+ }
378
+ }, [selectedEventSource, listSources, form, selectedDynamicContentType]);
379
+ useDeepCompareEffect(() => {
380
+ var _a, _b;
381
+ if (listEventAttributes &&
382
+ selectedDynamicContentType === DYNAMIC_CONTENT_TYPE.EVENT_ATTRIBUTE.value) {
383
+ const initEventAttr = ((_a = listEventAttributes[0]) === null || _a === void 0 ? void 0 : _a.children.length)
384
+ ? getAvailableAttrs((_b = listEventAttributes[0]) === null || _b === void 0 ? void 0 : _b.children)[0]
385
+ : listEventAttributes[0];
386
+ if (form.getFieldValue(DYNAMIC_CONTENT_SETTING_KEY.ATTRIBUTE)) {
387
+ const eventAttr = form.getFieldValue(DYNAMIC_CONTENT_SETTING_KEY.ATTRIBUTE);
388
+ setExpandedEventAttributes([eventAttr.value.split('.')[0]]);
389
+ return;
390
+ }
391
+ form.setFieldsValue({
392
+ [DYNAMIC_CONTENT_SETTING_KEY.ATTRIBUTE]: initEventAttr,
393
+ });
394
+ setExpandedEventAttributes([initEventAttr.value.split('.')[0]]);
395
+ }
396
+ }, [selectedSource, selectedEventSource, listEventAttributes, form, selectedDynamicContentType]);
397
+ useDeepCompareEffect(() => {
398
+ if (listPromotionCodeAttributes &&
399
+ selectedDynamicContentType === DYNAMIC_CONTENT_TYPE.PROMOTION_CODE.value) {
400
+ if (form.getFieldValue(DYNAMIC_CONTENT_SETTING_KEY.ATTRIBUTE))
401
+ return;
402
+ form.setFieldsValue({
403
+ [DYNAMIC_CONTENT_SETTING_KEY.ATTRIBUTE]: getAvailableAttrs(listPromotionCodeAttributes)[0],
404
+ });
405
+ }
406
+ }, [selectedDynamicContentType, listPromotionCodeAttributes, form]);
407
+ // Update form field data with default data/ or reset it to initial states
408
+ const resetStateAndFormValueDF = useCallback(() => {
409
+ setShowDetailEditDF(false);
410
+ setAttrDFSettings(undefined);
411
+ setAttrDFOptions([]);
412
+ setFormatedAttr('');
413
+ setsaveAsTemplate(false);
414
+ setTemplateName('');
415
+ setSearchValue('');
416
+ form.setFieldsValue({
417
+ [DYNAMIC_CONTENT_SETTING_KEY.ATTRIBUTE]: undefined,
418
+ [DYNAMIC_CONTENT_SETTING_KEY.DISPLAY_FORMAT_TYPE]: undefined,
419
+ [DYNAMIC_CONTENT_SETTING_KEY.FUNCTION]: undefined,
420
+ [DYNAMIC_CONTENT_SETTING_KEY.DATA_TYPE]: optionDataType[0].value,
421
+ });
422
+ }, [form]);
423
+ useEffect(() => {
424
+ if (!visible) {
425
+ setTimeout(() => {
426
+ resetStateAndFormValueDF();
427
+ }, 200);
428
+ }
429
+ }, [visible, resetStateAndFormValueDF]);
430
+ useEffect(() => {
431
+ let listTmp = [];
432
+ switch (true) {
433
+ case selectedDynamicContentType && regexCSType.test(selectedDynamicContentType):
434
+ listTmp = [...listBoAttributes];
435
+ break;
436
+ case selectedDynamicContentType === DYNAMIC_CONTENT_TYPE.PROMOTION_CODE.value:
437
+ listTmp = listPromotionCodeAttributes ? [...listPromotionCodeAttributes] : [];
438
+ break;
439
+ case selectedDynamicContentType === DYNAMIC_CONTENT_TYPE.CUSTOMER_ATTRIBUTE.value:
440
+ listTmp = [...listCustomerAttributes];
441
+ break;
442
+ case selectedDynamicContentType === DYNAMIC_CONTENT_TYPE.VISITOR_ATTRIBUTE.value:
443
+ listTmp = [...listVisitorAttributes];
444
+ break;
445
+ default:
446
+ break;
447
+ }
448
+ const { errorMessage, isDisable } = checkStatusAttr({
449
+ listBO: listBO,
450
+ itemTypeId: itemTypeId || 0,
451
+ listAttribute: listTmp,
452
+ field: selectedAttr === null || selectedAttr === void 0 ? void 0 : selectedAttr.value,
453
+ });
454
+ setActionArchive(isDisable);
455
+ setErrorMessageAttr(errorMessage);
456
+ }, [selectedAttr]);
457
+ useEffect(() => {
458
+ var _a;
459
+ if (!visible) {
460
+ return;
461
+ }
462
+ if ((_a = Object.keys(Object.assign({}, defaultData))) === null || _a === void 0 ? void 0 : _a.length) {
463
+ let draftDefaultData = Object.assign({}, defaultData);
464
+ if (draftDefaultData.type !== 'custom') {
465
+ if (triggerEvent === null || triggerEvent === void 0 ? void 0 : triggerEvent.eventActionId) {
466
+ draftDefaultData = omit(draftDefaultData, ['event', 'source']);
467
+ }
468
+ form.setFieldsValue(draftDefaultData);
469
+ const defaultDMType = form.getFieldValue(DYNAMIC_CONTENT_SETTING_KEY.DYNAMIC_CONTENT_TYPE);
470
+ const defaultAttr = form.getFieldValue(DYNAMIC_CONTENT_SETTING_KEY.ATTRIBUTE);
471
+ if (defaultDMType && regexCSType.test(defaultDMType)) {
472
+ const { itemTypeId } = serializeCSSelectedString(defaultDMType);
473
+ if (!isNaN(itemTypeId))
474
+ setItemTypeId(itemTypeId);
475
+ }
476
+ if (defaultAttr) {
477
+ const defaultAttr = draftDefaultData[DYNAMIC_CONTENT_SETTING_KEY.ATTRIBUTE];
478
+ // eslint-disable-next-line no-prototype-builtins
479
+ if (!defaultAttr.hasOwnProperty('dataType'))
480
+ return;
481
+ let key = '';
482
+ if (defaultAttr.dataType === 'number') {
483
+ key = DYNAMIC_CONTENT_SETTING_KEY.DYNAMIC_CONTENT_NUMBERIC_ATTR_FORMAT_SETTINGS;
484
+ }
485
+ if (defaultAttr.dataType === 'datetime') {
486
+ key = DYNAMIC_CONTENT_SETTING_KEY.DYNAMIC_CONTENT_DATETIME_ATTR_FORMAT_SETTINGS;
487
+ }
488
+ if (key && defaultAttr[key]) {
489
+ const _b = defaultAttr[key], { type } = _b, settingValues = __rest(_b, ["type"]);
490
+ form.setFieldsValue({
491
+ [DYNAMIC_CONTENT_SETTING_KEY.DISPLAY_FORMAT_TYPE]: type,
492
+ });
493
+ setDefaultAttrDFSetings({
494
+ itemPropertyName: defaultAttr.value,
495
+ settings: settingValues,
496
+ });
497
+ setAttrDFSettings(settingValues);
498
+ setAttrDFOptions(DYNAMIC_CONTENT_ATTR_DF_TYPE.filter((dfType) => dfType.dataType === defaultAttr.dataType));
499
+ }
500
+ }
501
+ }
502
+ else {
503
+ const { customFunction } = draftDefaultData;
504
+ const { outputFormat } = customFunction;
505
+ form.setFieldsValue({
506
+ [DYNAMIC_CONTENT_SETTING_KEY.DYNAMIC_CONTENT_TYPE]: draftDefaultData.type,
507
+ [DYNAMIC_CONTENT_SETTING_KEY.DISPLAY_FORMAT_TYPE]: outputFormat.type,
508
+ [DYNAMIC_CONTENT_SETTING_KEY.DATA_TYPE]: customFunction.outputDataType,
509
+ [DYNAMIC_CONTENT_SETTING_KEY.FUNCTION]: customFunction.customFunction,
510
+ });
511
+ setTemplateName(customFunction.templateName);
512
+ setAttrDFOptions(DYNAMIC_CONTENT_ATTR_DF_TYPE.filter((dfType) => dfType.dataType === customFunction.outputDataType));
513
+ setShowDetailEditDF(true);
514
+ setAttrDFSettings(customFunction.outputDataType === 'string' ? undefined : outputFormat.config);
515
+ }
516
+ // Check if trigger event of journey has event then don's set current event and source
517
+ }
518
+ else {
519
+ // Hard reset to Visitor attr
520
+ if (listVisitorAttributes) {
521
+ form.setFieldsValue({
522
+ [DYNAMIC_CONTENT_SETTING_KEY.DYNAMIC_CONTENT_TYPE]: DYNAMIC_CONTENT_TYPE.VISITOR_ATTRIBUTE.value,
523
+ [DYNAMIC_CONTENT_SETTING_KEY.ATTRIBUTE]: listVisitorAttributes[0],
524
+ });
525
+ }
526
+ }
527
+ // eslint-disable-next-line react-hooks/exhaustive-deps
528
+ }, [defaultData, visible, form]);
529
+ useDeepCompareEffect(() => {
530
+ if (selectedDynamicContentType === DYNAMIC_CONTENT_TYPE.EVENT_ATTRIBUTE.value) {
531
+ const { eventActionId, eventCategoryId, insightPropertyIds } = triggerEvent || {};
532
+ if (!!eventActionId && !!eventCategoryId) {
533
+ form.setFieldsValue({
534
+ [DYNAMIC_CONTENT_SETTING_KEY.EVENT]: `${eventActionId}:${eventCategoryId}`,
535
+ });
536
+ }
537
+ if (Array.isArray(insightPropertyIds) && insightPropertyIds.length) {
538
+ form.setFieldsValue({
539
+ [DYNAMIC_CONTENT_SETTING_KEY.SOURCE]: insightPropertyIds,
540
+ });
541
+ }
542
+ }
543
+ }, [triggerEvent, selectedDynamicContentType]);
544
+ // Disable Apply button if there's any error
545
+ useLayoutEffect(() => {
546
+ setFormSubmitDisabled(Object.values(hasError).some(error => error));
547
+ }, [hasError]);
548
+ useLayoutEffect(() => {
549
+ if (selectedDynamicContentType === DYNAMIC_CONTENT_TYPE.VISITOR_ATTRIBUTE.value ||
550
+ selectedDynamicContentType === DYNAMIC_CONTENT_TYPE.CUSTOMER_ATTRIBUTE.value) {
551
+ setFormSubmitDisabled(isFetchingDynamicContentAttr);
552
+ }
553
+ if (selectedDynamicContentType === DYNAMIC_CONTENT_TYPE.EVENT_ATTRIBUTE.value) {
554
+ setFormSubmitDisabled(isFetchingSourceBO || isFetchingEventBySource || isFetchingEventAttr);
555
+ }
556
+ if (selectedDynamicContentType === DYNAMIC_CONTENT_TYPE.PROMOTION_CODE.value) {
557
+ setFormSubmitDisabled(isFetchingPromotionPool || isFetchingPromotionCodeAttr);
558
+ }
559
+ if (selectedDynamicContentType && regexCSType.test(selectedDynamicContentType)) {
560
+ setFormSubmitDisabled(isFetchingListBoAttr);
561
+ }
562
+ }, [
563
+ isFetchingDynamicContentAttr,
564
+ selectedDynamicContentType,
565
+ isFetchingSourceBO,
566
+ isFetchingEventBySource,
567
+ isFetchingEventAttr,
568
+ isFetchingPromotionPool,
569
+ isFetchingPromotionCodeAttr,
570
+ isFetchingListBoAttr,
571
+ ]);
572
+ useLayoutEffect(() => {
573
+ let formatedDFValue = '';
574
+ let settings = attrDFSettings;
575
+ const selectedAttr = form.getFieldValue(DYNAMIC_CONTENT_SETTING_KEY.ATTRIBUTE);
576
+ const dataType = form.getFieldValue(DYNAMIC_CONTENT_SETTING_KEY.DATA_TYPE);
577
+ const dynamicType = form.getFieldValue(DYNAMIC_CONTENT_SETTING_KEY.DYNAMIC_CONTENT_TYPE);
578
+ if ((Object.keys(defaultData).length > 0 && defaultData.type !== 'custom') ||
579
+ dynamicType !== 'custom') {
580
+ if (selectedAttr &&
581
+ selectedAttr.dataType &&
582
+ ['datetime', 'number'].includes(selectedAttr.dataType)) {
583
+ /* when change select if attr selected is previous selected default attr, set settings as default settings */
584
+ if (!settings &&
585
+ (defaultAttrDFSetings === null || defaultAttrDFSetings === void 0 ? void 0 : defaultAttrDFSetings.itemPropertyName) === selectedAttr.value) {
586
+ // Visitor and Customer don't have additional field
587
+ let equalDefaultAttr = true;
588
+ // Event need check additional field source, event by soucre
589
+ if (selectedDynamicContentType === DYNAMIC_CONTENT_TYPE.EVENT_ATTRIBUTE.value) {
590
+ const source = form.getFieldValue(DYNAMIC_CONTENT_SETTING_KEY.SOURCE);
591
+ const event = form.getFieldValue(DYNAMIC_CONTENT_SETTING_KEY.EVENT);
592
+ if (source !== defaultData[DYNAMIC_CONTENT_SETTING_KEY.SOURCE] ||
593
+ event !== defaultData[DYNAMIC_CONTENT_SETTING_KEY.EVENT])
594
+ equalDefaultAttr = false;
595
+ }
596
+ // Promotion need check additional field promotion pool
597
+ if (selectedDynamicContentType === DYNAMIC_CONTENT_TYPE.PROMOTION_CODE.value) {
598
+ const pool = form.getFieldValue(DYNAMIC_CONTENT_SETTING_KEY.PROMOTION_POOL);
599
+ if (pool !== defaultData[DYNAMIC_CONTENT_SETTING_KEY.PROMOTION_POOL])
600
+ equalDefaultAttr = false;
601
+ }
602
+ // BO settings need check additional field index
603
+ if (selectedDynamicContentType && regexCSType.test(selectedDynamicContentType)) {
604
+ if (selectedBoIndex !== defaultData[DYNAMIC_CONTENT_SETTING_KEY.INDEX])
605
+ equalDefaultAttr = false;
606
+ }
607
+ if (equalDefaultAttr) {
608
+ settings = defaultAttrDFSetings.settings;
609
+ }
610
+ }
611
+ // *********** //
612
+ // Numberic Attribute DF
613
+ if ((selectedAttr === null || selectedAttr === void 0 ? void 0 : selectedAttr.dataType) === 'number') {
614
+ settings = settings !== null && settings !== void 0 ? settings : initNumberDFSettings;
615
+ formatedDFValue = formatNumberDF(1234.56789, selectedDFType, settings);
616
+ }
617
+ // Datatime Attribute DF
618
+ if ((selectedAttr === null || selectedAttr === void 0 ? void 0 : selectedAttr.dataType) === 'datetime') {
619
+ settings = settings !== null && settings !== void 0 ? settings : Object.assign(Object.assign({}, initDatetimeDFSettings), { language: i18n.language });
620
+ formatedDFValue = formatDatetimeDF(dateExample, settings);
621
+ }
622
+ if (!attrDFOptions.length) {
623
+ setAttrDFOptions(DYNAMIC_CONTENT_ATTR_DF_TYPE.filter((dfType) => dfType.dataType === selectedAttr.dataType));
624
+ }
625
+ setAttrDFSettings(settings);
626
+ setFormatedAttr(formatedDFValue);
627
+ }
628
+ }
629
+ if (dataType && ['datetime', 'number'].includes(dataType) && dynamicType === 'custom') {
630
+ // Numberic Attribute DF
631
+ if (dataType === 'number') {
632
+ settings = settings !== null && settings !== void 0 ? settings : initNumberDFSettings;
633
+ formatedDFValue = formatNumberDF(1234.56789, selectedDFType, settings);
634
+ }
635
+ // Datatime Attribute DF
636
+ if (dataType === 'datetime') {
637
+ settings = settings !== null && settings !== void 0 ? settings : Object.assign(Object.assign({}, initDatetimeDFSettings), { language: i18n.language });
638
+ formatedDFValue = formatDatetimeDF(dateExample, settings);
639
+ }
640
+ if (!attrDFOptions.length) {
641
+ setAttrDFOptions(DYNAMIC_CONTENT_ATTR_DF_TYPE.filter((dfType) => dfType.dataType === dataType));
642
+ }
643
+ setAttrDFSettings(settings);
644
+ setFormatedAttr(formatedDFValue);
645
+ }
646
+ }, [
647
+ attrDFSettings,
648
+ selectedDFType,
649
+ attrDFOptions.length,
650
+ i18n.language,
651
+ defaultAttrDFSetings,
652
+ form,
653
+ selectedAttr,
654
+ defaultData,
655
+ selectedDynamicContentType,
656
+ selectedBoIndex,
657
+ ]);
658
+ //* Handlers
659
+ const handleOnCancelModal = () => {
660
+ if (onCancel) {
661
+ onCancel();
662
+ }
663
+ };
664
+ const onChangeDataInput = (value) => {
665
+ setTemplateName(value);
666
+ let tempState = [...listCustomTemplates];
667
+ if (value.length > 0) {
668
+ tempState = tempState.filter(item => item.label.toLowerCase().includes(value.trim().toLowerCase()));
669
+ }
670
+ setlistCustomTemplatesSearch(tempState);
671
+ setSearchValue(value);
672
+ };
673
+ const handleSelect = (data) => {
674
+ const dataTmp = listCustomTemplates.filter(each => each.value === data);
675
+ settemplateId(dataTmp[0].template_id);
676
+ let dataFormat = dataTmp[0].output_format.type.toLowerCase();
677
+ switch (dataTmp[0].output_format.type) {
678
+ case 'DATE_AND_TIME':
679
+ dataFormat = 'date_and_time';
680
+ break;
681
+ case 'RAW_STRING':
682
+ dataFormat = 'raw_string';
683
+ break;
684
+ default:
685
+ break;
686
+ }
687
+ // const dataFormat =
688
+ // dataTmp[0].output_format.type.toLowerCase() === 'date_and_time'
689
+ // ? 'datetime'
690
+ // : dataTmp[0].output_format.type.toLowerCase();
691
+ form.setFieldsValue({
692
+ [DYNAMIC_CONTENT_SETTING_KEY.FUNCTION]: dataTmp[0].custom_function,
693
+ [DYNAMIC_CONTENT_SETTING_KEY.DATA_TYPE]: dataTmp[0].output_data_type,
694
+ [DYNAMIC_CONTENT_SETTING_KEY.DISPLAY_FORMAT_TYPE]: dataFormat === 'date_and_time' ? 'datetime' : dataFormat,
695
+ });
696
+ setTemplateName(dataTmp[0].template_name);
697
+ setAttrDFOptions(DYNAMIC_CONTENT_ATTR_DF_TYPE.filter((dfType) => dfType.dataType === dataTmp[0].output_data_type));
698
+ const format = dataTmp[0].output_format.config;
699
+ switch (dataFormat) {
700
+ case 'currency': {
701
+ setAttrDFSettings(Object.assign(Object.assign({}, initNumberDFSettings), { grouping: format.group || ',', decimal: format.decimal, decimalPlaces: format.decimalPlace, isCompact: format.isCompactNumber || false, currencyCode: format.currency || 'USD', prefixType: format.prefixType || 'code' }));
702
+ break;
703
+ }
704
+ case 'number':
705
+ case 'percentage': {
706
+ setAttrDFSettings(Object.assign(Object.assign({}, initNumberDFSettings), { grouping: format.group || ',', decimal: format.decimal, decimalPlaces: format.decimalPlace, isCompact: format.isCompactNumber || false }));
707
+ break;
708
+ }
709
+ case 'date_and_time': {
710
+ setAttrDFSettings(Object.assign(Object.assign({}, initDatetimeDFSettings), { language: i18n.language, hasDateFormat: format.date.check || true, hasTimeFormat: format.time.check || true, dateParseOption: format.date.value || 'medium', timeParseOption: format.time.value || 'medium', dateParseFormat: format.format || 'MM/DD/YYYY', timeParseFormat: `${format.time.timeFormat || 12}hour` }));
711
+ break;
712
+ }
713
+ case 'raw_string': {
714
+ setAttrDFSettings(undefined);
715
+ break;
716
+ }
717
+ default:
718
+ break;
719
+ }
720
+ };
721
+ // const handleSearch = data => {
722
+ // console.log('onSelect', data);
723
+ // };
724
+ const handleOnOkModal = () => {
725
+ if (isActionArchive &&
726
+ selectedDynamicContentType !== DYNAMIC_CONTENT_TYPE.EVENT_ATTRIBUTE.value) {
727
+ return;
728
+ }
729
+ form.validateFields().then((values) => {
730
+ var _a;
731
+ values = omit(values, 'dfType');
732
+ if (onOk) {
733
+ const type = form.getFieldValue(DYNAMIC_CONTENT_SETTING_KEY.DYNAMIC_CONTENT_TYPE);
734
+ if (type === 'custom') {
735
+ const outputFormat = {};
736
+ const perName = templateName;
737
+ const functionCustom = form.getFieldValue(DYNAMIC_CONTENT_SETTING_KEY.FUNCTION);
738
+ const dataType = form.getFieldValue(DYNAMIC_CONTENT_SETTING_KEY.DATA_TYPE);
739
+ const displayFormat = form.getFieldValue([
740
+ DYNAMIC_CONTENT_SETTING_KEY.DISPLAY_FORMAT_TYPE,
741
+ ]);
742
+ if (templateId && !saveAsTemplate) {
743
+ try {
744
+ updateCSFunction({
745
+ url,
746
+ infos,
747
+ templateId,
748
+ name: perName,
749
+ dataType,
750
+ functionCustom,
751
+ dataFormat: attrDFSettings,
752
+ displayFormat,
753
+ outputFormat,
754
+ });
755
+ }
756
+ catch (error) {
757
+ handleError(error, {
758
+ path: PATH,
759
+ name: 'onClickSaveDynamicContent',
760
+ args: {},
761
+ });
762
+ }
763
+ }
764
+ else if (saveAsTemplate) {
765
+ try {
766
+ addSavedCSFunction({
767
+ url,
768
+ infos,
769
+ name: perName,
770
+ dataType,
771
+ functionCustom,
772
+ dataFormat: attrDFSettings,
773
+ displayFormat,
774
+ outputFormat,
775
+ });
776
+ }
777
+ catch (error) {
778
+ handleError(error, {
779
+ path: PATH,
780
+ name: 'onClickSaveDynamicContent',
781
+ args: {},
782
+ });
783
+ }
784
+ }
785
+ if (!showIndex) {
786
+ values = omit(values, 'index');
787
+ }
788
+ const config = Object.assign({}, attrDFSettings);
789
+ if (dataType === 'datetime') {
790
+ config.dateFormatString = getStringFormatDateDF(attrDFSettings);
791
+ }
792
+ onOk(Object.assign(Object.assign({}, values), { customFunction: {
793
+ outputFormat: {
794
+ type: displayFormat,
795
+ config,
796
+ },
797
+ templateCode: serializeLabelToCode(perName),
798
+ templateName: perName,
799
+ templateType: 'custom',
800
+ customFunction: functionCustom,
801
+ outputDataType: dataType,
802
+ }, attribute: {
803
+ label: perName,
804
+ value: serializeLabelToCode(perName),
805
+ }, mappingFields: `#{custom.${serializeLabelToCode(perName)}}` }));
806
+ }
807
+ else {
808
+ let key = '';
809
+ const otherField = {};
810
+ const selectedAttr = form.getFieldValue(DYNAMIC_CONTENT_SETTING_KEY.ATTRIBUTE);
811
+ if ((selectedAttr === null || selectedAttr === void 0 ? void 0 : selectedAttr.dataType) === 'number') {
812
+ key = DYNAMIC_CONTENT_SETTING_KEY.DYNAMIC_CONTENT_NUMBERIC_ATTR_FORMAT_SETTINGS;
813
+ }
814
+ if ((selectedAttr === null || selectedAttr === void 0 ? void 0 : selectedAttr.dataType) === 'datetime') {
815
+ key = DYNAMIC_CONTENT_SETTING_KEY.DYNAMIC_CONTENT_DATETIME_ATTR_FORMAT_SETTINGS;
816
+ otherField.dateFormatString = getStringFormatDateDF(attrDFSettings);
817
+ }
818
+ if (key && showDisplayFormat) {
819
+ values[DYNAMIC_CONTENT_SETTING_KEY.ATTRIBUTE][key] = Object.assign(Object.assign(Object.assign({}, attrDFSettings), otherField), { type: selectedDFType });
820
+ }
821
+ // Handle Merge tag for event attributes
822
+ if (values.type === DYNAMIC_CONTENT_TYPE.EVENT_ATTRIBUTE.value) {
823
+ if (values.index != null && !get(values, 'attribute.itemTypeName', null)) {
824
+ const itemTypeName = ((_a = listBO === null || listBO === void 0 ? void 0 : listBO.find(({ id }) => get(eventTrackingAttributes, 'mainObjects', []).some(({ itemTypeId }) => itemTypeId === id))) === null || _a === void 0 ? void 0 : _a.name) || null;
825
+ if (itemTypeName) {
826
+ set(values, 'attribute.itemTypeName', itemTypeName);
827
+ }
828
+ }
829
+ }
830
+ // Set itemTypeName if Selecting content source
831
+ if (regexCSType.test(values.type) && !!itemTypeName) {
832
+ set(values, 'attribute.itemTypeName', itemTypeName);
833
+ }
834
+ if (!showIndex) {
835
+ values = omit(values, 'index');
836
+ }
837
+ const mappingFields = buildMappingFields(values);
838
+ onOk(Object.assign(Object.assign({}, values), (mappingFields && { mappingFields })));
839
+ }
840
+ }
841
+ });
842
+ };
843
+ const handleOnClickParentNode = (item) => {
844
+ if (item.children.length) {
845
+ if (expandedEventAttributes.includes(item.value)) {
846
+ // close expand
847
+ const newExpandedKeys = expandedEventAttributes.filter(key => key !== item.value);
848
+ handleTreeExpand(newExpandedKeys);
849
+ }
850
+ else {
851
+ // open expand
852
+ handleTreeExpand((prev) => [...prev, item.value]);
853
+ }
854
+ }
855
+ };
856
+ const handleTreeExpand = (expandedKeys) => {
857
+ setExpandedEventAttributes(expandedKeys);
858
+ };
859
+ const handleSaveAsTemplate = () => {
860
+ setsaveAsTemplate(!saveAsTemplate);
861
+ };
862
+ const handleFormValuesChanges = (changedValues, _allValues) => {
863
+ var _a;
864
+ const [fieldName, fieldValue] = Object.entries(changedValues)[0];
865
+ switch (fieldName) {
866
+ case DYNAMIC_CONTENT_SETTING_KEY.DYNAMIC_CONTENT_TYPE:
867
+ resetStateAndFormValueDF();
868
+ switch (true) {
869
+ case fieldValue === DYNAMIC_CONTENT_TYPE.CUSTOMER_ATTRIBUTE.value:
870
+ form.setFieldsValue({
871
+ [DYNAMIC_CONTENT_SETTING_KEY.ATTRIBUTE]: getAvailableAttrs(listCustomerAttributes)[0],
872
+ });
873
+ setHasError({ [DYNAMIC_CONTENT_SETTING_KEY.ATTRIBUTE]: isErrorDynamicContentAttr });
874
+ break;
875
+ case fieldValue === DYNAMIC_CONTENT_TYPE.VISITOR_ATTRIBUTE.value:
876
+ form.setFieldsValue({
877
+ [DYNAMIC_CONTENT_SETTING_KEY.ATTRIBUTE]: getAvailableAttrs(listVisitorAttributes)[0],
878
+ });
879
+ setHasError({ [DYNAMIC_CONTENT_SETTING_KEY.ATTRIBUTE]: isErrorDynamicContentAttr });
880
+ break;
881
+ case fieldValue === DYNAMIC_CONTENT_TYPE.EVENT_ATTRIBUTE.value:
882
+ if (!(listEvents === null || listEvents === void 0 ? void 0 : listEvents.length))
883
+ break;
884
+ form.setFieldsValue({
885
+ [DYNAMIC_CONTENT_SETTING_KEY.EVENT]: listEvents[0].value,
886
+ [DYNAMIC_CONTENT_SETTING_KEY.SOURCE]: undefined,
887
+ });
888
+ setHasError({ [DYNAMIC_CONTENT_SETTING_KEY.ATTRIBUTE]: isErrorEventAttr });
889
+ break;
890
+ case fieldValue === CUSTOM_TYPE.value:
891
+ if (!(listEvents === null || listEvents === void 0 ? void 0 : listEvents.length))
892
+ break;
893
+ let formatedDFValue = '';
894
+ let settings = attrDFSettings;
895
+ settings = settings !== null && settings !== void 0 ? settings : initNumberDFSettings;
896
+ formatedDFValue = formatNumberDF(1234.56789, selectedDFType, settings);
897
+ setFormatedAttr(formatedDFValue);
898
+ setAttrDFSettings(settings);
899
+ form.setFieldsValue({
900
+ [DYNAMIC_CONTENT_SETTING_KEY.DISPLAY_FORMAT_TYPE]: optionDataType[0].value,
901
+ [DYNAMIC_CONTENT_SETTING_KEY.DATA_TYPE]: optionDataType[0].value,
902
+ });
903
+ setAttrDFOptions(DYNAMIC_CONTENT_ATTR_DF_TYPE.filter(dfType => dfType.dataType === optionDataType[0].value));
904
+ setHasError({ [DYNAMIC_CONTENT_SETTING_KEY.ATTRIBUTE]: isErrorEventAttr });
905
+ setShowDetailEditDF(true);
906
+ break;
907
+ case fieldValue === DYNAMIC_CONTENT_TYPE.PROMOTION_CODE.value:
908
+ if (!listPromotionCodeAttributes || !listPromotionPools)
909
+ break;
910
+ form.setFieldsValue({
911
+ [DYNAMIC_CONTENT_SETTING_KEY.PROMOTION_POOL]: (_a = listPromotionPools[0]) === null || _a === void 0 ? void 0 : _a.value,
912
+ [DYNAMIC_CONTENT_SETTING_KEY.ATTRIBUTE]: getAvailableAttrs(listPromotionCodeAttributes)[0],
913
+ });
914
+ setHasError({ [DYNAMIC_CONTENT_SETTING_KEY.ATTRIBUTE]: isErrorListPromotionCodeAttr });
915
+ break;
916
+ case regexCSType.test(fieldValue): {
917
+ const { itemTypeId: selectedItemTypeId } = serializeCSSelectedString(String(fieldValue));
918
+ if (isNaN(selectedItemTypeId))
919
+ break;
920
+ setItemTypeId(Number(selectedItemTypeId));
921
+ const key = [QUERY_KEYS.GET_EVENT_ATTRIBUTE_BO, [selectedItemTypeId]];
922
+ const listAttBOByItemTypeId = serilizeBOAttr(queryClientAntsomiUI.getQueryData(key));
923
+ if (listAttBOByItemTypeId.length) {
924
+ form.setFieldsValue({
925
+ [DYNAMIC_CONTENT_SETTING_KEY.ATTRIBUTE]: listAttBOByItemTypeId[0],
926
+ [DYNAMIC_CONTENT_SETTING_KEY.INDEX]: defaultDynamicIndex,
927
+ });
928
+ }
929
+ setHasError({ [DYNAMIC_CONTENT_SETTING_KEY.ATTRIBUTE]: isErrorBoAttr });
930
+ break;
931
+ }
932
+ default: {
933
+ break;
934
+ }
935
+ }
936
+ break;
937
+ case DYNAMIC_CONTENT_SETTING_KEY.ATTRIBUTE:
938
+ let listAttributes = [];
939
+ switch (true) {
940
+ case selectedDynamicContentType === DYNAMIC_CONTENT_TYPE.EVENT_ATTRIBUTE.value:
941
+ if (!listEventAttributes)
942
+ break;
943
+ let newSelectEventAttr = listEventAttributes.find((row) => {
944
+ if (row === null || row === void 0 ? void 0 : row.children.length) {
945
+ return row.children.find((item) => item.value === fieldValue.value);
946
+ }
947
+ return row.value === fieldValue.value;
948
+ });
949
+ if (newSelectEventAttr === null || newSelectEventAttr === void 0 ? void 0 : newSelectEventAttr.children.length) {
950
+ newSelectEventAttr = newSelectEventAttr.children.find((item) => item.value === fieldValue.value);
951
+ }
952
+ listAttributes = flatMapDeep(listEventAttributes, getMembers);
953
+ form.setFieldsValue({ [DYNAMIC_CONTENT_SETTING_KEY.INDEX]: defaultDynamicIndex });
954
+ break;
955
+ case selectedDynamicContentType === DYNAMIC_CONTENT_TYPE.CUSTOMER_ATTRIBUTE.value:
956
+ listAttributes = listCustomerAttributes;
957
+ break;
958
+ case selectedDynamicContentType === DYNAMIC_CONTENT_TYPE.PROMOTION_CODE.value:
959
+ listAttributes = listPromotionCodeAttributes !== null && listPromotionCodeAttributes !== void 0 ? listPromotionCodeAttributes : [];
960
+ break;
961
+ case selectedDynamicContentType === DYNAMIC_CONTENT_TYPE.VISITOR_ATTRIBUTE.value:
962
+ listAttributes = listVisitorAttributes;
963
+ break;
964
+ case selectedDynamicContentType && regexCSType.test(selectedDynamicContentType):
965
+ form.setFieldsValue({ [DYNAMIC_CONTENT_SETTING_KEY.INDEX]: defaultDynamicIndex });
966
+ if (!listBoAttributes)
967
+ break;
968
+ listAttributes = listBoAttributes;
969
+ break;
970
+ default: {
971
+ break;
972
+ }
973
+ }
974
+ // add dataType to
975
+ if (listAttributes.length) {
976
+ const attr = listAttributes.find(attr => {
977
+ if (attr.value === fieldValue.value) {
978
+ return attr;
979
+ }
980
+ return null;
981
+ });
982
+ form.setFieldsValue({
983
+ [DYNAMIC_CONTENT_SETTING_KEY.ATTRIBUTE]: attr,
984
+ });
985
+ // set new value for options display format
986
+ if (attr) {
987
+ const newAttrDFOptions = DYNAMIC_CONTENT_ATTR_DF_TYPE.filter((dfType) => dfType.dataType === attr.dataType);
988
+ if (newAttrDFOptions.length) {
989
+ form.setFieldsValue({
990
+ [DYNAMIC_CONTENT_SETTING_KEY.DISPLAY_FORMAT_TYPE]: newAttrDFOptions[0].value,
991
+ });
992
+ setAttrDFOptions(newAttrDFOptions);
993
+ }
994
+ // reset detail display format settings
995
+ setAttrDFSettings(undefined);
996
+ setShowDetailEditDF(false);
997
+ }
998
+ }
999
+ break;
1000
+ case DYNAMIC_CONTENT_SETTING_KEY.INDEX:
1001
+ break;
1002
+ case DYNAMIC_CONTENT_SETTING_KEY.FUNCTION:
1003
+ form.setFieldsValue({
1004
+ [DYNAMIC_CONTENT_SETTING_KEY.FUNCTION]: fieldValue,
1005
+ });
1006
+ break;
1007
+ case DYNAMIC_CONTENT_SETTING_KEY.DATA_TYPE:
1008
+ form.setFieldsValue({
1009
+ [DYNAMIC_CONTENT_SETTING_KEY.DATA_TYPE]: fieldValue,
1010
+ [DYNAMIC_CONTENT_SETTING_KEY.DISPLAY_FORMAT_TYPE]: fieldValue === 'string' ? 'raw_string' : fieldValue,
1011
+ });
1012
+ let settings = attrDFSettings;
1013
+ // Datatime Attribute DF
1014
+ if (fieldValue === 'datetime') {
1015
+ settings = Object.assign(Object.assign({}, initDatetimeDFSettings), { language: i18n.language });
1016
+ }
1017
+ else if (fieldValue === 'string') {
1018
+ settings = undefined;
1019
+ }
1020
+ setAttrDFOptions(DYNAMIC_CONTENT_ATTR_DF_TYPE.filter((dfType) => dfType.dataType === fieldValue));
1021
+ setAttrDFSettings(settings);
1022
+ break;
1023
+ case DYNAMIC_CONTENT_SETTING_KEY.EVENT:
1024
+ form.setFieldsValue({
1025
+ [DYNAMIC_CONTENT_SETTING_KEY.SOURCE]: undefined,
1026
+ });
1027
+ resetStateAndFormValueDF();
1028
+ break;
1029
+ case DYNAMIC_CONTENT_SETTING_KEY.SOURCE:
1030
+ resetStateAndFormValueDF();
1031
+ break;
1032
+ case DYNAMIC_CONTENT_SETTING_KEY.DISPLAY_FORMAT_TYPE:
1033
+ switch (fieldValue) {
1034
+ case 'currency': {
1035
+ setAttrDFSettings(Object.assign(Object.assign({}, initNumberDFSettings), { decimalPlaces: 1 }));
1036
+ break;
1037
+ }
1038
+ case 'number':
1039
+ case 'percentage': {
1040
+ setAttrDFSettings(initNumberDFSettings);
1041
+ break;
1042
+ }
1043
+ case 'datetime': {
1044
+ setAttrDFSettings(Object.assign(Object.assign({}, initDatetimeDFSettings), { language: i18n.language }));
1045
+ break;
1046
+ }
1047
+ case 'raw_string': {
1048
+ setAttrDFSettings(undefined);
1049
+ break;
1050
+ }
1051
+ default: {
1052
+ break;
1053
+ }
1054
+ }
1055
+ break;
1056
+ default: {
1057
+ break;
1058
+ }
1059
+ }
1060
+ };
1061
+ //* Render functions
1062
+ const renderBoAttrFields = () => {
1063
+ if (hasError[DYNAMIC_CONTENT_SETTING_KEY.ATTRIBUTE]) {
1064
+ return (React.createElement(Text, { type: "error" }, t(translations.dynamicContent.modal.error.boAttr)));
1065
+ }
1066
+ return (React.createElement(Form.Item, { className: "ants-items-center", label: t(translations.dynamicContent.modal.label.attribute), name: DYNAMIC_CONTENT_SETTING_KEY.ATTRIBUTE, required: true },
1067
+ React.createElement(Select, { loading: isFetchingListBoAttr, className: classnames('ants-h-7'), labelInValue: true, options: buildOptionAttrArchive(listBoAttributes || [], selectedAttr),
1068
+ // errorArchive={errorMessageAttr}
1069
+ disabled: isActionArchive, showSearch: true })));
1070
+ };
1071
+ const renderIndexFields = ({ disabled = false, loading = false }) => {
1072
+ if (!showIndex)
1073
+ return null;
1074
+ if (hasError[DYNAMIC_CONTENT_SETTING_KEY.ATTRIBUTE]) {
1075
+ return null;
1076
+ }
1077
+ return (React.createElement(Form.Item, { className: "ants-items-center", label: t(translations.dynamicContent.modal.label.index), name: DYNAMIC_CONTENT_SETTING_KEY.INDEX, required: true },
1078
+ React.createElement(Select, { disabled: disabled, loading: loading, className: classnames('ants-h-7'), options: Array.from({ length: 90 }, (_, i) => ({ value: i + 1, label: i + 1 })), showSearch: true })));
1079
+ };
1080
+ const renderCustomFunctionFields = () => {
1081
+ const dataType = form.getFieldValue([DYNAMIC_CONTENT_SETTING_KEY.DISPLAY_FORMAT_TYPE]);
1082
+ return (React.createElement(React.Fragment, null,
1083
+ React.createElement(Form.Item, { className: "ants-items-center", label: t(translations.dynamicContent.modal.label.personalizationName), name: DYNAMIC_CONTENT_SETTING_KEY.PERNAME, required: true },
1084
+ React.createElement(InputSuggestion, { onSelect: handleSelect, placeholder: "Custom function name...", options: searchValue.length > 0 ? listCustomTemplatesSearch : listCustomTemplates, onChange: onChangeDataInput, value: templateName }),
1085
+ hasError[DYNAMIC_CONTENT_SETTING_KEY.PERNAME] && (React.createElement(Text, { type: "error" }, t(translations.dynamicContent.modal.error.perName)))),
1086
+ React.createElement(Form.Item, { className: "ants-items-center", label: t(translations.dynamicContent.modal.label.function), name: DYNAMIC_CONTENT_SETTING_KEY.FUNCTION, required: true }),
1087
+ React.createElement(Form.Item, { className: "ants-items-center", label: t(translations.dynamicContent.modal.label.ouputDataType), name: DYNAMIC_CONTENT_SETTING_KEY.DATA_TYPE, required: true },
1088
+ React.createElement(Select, { className: classnames('ants-h-7'), options: optionDataType })),
1089
+ React.createElement(Form.Item
1090
+ // initialValue={attrDFOptions[0].value}
1091
+ , {
1092
+ // initialValue={attrDFOptions[0].value}
1093
+ className: "ants-items-start", required: true, label: t(translations.dynamicContent.modal.label.ouputFormat), name: DYNAMIC_CONTENT_SETTING_KEY.DISPLAY_FORMAT_TYPE, extra: React.createElement("div", { className: "ants-flex ants-flex-wrap ants-items-center ants-mt-4 ants-gap-2" },
1094
+ dataType !== 'raw_string' ? (React.createElement(Text, { color: "#555", dangerouslySetInnerHTML: {
1095
+ __html: `${t(translations.dynamicContent.modal.label.displayFormat)}: <bdo dir='ltr'>${formatedAttr}</bdo>`,
1096
+ } })) : null,
1097
+ !showDetailEditDF && (React.createElement(Button, { disabled: isActionArchive &&
1098
+ selectedDynamicContentType !== DYNAMIC_CONTENT_TYPE.EVENT_ATTRIBUTE.value, type: "text", className: "ants-inline-block", onClick: () => setShowDetailEditDF(prevShow => !prevShow) }, t(translations.edit.title)))) },
1099
+ React.createElement(Select, { disabled: isActionArchive &&
1100
+ selectedDynamicContentType !== DYNAMIC_CONTENT_TYPE.EVENT_ATTRIBUTE.value, className: classnames('ants-h-7'), options: attrDFOptions }))));
1101
+ };
1102
+ const renderCustomerAttrFields = () => {
1103
+ if (hasError[DYNAMIC_CONTENT_SETTING_KEY.ATTRIBUTE]) {
1104
+ return (React.createElement(Text, { type: "error" }, t(translations.dynamicContent.modal.error.customerAttr)));
1105
+ }
1106
+ return (React.createElement(Form.Item, { className: "ants-items-center", initialValue: listCustomerAttributes[0], label: t(translations.dynamicContent.modal.label.attribute), name: DYNAMIC_CONTENT_SETTING_KEY.ATTRIBUTE, required: true },
1107
+ React.createElement(Select, { loading: isFetchingDynamicContentAttr, className: classnames('ants-h-7'), labelInValue: true,
1108
+ // errorArchive={errorMessageAttr}
1109
+ disabled: isActionArchive, options: buildOptionAttrArchive(listCustomerAttributes, selectedAttr), showSearch: true })));
1110
+ };
1111
+ const renderEventAttrFields = () => {
1112
+ var _a;
1113
+ if (hasError[DYNAMIC_CONTENT_SETTING_KEY.ATTRIBUTE]) {
1114
+ return (React.createElement(Text, { type: "error" }, t(translations.dynamicContent.modal.error.eventAttr)));
1115
+ }
1116
+ return (React.createElement(React.Fragment, null,
1117
+ React.createElement(Form.Item, { className: "ants-items-center", label: t(translations.dynamicContent.modal.label.selectEventAttr), name: DYNAMIC_CONTENT_SETTING_KEY.ATTRIBUTE, required: true },
1118
+ React.createElement(TreeSelect, { loading: isFetchingEventAttr || !(listEvents === null || listEvents === void 0 ? void 0 : listEvents.length), className: classnames('ants-h-7'),
1119
+ // filterTreeNode={(val, option) => {
1120
+ // if (option?.children?.length) {
1121
+ // return option?.children?.some(
1122
+ // child => (child?.title?.toString() || '').toLowerCase().indexOf(val.toLowerCase().trim()) >= 0,
1123
+ // );
1124
+ // } else {
1125
+ // return (option?.title?.toString() || '').toLowerCase().indexOf(val.toLowerCase().trim()) >= 0;
1126
+ // }
1127
+ // }}
1128
+ labelInValue: true, showSearch: true }, listEventAttributes &&
1129
+ listEventAttributes.map((attr) => {
1130
+ var _a, _b, _c;
1131
+ return (React.createElement(TreeNode, { key: attr.value, value: attr.value, selectable: !((_a = attr === null || attr === void 0 ? void 0 : attr.children) === null || _a === void 0 ? void 0 : _a.length), title: ((_b = attr.children) === null || _b === void 0 ? void 0 : _b.length) ? (React.createElement("div", { onClick: () => handleOnClickParentNode(attr) }, attr.label)) : (attr.label) }, (_c = buildOptionAttrArchive(attr === null || attr === void 0 ? void 0 : attr.children, selectedAttr)) === null || _c === void 0 ? void 0 : _c.map((item) => (React.createElement(TreeNode, { key: item.value, value: item.value, title: item.label })))));
1132
+ }))),
1133
+ form.getFieldValue(DYNAMIC_CONTENT_SETTING_KEY.ATTRIBUTE) &&
1134
+ ((_a = form.getFieldValue(DYNAMIC_CONTENT_SETTING_KEY.ATTRIBUTE)) === null || _a === void 0 ? void 0 : _a.status) !== 1 && (React.createElement(Text, { type: "warning" }, t(translations.dynamicContent.modal.message.selectDisableEventAttr)))));
1135
+ };
1136
+ const renderEventFields = () => {
1137
+ if (hasError[DYNAMIC_CONTENT_SETTING_KEY.EVENT]) {
1138
+ return (React.createElement(Text, { type: "error" }, t(translations.dynamicContent.modal.error.eventBySource)));
1139
+ }
1140
+ return (React.createElement(Form.Item, { className: "ants-items-center", label: t(translations.dynamicContent.modal.label.selectEvent), name: DYNAMIC_CONTENT_SETTING_KEY.EVENT, required: true, preserve: false },
1141
+ React.createElement(Select, { disabled: !!(triggerEvent === null || triggerEvent === void 0 ? void 0 : triggerEvent.eventActionId) && !!(triggerEvent === null || triggerEvent === void 0 ? void 0 : triggerEvent.eventCategoryId), loading: isFetchingEventBySource, className: classnames('ants-h-7'), options: listEvents, showSearch: true })));
1142
+ };
1143
+ const renderSourceFields = () => {
1144
+ if (hasError[DYNAMIC_CONTENT_SETTING_KEY.SOURCE]) {
1145
+ return (React.createElement(Text, { type: "error" }, t(translations.dynamicContent.modal.error.source)));
1146
+ }
1147
+ return (React.createElement(Form.Item, { className: "ants-items-center", label: t(translations.dynamicContent.modal.label.selectSource), name: DYNAMIC_CONTENT_SETTING_KEY.SOURCE, required: true },
1148
+ React.createElement(Select, { disabled: !isEmpty(triggerEvent === null || triggerEvent === void 0 ? void 0 : triggerEvent.insightPropertyIds), mode: "multiple", loading: isFetchingSourceBO, options: listSources, showSearch: true })));
1149
+ };
1150
+ const renderPromotionCodeAttr = () => {
1151
+ if (hasError[DYNAMIC_CONTENT_SETTING_KEY.ATTRIBUTE]) {
1152
+ return (React.createElement(Text, { type: "error" }, t(translations.dynamicContent.modal.error.promotionCodeAttr)));
1153
+ }
1154
+ return (React.createElement(Form.Item, { className: "ants-items-center", label: t(translations.dynamicContent.modal.label.promotionCodeAttr), name: DYNAMIC_CONTENT_SETTING_KEY.ATTRIBUTE, required: true },
1155
+ React.createElement(Select, { loading: isFetchingPromotionCodeAttr, className: classnames('ants-h-7'), labelInValue: true, options: buildOptionAttrArchive(listPromotionCodeAttributes || [], selectedAttr), showSearch: true,
1156
+ // errorArchive={errorMessageAttr}
1157
+ disabled: isActionArchive })));
1158
+ };
1159
+ const renderPromotionPoolFields = () => {
1160
+ if (hasError[DYNAMIC_CONTENT_SETTING_KEY.PROMOTION_POOL]) {
1161
+ return (React.createElement(Text, { type: "error" }, t(translations.dynamicContent.modal.error.promotionPools)));
1162
+ }
1163
+ return (React.createElement(Form.Item, { className: "ants-items-center",
1164
+ // initialValue={listPromotionPools[0]?.value}
1165
+ label: t(translations.dynamicContent.modal.label.promotionPools), name: DYNAMIC_CONTENT_SETTING_KEY.PROMOTION_POOL, required: true },
1166
+ React.createElement(Select, { loading: isFetchingPromotionPool, className: classnames('ants-h-7'), options: listPromotionPools, showSearch: true })));
1167
+ };
1168
+ const renderVisitorAttrFields = () => {
1169
+ if (hasError[DYNAMIC_CONTENT_SETTING_KEY.ATTRIBUTE]) {
1170
+ return (React.createElement(Text, { type: "error" }, t(translations.dynamicContent.modal.error.visitorAttr)));
1171
+ }
1172
+ return (React.createElement(Form.Item, { className: "ants-items-center", initialValue: listVisitorAttributes[0], label: t(translations.dynamicContent.modal.label.attribute), name: DYNAMIC_CONTENT_SETTING_KEY.ATTRIBUTE, required: true },
1173
+ React.createElement(Select, { loading: isFetchingDynamicContentAttr, className: classnames('ants-h-7'), labelInValue: true, options: buildOptionAttrArchive(listVisitorAttributes, selectedAttr === null || selectedAttr === void 0 ? void 0 : selectedAttr.value), showSearch: true,
1174
+ // errorArchive={errorMessageAttr}
1175
+ disabled: isActionArchive })));
1176
+ };
1177
+ const renderDisplayFormat = () => {
1178
+ const selectedAttr = form.getFieldValue(DYNAMIC_CONTENT_SETTING_KEY.ATTRIBUTE);
1179
+ if (formSubmitDisabled ||
1180
+ !attrDFSettings ||
1181
+ isEmpty(attrDFSettings) ||
1182
+ !(selectedAttr === null || selectedAttr === void 0 ? void 0 : selectedAttr.dataType) ||
1183
+ !attrDFOptions.length)
1184
+ return null;
1185
+ if (selectedAttr.dataType === 'number' || selectedAttr.dataType === 'datetime')
1186
+ return (React.createElement(Form.Item, { initialValue: attrDFOptions[0].value, className: "ants-items-start", label: t(translations.dynamicContent.modal.label.displayFormat), name: DYNAMIC_CONTENT_SETTING_KEY.DISPLAY_FORMAT_TYPE, extra: React.createElement("div", { className: "ants-flex ants-flex-wrap ants-items-center ants-mt-4 ants-gap-2" },
1187
+ React.createElement(Text, { color: "#555", dangerouslySetInnerHTML: {
1188
+ __html: `${t(translations.dynamicContent.modal.label.displayFormat)}: <bdo dir='ltr'>${formatedAttr}</bdo>`,
1189
+ } }),
1190
+ !showDetailEditDF && (React.createElement(Button, { disabled: isActionArchive &&
1191
+ selectedDynamicContentType !== DYNAMIC_CONTENT_TYPE.EVENT_ATTRIBUTE.value, type: "text", className: "ants-inline-block", onClick: () => setShowDetailEditDF(prevShow => !prevShow) }, t(translations.edit.title)))) },
1192
+ React.createElement(Select, { disabled: isActionArchive &&
1193
+ selectedDynamicContentType !== DYNAMIC_CONTENT_TYPE.EVENT_ATTRIBUTE.value, className: classnames('ants-h-7'), options: attrDFOptions })));
1194
+ return null;
1195
+ };
1196
+ const renderDetailDFSettings = () => {
1197
+ if (showDetailEditDF && selectedDFType && attrDFSettings)
1198
+ return (React.createElement("div", { className: "ants-border-[1px] ants-border-[#9e9e9e] ants-rounded-sm ants-p-2 ants-mt-2 ants-flex ants-flex-col ants-gap-2" },
1199
+ React.createElement(DisplayFormat, { infos: infos, url: url, displayFormatType: selectedDFType, formatSettings: attrDFSettings, onSettingsChange: (values) => setAttrDFSettings(values), dynamicContentType: form.getFieldValue(DYNAMIC_CONTENT_SETTING_KEY.DYNAMIC_CONTENT_TYPE) })));
1200
+ };
1201
+ return (React.createElement(ModalCustom, { closable: false, destroyOnClose: true, forceRender: true, mask: true, okButtonProps: { disabled: formSubmitDisabled }, title: modalTitle || t(translations.dynamicContent.modal.title.addDynamicContent), visible: visible, onCancel: handleOnCancelModal, onOk: handleOnOkModal },
1202
+ React.createElement(Spin, { spinning: isFetchingSourceBO ||
1203
+ isFetchingListBoAttr ||
1204
+ isFetchingEventAttr ||
1205
+ isFetchingPromotionPool ||
1206
+ isFetchingPromotionCodeAttr ||
1207
+ isFetchingDynamicContentAttr },
1208
+ React.createElement(Form, { className: classnames('ants-w-full'), form: form, labelAlign: "left", labelCol: { span: 9 }, wrapperCol: { span: 15 }, onValuesChange: handleFormValuesChanges, initialValues: {
1209
+ [DYNAMIC_CONTENT_SETTING_KEY.DYNAMIC_CONTENT_TYPE]: listDynamicContentTypes[0].value,
1210
+ } },
1211
+ React.createElement(Form.Item, { className: "ants-items-center", label: t(translations.dynamicContent.modal.label.contentSource), name: DYNAMIC_CONTENT_SETTING_KEY.DYNAMIC_CONTENT_TYPE, required: true },
1212
+ React.createElement(Select, { className: classnames('ants-h-7'), options: listDynamicContentTypes })),
1213
+ selectedDynamicContentType === DYNAMIC_CONTENT_TYPE.VISITOR_ATTRIBUTE.value && (React.createElement(React.Fragment, null, renderVisitorAttrFields())),
1214
+ selectedDynamicContentType === DYNAMIC_CONTENT_TYPE.CUSTOMER_ATTRIBUTE.value && (React.createElement(React.Fragment, null, renderCustomerAttrFields())),
1215
+ selectedDynamicContentType === CUSTOM_TYPE.value && React.createElement(React.Fragment, null, renderCustomFunctionFields()),
1216
+ selectedDynamicContentType === DYNAMIC_CONTENT_TYPE.EVENT_ATTRIBUTE.value && (React.createElement(React.Fragment, null,
1217
+ renderEventFields(),
1218
+ renderSourceFields(),
1219
+ renderEventAttrFields(),
1220
+ isShowEventIndexField
1221
+ ? renderIndexFields({ disabled: false, loading: false })
1222
+ : null)),
1223
+ selectedDynamicContentType === DYNAMIC_CONTENT_TYPE.PROMOTION_CODE.value && (React.createElement(React.Fragment, null,
1224
+ renderPromotionPoolFields(),
1225
+ renderPromotionCodeAttr())),
1226
+ selectedDynamicContentType && regexCSType.test(selectedDynamicContentType) && (React.createElement(React.Fragment, null,
1227
+ renderBoAttrFields(),
1228
+ renderIndexFields({ disabled: isActionArchive, loading: isFetchingListBoAttr }))),
1229
+ showDisplayFormat && renderDisplayFormat()),
1230
+ showDisplayFormat && renderDisplayFormat() !== null && renderDetailDFSettings(),
1231
+ isShowCustomFunction && selectedDynamicContentType === CUSTOM_TYPE.value && (React.createElement("div", { className: "ants-flex ants-items-center ants-justify-start ants-mb-2", style: { marginTop: '10px' } },
1232
+ React.createElement(Checkbox, { onChange: handleSaveAsTemplate, checked: saveAsTemplate },
1233
+ React.createElement("span", { style: { fontSize: '12px' } }, t(translations.dynamicContent.modal.label.saveTemplate))))))));
1234
+ };
1235
+ AddDynamicContent.defaultProps = {
1236
+ showDisplayFormat: true,
1237
+ showIndex: true,
1238
+ APIConfig: {
1239
+ domain: 'https://sandbox-media-template.antsomi.com',
1240
+ slug: '/api/v1',
1241
+ token: '',
1242
+ userId: '',
1243
+ accountId: '',
1244
+ },
1245
+ };