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