@antscorp/antsomi-ui 2.0.107 → 2.0.108
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/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/TagifyInput/TagifyInput.js +15 -4
- 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/types.d.ts +13 -3
- package/es/components/molecules/TagifyInput/utils.d.ts +1 -0
- package/es/components/molecules/TagifyInput/utils.js +2 -1
- 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/index.d.ts +4 -0
- package/es/components/molecules/index.js +2 -0
- package/es/components/organism/PreviewCollections/WhatsappMessage/FooterMessage/index.js +3 -1
- 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/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/Unsubscribe/index.d.ts +41 -0
- package/es/services/Unsubscribe/index.js +78 -0
- 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/package.json +1 -1
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Masks an email address to show only the first and last characters of the local part and the first and last characters of the domain.
|
|
3
|
+
* @param {string} [email=''] - the email address to mask
|
|
4
|
+
* @returns {string} the masked email address
|
|
5
|
+
* @example
|
|
6
|
+
* maskEmail('user@example.com') // 'u**r@e**mple.com'
|
|
7
|
+
*/
|
|
8
|
+
export declare const maskEmail: (email?: string) => string;
|
|
9
|
+
export declare const maskPhone: (phone?: string) => string;
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Masks an email address to show only the first and last characters of the local part and the first and last characters of the domain.
|
|
3
|
+
* @param {string} [email=''] - the email address to mask
|
|
4
|
+
* @returns {string} the masked email address
|
|
5
|
+
* @example
|
|
6
|
+
* maskEmail('user@example.com') // 'u**r@e**mple.com'
|
|
7
|
+
*/
|
|
8
|
+
export const maskEmail = (email = '') => {
|
|
9
|
+
if (!email.includes('@'))
|
|
10
|
+
return 'Invalid email';
|
|
11
|
+
const [local, domain] = email.split('@');
|
|
12
|
+
const localLength = local.length;
|
|
13
|
+
const domainLength = domain.length;
|
|
14
|
+
if (localLength < 2 || domainLength < 3)
|
|
15
|
+
return 'Invalid email';
|
|
16
|
+
const maskedLocal = `${local[0]}${'*'.repeat(localLength - 2)}${local[localLength - 1]}`;
|
|
17
|
+
const maskedDomain = `${domain[0]}${'*'.repeat(domainLength - 2)}${domain[domainLength - 1]}`;
|
|
18
|
+
return `${maskedLocal}@${maskedDomain}`;
|
|
19
|
+
};
|
|
20
|
+
export const maskPhone = (phone = '') => {
|
|
21
|
+
const digits = phone.replace(/\D/g, '');
|
|
22
|
+
if (digits.length < 6)
|
|
23
|
+
return 'Invalid phone';
|
|
24
|
+
const end = digits.slice(-3);
|
|
25
|
+
const masked = '*'.repeat(digits.length - end.length);
|
|
26
|
+
return `${masked}${end}`;
|
|
27
|
+
};
|
|
@@ -129,6 +129,10 @@ export interface UploadImageProps extends AntdUploadProps {
|
|
|
129
129
|
* Indicates if the input is currently focused.
|
|
130
130
|
*/
|
|
131
131
|
focused?: boolean;
|
|
132
|
+
/**
|
|
133
|
+
* Whether to disable the remove button.
|
|
134
|
+
*/
|
|
135
|
+
disableRemove?: boolean;
|
|
132
136
|
}
|
|
133
137
|
interface UploadMediaObject {
|
|
134
138
|
url: string;
|
|
@@ -44,7 +44,7 @@ const SORT_OPTIONS = {
|
|
|
44
44
|
},
|
|
45
45
|
};
|
|
46
46
|
export const UploadImage = props => {
|
|
47
|
-
const { labelHeadingModal, labelButtonSelect, labelModalDelete, searchPlaceholder, onRemoveImage, onChangeImage: onChangeMedia, isOpen, isInputMode, width, placeholder, extensions, maxSize, title, showImageURL: showMediaURL, selectedImage: selectedMediaProp, required, focused, domainMedia, slug, paramConfigs, errors, iconName, mode, } = props;
|
|
47
|
+
const { labelHeadingModal, labelButtonSelect, labelModalDelete, searchPlaceholder, onRemoveImage, onChangeImage: onChangeMedia, isOpen, isInputMode, width, placeholder, extensions, maxSize, title, showImageURL: showMediaURL, selectedImage: selectedMediaProp, required, focused, domainMedia, slug, paramConfigs, errors, iconName, mode, disableRemove, } = props;
|
|
48
48
|
const { Dragger } = Upload;
|
|
49
49
|
const [selectedMedia, setSelectedMedia] = useState(selectedMediaProp || { url: '' });
|
|
50
50
|
const [isModalOpen, setIsModalOpen] = useState(isOpen);
|
|
@@ -237,7 +237,7 @@ export const UploadImage = props => {
|
|
|
237
237
|
zIndex: 1,
|
|
238
238
|
marginLeft: 25,
|
|
239
239
|
color: THEME.token?.colorIcon,
|
|
240
|
-
} })) : null, _jsxs("div", { style: flexStyleCenter, children: [_jsxs(Button, { onClick: showModal, style: { backgroundColor: '#ffffff' }, children: ["Browse ", mode === 'video' ? 'Video' : 'Image'] }), selectedMedia && selectedMedia.url ? (_jsx(Button, { onClick: handleRemoveMedia, style: { backgroundColor: '#ffffff' }, children: _jsx(Icon, { type: "icon-ants-remove-trash", size: 15, style: { color: THEME.token?.colorPrimary } }) })) : null] })] }), _jsxs("div", { className: "upload-file-info", style: { marginTop: 12 }, children: [_jsxs(Text, { children: ["File type: ", extensions?.join(', ')] }), _jsxs(Text, { children: ["File size:
|
|
240
|
+
} })) : null, _jsxs("div", { style: flexStyleCenter, children: [_jsxs(Button, { onClick: showModal, style: { backgroundColor: '#ffffff' }, children: ["Browse ", mode === 'video' ? 'Video' : 'Image'] }), !disableRemove && selectedMedia && selectedMedia.url ? (_jsx(Button, { onClick: handleRemoveMedia, style: { backgroundColor: '#ffffff' }, children: _jsx(Icon, { type: "icon-ants-remove-trash", size: 15, style: { color: THEME.token?.colorPrimary } }) })) : null] })] }), _jsxs("div", { className: "upload-file-info", style: { marginTop: 12 }, children: [_jsxs(Text, { children: ["File type: ", extensions?.join(', ')] }), _jsxs(Text, { children: ["File size: Under ", maxSize, "MB"] })] }), showMediaURL && (_jsx(Space, { size: 5, direction: "vertical", style: { marginTop: 12 }, children: _jsx(Input, { label: mode === 'video' ? 'Video URL' : 'Image URL', required: required, placeholder: placeholder, value: selectedMedia.url ? selectedMedia.url : '', focused: focused, maxLength: 255, onAfterChange: value => handleSelectMedia({
|
|
241
241
|
url: value,
|
|
242
242
|
}) }) }))] })), _jsx(Modal, { title: labelModalDelete, open: isOpenConfirmDelete, onOk: () => handleRemoveUploadedMedia(deleteMediaRef.current, false), onCancel: () => setOpenConfirmDelete(prev => !prev), okText: "OK", cancelText: "Cancel", destroyOnClose: true, children: _jsxs("p", { children: ["Are you sure you want to delete ", deleteMediaRef.current?.name, "?"] }) }), _jsxs(Modal, { wrapClassName: "icons-selection-modal", title: _jsxs("div", { style: { display: 'flex', gap: '8px', alignItems: 'center' }, children: [_jsx(Icon, { type: `icon-ants-${iconName}`, size: 20 }), labelHeadingModal] }), centered: true, headerStyle: {
|
|
243
243
|
padding: '20px 20px 0',
|
|
@@ -51,6 +51,8 @@ export { SearchPopover, PopoverAddField, PopoverSelect } from './SearchPopover';
|
|
|
51
51
|
export { CalendarSelection, CalendarSelectionConstants, CalendarSelectionUtils, } from './CalendarSelection';
|
|
52
52
|
export { RequestAccess } from './RequestAccess';
|
|
53
53
|
export { EditingList } from './EditingList';
|
|
54
|
+
export { UnsubscribePreferences } from './UnsubscribePreferences';
|
|
55
|
+
export { UnsubscribePreview } from './UnsubscribePreview';
|
|
54
56
|
export * from './EmptyData';
|
|
55
57
|
export * from './PreviewModal';
|
|
56
58
|
export * from './DrawerDetail';
|
|
@@ -94,3 +96,5 @@ export type { EditorTabItem } from './EditorTab';
|
|
|
94
96
|
export type { CalendarSelectionValue } from './CalendarSelection';
|
|
95
97
|
export type { EditingListProps } from './EditingList';
|
|
96
98
|
export type { ImagePreviewProps } from './ImagePreview';
|
|
99
|
+
export type { TUnsubscribePreferencesProps } from './UnsubscribePreferences';
|
|
100
|
+
export type { TUnsubscribePreviewProps } from './UnsubscribePreview';
|
|
@@ -51,6 +51,8 @@ export { SearchPopover, PopoverAddField, PopoverSelect } from './SearchPopover';
|
|
|
51
51
|
export { CalendarSelection, CalendarSelectionConstants, CalendarSelectionUtils, } from './CalendarSelection';
|
|
52
52
|
export { RequestAccess } from './RequestAccess';
|
|
53
53
|
export { EditingList } from './EditingList';
|
|
54
|
+
export { UnsubscribePreferences } from './UnsubscribePreferences';
|
|
55
|
+
export { UnsubscribePreview } from './UnsubscribePreview';
|
|
54
56
|
export * from './EmptyData';
|
|
55
57
|
export * from './PreviewModal';
|
|
56
58
|
export * from './DrawerDetail';
|
|
@@ -43,6 +43,8 @@ export default memo((props) => {
|
|
|
43
43
|
break;
|
|
44
44
|
}
|
|
45
45
|
}
|
|
46
|
-
return (_jsx(Button, { icon: icon, type: "link",
|
|
46
|
+
return (_jsx(Button, { icon: icon, type: "link",
|
|
47
|
+
// href={isURL ? btn.url : undefined}
|
|
48
|
+
target: "_blank", style: { gap: 5 }, children: _jsx(Typography.Text, { ellipsis: { tooltip: true }, style: { color: '#1670A8' }, children: btn.text }) }, btnIdx));
|
|
47
49
|
}) })] })) : null] }));
|
|
48
50
|
});
|
package/es/constants/index.d.ts
CHANGED
package/es/constants/index.js
CHANGED
|
@@ -38,4 +38,9 @@ export declare const QUERY_KEYS: {
|
|
|
38
38
|
GET_MATCHES_ANY_LIST: string;
|
|
39
39
|
GET_INFINITE_MATCHES_ANY_LIST: string;
|
|
40
40
|
GET_LOGGED_USER: string;
|
|
41
|
+
GET_UNSUBSCRIBE_PREFERENCES: string;
|
|
42
|
+
GET_UNSUBSCRIBE_LIST_BY_IDENTIFIER: string;
|
|
43
|
+
UPDATE_UNSUBSCRIBE_PREFERENCES_LIST: string;
|
|
44
|
+
GET_UNSUBSCRIBE_LIST: string;
|
|
45
|
+
GET_UNSUBSCRIBE_LIST_PERMISSION: string;
|
|
41
46
|
};
|
package/es/constants/queries.js
CHANGED
|
@@ -52,4 +52,10 @@ export const QUERY_KEYS = {
|
|
|
52
52
|
GET_INFINITE_MATCHES_ANY_LIST: 'GET_INFINITE_MATCHES_ANY_LIST',
|
|
53
53
|
// USER
|
|
54
54
|
GET_LOGGED_USER: 'GET_LOGGED_USER',
|
|
55
|
+
// UNSUBSCRIBE
|
|
56
|
+
GET_UNSUBSCRIBE_PREFERENCES: 'GET_UNSUBSCRIBE_PREFERENCES',
|
|
57
|
+
GET_UNSUBSCRIBE_LIST_BY_IDENTIFIER: 'GET_UNSUBSCRIBE_LIST_BY_IDENTIFIER',
|
|
58
|
+
UPDATE_UNSUBSCRIBE_PREFERENCES_LIST: 'UPDATE_UNSUBSCRIBE_PREFERENCES_LIST',
|
|
59
|
+
GET_UNSUBSCRIBE_LIST: 'GET_UNSUBSCRIBE_LIST',
|
|
60
|
+
GET_UNSUBSCRIBE_LIST_PERMISSION: 'GET_UNSUBSCRIBE_LIST_PERMISSION',
|
|
55
61
|
};
|
|
@@ -0,0 +1,56 @@
|
|
|
1
|
+
import { TUnsubscribeList } from '@antscorp/antsomi-ui/es/types';
|
|
2
|
+
export declare const SEARCH_PARAM_KEYS: {
|
|
3
|
+
IDENTIFIER: string;
|
|
4
|
+
PAGE: string;
|
|
5
|
+
JOURNEY_ID: string;
|
|
6
|
+
CAMPAIGN_ID: string;
|
|
7
|
+
STORY_ID: string;
|
|
8
|
+
VARIANT_ID: string;
|
|
9
|
+
CUSTOMER_ID: string;
|
|
10
|
+
UID: string;
|
|
11
|
+
PROP_ID: string;
|
|
12
|
+
IS_CLICK_UNSUBSCRIBE: string;
|
|
13
|
+
IS_PREVIEW: string;
|
|
14
|
+
PORTAL_ID: string;
|
|
15
|
+
TYPE: string;
|
|
16
|
+
IDENTIFIER_SHORT: string;
|
|
17
|
+
PAGE_SHORT: string;
|
|
18
|
+
JOURNEY_ID_SHORT: string;
|
|
19
|
+
CAMPAIGN_ID_SHORT: string;
|
|
20
|
+
STORY_ID_SHORT: string;
|
|
21
|
+
VARIANT_ID_SHORT: string;
|
|
22
|
+
CUSTOMER_ID_SHORT: string;
|
|
23
|
+
UID_SHORT: string;
|
|
24
|
+
PROP_ID_SHORT: string;
|
|
25
|
+
IS_CLICK_UNSUBSCRIBE_SHORT: string;
|
|
26
|
+
IS_PREVIEW_SHORT: string;
|
|
27
|
+
PORTAL_ID_SHORT: string;
|
|
28
|
+
TYPE_SHORT: string;
|
|
29
|
+
};
|
|
30
|
+
export declare const RESULT_PAGE_TYPES: {
|
|
31
|
+
RESUBSCRIBED: string;
|
|
32
|
+
OPT_OUT: string;
|
|
33
|
+
};
|
|
34
|
+
export declare const RESULT_PAGE_MESSAGES: {
|
|
35
|
+
[x: string]: {
|
|
36
|
+
email: {
|
|
37
|
+
title: string;
|
|
38
|
+
description: string;
|
|
39
|
+
};
|
|
40
|
+
whatsapp: {
|
|
41
|
+
title: string;
|
|
42
|
+
description: string;
|
|
43
|
+
};
|
|
44
|
+
};
|
|
45
|
+
};
|
|
46
|
+
export declare const LANDING_PAGE_TYPE: {
|
|
47
|
+
UNSUBSCRIBE: string;
|
|
48
|
+
PREFERENCES: string;
|
|
49
|
+
RESULT: string;
|
|
50
|
+
};
|
|
51
|
+
export declare const GLOBAL_UNSUBSCRIBED_LIST: TUnsubscribeList;
|
|
52
|
+
export declare const GLOBAL_UNSUBSCRIBED_WHATSAPP: TUnsubscribeList;
|
|
53
|
+
export declare const UNSUBSCRIBE_STATUS: {
|
|
54
|
+
readonly UNSUBSCRIBE: "unsubscribe";
|
|
55
|
+
readonly RESUBSCRIBE: "resubscribe";
|
|
56
|
+
};
|
|
@@ -0,0 +1,77 @@
|
|
|
1
|
+
export const SEARCH_PARAM_KEYS = {
|
|
2
|
+
IDENTIFIER: 'identifier',
|
|
3
|
+
PAGE: 'page',
|
|
4
|
+
JOURNEY_ID: 'journeyId',
|
|
5
|
+
CAMPAIGN_ID: 'campaignId',
|
|
6
|
+
STORY_ID: 'storyId',
|
|
7
|
+
VARIANT_ID: 'variantId',
|
|
8
|
+
CUSTOMER_ID: 'customerId',
|
|
9
|
+
UID: 'uid',
|
|
10
|
+
PROP_ID: 'propId',
|
|
11
|
+
IS_CLICK_UNSUBSCRIBE: 'isClickUnsubscribe',
|
|
12
|
+
IS_PREVIEW: 'isPreview',
|
|
13
|
+
PORTAL_ID: 'portalId',
|
|
14
|
+
TYPE: 'type',
|
|
15
|
+
IDENTIFIER_SHORT: 'id',
|
|
16
|
+
PAGE_SHORT: 'p',
|
|
17
|
+
JOURNEY_ID_SHORT: 'j',
|
|
18
|
+
CAMPAIGN_ID_SHORT: 'c',
|
|
19
|
+
STORY_ID_SHORT: 's',
|
|
20
|
+
VARIANT_ID_SHORT: 'v',
|
|
21
|
+
CUSTOMER_ID_SHORT: 'u',
|
|
22
|
+
UID_SHORT: 'uid',
|
|
23
|
+
PROP_ID_SHORT: 'pid',
|
|
24
|
+
IS_CLICK_UNSUBSCRIBE_SHORT: 'icu',
|
|
25
|
+
IS_PREVIEW_SHORT: 'ip',
|
|
26
|
+
PORTAL_ID_SHORT: 'poid',
|
|
27
|
+
TYPE_SHORT: 't',
|
|
28
|
+
};
|
|
29
|
+
export const RESULT_PAGE_TYPES = {
|
|
30
|
+
RESUBSCRIBED: 'resubscribed',
|
|
31
|
+
OPT_OUT: 'opt-out',
|
|
32
|
+
};
|
|
33
|
+
export const RESULT_PAGE_MESSAGES = {
|
|
34
|
+
[RESULT_PAGE_TYPES.RESUBSCRIBED]: {
|
|
35
|
+
email: {
|
|
36
|
+
title: 'Success!',
|
|
37
|
+
description: 'Thank you for signing up.',
|
|
38
|
+
},
|
|
39
|
+
whatsapp: {
|
|
40
|
+
title: 'Success!',
|
|
41
|
+
description: 'Thank you for signing up.',
|
|
42
|
+
},
|
|
43
|
+
},
|
|
44
|
+
[RESULT_PAGE_TYPES.OPT_OUT]: {
|
|
45
|
+
email: {
|
|
46
|
+
title: '',
|
|
47
|
+
description: 'You will no longer receive any emails from us.',
|
|
48
|
+
},
|
|
49
|
+
whatsapp: {
|
|
50
|
+
title: '',
|
|
51
|
+
description: 'You will no longer receive WhatsApp messages from us.',
|
|
52
|
+
},
|
|
53
|
+
},
|
|
54
|
+
};
|
|
55
|
+
export const LANDING_PAGE_TYPE = {
|
|
56
|
+
UNSUBSCRIBE: 'unsubscribed',
|
|
57
|
+
PREFERENCES: 'preferences',
|
|
58
|
+
RESULT: 'result',
|
|
59
|
+
};
|
|
60
|
+
export const GLOBAL_UNSUBSCRIBED_LIST = {
|
|
61
|
+
list_id: '-1',
|
|
62
|
+
description: '',
|
|
63
|
+
list_name: 'Global unsubscribed list',
|
|
64
|
+
status: '1',
|
|
65
|
+
type: '1',
|
|
66
|
+
};
|
|
67
|
+
export const GLOBAL_UNSUBSCRIBED_WHATSAPP = {
|
|
68
|
+
list_id: '-3',
|
|
69
|
+
list_name: 'Global unsubscribed WhatsApp',
|
|
70
|
+
status: '1',
|
|
71
|
+
type: '3',
|
|
72
|
+
description: '',
|
|
73
|
+
};
|
|
74
|
+
export const UNSUBSCRIBE_STATUS = {
|
|
75
|
+
UNSUBSCRIBE: 'unsubscribe',
|
|
76
|
+
RESUBSCRIBE: 'resubscribe',
|
|
77
|
+
};
|
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
import { useGetUnsubscribeListByIdentifier } from './useGetUnsubscribeListByIdentifier';
|
|
2
|
+
import { useGetUnsubscribeList } from './useGetUnsubscribeList';
|
|
3
|
+
import { useGetUnsubscribePreferences } from './useGetUnsubscribePreferences';
|
|
4
|
+
import { useGetUnsubscribeListPermission } from './useGetUnsubscribeListPermission';
|
|
5
|
+
export { useGetUnsubscribeListByIdentifier, useGetUnsubscribePreferences, useGetUnsubscribeList, useGetUnsubscribeListPermission, };
|
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
import { useGetUnsubscribeListByIdentifier } from './useGetUnsubscribeListByIdentifier';
|
|
2
|
+
import { useGetUnsubscribeList } from './useGetUnsubscribeList';
|
|
3
|
+
import { useGetUnsubscribePreferences } from './useGetUnsubscribePreferences';
|
|
4
|
+
import { useGetUnsubscribeListPermission } from './useGetUnsubscribeListPermission';
|
|
5
|
+
export { useGetUnsubscribeListByIdentifier, useGetUnsubscribePreferences, useGetUnsubscribeList, useGetUnsubscribeListPermission, };
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import { UseQueryOptions } from '@tanstack/react-query';
|
|
2
|
+
import { TGetUnsubscribeListArgs, TUnsubscribePayloadInfo } from '../../services/Unsubscribe';
|
|
3
|
+
interface UseGetUnsubscribeListProps {
|
|
4
|
+
args: TGetUnsubscribeListArgs;
|
|
5
|
+
options?: UseQueryOptions<any, Error, any>;
|
|
6
|
+
}
|
|
7
|
+
export declare const useGetUnsubscribeList: ({ args, options }: UseGetUnsubscribeListProps, infos: TUnsubscribePayloadInfo) => import("@tanstack/react-query").UseQueryResult<any, Error>;
|
|
8
|
+
export {};
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
// Libraries
|
|
2
|
+
import { useQuery } from '@tanstack/react-query';
|
|
3
|
+
// Services
|
|
4
|
+
// import { TGetUnsubscribeListArgs, unsubscribeServices } from 'app/services/Unsubscribe';
|
|
5
|
+
import { unsubscribeServices, } from '../../services/Unsubscribe';
|
|
6
|
+
// Constants
|
|
7
|
+
import { QUERY_KEYS } from '../../constants';
|
|
8
|
+
export const useGetUnsubscribeList = ({ args, options }, infos) => useQuery({
|
|
9
|
+
queryKey: [QUERY_KEYS.GET_UNSUBSCRIBE_LIST, args, options, infos],
|
|
10
|
+
queryFn: async () => unsubscribeServices.getUnsubscribeList(args, infos),
|
|
11
|
+
onSuccess: data => {
|
|
12
|
+
if (!data)
|
|
13
|
+
return [];
|
|
14
|
+
const unsubscribedList = data?.entries[0] || [];
|
|
15
|
+
return unsubscribedList.sort((a, b) => Number(a.list_id) - Number(b.list_id));
|
|
16
|
+
},
|
|
17
|
+
...options,
|
|
18
|
+
});
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import { UseQueryOptions } from '@tanstack/react-query';
|
|
2
|
+
import { TGetUnsubscribeListByIdentifierArgs, TUnsubscribePayloadInfo } from '../../services/Unsubscribe';
|
|
3
|
+
interface UseGetUnsubscribeListByIdentifierProps {
|
|
4
|
+
args: TGetUnsubscribeListByIdentifierArgs;
|
|
5
|
+
options?: UseQueryOptions<any, Error, any>;
|
|
6
|
+
}
|
|
7
|
+
export declare const useGetUnsubscribeListByIdentifier: ({ args, options }: UseGetUnsubscribeListByIdentifierProps, infos: TUnsubscribePayloadInfo) => import("@tanstack/react-query").UseQueryResult<any, Error>;
|
|
8
|
+
export {};
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
// Libraries
|
|
2
|
+
import { useQuery } from '@tanstack/react-query';
|
|
3
|
+
// Services
|
|
4
|
+
import { unsubscribeServices, } from '../../services/Unsubscribe';
|
|
5
|
+
// Constants
|
|
6
|
+
import { QUERY_KEYS } from '../../constants';
|
|
7
|
+
export const useGetUnsubscribeListByIdentifier = ({ args, options }, infos) => useQuery({
|
|
8
|
+
queryKey: [QUERY_KEYS.GET_UNSUBSCRIBE_LIST_BY_IDENTIFIER, args, options, infos],
|
|
9
|
+
queryFn: () => unsubscribeServices.getUnsubscribeListByIdentifier(args, infos),
|
|
10
|
+
...options,
|
|
11
|
+
});
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import { UseQueryOptions } from '@tanstack/react-query';
|
|
2
|
+
import { TGetUnsubscribeListPermissionArgs, TUnsubscribePayloadInfo } from '../../services/Unsubscribe';
|
|
3
|
+
interface UseGetUnsubscribeListPermissionProps {
|
|
4
|
+
args: TGetUnsubscribeListPermissionArgs;
|
|
5
|
+
options?: UseQueryOptions<any, Error, any>;
|
|
6
|
+
}
|
|
7
|
+
export declare const useGetUnsubscribeListPermission: ({ args, options }: UseGetUnsubscribeListPermissionProps, infos: TUnsubscribePayloadInfo) => import("@tanstack/react-query").UseQueryResult<any, Error>;
|
|
8
|
+
export {};
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
// Libraries
|
|
2
|
+
import { useQuery } from '@tanstack/react-query';
|
|
3
|
+
// Services
|
|
4
|
+
import { unsubscribeServices, } from '../../services/Unsubscribe';
|
|
5
|
+
// Constants
|
|
6
|
+
import { QUERY_KEYS } from '../../constants';
|
|
7
|
+
export const useGetUnsubscribeListPermission = ({ args, options }, infos) => useQuery({
|
|
8
|
+
queryKey: [QUERY_KEYS.GET_UNSUBSCRIBE_LIST_PERMISSION, args, options, infos],
|
|
9
|
+
queryFn: async () => unsubscribeServices.getUnsubscribeListPermission(args, infos),
|
|
10
|
+
onSuccess: data => {
|
|
11
|
+
if (!data)
|
|
12
|
+
return [];
|
|
13
|
+
const unsubscribedList = data?.entries[0] || [];
|
|
14
|
+
return unsubscribedList.sort((a, b) => Number(a.list_id) - Number(b.list_id));
|
|
15
|
+
},
|
|
16
|
+
...options,
|
|
17
|
+
});
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
import { UseQueryOptions } from '@tanstack/react-query';
|
|
2
|
+
import { GetUnsubscribePreferencesArgs, TUnsubscribePayloadInfo } from '../../services/Unsubscribe';
|
|
3
|
+
interface UseGetUnsubscribePreferencesProps {
|
|
4
|
+
args: GetUnsubscribePreferencesArgs;
|
|
5
|
+
options?: UseQueryOptions<any, Error, any>;
|
|
6
|
+
}
|
|
7
|
+
/**
|
|
8
|
+
* React Query hook to get unsubscribe preferences by given identifier
|
|
9
|
+
*
|
|
10
|
+
* @example
|
|
11
|
+
* const { data, isLoading } = useGetUnsubscribePreferences({
|
|
12
|
+
* args: {
|
|
13
|
+
* id: '1234567890',
|
|
14
|
+
* },
|
|
15
|
+
* });
|
|
16
|
+
*
|
|
17
|
+
* @param {UseGetUnsubscribePreferencesProps} props
|
|
18
|
+
* @param {GetUnsubscribePreferencesArgs} props.args - Arguments to get unsubscribe preferences
|
|
19
|
+
* @param {UseQueryOptions<any, Error, any>} [props.options] - Options for React Query
|
|
20
|
+
* @returns {UseQueryResult<any, Error>} - Response data and meta data
|
|
21
|
+
*/
|
|
22
|
+
export declare const useGetUnsubscribePreferences: ({ args, options }: UseGetUnsubscribePreferencesProps, infos: TUnsubscribePayloadInfo) => import("@tanstack/react-query").UseQueryResult<any, Error>;
|
|
23
|
+
export {};
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
// Libraries
|
|
2
|
+
import { useQuery } from '@tanstack/react-query';
|
|
3
|
+
// Services
|
|
4
|
+
import { unsubscribeServices, } from '../../services/Unsubscribe';
|
|
5
|
+
// Constants
|
|
6
|
+
import { QUERY_KEYS } from '../../constants';
|
|
7
|
+
/**
|
|
8
|
+
* React Query hook to get unsubscribe preferences by given identifier
|
|
9
|
+
*
|
|
10
|
+
* @example
|
|
11
|
+
* const { data, isLoading } = useGetUnsubscribePreferences({
|
|
12
|
+
* args: {
|
|
13
|
+
* id: '1234567890',
|
|
14
|
+
* },
|
|
15
|
+
* });
|
|
16
|
+
*
|
|
17
|
+
* @param {UseGetUnsubscribePreferencesProps} props
|
|
18
|
+
* @param {GetUnsubscribePreferencesArgs} props.args - Arguments to get unsubscribe preferences
|
|
19
|
+
* @param {UseQueryOptions<any, Error, any>} [props.options] - Options for React Query
|
|
20
|
+
* @returns {UseQueryResult<any, Error>} - Response data and meta data
|
|
21
|
+
*/
|
|
22
|
+
export const useGetUnsubscribePreferences = ({ args, options }, infos) => useQuery({
|
|
23
|
+
queryKey: [QUERY_KEYS.GET_UNSUBSCRIBE_PREFERENCES],
|
|
24
|
+
queryFn: () => unsubscribeServices.getUnsubscribePreferences(args, infos),
|
|
25
|
+
...options,
|
|
26
|
+
});
|
|
@@ -0,0 +1,41 @@
|
|
|
1
|
+
import { PayloadInfo } from '../../types';
|
|
2
|
+
export type GetUnsubscribePreferencesArgs = {
|
|
3
|
+
id: string;
|
|
4
|
+
};
|
|
5
|
+
export type TGetUnsubscribeListByIdentifierArgs = {
|
|
6
|
+
data: {
|
|
7
|
+
identifier: string;
|
|
8
|
+
type: 'email' | 'phone';
|
|
9
|
+
portalId: number;
|
|
10
|
+
listId: (number | string)[];
|
|
11
|
+
};
|
|
12
|
+
};
|
|
13
|
+
export type TUpdateUnsubscribePreferencesListArgs = {
|
|
14
|
+
data: {
|
|
15
|
+
identifier: string;
|
|
16
|
+
type: 'email' | 'phone';
|
|
17
|
+
portalId: number;
|
|
18
|
+
journeyId: number;
|
|
19
|
+
campaignId: number;
|
|
20
|
+
variantId: number;
|
|
21
|
+
config: {
|
|
22
|
+
listId: number;
|
|
23
|
+
status: 'resubscribe' | 'unsubscribe';
|
|
24
|
+
}[];
|
|
25
|
+
};
|
|
26
|
+
};
|
|
27
|
+
export type TGetUnsubscribeListArgs = {
|
|
28
|
+
data: {
|
|
29
|
+
type: 'email' | 'sms' | 'whatsapp';
|
|
30
|
+
portalId: number;
|
|
31
|
+
};
|
|
32
|
+
};
|
|
33
|
+
export type TGetUnsubscribeListPermissionArgs = TGetUnsubscribeListArgs;
|
|
34
|
+
export type TUnsubscribePayloadInfo = Required<PayloadInfo>;
|
|
35
|
+
export declare const unsubscribeServices: {
|
|
36
|
+
getUnsubscribePreferences: ({ id }: GetUnsubscribePreferencesArgs, infos: TUnsubscribePayloadInfo) => Promise<any>;
|
|
37
|
+
getUnsubscribeListByIdentifier: ({ data }: TGetUnsubscribeListByIdentifierArgs, infos: TUnsubscribePayloadInfo) => Promise<any>;
|
|
38
|
+
updateUnsubscribePreferencesList: ({ data }: TUpdateUnsubscribePreferencesListArgs, infos: TUnsubscribePayloadInfo) => Promise<any>;
|
|
39
|
+
getUnsubscribeList: ({ data }: TGetUnsubscribeListArgs, infos: TUnsubscribePayloadInfo) => Promise<any>;
|
|
40
|
+
getUnsubscribeListPermission: ({ data }: TGetUnsubscribeListPermissionArgs, infos: TUnsubscribePayloadInfo) => Promise<any>;
|
|
41
|
+
};
|
|
@@ -0,0 +1,78 @@
|
|
|
1
|
+
// Libraries
|
|
2
|
+
import { services } from '..';
|
|
3
|
+
const UNSUBSCRIBE_URL = `/email-template/unsubscribe`;
|
|
4
|
+
export const unsubscribeServices = {
|
|
5
|
+
getUnsubscribePreferences: async ({ id }, infos) => {
|
|
6
|
+
try {
|
|
7
|
+
const response = await services.mediaTemplateDesign.get({
|
|
8
|
+
API_HOST: `${infos.url}${UNSUBSCRIBE_URL}/get-detail`,
|
|
9
|
+
id,
|
|
10
|
+
}, infos);
|
|
11
|
+
if (response) {
|
|
12
|
+
return response.data?.data || {};
|
|
13
|
+
}
|
|
14
|
+
return {};
|
|
15
|
+
}
|
|
16
|
+
catch (error) {
|
|
17
|
+
return new Promise((_, reject) => {
|
|
18
|
+
reject(error);
|
|
19
|
+
});
|
|
20
|
+
}
|
|
21
|
+
},
|
|
22
|
+
getUnsubscribeListByIdentifier: async ({ data }, infos) => {
|
|
23
|
+
try {
|
|
24
|
+
const response = await services.mediaTemplateDesign.create({
|
|
25
|
+
API_HOST: `${infos.url}${UNSUBSCRIBE_URL}/get-by-identifier`,
|
|
26
|
+
...data,
|
|
27
|
+
}, infos);
|
|
28
|
+
return response.data?.data || [];
|
|
29
|
+
}
|
|
30
|
+
catch (error) {
|
|
31
|
+
return new Promise((_, reject) => {
|
|
32
|
+
reject(error);
|
|
33
|
+
});
|
|
34
|
+
}
|
|
35
|
+
},
|
|
36
|
+
updateUnsubscribePreferencesList: async ({ data }, infos) => {
|
|
37
|
+
try {
|
|
38
|
+
const response = await services.mediaTemplateDesign.create({
|
|
39
|
+
API_HOST: `${infos.url}${UNSUBSCRIBE_URL}/save`,
|
|
40
|
+
...data,
|
|
41
|
+
}, infos);
|
|
42
|
+
return response.data?.data || [];
|
|
43
|
+
}
|
|
44
|
+
catch (error) {
|
|
45
|
+
return new Promise((_, reject) => {
|
|
46
|
+
reject(error);
|
|
47
|
+
});
|
|
48
|
+
}
|
|
49
|
+
},
|
|
50
|
+
getUnsubscribeList: async ({ data }, infos) => {
|
|
51
|
+
try {
|
|
52
|
+
const response = await services.mediaTemplateDesign.getList({
|
|
53
|
+
API_HOST: `${infos.url}${UNSUBSCRIBE_URL}/get-unsubscribe-list`,
|
|
54
|
+
...data,
|
|
55
|
+
}, infos);
|
|
56
|
+
return response.data?.data || [];
|
|
57
|
+
}
|
|
58
|
+
catch (error) {
|
|
59
|
+
return new Promise((_, reject) => {
|
|
60
|
+
reject(error);
|
|
61
|
+
});
|
|
62
|
+
}
|
|
63
|
+
},
|
|
64
|
+
getUnsubscribeListPermission: async ({ data }, infos) => {
|
|
65
|
+
try {
|
|
66
|
+
const response = await services.mediaTemplateDesign.getList({
|
|
67
|
+
API_HOST: `${infos.url}${UNSUBSCRIBE_URL}/get-unsubscribe-list-permissions`,
|
|
68
|
+
...data,
|
|
69
|
+
}, infos);
|
|
70
|
+
return response.data?.data || [];
|
|
71
|
+
}
|
|
72
|
+
catch (error) {
|
|
73
|
+
return new Promise((_, reject) => {
|
|
74
|
+
reject(error);
|
|
75
|
+
});
|
|
76
|
+
}
|
|
77
|
+
},
|
|
78
|
+
};
|
package/es/types/index.d.ts
CHANGED
package/es/types/index.js
CHANGED
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
export type TTab = {
|
|
2
|
+
activePanel?: string;
|
|
3
|
+
onChangeActivePanel?: (panelKey: any) => void;
|
|
4
|
+
};
|
|
5
|
+
export type TUnsubscribeList = {
|
|
6
|
+
status: string;
|
|
7
|
+
list_name: string;
|
|
8
|
+
type: string;
|
|
9
|
+
list_id: string;
|
|
10
|
+
description: string;
|
|
11
|
+
};
|
|
12
|
+
export type TUnsubscribeType = 'email' | 'sms' | 'whatsapp';
|
|
13
|
+
export type TUnsubscribeSettings = {
|
|
14
|
+
unsubscribePreferences: {
|
|
15
|
+
landingPageType?: string;
|
|
16
|
+
segmentId: number | string | null;
|
|
17
|
+
unsubscribeListId: number | string | null;
|
|
18
|
+
logo: string;
|
|
19
|
+
title: string;
|
|
20
|
+
description: string;
|
|
21
|
+
customLink: string;
|
|
22
|
+
haveResubscribeButton?: boolean;
|
|
23
|
+
preferenceListIds: string[] | undefined;
|
|
24
|
+
};
|
|
25
|
+
};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
package/es/utils/common.d.ts
CHANGED
|
@@ -166,3 +166,4 @@ export declare function numberWithCommas(n: number): string;
|
|
|
166
166
|
export declare const multiPercentageValue: (value?: string) => string;
|
|
167
167
|
export declare const antsomiClsx: (componentName: string) => (className: string) => string;
|
|
168
168
|
export declare function arrayToMapByProperty<T extends object, K extends keyof T>(array: T[], propertyName: K): Map<T[K], T>;
|
|
169
|
+
export declare function compareStrings(a: any, b: any): number;
|
package/es/utils/common.js
CHANGED
|
@@ -757,3 +757,6 @@ export function arrayToMapByProperty(array, propertyName) {
|
|
|
757
757
|
// new Map() có thể nhận mảng này để khởi tạo Map
|
|
758
758
|
return new Map(Object.entries(keyedObject));
|
|
759
759
|
}
|
|
760
|
+
export function compareStrings(a, b) {
|
|
761
|
+
return String(a).localeCompare(String(b));
|
|
762
|
+
}
|