@antscorp/antsomi-ui 2.0.107 → 2.0.109
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/CHANGELOG.md +63 -0
- package/README.md +78 -78
- package/es/__mocks__/1000_city.json +802 -802
- package/es/__mocks__/sql-query.json +56 -56
- package/es/assets/css/main.scss +6 -6
- package/es/assets/images/feedback.svg +3 -3
- package/es/assets/svg/mobile-frame.svg +3 -3
- package/es/assets/svg/warning-icon.svg +5 -5
- package/es/components/atoms/Alert/Alert.js +28 -28
- package/es/components/atoms/ContentEditable/styled.js +16 -16
- package/es/components/atoms/DividerPure/styled.js +35 -35
- package/es/components/atoms/Icon/index.js +19 -19
- package/es/components/atoms/Iframe/Iframe.js +18 -18
- package/es/components/atoms/Input/styled.js +104 -104
- package/es/components/atoms/InputDynamic/styled.js +284 -284
- package/es/components/atoms/MobileBrandingBar/styled.js +21 -21
- package/es/components/atoms/MobileFrame/styled.js +30 -30
- package/es/components/atoms/MobileFrameV2/styled.js +42 -42
- package/es/components/atoms/MobileFrameV3/styled.js +31 -31
- package/es/components/atoms/NotificationStatus/styled.js +10 -10
- package/es/components/atoms/PreviewTabs/styled.js +69 -69
- package/es/components/atoms/Radio/index.js +16 -16
- package/es/components/atoms/ReactIframe/ReactIframe.js +5 -5
- package/es/components/atoms/ReactIframe/styled.js +9 -9
- package/es/components/atoms/RequiredLabel/styled.js +3 -3
- package/es/components/atoms/ScrollBox/index.js +5 -5
- package/es/components/atoms/Scrollbars/styled.js +21 -21
- package/es/components/atoms/SlideBar/styled.js +194 -194
- package/es/components/atoms/Slider/styled.js +31 -31
- package/es/components/atoms/Space/Space.js +4 -4
- package/es/components/atoms/Spin/styled.js +11 -11
- package/es/components/atoms/Steps/styled.js +244 -244
- package/es/components/atoms/Switch/styled.js +56 -56
- package/es/components/atoms/Tag/Tag.js +10 -10
- package/es/components/atoms/Text/styled.js +34 -34
- package/es/components/icons/DomainManagementIcon.js +1 -1
- package/es/components/icons/LoadingIcon.js +33 -33
- package/es/components/icons/document/styled.js +43 -43
- package/es/components/index.scss +1 -1
- package/es/components/molecules/AccessDenied/styled.js +28 -28
- package/es/components/molecules/AccountSelection/styled.js +110 -110
- package/es/components/molecules/AddDynamicContent/styled.js +23 -23
- package/es/components/molecules/AlignSetting/styled.js +4 -4
- package/es/components/molecules/ApplyPopupContent/styled.js +32 -32
- package/es/components/molecules/CalendarSelection/components/AutoUpdateTo/styled.js +8 -8
- package/es/components/molecules/CalendarSelection/components/CustomPicker/styled.js +79 -79
- package/es/components/molecules/CalendarSelection/components/Footer/styled.js +4 -4
- package/es/components/molecules/CalendarSelection/components/RangePicker/styled.js +21 -21
- package/es/components/molecules/CalendarSelection/components/RangeSelectOptions/components/Option/Option.js +26 -26
- package/es/components/molecules/CalendarSelection/components/RangeSelectOptions/styled.js +30 -30
- package/es/components/molecules/CalendarSelection/components/TimeRangeDisplay/styled.js +26 -26
- package/es/components/molecules/CalendarSelection/styled.js +8 -8
- package/es/components/molecules/CaptureScreen/components/CommentBox/styled.js +119 -119
- package/es/components/molecules/CaptureScreen/components/Cursor/styled.js +67 -67
- package/es/components/molecules/CaptureScreen/styled.js +240 -240
- package/es/components/molecules/ChartTab/components/styled.js +24 -24
- package/es/components/molecules/ChartTab/styled.js +20 -20
- package/es/components/molecules/ChatBox/AntsomiAI.js +8 -8
- package/es/components/molecules/ChatBox/ChatBoxInsight/QuestionItem.js +9 -9
- package/es/components/molecules/ChatBox/ChatBoxInsight/styled.js +365 -365
- package/es/components/molecules/ChatBox/styled.js +324 -324
- package/es/components/molecules/CodeStructure/styled.js +5 -5
- package/es/components/molecules/ColorPicker/ChromePicker/styled.js +10 -10
- package/es/components/molecules/ColorPicker/CustomPicker/styled.js +89 -89
- package/es/components/molecules/ColorPicker/SketchPicker/styled.js +5 -5
- package/es/components/molecules/ColorPicker/styled.js +7 -7
- package/es/components/molecules/ColorSetting/styled.js +39 -39
- package/es/components/molecules/DatePicker/components/AdvancedPicker/styled.js +110 -110
- package/es/components/molecules/DatePickerV2/styled.js +6 -6
- package/es/components/molecules/DisplayFormat/styled.js +12 -12
- package/es/components/molecules/DrawerDetail/components/ToggleDrawerSizeButton.js +24 -24
- package/es/components/molecules/DrawerDetail/styled.js +109 -109
- package/es/components/molecules/Dropdown/style.scss +11 -11
- package/es/components/molecules/Dropdown/styled.js +28 -28
- package/es/components/molecules/EdgeSetting/styled.js +10 -10
- package/es/components/molecules/EditableName/styled.js +70 -70
- package/es/components/molecules/EditingList/styled.js +29 -29
- package/es/components/molecules/EditingListV2/components/List/List.d.ts +1 -1
- package/es/components/molecules/EditingListV2/components/List/List.js +16 -7
- package/es/components/molecules/EditorTab/styled.js +156 -156
- package/es/components/molecules/EmojiCollections/styled.js +22 -22
- package/es/components/molecules/EmojiPopover/styled.js +4 -4
- package/es/components/molecules/EmptyData/styled.js +53 -53
- package/es/components/molecules/FontSizeInput/index.scss +15 -15
- package/es/components/molecules/GradientSetting/styled.js +57 -57
- package/es/components/molecules/HeaderV2/styled.js +70 -70
- package/es/components/molecules/IconSelection/styled.js +69 -69
- package/es/components/molecules/ImageEditor/components/ModalShortcut.js +21 -21
- package/es/components/molecules/ImageEditor/styled.js +5 -5
- package/es/components/molecules/ImagePreview/styled.js +3 -3
- package/es/components/molecules/InputNumberWithUnit/styled.js +14 -14
- package/es/components/molecules/InputSearch/styled.js +41 -41
- package/es/components/molecules/ItemNotFound/styled.js +26 -26
- package/es/components/molecules/MatchAnySelect/components/ExtendValuePopup.js +8 -8
- package/es/components/molecules/MatchAnySelect/styled.js +247 -247
- package/es/components/molecules/Modal/styled.js +63 -63
- package/es/components/molecules/ModalSelect/styled.js +152 -152
- package/es/components/molecules/ModalV2/styled.js +27 -27
- package/es/components/molecules/PopupDraggable/styled.js +57 -57
- package/es/components/molecules/PreviewModal/styled.js +26 -26
- package/es/components/molecules/ProcessLoading/styled.js +2 -2
- package/es/components/molecules/QuillEditor/CustomToolbar.js +3165 -3165
- package/es/components/molecules/QuillEditor/EditorToolbar.js +7 -7
- package/es/components/molecules/QuillEditor/styled.js +25 -25
- package/es/components/molecules/RadioGroup/styled.js +9 -9
- package/es/components/molecules/RequestAccess/styled.js +38 -38
- package/es/components/molecules/ResizeGrid/components/Cell/styled.js +77 -77
- package/es/components/molecules/ResizeGrid/styled.js +50 -50
- package/es/components/molecules/RichMenu/RichMenuBlock/RichMenuCell/styled.js +118 -118
- package/es/components/molecules/RichMenu/RichMenuBlock/styled.js +13 -13
- package/es/components/molecules/RichMenu/RichMenuChatBar/TypingChat/styled.js +40 -40
- package/es/components/molecules/RichMenu/RichMenuChatBar/styled.js +27 -27
- package/es/components/molecules/RichMenu/RichMenuMobileView/RichMenuMobileView.js +2 -2
- package/es/components/molecules/RichMenu/RichMenuMobileView/styled.js +38 -38
- package/es/components/molecules/SearchPopover/components/PopoverSelect/styled.js +36 -36
- package/es/components/molecules/SearchPopover/components/PopoverSelect/styles.scss +7 -7
- package/es/components/molecules/SearchPopover/styled.js +32 -32
- package/es/components/molecules/Select/styled.js +32 -32
- package/es/components/molecules/SelectAccount/styled.js +147 -147
- package/es/components/molecules/SelectEventAttribute/styled.js +8 -8
- package/es/components/molecules/SelectMulti/styled.js +62 -62
- package/es/components/molecules/SelectV2/styled.js +124 -124
- package/es/components/molecules/SettingWrapper/styled.js +12 -12
- package/es/components/molecules/ShareAccess/components/GeneralAccess/styled.js +56 -56
- package/es/components/molecules/ShareAccess/components/LayoutContent/styled.js +5 -5
- package/es/components/molecules/ShareAccess/components/ModalTransferOwnerShip/styled.js +15 -15
- package/es/components/molecules/ShareAccess/components/PeopleAccess/styled.js +63 -63
- package/es/components/molecules/ShareAccess/components/SearchUser/styled.js +31 -31
- package/es/components/molecules/SliderWithInputNumber/styled.js +2 -2
- package/es/components/molecules/Tabs/Tabs.js +11 -11
- package/es/components/molecules/TagifyInput/TagifyInput.js +65 -54
- package/es/components/molecules/TagifyInput/constants.d.ts +7 -3
- package/es/components/molecules/TagifyInput/constants.js +7 -2
- package/es/components/molecules/TagifyInput/patternHandlers.js +34 -1
- package/es/components/molecules/TagifyInput/styled.js +37 -37
- package/es/components/molecules/TagifyInput/types.d.ts +13 -3
- package/es/components/molecules/TagifyInput/utils.d.ts +1 -0
- package/es/components/molecules/TagifyInput/utils.js +15 -14
- package/es/components/molecules/TagifyInput/utils.style.js +218 -218
- package/es/components/molecules/TemplateSaveAs/components/Category/Category.js +5 -5
- package/es/components/molecules/TemplateSaveAs/components/ImageSlider/styled.js +276 -276
- package/es/components/molecules/TemplateSaveAs/styled.js +134 -134
- package/es/components/molecules/ThumbnailCard/styled.js +92 -92
- package/es/components/molecules/Tree/styled.js +38 -38
- package/es/components/molecules/UnsubscribePreferences/constants.d.ts +27 -0
- package/es/components/molecules/UnsubscribePreferences/constants.js +28 -0
- package/es/components/molecules/UnsubscribePreferences/index.d.ts +17 -0
- package/es/components/molecules/UnsubscribePreferences/index.js +203 -0
- package/es/components/molecules/UnsubscribePreferences/styled.d.ts +2 -0
- package/es/components/molecules/UnsubscribePreferences/styled.js +11 -0
- package/es/components/molecules/UnsubscribePreferences/utils.d.ts +15 -0
- package/es/components/molecules/UnsubscribePreferences/utils.js +56 -0
- package/es/components/molecules/UnsubscribePreview/components/PreferencesPage/index.d.ts +12 -0
- package/es/components/molecules/UnsubscribePreview/components/PreferencesPage/index.js +159 -0
- package/es/components/molecules/UnsubscribePreview/components/ResultPage/index.d.ts +13 -0
- package/es/components/molecules/UnsubscribePreview/components/ResultPage/index.js +28 -0
- package/es/components/molecules/UnsubscribePreview/components/TestAlert/index.d.ts +9 -0
- package/es/components/molecules/UnsubscribePreview/components/TestAlert/index.js +18 -0
- package/es/components/molecules/UnsubscribePreview/components/UnsubscribedPage/index.d.ts +13 -0
- package/es/components/molecules/UnsubscribePreview/components/UnsubscribedPage/index.js +85 -0
- package/es/components/molecules/UnsubscribePreview/components/index.d.ts +3 -0
- package/es/components/molecules/UnsubscribePreview/components/index.js +3 -0
- package/es/components/molecules/UnsubscribePreview/components/styled.d.ts +13 -0
- package/es/components/molecules/UnsubscribePreview/components/styled.js +65 -0
- package/es/components/molecules/UnsubscribePreview/index.d.ts +10 -0
- package/es/components/molecules/UnsubscribePreview/index.js +66 -0
- package/es/components/molecules/UnsubscribePreview/styled.d.ts +9 -0
- package/es/components/molecules/UnsubscribePreview/styled.js +51 -0
- package/es/components/molecules/UnsubscribePreview/type.d.ts +5 -0
- package/es/components/molecules/UnsubscribePreview/type.js +1 -0
- package/es/components/molecules/UnsubscribePreview/utils.d.ts +9 -0
- package/es/components/molecules/UnsubscribePreview/utils.js +27 -0
- package/es/components/molecules/UploadImage/index.d.ts +4 -0
- package/es/components/molecules/UploadImage/index.js +2 -2
- package/es/components/molecules/UploadImage/styled.js +114 -114
- package/es/components/molecules/VirtualizedMenu/styled.js +82 -82
- package/es/components/molecules/index.d.ts +4 -0
- package/es/components/molecules/index.js +2 -0
- package/es/components/organism/AccountProfile/components/AccountSetting/components/EditableInput/styles.js +98 -98
- package/es/components/organism/AccountProfile/components/AccountSetting/components/LanguageSelector/styles.js +18 -18
- package/es/components/organism/AccountProfile/components/AccountSetting/styled.js +543 -543
- package/es/components/organism/AccountProfile/components/AccountSetting/styles.scss +39 -39
- package/es/components/organism/AccountSharing/styled.js +336 -336
- package/es/components/organism/ActivityTimeline/__mocks__/event_tracking.json +1290 -1290
- package/es/components/organism/ActivityTimeline/__mocks__/timeline.json +3059 -3059
- package/es/components/organism/ActivityTimeline/components/ActionHistory/styled.js +28 -28
- package/es/components/organism/ActivityTimeline/components/CardMember/styled.js +60 -60
- package/es/components/organism/ActivityTimeline/components/ItemGroupEvent/styled.js +4 -4
- package/es/components/organism/ActivityTimeline/components/List/styled.js +77 -77
- package/es/components/organism/ActivityTimeline/components/ListItem/styled.js +37 -37
- package/es/components/organism/ActivityTimeline/components/ProductCard/styled.js +92 -92
- package/es/components/organism/ActivityTimeline/components/Redeem/styled.js +7 -7
- package/es/components/organism/ActivityTimeline/components/Slide/styled.js +20 -20
- package/es/components/organism/ActivityTimeline/components/TimeLineTitle/styled.js +7 -7
- package/es/components/organism/ActivityTimeline/components/TimelineSection/styled.js +69 -69
- package/es/components/organism/ActivityTimeline/styled.js +39 -39
- package/es/components/organism/AlgorithmsSetting/styled.js +35 -35
- package/es/components/organism/BasicLogin/components/ChooseMethod/styled.js +19 -19
- package/es/components/organism/BasicLogin/components/LoginWithEmail/styled.js +3 -3
- package/es/components/organism/BasicLogin/components/LoginWithGG/styled.js +3 -3
- package/es/components/organism/BasicLogin/components/SignIn/styled.js +8 -8
- package/es/components/organism/BasicLogin/components/WidgetLayout/styled.js +18 -18
- package/es/components/organism/BasicLogin/styled.js +107 -107
- package/es/components/organism/ContentSources/styled.js +50 -50
- package/es/components/organism/DataTable/components/AddButton/index.js +8 -8
- package/es/components/organism/DataTable/components/ModifyColumn/styled.js +18 -18
- package/es/components/organism/DataTable/components/Pagination/styled.js +26 -26
- package/es/components/organism/DataTable/components/Table/styled.js +135 -135
- package/es/components/organism/DataTable/components/Toolbar/SearchPopover.js +17 -17
- package/es/components/organism/DataTable/components/Toolbar/styled.js +70 -70
- package/es/components/organism/DataTable/styled/index.js +84 -84
- package/es/components/organism/Filter/components/FilterCondition/styled.js +34 -34
- package/es/components/organism/Filter/styled.js +109 -109
- package/es/components/organism/FilterSetting/components/common/InputArray/styled.js +5 -5
- package/es/components/organism/FilterSetting/components/common/InputOrSelect/index.js +63 -63
- package/es/components/organism/FilterSetting/components/common/InputSelectMulti/ColumnSuggestion/index.js +31 -31
- package/es/components/organism/FilterSetting/components/common/InputSelectMulti/Tree/index.js +22 -22
- package/es/components/organism/FilterSetting/components/common/InputSelectMulti/index.js +55 -55
- package/es/components/organism/FilterSetting/styled.js +19 -19
- package/es/components/organism/Help/styled.js +267 -267
- package/es/components/organism/LeftMenu/components/HomeMenu/styled.js +39 -39
- package/es/components/organism/LeftMenu/components/common/ChildMenu/components/MenuItemImage/styled.js +16 -16
- package/es/components/organism/LeftMenu/components/common/ChildMenu/styled.js +156 -156
- package/es/components/organism/LeftMenu/styled.js +214 -214
- package/es/components/organism/Login/components/ChooseMethod/styled.js +19 -19
- package/es/components/organism/Login/components/ForgotPassword/styled.js +8 -8
- package/es/components/organism/Login/components/LoginSelectPortal/Item/styled.js +31 -31
- package/es/components/organism/Login/components/LoginSelectPortal/styled.js +3 -3
- package/es/components/organism/Login/components/LoginWithEmail/styled.js +3 -3
- package/es/components/organism/Login/components/LoginWithGG/styled.js +3 -3
- package/es/components/organism/Login/components/SetupGGAuthenticator/styled.js +7 -7
- package/es/components/organism/Login/components/SignIn/styled.js +8 -8
- package/es/components/organism/Login/components/VerifyAccount/styled.js +13 -13
- package/es/components/organism/Login/components/WidgetLayout/styled.js +18 -18
- package/es/components/organism/Login/styled.js +115 -115
- package/es/components/organism/Menu/styled.js +6 -6
- package/es/components/organism/ModifyColumnModal/styled.js +132 -132
- package/es/components/organism/Notification/styled.js +155 -155
- package/es/components/organism/PreviewCollections/Messages/SkeletonMessage/styled.js +14 -14
- package/es/components/organism/PreviewCollections/WhatsappMessage/CarouselMessage/styled.js +63 -63
- package/es/components/organism/PreviewCollections/WhatsappMessage/FooterMessage/index.js +3 -1
- package/es/components/organism/PreviewCollections/constants.js +50 -50
- package/es/components/organism/PreviewCollections/styled.js +16 -16
- package/es/components/organism/PreviewTemplateModal/components/Banner/styled.js +78 -78
- package/es/components/organism/PreviewTemplateModal/components/Information/styled.js +52 -52
- package/es/components/organism/PreviewTemplateModal/components/SimilarTemplate/styled.js +18 -18
- package/es/components/organism/PreviewTemplateModal/components/ThumbnailSlider/styled.js +77 -77
- package/es/components/organism/PreviewTemplateModal/styled.js +21 -21
- package/es/components/organism/SQLGeneration/components/styled.js +354 -354
- package/es/components/organism/SQLGeneration/index.scss +1 -1
- package/es/components/organism/SQLGeneration/integrations/AceEditor/index.scss +4 -4
- package/es/components/organism/Table/CrossTabTable/components/CustomCell/styled.js +11 -11
- package/es/components/organism/Table/CrossTabTable/styled.js +11 -11
- package/es/components/organism/Table/ExplorePivotTable/components/CustomCell/styled.js +17 -17
- package/es/components/organism/Table/ExplorePivotTable/styled.js +11 -11
- package/es/components/organism/TicketEditor/styled.js +850 -850
- package/es/components/organism/TicketEditorV2/styled.js +839 -839
- package/es/components/organism/index.scss +1 -1
- package/es/components/template/Layout/Layout.js +10 -10
- package/es/components/template/Layout/components/RecommendationWorkspace/components/MenuMapping/components/OldLeftMenu/styled.js +73 -73
- package/es/components/template/Layout/components/RecommendationWorkspace/components/MenuMapping/styled.js +39 -39
- package/es/components/template/Layout/components/RecommendationWorkspace/components/RecommendationImage/styled.js +61 -61
- package/es/components/template/Layout/components/RecommendationWorkspace/styled.js +16 -16
- package/es/components/template/Layout/styled.js +84 -84
- package/es/components/template/TemplateListing/components/BlankTemplate/styled.js +21 -21
- package/es/components/template/TemplateListing/components/CategoryListing/styled.js +123 -123
- package/es/components/template/TemplateListing/components/Empty/styled.js +20 -20
- package/es/components/template/TemplateListing/stories/demo/styled.js +4 -4
- package/es/components/template/TemplateListing/styled/index.js +40 -40
- package/es/constants/index.d.ts +1 -0
- package/es/constants/index.js +1 -0
- package/es/constants/queries.d.ts +5 -0
- package/es/constants/queries.js +6 -0
- package/es/constants/unsubscribe.d.ts +56 -0
- package/es/constants/unsubscribe.js +77 -0
- package/es/providers/ConfigProvider/GlobalStyle.js +1249 -1249
- package/es/queries/Unsubscribe/index.d.ts +5 -0
- package/es/queries/Unsubscribe/index.js +5 -0
- package/es/queries/Unsubscribe/useGetUnsubscribeList.d.ts +8 -0
- package/es/queries/Unsubscribe/useGetUnsubscribeList.js +18 -0
- package/es/queries/Unsubscribe/useGetUnsubscribeListByIdentifier.d.ts +8 -0
- package/es/queries/Unsubscribe/useGetUnsubscribeListByIdentifier.js +11 -0
- package/es/queries/Unsubscribe/useGetUnsubscribeListPermission.d.ts +8 -0
- package/es/queries/Unsubscribe/useGetUnsubscribeListPermission.js +17 -0
- package/es/queries/Unsubscribe/useGetUnsubscribePreferences.d.ts +23 -0
- package/es/queries/Unsubscribe/useGetUnsubscribePreferences.js +26 -0
- package/es/services/MediaTemplateDesign/UploadFile/index.js +4 -4
- package/es/services/Unsubscribe/index.d.ts +41 -0
- package/es/services/Unsubscribe/index.js +78 -0
- package/es/styled/common.js +51 -51
- package/es/tests/styled.js +4 -4
- package/es/types/index.d.ts +1 -0
- package/es/types/index.js +1 -0
- package/es/types/unsubscribe.d.ts +25 -0
- package/es/types/unsubscribe.js +1 -0
- package/es/utils/common.d.ts +1 -0
- package/es/utils/common.js +3 -0
- package/es/utils/variables.js +7 -7
- package/package.json +266 -266
|
@@ -0,0 +1,203 @@
|
|
|
1
|
+
import { jsx as _jsx, jsxs as _jsxs, Fragment as _Fragment } from "react/jsx-runtime";
|
|
2
|
+
// Libraries
|
|
3
|
+
import { useMemo } from 'react';
|
|
4
|
+
import { translate, translations } from '@antscorp/antsomi-locales';
|
|
5
|
+
// Queries
|
|
6
|
+
import { useGetUnsubscribeListPermission } from '@antscorp/antsomi-ui/es/queries/Unsubscribe';
|
|
7
|
+
// Constants
|
|
8
|
+
import { CUSTOM_SEGMENT, LANDING_PAGE_TYPE, UNSUBSCRIBE_LIST_MESSAGE_ERRORS } from './constants';
|
|
9
|
+
import { GLOBAL_UNSUBSCRIBED_LIST, GLOBAL_UNSUBSCRIBED_WHATSAPP, } from '@antscorp/antsomi-ui/es/constants';
|
|
10
|
+
// Utils
|
|
11
|
+
import { buildOptionPreferencesList, buildOptionUnsubscribedList, checkUnsubscribeList, unsubscribeListNotExist, } from './utils';
|
|
12
|
+
import { compareStrings, handleError } from '@antscorp/antsomi-ui/es/utils';
|
|
13
|
+
// Components
|
|
14
|
+
import { EditingListV2, Input, RadioGroup, SelectV2, SettingWrapper, Space, Spin, Switch, UploadImage, } from '../../index';
|
|
15
|
+
import { TextStyled } from './styled';
|
|
16
|
+
const PATH = 'antsomi-ui/src/components/molecules/UnsubscribePreferences/index.tsx';
|
|
17
|
+
export const UnsubscribePreferences = (props) => {
|
|
18
|
+
const { type, apiConfig, unsubscribePreferences, hideLandingPageType, fieldPath = 'settings.unsubscribePreferences', required = ['unsubscribeListId', 'title', 'description'], onChange, } = props;
|
|
19
|
+
const { segmentId, logo, title, description, customLink, haveResubscribeButton, unsubscribeListId, } = unsubscribePreferences || {};
|
|
20
|
+
const preferenceListIds = useMemo(() => Array.isArray(unsubscribePreferences.preferenceListIds)
|
|
21
|
+
? [...unsubscribePreferences.preferenceListIds]
|
|
22
|
+
: unsubscribePreferences.preferenceListIds
|
|
23
|
+
? [`${unsubscribePreferences.preferenceListIds}`]
|
|
24
|
+
: [], [unsubscribePreferences.preferenceListIds]);
|
|
25
|
+
const landingPageType = unsubscribePreferences?.landingPageType ||
|
|
26
|
+
(segmentId === CUSTOM_SEGMENT.value
|
|
27
|
+
? LANDING_PAGE_TYPE.SPECIFIC_LINK.value
|
|
28
|
+
: LANDING_PAGE_TYPE.CUSTOM_PAGE.value);
|
|
29
|
+
const isGlobalUnsubscribedList = [GLOBAL_UNSUBSCRIBED_LIST, GLOBAL_UNSUBSCRIBED_WHATSAPP].some(({ list_id }) => compareStrings(list_id, unsubscribeListId) === 0);
|
|
30
|
+
const { data: unsubscribeDataPermission, isFetching: isLoadingUnsubscribeListPermission } = useGetUnsubscribeListPermission({
|
|
31
|
+
args: {
|
|
32
|
+
data: {
|
|
33
|
+
type,
|
|
34
|
+
portalId: apiConfig.portalId || 0,
|
|
35
|
+
},
|
|
36
|
+
},
|
|
37
|
+
options: {
|
|
38
|
+
enabled: !!apiConfig.portalId,
|
|
39
|
+
},
|
|
40
|
+
}, apiConfig);
|
|
41
|
+
// Memoized
|
|
42
|
+
const unsubscribeList = useMemo(() => {
|
|
43
|
+
if (isLoadingUnsubscribeListPermission)
|
|
44
|
+
return [];
|
|
45
|
+
return unsubscribeDataPermission?.entries[0] || [];
|
|
46
|
+
}, [unsubscribeDataPermission, isLoadingUnsubscribeListPermission]);
|
|
47
|
+
const memoizedUnsubscribedLists = useMemo(() => buildOptionUnsubscribedList(unsubscribeList || [], unsubscribeListId?.toString() || [])?.map(({ list_id, list_name }) => ({
|
|
48
|
+
value: list_id,
|
|
49
|
+
label: list_name,
|
|
50
|
+
})), [unsubscribeList, unsubscribeListId]);
|
|
51
|
+
const memoizedPreferencesLists = useMemo(() => {
|
|
52
|
+
const list = buildOptionPreferencesList(unsubscribeList || [], unsubscribeListId?.toString() || []);
|
|
53
|
+
return ([
|
|
54
|
+
...(preferenceListIds?.map(key => {
|
|
55
|
+
const select = list?.find(opt => `${opt.key}` === `${key}`);
|
|
56
|
+
if (!select) {
|
|
57
|
+
return {
|
|
58
|
+
value: key,
|
|
59
|
+
label: `[ID - ${key}]`,
|
|
60
|
+
key,
|
|
61
|
+
errorMessage: UNSUBSCRIBE_LIST_MESSAGE_ERRORS.UNAUTHORIZED,
|
|
62
|
+
};
|
|
63
|
+
}
|
|
64
|
+
return null;
|
|
65
|
+
}) || []),
|
|
66
|
+
...(list || []),
|
|
67
|
+
]?.filter((item) => Boolean(item)) || []);
|
|
68
|
+
}, [unsubscribeList, unsubscribeListId, preferenceListIds]);
|
|
69
|
+
const { errorMessage: unsubscribeListErrorMessage } = checkUnsubscribeList({
|
|
70
|
+
listUnsubscribe: unsubscribeList || [],
|
|
71
|
+
unsubscribeId: `${unsubscribeListId}`,
|
|
72
|
+
});
|
|
73
|
+
const handleChange = (key, value) => {
|
|
74
|
+
try {
|
|
75
|
+
switch (key) {
|
|
76
|
+
case 'unsubscribeListId': {
|
|
77
|
+
const newPreferenceListIds = buildOptionPreferencesList(unsubscribeList || [], value || [])
|
|
78
|
+
?.filter(each => !each.errorMessage)
|
|
79
|
+
.map(item => item.value);
|
|
80
|
+
onChange({
|
|
81
|
+
...unsubscribePreferences,
|
|
82
|
+
unsubscribeListId: value,
|
|
83
|
+
preferenceListIds: newPreferenceListIds,
|
|
84
|
+
}, [
|
|
85
|
+
{
|
|
86
|
+
fieldPath: `${fieldPath}.unsubscribeListId`,
|
|
87
|
+
data: value,
|
|
88
|
+
},
|
|
89
|
+
{
|
|
90
|
+
fieldPath: `${fieldPath}.preferenceListIds`,
|
|
91
|
+
data: newPreferenceListIds,
|
|
92
|
+
},
|
|
93
|
+
]);
|
|
94
|
+
break;
|
|
95
|
+
}
|
|
96
|
+
case 'landingPageType': {
|
|
97
|
+
onChange({
|
|
98
|
+
...unsubscribePreferences,
|
|
99
|
+
landingPageType: value,
|
|
100
|
+
}, [
|
|
101
|
+
{
|
|
102
|
+
fieldPath: `${fieldPath}.landingPageType`,
|
|
103
|
+
data: value,
|
|
104
|
+
},
|
|
105
|
+
]);
|
|
106
|
+
break;
|
|
107
|
+
}
|
|
108
|
+
case 'customLink': {
|
|
109
|
+
onChange({
|
|
110
|
+
...unsubscribePreferences,
|
|
111
|
+
customLink: value,
|
|
112
|
+
}, [
|
|
113
|
+
{
|
|
114
|
+
fieldPath: `${fieldPath}.customLink`,
|
|
115
|
+
data: value,
|
|
116
|
+
},
|
|
117
|
+
]);
|
|
118
|
+
break;
|
|
119
|
+
}
|
|
120
|
+
case 'logo': {
|
|
121
|
+
onChange({
|
|
122
|
+
...unsubscribePreferences,
|
|
123
|
+
logo: value,
|
|
124
|
+
}, [
|
|
125
|
+
{
|
|
126
|
+
fieldPath: `${fieldPath}.logo`,
|
|
127
|
+
data: value,
|
|
128
|
+
},
|
|
129
|
+
]);
|
|
130
|
+
break;
|
|
131
|
+
}
|
|
132
|
+
case 'title': {
|
|
133
|
+
onChange({
|
|
134
|
+
...unsubscribePreferences,
|
|
135
|
+
title: value,
|
|
136
|
+
}, [
|
|
137
|
+
{
|
|
138
|
+
fieldPath: `${fieldPath}.title`,
|
|
139
|
+
data: value,
|
|
140
|
+
},
|
|
141
|
+
]);
|
|
142
|
+
break;
|
|
143
|
+
}
|
|
144
|
+
case 'description': {
|
|
145
|
+
onChange({
|
|
146
|
+
...unsubscribePreferences,
|
|
147
|
+
description: value,
|
|
148
|
+
}, [
|
|
149
|
+
{
|
|
150
|
+
fieldPath: `${fieldPath}.description`,
|
|
151
|
+
data: value,
|
|
152
|
+
},
|
|
153
|
+
]);
|
|
154
|
+
break;
|
|
155
|
+
}
|
|
156
|
+
case 'haveResubscribeButton': {
|
|
157
|
+
onChange({
|
|
158
|
+
...unsubscribePreferences,
|
|
159
|
+
haveResubscribeButton: value,
|
|
160
|
+
}, [
|
|
161
|
+
{
|
|
162
|
+
fieldPath: `${fieldPath}.haveResubscribeButton`,
|
|
163
|
+
data: value,
|
|
164
|
+
},
|
|
165
|
+
]);
|
|
166
|
+
break;
|
|
167
|
+
}
|
|
168
|
+
case 'preferenceListIds': {
|
|
169
|
+
onChange({
|
|
170
|
+
...unsubscribePreferences,
|
|
171
|
+
preferenceListIds: value,
|
|
172
|
+
}, [
|
|
173
|
+
{
|
|
174
|
+
fieldPath: `${fieldPath}.preferenceListIds`,
|
|
175
|
+
data: value,
|
|
176
|
+
},
|
|
177
|
+
]);
|
|
178
|
+
break;
|
|
179
|
+
}
|
|
180
|
+
default:
|
|
181
|
+
break;
|
|
182
|
+
}
|
|
183
|
+
}
|
|
184
|
+
catch (error) {
|
|
185
|
+
handleError(error, {
|
|
186
|
+
path: PATH,
|
|
187
|
+
name: 'handleChange',
|
|
188
|
+
args: { key, value },
|
|
189
|
+
});
|
|
190
|
+
}
|
|
191
|
+
};
|
|
192
|
+
return (_jsxs(Space, { className: "unsubscribe-preferences", size: 20, direction: "vertical", children: [_jsx(SelectV2, { showSearch: true, label: _jsx(TextStyled, { color: "#666666", required: required.includes('unsubscribeListId'), children: translate(translations._TITLE_UNSUBSCRIBED_LIST, 'Unsubscribed list') }), placeholder: translate('', 'Select Unsubscribed List'), loading: isLoadingUnsubscribeListPermission, options: memoizedUnsubscribedLists, value: unsubscribeListNotExist(unsubscribeList, unsubscribeListId?.toString()), errorMsg: unsubscribeListErrorMessage, status: !isLoadingUnsubscribeListPermission && unsubscribeListErrorMessage !== '' ? 'error' : '', onChange: value => {
|
|
193
|
+
handleChange('unsubscribeListId', value);
|
|
194
|
+
} }), !hideLandingPageType && (_jsx(SettingWrapper, { label: translate(translations._TITLE_UNSUBSCRIBE_LANDING_PAGE, 'Landing page'), children: _jsx(RadioGroup, { value: landingPageType, options: Object.values(LANDING_PAGE_TYPE), onChange: e => {
|
|
195
|
+
handleChange('landingPageType', e.target.value);
|
|
196
|
+
} }) })), landingPageType === LANDING_PAGE_TYPE.SPECIFIC_LINK.value ? (_jsxs(Space, { size: 5, direction: "vertical", children: [_jsx(TextStyled, { color: "#666666", required: required.includes('customLink'), children: translate(translations._TITLE_UNSUBSCRIBE_PAGE_URL, 'Page URL') }), _jsx(Input, { value: customLink, placeholder: translate('_', 'Enter text here...'), onAfterChange: value => handleChange('customLink', value) })] })) : (_jsxs(_Fragment, { children: [_jsx(UploadImage, { domainMedia: `${apiConfig.url}`, slug: "", paramConfigs: apiConfig, title: translate('_', 'Logo'), disableRemove: true, isInputMode: false, selectedImage: {
|
|
197
|
+
url: logo,
|
|
198
|
+
}, onChangeImage: image => {
|
|
199
|
+
handleChange('logo', image.url);
|
|
200
|
+
}, onRemoveImage: () => {
|
|
201
|
+
handleChange('logo', '');
|
|
202
|
+
}, required: required.includes('logo') }), _jsxs(Space, { size: 5, direction: "vertical", children: [_jsx(TextStyled, { color: "#666666", required: required.includes('title'), children: translate(translations._TITLE_TICKET_TITLE, 'Title') }), _jsx(Input, { value: title, placeholder: translate('_', 'Enter text here...'), maxLength: 70, onAfterChange: value => handleChange('title', value) })] }), _jsxs(Space, { size: 5, direction: "vertical", children: [_jsx(TextStyled, { color: "#666666", required: required.includes('description'), children: translate(translations._TITL_DESCRIPTION, 'Description') }), _jsx(Input, { value: description, placeholder: translate('_', 'Enter text here...'), maxLength: 255, onAfterChange: value => handleChange('description', value) })] }), isGlobalUnsubscribedList ? (_jsxs(Space, { size: 5, direction: "horizontal", style: { display: 'flex', justifyContent: 'space-between' }, children: [_jsx(TextStyled, { color: "#666666", required: required.includes('haveResubscribeButton'), children: translate(`${translations._TITLE_DISPLAY_RESUBSCRIBE_BUTTON}?`, 'Display Resubscribe button?') }), _jsx(Switch, { checked: haveResubscribeButton || false, onChange: checked => handleChange('haveResubscribeButton', checked) })] })) : (_jsxs(Space, { size: 5, direction: "vertical", children: [_jsx(TextStyled, { color: "#666666", required: required.includes('preferenceListIds'), children: translate(translations._TITLE_PREFERENCES, 'Preferences') }), isLoadingUnsubscribeListPermission ? (_jsx(Spin, { spinning: true, className: "ants-flex ants-justify-center", size: "small" })) : (_jsx(EditingListV2, { className: "ants-mt-2", addButtonLabel: translate(translations._ACT_ADD_UNSUBSCRIBED_LIST, 'Add unsubscribed list'), options: memoizedPreferencesLists, selected: preferenceListIds, onChange: value => handleChange('preferenceListIds', value) }))] }))] }))] }));
|
|
203
|
+
};
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
import { TUnsubscribeList } from '@antscorp/antsomi-ui/es/types';
|
|
2
|
+
export declare const buildOptionUnsubscribedList: (list: TUnsubscribeList[], selected: any) => TUnsubscribeList[];
|
|
3
|
+
export declare const unsubscribeListNotExist: (options: any, value: any) => any;
|
|
4
|
+
export declare const checkUnsubscribeList: ({ listUnsubscribe, unsubscribeId, }: {
|
|
5
|
+
listUnsubscribe?: any[];
|
|
6
|
+
unsubscribeId?: string;
|
|
7
|
+
}) => {
|
|
8
|
+
errorMessage: string;
|
|
9
|
+
};
|
|
10
|
+
export declare const buildOptionPreferencesList: (list: TUnsubscribeList[], selected: any) => {
|
|
11
|
+
value: string;
|
|
12
|
+
label: string;
|
|
13
|
+
key: string;
|
|
14
|
+
errorMessage: any;
|
|
15
|
+
}[];
|
|
@@ -0,0 +1,56 @@
|
|
|
1
|
+
import { compareStrings } from '@antscorp/antsomi-ui/es/utils';
|
|
2
|
+
import { UNSUBSCRIBE_LIST_MESSAGE_ERRORS, UNSUBSCRIBE_LIST_STATUS } from './constants';
|
|
3
|
+
import { GLOBAL_UNSUBSCRIBED_LIST, GLOBAL_UNSUBSCRIBED_WHATSAPP, } from '@antscorp/antsomi-ui/es/constants';
|
|
4
|
+
export const buildOptionUnsubscribedList = (list, selected) => {
|
|
5
|
+
const arrSelected = Array.isArray(selected) ? selected : [selected];
|
|
6
|
+
const result = list?.filter(each => compareStrings(each.status, UNSUBSCRIBE_LIST_STATUS.ACTIVE) === 0 ||
|
|
7
|
+
arrSelected.includes(each.list_id)) || [];
|
|
8
|
+
return result;
|
|
9
|
+
};
|
|
10
|
+
export const unsubscribeListNotExist = (options, value) => {
|
|
11
|
+
// eslint-disable-next-line no-extra-boolean-cast
|
|
12
|
+
if (!!value) {
|
|
13
|
+
const selected = options?.find(item => compareStrings(item.list_id, value) === 0);
|
|
14
|
+
if (!selected) {
|
|
15
|
+
return `[ID - ${value}]`;
|
|
16
|
+
}
|
|
17
|
+
}
|
|
18
|
+
return value;
|
|
19
|
+
};
|
|
20
|
+
export const checkUnsubscribeList = ({ listUnsubscribe, unsubscribeId, }) => {
|
|
21
|
+
let errorMessage = '';
|
|
22
|
+
const listSelected = listUnsubscribe?.find(({ list_id }) => list_id === unsubscribeId);
|
|
23
|
+
if (listSelected) {
|
|
24
|
+
switch (listSelected.status) {
|
|
25
|
+
case UNSUBSCRIBE_LIST_STATUS.INACTIVE:
|
|
26
|
+
errorMessage = UNSUBSCRIBE_LIST_MESSAGE_ERRORS.DISABLED;
|
|
27
|
+
break;
|
|
28
|
+
default:
|
|
29
|
+
errorMessage = '';
|
|
30
|
+
break;
|
|
31
|
+
}
|
|
32
|
+
}
|
|
33
|
+
else {
|
|
34
|
+
errorMessage = UNSUBSCRIBE_LIST_MESSAGE_ERRORS.UNAUTHORIZED;
|
|
35
|
+
}
|
|
36
|
+
return { errorMessage };
|
|
37
|
+
};
|
|
38
|
+
export const buildOptionPreferencesList = (list, selected) => {
|
|
39
|
+
const arrSelected = Array.isArray(selected) ? selected : [selected];
|
|
40
|
+
const result = list
|
|
41
|
+
?.filter(each => !arrSelected.includes(each.list_id) &&
|
|
42
|
+
[GLOBAL_UNSUBSCRIBED_LIST, GLOBAL_UNSUBSCRIBED_WHATSAPP].every(({ list_id }) => compareStrings(each.list_id, list_id) !== 0))
|
|
43
|
+
.map(each => {
|
|
44
|
+
let messageError;
|
|
45
|
+
if (compareStrings(each.status, UNSUBSCRIBE_LIST_STATUS.INACTIVE) === 0) {
|
|
46
|
+
messageError = UNSUBSCRIBE_LIST_MESSAGE_ERRORS.DISABLED;
|
|
47
|
+
}
|
|
48
|
+
return {
|
|
49
|
+
value: each.list_id,
|
|
50
|
+
label: each.list_name,
|
|
51
|
+
key: each.list_id,
|
|
52
|
+
errorMessage: messageError,
|
|
53
|
+
};
|
|
54
|
+
}) || [];
|
|
55
|
+
return result;
|
|
56
|
+
};
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
import { TUnsubscribePayloadInfo } from '@antscorp/antsomi-ui/es/services/Unsubscribe';
|
|
3
|
+
import { TUnsubscribeSettings, TUnsubscribeType } from '@antscorp/antsomi-ui/es';
|
|
4
|
+
interface PreferencesProps {
|
|
5
|
+
preferences: TUnsubscribeSettings['unsubscribePreferences'];
|
|
6
|
+
identifier: string[];
|
|
7
|
+
onOptOutAll?: () => void;
|
|
8
|
+
apiConfig: TUnsubscribePayloadInfo;
|
|
9
|
+
type: TUnsubscribeType;
|
|
10
|
+
}
|
|
11
|
+
export declare const Preferences: React.FC<PreferencesProps>;
|
|
12
|
+
export {};
|
|
@@ -0,0 +1,159 @@
|
|
|
1
|
+
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
2
|
+
// Libraries
|
|
3
|
+
import { useEffect, useMemo, useState } from 'react';
|
|
4
|
+
// Icons
|
|
5
|
+
import { DataIcon, UnsubscribeIcon } from '@antscorp/antsomi-ui/es/components/icons';
|
|
6
|
+
// Utils
|
|
7
|
+
import { maskEmail, maskPhone } from '../../utils';
|
|
8
|
+
import { compareStrings } from '@antscorp/antsomi-ui/es/utils';
|
|
9
|
+
// Queries
|
|
10
|
+
import { useGetUnsubscribeList } from '@antscorp/antsomi-ui/es/queries/Unsubscribe';
|
|
11
|
+
// Constants
|
|
12
|
+
import { UNSUBSCRIBE_LIST_STATUS } from '../../../UnsubscribePreferences/constants';
|
|
13
|
+
// Components
|
|
14
|
+
import { Button, EmptyData, Flex, Spin, Typography, } from '@antscorp/antsomi-ui/es';
|
|
15
|
+
import { TestAlert } from '../TestAlert';
|
|
16
|
+
import { CheckboxStyled, Description, Identifier, ListStyled, LogoContainer, LogoImg, Title, Wrapper, } from '../styled';
|
|
17
|
+
import { SpinContainer } from '../../styled';
|
|
18
|
+
export const Preferences = props => {
|
|
19
|
+
const { preferences, identifier, onOptOutAll, apiConfig, type } = props;
|
|
20
|
+
const identifierLabel = useMemo(() => {
|
|
21
|
+
switch (type) {
|
|
22
|
+
case 'sms':
|
|
23
|
+
case 'whatsapp':
|
|
24
|
+
return identifier.length > 1
|
|
25
|
+
? identifier.map(item => maskPhone(item)).join(', ')
|
|
26
|
+
: maskPhone(identifier[0]);
|
|
27
|
+
default:
|
|
28
|
+
return identifier.length > 1
|
|
29
|
+
? identifier.map(item => maskEmail(item)).join(', ')
|
|
30
|
+
: maskEmail(identifier[0]);
|
|
31
|
+
}
|
|
32
|
+
}, [type, identifier]);
|
|
33
|
+
const DESCRIPTION = {
|
|
34
|
+
email: 'Please check the types of emails you would like to receive. Uncheck any that you do not wish to subscribe to.',
|
|
35
|
+
sms: 'Select the SMS message types you wish to receive. Uncheck any to stop.',
|
|
36
|
+
whatsapp: 'Select the WhatsApp message types you wish to receive. Uncheck any to stop.',
|
|
37
|
+
};
|
|
38
|
+
const BTN_UNSUBSCRIBE_ALL = {
|
|
39
|
+
email: 'Unsubscribe from all emails',
|
|
40
|
+
sms: 'Unsubscribe from all messages',
|
|
41
|
+
whatsapp: 'Unsubscribe from all messages',
|
|
42
|
+
};
|
|
43
|
+
// Hooks
|
|
44
|
+
const { data: unsubscribeData, isLoading: isLoadingUnsubscribeList, isFetching: isFetchingUnsubscribeList, } = useGetUnsubscribeList({
|
|
45
|
+
args: {
|
|
46
|
+
data: {
|
|
47
|
+
type,
|
|
48
|
+
portalId: Number(apiConfig.portalId),
|
|
49
|
+
},
|
|
50
|
+
},
|
|
51
|
+
options: {
|
|
52
|
+
enabled: !!apiConfig.portalId,
|
|
53
|
+
},
|
|
54
|
+
}, apiConfig);
|
|
55
|
+
// Memo
|
|
56
|
+
const allUnsubscribeList = useMemo(() => unsubscribeData?.entries[0], [unsubscribeData]);
|
|
57
|
+
const preferencesUnsubscribeList = useMemo(() => {
|
|
58
|
+
if (!allUnsubscribeList)
|
|
59
|
+
return [];
|
|
60
|
+
// Lấy listId đang được chọn (mảng hoặc 1 id)
|
|
61
|
+
const prefIds = Array.isArray(preferences.preferenceListIds)
|
|
62
|
+
? preferences.preferenceListIds
|
|
63
|
+
: preferences.preferenceListIds
|
|
64
|
+
? [`${preferences.preferenceListIds}`]
|
|
65
|
+
: [];
|
|
66
|
+
// Lọc theo preferenceListIds
|
|
67
|
+
let filtered = allUnsubscribeList.filter(list => prefIds.includes(list.list_id) &&
|
|
68
|
+
compareStrings(list.status, UNSUBSCRIBE_LIST_STATUS.ACTIVE) === 0);
|
|
69
|
+
// Tìm thêm list theo unsubscribeListId
|
|
70
|
+
const unsubscribeItem = allUnsubscribeList.find(list => compareStrings(list.list_id, preferences.unsubscribeListId) === 0 &&
|
|
71
|
+
compareStrings(list.status, UNSUBSCRIBE_LIST_STATUS.ACTIVE) === 0);
|
|
72
|
+
// Nếu có và chưa nằm trong filtered thì thêm vào
|
|
73
|
+
if (unsubscribeItem && !filtered.some(l => l.list_id === unsubscribeItem.list_id)) {
|
|
74
|
+
filtered = [unsubscribeItem, ...filtered];
|
|
75
|
+
}
|
|
76
|
+
return filtered;
|
|
77
|
+
}, [allUnsubscribeList, preferences.preferenceListIds, preferences.unsubscribeListId]);
|
|
78
|
+
// States
|
|
79
|
+
const initialState = {
|
|
80
|
+
isUpdated: false,
|
|
81
|
+
isChanged: false,
|
|
82
|
+
};
|
|
83
|
+
const [preferenceList, setPreferenceList] = useState([]);
|
|
84
|
+
const [pageStatus, setPageStatus] = useState(initialState);
|
|
85
|
+
const { isUpdated, isChanged } = pageStatus;
|
|
86
|
+
// Effects
|
|
87
|
+
useEffect(() => {
|
|
88
|
+
// setState(prevState => ({
|
|
89
|
+
// ...prevState,
|
|
90
|
+
// preferenceList: [
|
|
91
|
+
// ...(preferencesUnsubscribeList || []),
|
|
92
|
+
// // ...(Array.isArray(allUnsubscribeList)
|
|
93
|
+
// // ? allUnsubscribeList?.filter(
|
|
94
|
+
// // list =>
|
|
95
|
+
// // (Array.isArray(preferences.preferenceListIds)
|
|
96
|
+
// // ? [...preferences.preferenceListIds]
|
|
97
|
+
// // : preferences.preferenceListIds
|
|
98
|
+
// // ? [`${preferences.preferenceListIds}`]
|
|
99
|
+
// // : []
|
|
100
|
+
// // )?.includes(list.list_id) &&
|
|
101
|
+
// // compareStrings(list.status, UNSUBSCRIBE_LIST_STATUS.ACTIVE) === 0,
|
|
102
|
+
// // )
|
|
103
|
+
// // : []),
|
|
104
|
+
// ],
|
|
105
|
+
// }));
|
|
106
|
+
setPreferenceList((preferencesUnsubscribeList || []).map(item => ({
|
|
107
|
+
...item,
|
|
108
|
+
checked: true,
|
|
109
|
+
})));
|
|
110
|
+
}, [preferencesUnsubscribeList, allUnsubscribeList]);
|
|
111
|
+
const onChangeSelectPreference = (event, index) => {
|
|
112
|
+
const { checked } = event.target;
|
|
113
|
+
setPreferenceList(prev => prev.map((item, i) => (i === index ? { ...item, checked } : item)));
|
|
114
|
+
setPageStatus(prev => ({
|
|
115
|
+
...prev,
|
|
116
|
+
isChanged: true,
|
|
117
|
+
}));
|
|
118
|
+
};
|
|
119
|
+
const onClickSavePreferences = () => {
|
|
120
|
+
// If already updated, do nothing
|
|
121
|
+
if (!isChanged) {
|
|
122
|
+
return;
|
|
123
|
+
}
|
|
124
|
+
const timeout = setTimeout(() => {
|
|
125
|
+
setPageStatus(prevState => ({ ...prevState, isUpdated: true }));
|
|
126
|
+
}, 1000);
|
|
127
|
+
setPageStatus(prevState => ({ ...prevState, isChanged: false }));
|
|
128
|
+
return () => clearTimeout(timeout);
|
|
129
|
+
};
|
|
130
|
+
const onClickOptOutAll = async () => {
|
|
131
|
+
onOptOutAll?.();
|
|
132
|
+
};
|
|
133
|
+
const renderPreferencesList = () => {
|
|
134
|
+
if (isLoadingUnsubscribeList || isFetchingUnsubscribeList) {
|
|
135
|
+
return (_jsx(SpinContainer, { children: _jsx(Spin, { spinning: true }) }));
|
|
136
|
+
}
|
|
137
|
+
return preferenceList?.length > 0 ? (preferenceList?.map((preference, index) => (_jsx(ListStyled.Item, { style: { gap: '9px' }, children: _jsxs(CheckboxStyled, { checked: preference?.checked, className: "ants-flex ants-self-start", onChange: event => onChangeSelectPreference(event, index), style: {
|
|
138
|
+
alignItems: 'flex-start',
|
|
139
|
+
}, children: [_jsx("div", { style: { width: '100%', fontSize: '12px' }, children: preference?.list_name }), _jsx(Typography.Paragraph, { style: { fontSize: '11px', color: '#595959', marginBottom: '0px' }, children: preference?.description })] }) }, preference?.list_id)))) : (_jsx(EmptyData, { style: { marginBottom: '10px' }, icon: _jsx(DataIcon, {}), size: "medium", title: "No data available" }));
|
|
140
|
+
};
|
|
141
|
+
const renderActions = () => {
|
|
142
|
+
if (!preferenceList?.length)
|
|
143
|
+
return null;
|
|
144
|
+
return (_jsxs(Flex, { justify: "space-between", align: "center", style: {
|
|
145
|
+
width: '100%',
|
|
146
|
+
fontSize: '12px',
|
|
147
|
+
paddingTop: 15,
|
|
148
|
+
borderTop: '1px solid #E5E5E5',
|
|
149
|
+
}, children: [_jsx(Button, { type: "primary", onClick: onClickSavePreferences, disabled: !isChanged, children: "Save preferences" }), _jsx(Button, { onClick: onClickOptOutAll, icon: _jsx(UnsubscribeIcon, { color: "#005EB8" }), disabled: preferenceList?.length === 0, children: BTN_UNSUBSCRIBE_ALL[type] })] }));
|
|
150
|
+
};
|
|
151
|
+
return (_jsxs(Wrapper, { children: [_jsx(LogoContainer, { children: _jsx(LogoImg, { src: preferences.logo, alt: "Antsomi Logo" }) }), _jsx(Identifier, { children: identifierLabel }), !isUpdated || isChanged ? (_jsx(Title, { children: "Communication Preference" })) : (_jsx(Title, { style: { color: '#12B800' }, children: "Communication Preferences Updated!" })), _jsx(Description, { style: {
|
|
152
|
+
marginBottom: preferences.haveResubscribeButton || preferenceList?.length > 0 ? '30px' : 0,
|
|
153
|
+
}, children: DESCRIPTION[type] }), _jsx(ListStyled, { style: {
|
|
154
|
+
maxHeight: '400px',
|
|
155
|
+
overflow: 'auto',
|
|
156
|
+
}, header: _jsx("span", {}), children: renderPreferencesList() }), renderActions(), !!preferenceList?.length && (_jsx(TestAlert, { type: type, style: {
|
|
157
|
+
marginTop: !preferences.haveResubscribeButton ? '30px' : '10px',
|
|
158
|
+
} }))] }));
|
|
159
|
+
};
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
import { RESULT_PAGE_TYPES } from '@antscorp/antsomi-ui/es/constants';
|
|
3
|
+
import { TUnsubscribeSettings, TUnsubscribeType } from '@antscorp/antsomi-ui/es/types';
|
|
4
|
+
type ResultPageType = (typeof RESULT_PAGE_TYPES)[keyof typeof RESULT_PAGE_TYPES];
|
|
5
|
+
interface ResultProps {
|
|
6
|
+
unsubscribeType: TUnsubscribeType;
|
|
7
|
+
type: ResultPageType;
|
|
8
|
+
preferences: TUnsubscribeSettings['unsubscribePreferences'];
|
|
9
|
+
identifier: string[];
|
|
10
|
+
onClickOptIn?: () => void;
|
|
11
|
+
}
|
|
12
|
+
export declare const Result: React.FC<ResultProps>;
|
|
13
|
+
export {};
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
2
|
+
// Libraries
|
|
3
|
+
import { useMemo } from 'react';
|
|
4
|
+
// Constants
|
|
5
|
+
import { RESULT_PAGE_TYPES, RESULT_PAGE_MESSAGES } from '@antscorp/antsomi-ui/es/constants';
|
|
6
|
+
// Utils
|
|
7
|
+
import { maskEmail, maskPhone } from '../../utils';
|
|
8
|
+
// Components
|
|
9
|
+
import { Button } from '@antscorp/antsomi-ui/es/components';
|
|
10
|
+
import { TestAlert } from '../TestAlert';
|
|
11
|
+
import { Description, Identifier, LogoContainer, LogoImg, TaskAltIconStyled, Title, Wrapper, } from '../styled';
|
|
12
|
+
export const Result = props => {
|
|
13
|
+
const { unsubscribeType, preferences, identifier, type, onClickOptIn } = props;
|
|
14
|
+
const identifierLabel = useMemo(() => {
|
|
15
|
+
switch (unsubscribeType) {
|
|
16
|
+
case 'sms':
|
|
17
|
+
case 'whatsapp':
|
|
18
|
+
return identifier.length > 1
|
|
19
|
+
? identifier.map(item => maskPhone(item)).join(', ')
|
|
20
|
+
: maskPhone(identifier[0]);
|
|
21
|
+
default:
|
|
22
|
+
return identifier.length > 1
|
|
23
|
+
? identifier.map(item => maskEmail(item)).join(', ')
|
|
24
|
+
: maskEmail(identifier[0]);
|
|
25
|
+
}
|
|
26
|
+
}, [unsubscribeType, identifier]);
|
|
27
|
+
return (_jsxs(Wrapper, { children: [_jsx(LogoContainer, { children: _jsx(LogoImg, { src: preferences.logo, alt: "Antsomi Logo" }) }), _jsx(Identifier, { style: { textAlign: 'center' }, children: identifierLabel }), _jsx(TaskAltIconStyled, { size: 100, color: "#005EB8", style: { margin: '0px auto 30px' } }), RESULT_PAGE_MESSAGES[type][unsubscribeType].title && (_jsx(Title, { children: RESULT_PAGE_MESSAGES[type][unsubscribeType].title })), _jsx(Description, { style: { marginBottom: 0, textAlign: 'center' }, children: RESULT_PAGE_MESSAGES[type][unsubscribeType].description || '' }), _jsx(TestAlert, { type: unsubscribeType, showIcon: false, justify: "center", className: "ants-text-center !ants-m-[-9px]", style: { margin: '15px 0px' } }), type === RESULT_PAGE_TYPES.OPT_OUT && (_jsx(Button, { style: { height: '30px', width: 'fit-content', margin: '0px auto' }, onClick: onClickOptIn, children: "Opt In + Restore Preferences" }))] }));
|
|
28
|
+
};
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
import { TUnsubscribeType } from '@antscorp/antsomi-ui/es/types';
|
|
3
|
+
import { FlexProps } from '@antscorp/antsomi-ui/es/components';
|
|
4
|
+
interface TestAlertProps extends Omit<FlexProps, 'children'> {
|
|
5
|
+
showIcon?: boolean;
|
|
6
|
+
type: TUnsubscribeType;
|
|
7
|
+
}
|
|
8
|
+
export declare const TestAlert: React.FC<TestAlertProps>;
|
|
9
|
+
export {};
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
2
|
+
// Libraries
|
|
3
|
+
import { memo } from 'react';
|
|
4
|
+
import classNames from 'classnames';
|
|
5
|
+
// Icons
|
|
6
|
+
import { ViewDetailsInformationIcon } from '@antscorp/antsomi-ui/es/components/icons';
|
|
7
|
+
// Components
|
|
8
|
+
import { Flex } from '@antscorp/antsomi-ui/es/components';
|
|
9
|
+
const TEXT_ALERT = {
|
|
10
|
+
email: 'Unsubscribers from emails are not recorded',
|
|
11
|
+
sms: 'Unsubscribers from SMS messages are not recorded',
|
|
12
|
+
whatsapp: 'Unsubscribers from test WhatsApp messages are not recorded',
|
|
13
|
+
};
|
|
14
|
+
export const TestAlert = memo(({ className, showIcon = true, type, ...props }) => (_jsxs(Flex, { className: classNames(className), gap: 6, align: "center", ...props, children: [showIcon && (_jsx(ViewDetailsInformationIcon, { color: "#005EB8", size: 24, className: "ants-text-primary" })), _jsx("span", { style: {
|
|
15
|
+
fontSize: 11,
|
|
16
|
+
color: '#7F7F7F',
|
|
17
|
+
}, children: TEXT_ALERT[type] })] })));
|
|
18
|
+
TestAlert.displayName = 'TestAlert';
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
import { TUnsubscribeSettings, TUnsubscribeType } from '@antscorp/antsomi-ui/es/types';
|
|
3
|
+
import { TUnsubscribePayloadInfo } from '@antscorp/antsomi-ui/es/services/Unsubscribe';
|
|
4
|
+
interface UnsubscribedProps {
|
|
5
|
+
preferences: TUnsubscribeSettings['unsubscribePreferences'];
|
|
6
|
+
identifier: string[];
|
|
7
|
+
onViewPreferences?: () => void;
|
|
8
|
+
onResubscribe?: () => void;
|
|
9
|
+
apiConfig: TUnsubscribePayloadInfo;
|
|
10
|
+
type: TUnsubscribeType;
|
|
11
|
+
}
|
|
12
|
+
export declare const Unsubscribed: React.FC<UnsubscribedProps>;
|
|
13
|
+
export {};
|
|
@@ -0,0 +1,85 @@
|
|
|
1
|
+
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
2
|
+
// Libraries
|
|
3
|
+
import { useMemo } from 'react';
|
|
4
|
+
// Utils
|
|
5
|
+
import { maskEmail, maskPhone } from '../../utils';
|
|
6
|
+
import { compareStrings } from '@antscorp/antsomi-ui/es/utils';
|
|
7
|
+
// Constants
|
|
8
|
+
import { UNSUBSCRIBE_LIST_STATUS } from '../../../UnsubscribePreferences/constants';
|
|
9
|
+
import { GLOBAL_UNSUBSCRIBED_LIST, GLOBAL_UNSUBSCRIBED_WHATSAPP, } from '@antscorp/antsomi-ui/es/constants';
|
|
10
|
+
// Icons
|
|
11
|
+
import { DataIcon } from '@antscorp/antsomi-ui/es/components/icons';
|
|
12
|
+
// Queries
|
|
13
|
+
import { useGetUnsubscribeList } from '@antscorp/antsomi-ui/es/queries/Unsubscribe';
|
|
14
|
+
// Components
|
|
15
|
+
import { Button, EmptyData, Flex, Spin, Typography } from '@antscorp/antsomi-ui/es/components';
|
|
16
|
+
import { TestAlert } from '../TestAlert';
|
|
17
|
+
import { Description, Identifier, ListStyled, LogoContainer, LogoImg, Title, Wrapper, } from '../styled';
|
|
18
|
+
export const Unsubscribed = props => {
|
|
19
|
+
const { preferences, identifier, onViewPreferences, onResubscribe, apiConfig, type } = props;
|
|
20
|
+
// Hooks
|
|
21
|
+
const { data: unsubscribeData, isLoading: isLoadingUnsubscribe, isFetching: isFetchingUnsubscribeList, } = useGetUnsubscribeList({
|
|
22
|
+
args: {
|
|
23
|
+
data: {
|
|
24
|
+
type,
|
|
25
|
+
portalId: Number(apiConfig.portalId),
|
|
26
|
+
},
|
|
27
|
+
},
|
|
28
|
+
options: {
|
|
29
|
+
enabled: !!apiConfig.portalId,
|
|
30
|
+
},
|
|
31
|
+
}, apiConfig);
|
|
32
|
+
// Memo
|
|
33
|
+
const isGlobal = useMemo(() => [GLOBAL_UNSUBSCRIBED_LIST, GLOBAL_UNSUBSCRIBED_WHATSAPP].some(({ list_id }) => compareStrings(list_id, preferences.unsubscribeListId) === 0), [preferences.unsubscribeListId]);
|
|
34
|
+
const unsubscribeList = useMemo(() => {
|
|
35
|
+
const unsubscribeDataList = unsubscribeData?.entries[0];
|
|
36
|
+
return (unsubscribeDataList?.find(list => compareStrings(list.list_id, preferences.unsubscribeListId) === 0 &&
|
|
37
|
+
compareStrings(list.status, UNSUBSCRIBE_LIST_STATUS.ACTIVE) === 0) || null);
|
|
38
|
+
}, [unsubscribeData, preferences.unsubscribeListId]);
|
|
39
|
+
const identifierLabel = useMemo(() => {
|
|
40
|
+
switch (type) {
|
|
41
|
+
case 'sms':
|
|
42
|
+
case 'whatsapp':
|
|
43
|
+
return identifier.length > 1
|
|
44
|
+
? identifier.map(item => maskPhone(item)).join(', ')
|
|
45
|
+
: maskPhone(identifier[0]);
|
|
46
|
+
default:
|
|
47
|
+
return identifier.length > 1
|
|
48
|
+
? identifier.map(item => maskEmail(item)).join(', ')
|
|
49
|
+
: maskEmail(identifier[0]);
|
|
50
|
+
}
|
|
51
|
+
}, [type, identifier]);
|
|
52
|
+
// Handlers
|
|
53
|
+
const onClickResubscribe = async () => {
|
|
54
|
+
onResubscribe?.();
|
|
55
|
+
};
|
|
56
|
+
const renderUnsubscribedList = () => {
|
|
57
|
+
if (isLoadingUnsubscribe || isFetchingUnsubscribeList) {
|
|
58
|
+
if (isGlobal) {
|
|
59
|
+
return (_jsx("div", { className: "ants-absolute ants-inset-0 ants-h-full ants-top-0 ants-bottom-0 ants-flex ants-justify-center ants-items-center ants-bg-white/70 ants-z-10", children: _jsx(Spin, { spinning: true }) }));
|
|
60
|
+
}
|
|
61
|
+
return (_jsx("div", { className: "ants-my-5 ants-flex ants-justify-center", children: _jsx(Spin, { spinning: true }) }));
|
|
62
|
+
}
|
|
63
|
+
return isGlobal ? null : unsubscribeList ? (_jsx(ListStyled, { header: _jsx("span", {}), children: _jsxs(ListStyled.Item, { children: [_jsx("div", { style: { fontSize: 12 }, children: unsubscribeList?.list_name }), _jsx(Typography.Paragraph, { style: { fontSize: '11px', color: '#595959', marginBottom: '0px' }, children: unsubscribeList?.description })] }) })) : (_jsx(EmptyData, { icon: _jsx(DataIcon, {}), size: "medium", title: "No data available" }));
|
|
64
|
+
};
|
|
65
|
+
const renderActions = () => {
|
|
66
|
+
let actionItem = null;
|
|
67
|
+
if (!isGlobal) {
|
|
68
|
+
actionItem = (_jsx(Button, { type: "primary", className: "!ants-text-[12px] ants-p-2.5", onClick: onViewPreferences, disabled: isLoadingUnsubscribe, children: "View preferences" }));
|
|
69
|
+
}
|
|
70
|
+
if (isGlobal && preferences.haveResubscribeButton) {
|
|
71
|
+
actionItem = (_jsx(Button, { type: "primary", danger: true, className: "ants-color-primary !ants-text-[14px] !ants-p-2.5", onClick: onClickResubscribe, children: "Resubscribe" }));
|
|
72
|
+
}
|
|
73
|
+
if (actionItem) {
|
|
74
|
+
return (_jsx(Flex, { align: "center", justify: "center", style: {
|
|
75
|
+
paddingTop: 15,
|
|
76
|
+
borderTop: '1px solid #E5E5E5',
|
|
77
|
+
}, children: actionItem }));
|
|
78
|
+
}
|
|
79
|
+
};
|
|
80
|
+
return (_jsxs(Wrapper, { style: {
|
|
81
|
+
paddingBottom: isGlobal ? (!preferences.haveResubscribeButton ? '20px' : '10px') : '10px',
|
|
82
|
+
}, children: [_jsx(LogoContainer, { children: _jsx(LogoImg, { src: preferences.logo, alt: "Antsomi Logo" }) }), _jsx(Identifier, { children: identifierLabel }), _jsx(Title, { children: preferences.title }), _jsx(Description, { children: preferences.description }), renderUnsubscribedList(), renderActions(), _jsx(TestAlert, { type: type, showIcon: isGlobal && !preferences.haveResubscribeButton, justify: isGlobal && !preferences.haveResubscribeButton ? 'left' : 'center', style: {
|
|
83
|
+
marginTop: '10px',
|
|
84
|
+
} })] }));
|
|
85
|
+
};
|