@antscorp/antsomi-ui 1.3.5-beta.983 → 1.3.5-beta.985
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/AddDynamicContent/components/DisplayFormat/DisplayFormat.d.ts +0 -1
- package/es/components/molecules/InputSelectAttribute/index.d.ts +1 -1
- package/es/components/molecules/InputSelectAttribute/index.js +15 -10
- package/es/components/molecules/SelectV2/styled.d.ts +3 -1
- package/es/components/molecules/SelectV2/styled.js +2 -2
- package/es/components/molecules/TagifyInput/TagifyInput.js +23 -30
- package/es/components/molecules/TagifyInput/patternHandlers.d.ts +4 -9
- package/es/components/molecules/TagifyInput/patternHandlers.js +46 -66
- package/es/components/molecules/TagifyInput/utils.js +1 -1
- package/es/components/template/TemplateListing/Loadable.d.ts +0 -1
- package/package.json +1 -1
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
import { jsx as _jsx, jsxs as _jsxs, Fragment as _Fragment } from "react/jsx-runtime";
|
|
2
2
|
// Libraries
|
|
3
3
|
import { memo, useCallback, useEffect, useMemo, useState } from 'react';
|
|
4
|
-
import { get, keyBy } from 'lodash';
|
|
5
|
-
import { Form, Select, Typography } from 'antd';
|
|
4
|
+
import { get, isUndefined, keyBy } from 'lodash';
|
|
5
|
+
import { Flex, Form, Select, Tooltip, Typography } from 'antd';
|
|
6
6
|
// Translations
|
|
7
7
|
import { translate, translations } from '@antscorp/antsomi-ui/es/locales';
|
|
8
8
|
// Components
|
|
@@ -10,10 +10,12 @@ import Icon from '@antscorp/icons';
|
|
|
10
10
|
import { ModalV2 } from '../ModalV2';
|
|
11
11
|
import { StyledTag as Tag } from '@antscorp/antsomi-ui/es/components/molecules/SelectV2/styled';
|
|
12
12
|
import { StyledSelect } from './styled';
|
|
13
|
+
import { EmptyData } from '../EmptyData';
|
|
14
|
+
import { Dashboard30Icon, ErrorIcon } from '../../icons';
|
|
13
15
|
// Constants
|
|
14
16
|
import { THEME } from '@antscorp/antsomi-ui/es/constants';
|
|
15
17
|
const InputSelectAttribute = (props) => {
|
|
16
|
-
const { value, errorMsg, label,
|
|
18
|
+
const { value, errorMsg, label, sourceOptions = [], codeOptions = [], codeOptionsInitial = [], onChange, onChangeSelectSource, } = props;
|
|
17
19
|
const [form] = Form.useForm();
|
|
18
20
|
// States
|
|
19
21
|
const [openModal, setOpenModal] = useState(false);
|
|
@@ -28,13 +30,14 @@ const InputSelectAttribute = (props) => {
|
|
|
28
30
|
});
|
|
29
31
|
// Effects
|
|
30
32
|
useEffect(() => {
|
|
31
|
-
if (attributeState.code === ''
|
|
33
|
+
if (attributeState.code === '' ||
|
|
34
|
+
!codeOptions.find(option => option.value === attributeState.code)) {
|
|
32
35
|
form.setFieldsValue({ code: codeOptions[0]?.value });
|
|
33
36
|
}
|
|
34
37
|
}, [attributeState, codeOptions, form]);
|
|
35
38
|
// Memoized
|
|
36
39
|
const mapCodeOpts = useMemo(() => keyBy(codeOptions, 'value'), [codeOptions]);
|
|
37
|
-
const
|
|
40
|
+
const mapCodeOriginOpts = useMemo(() => keyBy(codeOptionsInitial, 'value'), [codeOptionsInitial]);
|
|
38
41
|
const onOpenModal = useCallback(() => {
|
|
39
42
|
setOpenModal(true);
|
|
40
43
|
}, []);
|
|
@@ -66,6 +69,8 @@ const InputSelectAttribute = (props) => {
|
|
|
66
69
|
let element = null;
|
|
67
70
|
const isObjValue = value && typeof value !== 'string';
|
|
68
71
|
if (openModal || isObjValue) {
|
|
72
|
+
const isErrorTag = (isObjValue &&
|
|
73
|
+
isUndefined(get(mapCodeOriginOpts, [value.code])));
|
|
69
74
|
element = (_jsxs("div", { style: {
|
|
70
75
|
display: 'flex',
|
|
71
76
|
alignItems: 'center',
|
|
@@ -73,21 +78,21 @@ const InputSelectAttribute = (props) => {
|
|
|
73
78
|
height: 32,
|
|
74
79
|
padding: '4px 12px 4px 4px',
|
|
75
80
|
borderBottom: `1px solid ${errorMsg ? THEME.token?.colorError : THEME.token?.blue1}`,
|
|
76
|
-
}, children: [_jsx("div", { style: { width: '100%', cursor: 'pointer' }, onClick: onOpenModal, children: isObjValue && (_jsx(Tag, { children: get(mapCodeOpts, [value.code, 'label'],
|
|
81
|
+
}, children: [_jsx("div", { style: { width: '100%', cursor: 'pointer' }, onClick: onOpenModal, children: isObjValue && (_jsx(Tag, { isError: isErrorTag, children: isErrorTag ? (_jsxs(Flex, { gap: 5, align: "center", children: ["Unknown", _jsx(Tooltip, { title: "The used dynamic content is removed", children: _jsx(ErrorIcon, { size: 16 }) })] })) : (get(mapCodeOpts, [value.code, 'label'], mapCodeOriginOpts[value.code]?.label)) })) }), _jsx(Icon, { type: "icon-ants-remove", style: { fontSize: 10, color: '#222', cursor: 'pointer' }, onClick: onDeselect })] }));
|
|
77
82
|
}
|
|
78
83
|
else {
|
|
79
|
-
element = (_jsx(StyledSelect, { mode: "multiple", options: [{ value: '', label:
|
|
84
|
+
element = (_jsx(StyledSelect, { mode: "multiple", options: [{ value: '', label: 'Or select a field' }], notFoundContent: null, onSelect: onOpenModal, style: { width: '100%', borderTop: 'none', borderLeft: 'none', borderRight: 'none' }, onDeselect: onDeselect, autoClearSearchValue: false, searchValue: typeof value === 'string' ? value : '', onSearch: onChangeInput, status: errorMsg ? 'error' : undefined, placeholder: typeof value === 'string' ? value : translate(translations.inputYourValue.title), "$isPlaceholder": !value, "$isError": !!errorMsg, dropdownStyle: {
|
|
80
85
|
...(openModal ? { display: 'none' } : {}),
|
|
81
86
|
} }));
|
|
82
87
|
}
|
|
83
88
|
return element;
|
|
84
89
|
};
|
|
85
|
-
return (_jsxs(_Fragment, { children: [renderInput(), errorMsg ? (_jsx(Typography.Text, { style: { marginLeft: 8, color: THEME.token?.red8, marginTop: 5 }, children: errorMsg })) : null, _jsx(ModalV2, { title: translate(translations._PREDICT_MODEL_SELECT_ATTRIBUTE, 'Select attribute'), okText: translate(translations._ACT_APPLY, 'Apply'), open: openModal, onOk: onOk, onCancel: onHideModal, destroyOnClose: true, children: _jsxs(Form, { colon: false, form: form, initialValues: {
|
|
90
|
+
return (_jsxs(_Fragment, { children: [renderInput(), errorMsg ? (_jsx(Typography.Text, { style: { marginLeft: 8, color: THEME.token?.red8, marginTop: 5 }, children: errorMsg })) : null, _jsx(ModalV2, { title: translate(translations._PREDICT_MODEL_SELECT_ATTRIBUTE, 'Select attribute'), okText: translate(translations._ACT_APPLY, 'Apply'), open: openModal, onOk: onOk, onCancel: onHideModal, destroyOnClose: true, centered: true, children: _jsxs(Form, { colon: false, form: form, initialValues: {
|
|
86
91
|
sources: attributeState.source || sourceOptions[0]?.value,
|
|
87
92
|
code: attributeState.code || codeOptions[0]?.value,
|
|
88
|
-
}, children: [_jsx(Form.Item, { label: translate(translations._TITL_PERSONALIZATION_TYPE, 'Content Source'), name: "sources", required: true, labelCol: { span: 6 }, labelAlign: "left", rules: [{ required: true, message: 'Please select field!' }], children: _jsx(Select, { suffixIcon: _jsx(Icon, { type: "icon-ants-expand-more", style: { fontSize: '20px', color: THEME.token?.colorIcon } }), options: sourceOptions, value: attributeState.source, onChange: newValue => {
|
|
93
|
+
}, children: [_jsx(Form.Item, { label: translate(translations._TITL_PERSONALIZATION_TYPE, 'Content Source'), name: "sources", required: true, labelCol: { span: 6 }, labelAlign: "left", rules: [{ required: true, message: 'Please select field!' }], children: _jsx(Select, { suffixIcon: _jsx(Icon, { type: "icon-ants-expand-more", style: { fontSize: '20px', color: THEME.token?.colorIcon } }), options: sourceOptions, placeholder: "Please select an item", value: attributeState.source, onChange: newValue => {
|
|
89
94
|
setAttributeState(state => ({ ...state, code: '', source: newValue }));
|
|
90
95
|
onChangeSelectSource(newValue);
|
|
91
|
-
} }) }), _jsx(Form.Item, { label: label || 'Allocated Code', required: true, labelCol: { span: 6 }, labelAlign: "left", name: "code", rules: [{ required: true, message: 'Please select field!' }], children: _jsx(Select, { suffixIcon: _jsx(Icon, { type: "icon-ants-expand-more", style: { fontSize: '20px', color: THEME.token?.colorIcon } }), value: attributeState.code, options: codeOptions }) })] }) })] }));
|
|
96
|
+
} }) }), _jsx(Form.Item, { label: label || 'Allocated Code', required: true, labelCol: { span: 6 }, labelAlign: "left", name: "code", rules: [{ required: true, message: 'Please select field!' }], children: _jsx(Select, { suffixIcon: _jsx(Icon, { type: "icon-ants-expand-more", style: { fontSize: '20px', color: THEME.token?.colorIcon } }), notFoundContent: _jsx(EmptyData, { size: "small", icon: _jsx(Dashboard30Icon, {}), description: "No personalized content in this journey" }), placeholder: "Please select an item", value: attributeState.code, options: codeOptions }) })] }) })] }));
|
|
92
97
|
};
|
|
93
98
|
export default memo(InputSelectAttribute);
|
|
@@ -9,7 +9,9 @@ export declare const StyledSelect: import("styled-components").StyledComponent<(
|
|
|
9
9
|
OptGroup: import("rc-select/lib/OptGroup").OptionGroupFC;
|
|
10
10
|
_InternalPanelDoNotUseOrYouWillBeFired: (props: import("antd/es/_util/type").AnyObject) => import("react").JSX.Element;
|
|
11
11
|
}, any, {}, never>;
|
|
12
|
-
export declare const StyledTag: import("styled-components").StyledComponent<import("antd").TagType, any, {
|
|
12
|
+
export declare const StyledTag: import("styled-components").StyledComponent<import("antd").TagType, any, {
|
|
13
|
+
isError?: boolean | undefined;
|
|
14
|
+
}, never>;
|
|
13
15
|
export declare const CloseButton: import("styled-components").StyledComponent<"div", any, {
|
|
14
16
|
borderColor?: any;
|
|
15
17
|
}, never>;
|
|
@@ -105,8 +105,8 @@ export const StyledTag = styled(Tag) `
|
|
|
105
105
|
margin-right: 5px !important;
|
|
106
106
|
padding: 5px 10px !important;
|
|
107
107
|
border-radius: 15px !important;
|
|
108
|
-
border: none !important;
|
|
109
|
-
background-color: ${THEME.token?.blue2} !important;
|
|
108
|
+
border: ${p => (p.isError ? `1px solid ${THEME.token?.colorError}` : 'none')} !important;
|
|
109
|
+
background-color: ${p => (p.isError ? THEME.token?.bw0 : THEME.token?.blue2)} !important;
|
|
110
110
|
cursor: pointer !important;
|
|
111
111
|
|
|
112
112
|
.antsomi-tag-close-icon {
|
|
@@ -19,7 +19,7 @@ import { TagTextArea, TagifyWrapper, WrapperPlaceHolder } from './styled';
|
|
|
19
19
|
import { parseTagStringToTagify, convertInputStringToOriginal, emojiManufacturer, getEmojiTag, isPersonalizeTagType, generateTagContent, unescapeString, hasLineBreak, selectRange, isTagClickable, findURLInTextNodes, getAttributesString, isAnchorNodeChildOfElement, isShortLinkTagType, isCustomTagType, sanitizeTagAttributes, getTagAttributes, applyTagAttributes, getTagContentAttributes, } from './utils';
|
|
20
20
|
import { acceptablePatternChecking, detectURLRegex, getCachedRegex, getCustomTagId, getPersonalizeTagInfo, getShortLinkTagInfo, patternHandlers, } from './patternHandlers';
|
|
21
21
|
// Constants
|
|
22
|
-
import { DETECT_LINK, EMOJI, PERSONALIZE_PTN,
|
|
22
|
+
import { DETECT_LINK, EMOJI, PERSONALIZE_PTN, SHORT_LINK, SHORT_LINK_PTN, SHORT_LINK_V2, TAG_TYPE, defaultCssVariables, tagifyDefaultProps, TAG_CUSTOM_ATTRIBUTES, } from './constants';
|
|
23
23
|
const { CUSTOM_TAG } = TAG_TYPE;
|
|
24
24
|
const { READONLY_TAG, INVALID_TAG, MESSAGE_TAG, FORCE_SHOW_TOOLTIP, ERROR_TAG, WARNING_TAG } = TAG_CUSTOM_ATTRIBUTES;
|
|
25
25
|
const TagifyInput = forwardRef((props, ref) => {
|
|
@@ -535,8 +535,8 @@ const TagifyInput = forwardRef((props, ref) => {
|
|
|
535
535
|
/*
|
|
536
536
|
* Any map attribute change will sync label of the tags
|
|
537
537
|
*/
|
|
538
|
-
const makeValidLabelTags = useCallback((attributes, errorAttributes
|
|
539
|
-
if (tagifyRef.current
|
|
538
|
+
const makeValidLabelTags = useCallback((attributes, errorAttributes) => {
|
|
539
|
+
if (tagifyRef.current) {
|
|
540
540
|
const tagElements = tagifyRef.current.getTagElms();
|
|
541
541
|
const { pattern, name: cachePatternName, acceptablePattern: acceptableType, } = patternHandlers[PERSONALIZE_PTN];
|
|
542
542
|
tagElements.forEach(tagElement => {
|
|
@@ -559,8 +559,7 @@ const TagifyInput = forwardRef((props, ref) => {
|
|
|
559
559
|
while ((match = regex.exec(value)) !== null) {
|
|
560
560
|
const [, personalizeContent] = match;
|
|
561
561
|
const [tagCode] = personalizeContent.split('||');
|
|
562
|
-
const { label: tagLabel,
|
|
563
|
-
const isPromotionCode = type === PROMOTION_CODE;
|
|
562
|
+
const { label: tagLabel, type, status, statusMsg, } = getPersonalizeTagInfo(tagCode, attributes, errorAttributes);
|
|
564
563
|
const tagTextNode = tagifyRef.current?.getTagTextNode(tagElement);
|
|
565
564
|
/*
|
|
566
565
|
* Just only update to the correct text of the tag
|
|
@@ -575,22 +574,14 @@ const TagifyInput = forwardRef((props, ref) => {
|
|
|
575
574
|
}
|
|
576
575
|
// Remove all existing attributes
|
|
577
576
|
sanitizeTagAttributes(tagElement);
|
|
578
|
-
//
|
|
579
|
-
|
|
580
|
-
|
|
581
|
-
|
|
582
|
-
|
|
583
|
-
|
|
584
|
-
|
|
585
|
-
|
|
586
|
-
tagElement.setAttribute(MESSAGE_TAG, message);
|
|
587
|
-
}
|
|
588
|
-
else if (!isValid) {
|
|
589
|
-
tagElement.setAttribute(READONLY_TAG, 'true');
|
|
590
|
-
tagElement.setAttribute(INVALID_TAG, 'true');
|
|
591
|
-
tagElement.setAttribute(MESSAGE_TAG, message);
|
|
592
|
-
}
|
|
593
|
-
}
|
|
577
|
+
// Update new tag attributes
|
|
578
|
+
const tagAttributes = getTagAttributes({
|
|
579
|
+
type: type,
|
|
580
|
+
status,
|
|
581
|
+
statusMsg,
|
|
582
|
+
displayName: tagLabel,
|
|
583
|
+
});
|
|
584
|
+
applyTagAttributes(tagElement, tagAttributes);
|
|
594
585
|
}
|
|
595
586
|
}
|
|
596
587
|
}
|
|
@@ -600,7 +591,7 @@ const TagifyInput = forwardRef((props, ref) => {
|
|
|
600
591
|
if (!isAccepted)
|
|
601
592
|
return;
|
|
602
593
|
const { url, shortener, label } = tagData;
|
|
603
|
-
const { label: tagLabel,
|
|
594
|
+
const { label: tagLabel, type: tagType, status, statusMsg, } = getShortLinkTagInfo({
|
|
604
595
|
type,
|
|
605
596
|
label,
|
|
606
597
|
shortener,
|
|
@@ -617,11 +608,14 @@ const TagifyInput = forwardRef((props, ref) => {
|
|
|
617
608
|
tagTextNode.textContent = tagLabel;
|
|
618
609
|
// Remove all existing attributes
|
|
619
610
|
sanitizeTagAttributes(tagElement);
|
|
620
|
-
//
|
|
621
|
-
|
|
622
|
-
|
|
623
|
-
|
|
624
|
-
|
|
611
|
+
// Update new tag attributes
|
|
612
|
+
const tagAttributes = getTagAttributes({
|
|
613
|
+
type: type,
|
|
614
|
+
status,
|
|
615
|
+
statusMsg,
|
|
616
|
+
displayName: tagLabel,
|
|
617
|
+
});
|
|
618
|
+
applyTagAttributes(tagElement, tagAttributes);
|
|
625
619
|
}
|
|
626
620
|
}
|
|
627
621
|
}
|
|
@@ -826,7 +820,7 @@ const TagifyInput = forwardRef((props, ref) => {
|
|
|
826
820
|
* Need to sync label of the tags if any map attribute is changed to make correct label
|
|
827
821
|
* */
|
|
828
822
|
useDeepCompareEffect(() => {
|
|
829
|
-
makeValidLabelTags(mapAttributes, mapErrorAttributes
|
|
823
|
+
makeValidLabelTags(mapAttributes, mapErrorAttributes);
|
|
830
824
|
}, [mapAttributes, mapErrorAttributes, makeValidLabelTags]);
|
|
831
825
|
useLayoutEffect(() => {
|
|
832
826
|
if (tagProperties) {
|
|
@@ -882,7 +876,7 @@ const TagifyInput = forwardRef((props, ref) => {
|
|
|
882
876
|
const content = parseTagStringToTagify(textValue, acceptableTagPattern);
|
|
883
877
|
tagifyRef.current.loadOriginalValues(content);
|
|
884
878
|
// Need to sync label of the tags if any map attribute is changed to make correct label
|
|
885
|
-
makeValidLabelTags(mapAttributes, mapErrorAttributes
|
|
879
|
+
makeValidLabelTags(mapAttributes, mapErrorAttributes);
|
|
886
880
|
}
|
|
887
881
|
}
|
|
888
882
|
}, [
|
|
@@ -891,7 +885,6 @@ const TagifyInput = forwardRef((props, ref) => {
|
|
|
891
885
|
mapErrorAttributes,
|
|
892
886
|
escapeHTML,
|
|
893
887
|
acceptableTagPattern,
|
|
894
|
-
tagProperties,
|
|
895
888
|
makeValidLabelTags,
|
|
896
889
|
]);
|
|
897
890
|
useEffect(() => {
|
|
@@ -1,14 +1,9 @@
|
|
|
1
|
-
import type { AcceptablePattern, MapAttributesProps, PatterTagName, PatternHandlerWrapper,
|
|
1
|
+
import type { AcceptablePattern, MapAttributesProps, PatterTagName, PatternHandlerWrapper, TagTypeProperty } from './types';
|
|
2
2
|
interface TagInfo {
|
|
3
3
|
label: string;
|
|
4
4
|
type: string;
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
isRemoved?: boolean;
|
|
8
|
-
canView?: boolean;
|
|
9
|
-
isArchived?: boolean;
|
|
10
|
-
isActive?: boolean;
|
|
11
|
-
isExpired?: boolean;
|
|
5
|
+
status: string;
|
|
6
|
+
statusMsg: string;
|
|
12
7
|
}
|
|
13
8
|
/**
|
|
14
9
|
* Retrieves a cached regular expression or compiles and caches it if not found.
|
|
@@ -29,7 +24,7 @@ export declare function acceptablePatternChecking(pattern: AcceptablePattern, ac
|
|
|
29
24
|
* @returns {string} The extracted custom tag ID if the tag type is a custom tag; otherwise, empty string.
|
|
30
25
|
*/
|
|
31
26
|
export declare const getCustomTagId: (tagType: TagTypeProperty, mergeCode: string) => string;
|
|
32
|
-
export declare const getPersonalizeTagInfo: (originalTag: string, mapAttributes: MapAttributesProps, mapErrorAttributes: MapAttributesProps
|
|
27
|
+
export declare const getPersonalizeTagInfo: (originalTag: string, mapAttributes: MapAttributesProps, mapErrorAttributes: MapAttributesProps) => TagInfo;
|
|
33
28
|
export declare const getShortLinkTagInfo: (params: {
|
|
34
29
|
type: string;
|
|
35
30
|
label: string;
|
|
@@ -1,14 +1,14 @@
|
|
|
1
1
|
/* eslint-disable no-cond-assign */
|
|
2
2
|
/* eslint-disable no-console */
|
|
3
3
|
// Libraries
|
|
4
|
-
import {
|
|
4
|
+
import { has } from 'lodash';
|
|
5
5
|
import { translate, translations } from '@antscorp/antsomi-locales';
|
|
6
6
|
// Utils
|
|
7
7
|
import { errorWrapper } from './errorWrapper';
|
|
8
8
|
import { isViberEmoji } from './iconsViber';
|
|
9
9
|
import { random } from '@antscorp/antsomi-ui/es/utils';
|
|
10
10
|
// Constants
|
|
11
|
-
import { CONTENT_SOURCE_GROUP, EMOJI, EMOJI_COLLECTIONS, LINE_EMOJI_PTN, PERSONALIZE_PTN, PREFIX_PATTERN_LINE_MESSAGE, PROMOTION_CODE, SHORT_LINK, SHORT_LINK_GENERAL_PTN, SHORT_LINK_INDIVIDUAL_PTN, SHORT_LINK_PTN, SHORT_LINK_TYPE, SHORT_LINK_V2, SHORT_LINK_V2_GENERAL_PTN, SHORT_LINK_V2_INDIVIDUAL_PTN, TAG_TYPE, VIBER_EMOJI_PTN, } from './constants';
|
|
11
|
+
import { CONTENT_SOURCE_GROUP, EMOJI, EMOJI_COLLECTIONS, LINE_EMOJI_PTN, PERSONALIZE_PTN, PREFIX_PATTERN_LINE_MESSAGE, PROMOTION_CODE, SHORT_LINK, SHORT_LINK_GENERAL_PTN, SHORT_LINK_INDIVIDUAL_PTN, SHORT_LINK_PTN, SHORT_LINK_TYPE, SHORT_LINK_V2, SHORT_LINK_V2_GENERAL_PTN, SHORT_LINK_V2_INDIVIDUAL_PTN, TAG_STATUS, TAG_TYPE, VIBER_EMOJI_PTN, } from './constants';
|
|
12
12
|
const { CUSTOM_TAG } = TAG_TYPE;
|
|
13
13
|
/*
|
|
14
14
|
* Usage to cache compiled regular expressions:
|
|
@@ -244,88 +244,68 @@ const getLabelAttribute = (type, attributeName, subAttributeName, mapAttributes)
|
|
|
244
244
|
mapping[combineAttribute]?.template_name ||
|
|
245
245
|
combineAttribute);
|
|
246
246
|
};
|
|
247
|
-
export const getPersonalizeTagInfo = (originalTag, mapAttributes, mapErrorAttributes
|
|
247
|
+
export const getPersonalizeTagInfo = (originalTag, mapAttributes, mapErrorAttributes) => {
|
|
248
248
|
try {
|
|
249
249
|
const [type, attributeName, subAttributeName] = originalTag.split('.');
|
|
250
250
|
const isCsGroup = type === CONTENT_SOURCE_GROUP;
|
|
251
251
|
const combineAttribute = subAttributeName
|
|
252
252
|
? `${attributeName}.${subAttributeName}`
|
|
253
253
|
: attributeName;
|
|
254
|
-
|
|
255
|
-
let
|
|
256
|
-
true,
|
|
257
|
-
'',
|
|
258
|
-
false,
|
|
259
|
-
true,
|
|
260
|
-
false,
|
|
261
|
-
true,
|
|
262
|
-
false,
|
|
263
|
-
];
|
|
264
|
-
if (!has(mapAttributes, type) && !has(tagProperties, attributeName) && !isCsGroup) {
|
|
265
|
-
// return fallback if no mapping
|
|
266
|
-
return {
|
|
267
|
-
type,
|
|
268
|
-
label: attributeName || type,
|
|
269
|
-
isValid: false,
|
|
270
|
-
message: 'This tag does not exist anymore',
|
|
271
|
-
isRemoved,
|
|
272
|
-
canView,
|
|
273
|
-
isArchived,
|
|
274
|
-
isActive,
|
|
275
|
-
isExpired,
|
|
276
|
-
};
|
|
277
|
-
}
|
|
254
|
+
let status = '';
|
|
255
|
+
let statusMsg = '';
|
|
278
256
|
// Get label based on mapping
|
|
279
257
|
const label = isCsGroup
|
|
280
258
|
? getContentSourceLabel(attributeName, subAttributeName, mapAttributes)
|
|
281
259
|
: getLabelAttribute(type, attributeName, subAttributeName, mapAttributes);
|
|
282
|
-
|
|
283
|
-
switch (tagType) {
|
|
260
|
+
switch (type) {
|
|
284
261
|
case PROMOTION_CODE: {
|
|
285
|
-
if (has(mapErrorAttributes, [
|
|
286
|
-
|
|
287
|
-
|
|
262
|
+
if (has(mapErrorAttributes, [type, attributeName])) {
|
|
263
|
+
status = TAG_STATUS.INVALID;
|
|
264
|
+
statusMsg = 'This pool does not exist anymore';
|
|
288
265
|
const {
|
|
289
266
|
// isEdit = false,
|
|
290
|
-
isView = false, isExist = true, isArchived: _isArchived = false, isActive: _isActive = true, isExpired: _isExpired = false, } = mapErrorAttributes?.[
|
|
267
|
+
isView = false, isExist = true, isArchived: _isArchived = false, isActive: _isActive = true, isExpired: _isExpired = false, } = mapErrorAttributes?.[type]?.[attributeName] || {};
|
|
291
268
|
if (!isExist) {
|
|
292
269
|
// Case Pool Removed
|
|
293
|
-
|
|
294
|
-
|
|
270
|
+
status = TAG_STATUS.REMOVED;
|
|
271
|
+
statusMsg = translate(translations._PERSONALIZATION_TAG_ERR_REMOVED, 'This pool is removed');
|
|
295
272
|
}
|
|
296
273
|
else if (_isArchived) {
|
|
297
274
|
// Case Pool is Archived
|
|
298
|
-
|
|
299
|
-
|
|
275
|
+
status = TAG_STATUS.ARCHIVED;
|
|
276
|
+
statusMsg = translate(translations._PERSONALIZATION_TAG_ERR_ATT_ARCHIVE, 'This attribute has been archived');
|
|
300
277
|
}
|
|
301
278
|
else if (!_isActive) {
|
|
302
279
|
// Case Pool is Inactive
|
|
303
|
-
|
|
304
|
-
|
|
280
|
+
status = TAG_STATUS.INACTIVE;
|
|
281
|
+
statusMsg = translate(translations._PERSONALIZATION_TAG_ERR_POOL_DEACTIVATE, 'This pool has been deactivated. You have to turn it on to use');
|
|
305
282
|
}
|
|
306
283
|
else if (_isExpired) {
|
|
307
284
|
// Case Pool is Expired
|
|
308
|
-
|
|
309
|
-
|
|
285
|
+
status = TAG_STATUS.EXPIRED;
|
|
286
|
+
statusMsg = translate(translations._PERSONALIZATION_TAG_ERR_POOL_EXPIRE, 'This pool has expired, new codes could not be allocated');
|
|
310
287
|
}
|
|
311
288
|
else if (!isView) {
|
|
312
289
|
// Case Pool Can't View
|
|
313
|
-
|
|
314
|
-
|
|
290
|
+
status = TAG_STATUS.DO_NOT_VIEW;
|
|
291
|
+
statusMsg = translate(translations._PERMISSION_ERR_POOL, 'You do not have permission on this pool');
|
|
315
292
|
}
|
|
316
293
|
}
|
|
317
294
|
// }
|
|
318
295
|
break;
|
|
319
296
|
}
|
|
297
|
+
case CUSTOM_TAG: {
|
|
298
|
+
break;
|
|
299
|
+
}
|
|
320
300
|
default: {
|
|
321
|
-
if (has(mapErrorAttributes, [
|
|
322
|
-
|
|
323
|
-
|
|
324
|
-
const { isArchived: _isArchived = false, isActive: _isActive = true, isExpired: _isExpired = false, } = mapErrorAttributes?.[
|
|
301
|
+
if (has(mapErrorAttributes, [type, combineAttribute])) {
|
|
302
|
+
status = TAG_STATUS.ERROR;
|
|
303
|
+
statusMsg = 'This attribute does not exist anymore';
|
|
304
|
+
const { isArchived: _isArchived = false, isActive: _isActive = true, isExpired: _isExpired = false, } = mapErrorAttributes?.[type]?.[combineAttribute] || {};
|
|
325
305
|
if (_isArchived) {
|
|
326
306
|
// Case Tag is Archived
|
|
327
|
-
|
|
328
|
-
|
|
307
|
+
status = TAG_STATUS.ARCHIVED;
|
|
308
|
+
statusMsg = translate(translations._PERSONALIZATION_TAG_ERR_ATT_ARCHIVE, 'This attribute has been archived');
|
|
329
309
|
}
|
|
330
310
|
}
|
|
331
311
|
break;
|
|
@@ -333,39 +313,39 @@ export const getPersonalizeTagInfo = (originalTag, mapAttributes, mapErrorAttrib
|
|
|
333
313
|
}
|
|
334
314
|
return {
|
|
335
315
|
type,
|
|
336
|
-
message,
|
|
337
|
-
isValid,
|
|
338
316
|
label: label || type,
|
|
339
|
-
|
|
340
|
-
|
|
341
|
-
isArchived,
|
|
342
|
-
isActive,
|
|
343
|
-
isExpired,
|
|
317
|
+
status,
|
|
318
|
+
statusMsg,
|
|
344
319
|
};
|
|
345
320
|
}
|
|
346
321
|
catch (error) {
|
|
347
322
|
console.error('Error in getTagLabel', error);
|
|
348
|
-
return {
|
|
323
|
+
return {
|
|
324
|
+
label: originalTag,
|
|
325
|
+
type: originalTag,
|
|
326
|
+
status: TAG_STATUS.ERROR,
|
|
327
|
+
statusMsg: 'This tag does not exist anymore',
|
|
328
|
+
};
|
|
349
329
|
}
|
|
350
330
|
};
|
|
351
331
|
export const getShortLinkTagInfo = (params) => {
|
|
352
332
|
const { type, label, url, shortener, mapAttributes, mapErrorAttributes } = params;
|
|
353
333
|
try {
|
|
354
|
-
let [
|
|
334
|
+
let [status, statusMsg] = ['', ''];
|
|
355
335
|
switch (type) {
|
|
356
336
|
case SHORT_LINK_V2:
|
|
357
337
|
if (mapAttributes && mapAttributes[type]) {
|
|
358
338
|
const isExistShortLink = has(mapAttributes[type], shortener);
|
|
359
339
|
if (!isExistShortLink) {
|
|
360
|
-
|
|
361
|
-
|
|
340
|
+
status = TAG_STATUS.INVALID;
|
|
341
|
+
statusMsg = translate(translations?._PER_TAG_LINK_ERR || '', 'This shortener is inactivated or removed');
|
|
362
342
|
if (mapErrorAttributes &&
|
|
363
343
|
mapErrorAttributes?.[type] &&
|
|
364
344
|
mapErrorAttributes?.[type]?.[shortener]) {
|
|
365
345
|
const { isView = true, isExist = true } = mapErrorAttributes[type][shortener] || {};
|
|
366
346
|
if (!isExist || !isView) {
|
|
367
|
-
|
|
368
|
-
|
|
347
|
+
status = TAG_STATUS.REMOVED;
|
|
348
|
+
statusMsg = translate(translations?._PER_TAG_LINK_ERR || '', 'This shortener is inactivated or removed');
|
|
369
349
|
}
|
|
370
350
|
}
|
|
371
351
|
}
|
|
@@ -376,9 +356,9 @@ export const getShortLinkTagInfo = (params) => {
|
|
|
376
356
|
}
|
|
377
357
|
return {
|
|
378
358
|
type,
|
|
379
|
-
message,
|
|
380
|
-
isValid,
|
|
381
359
|
label,
|
|
360
|
+
status,
|
|
361
|
+
statusMsg,
|
|
382
362
|
};
|
|
383
363
|
}
|
|
384
364
|
catch (error) {
|
|
@@ -386,8 +366,8 @@ export const getShortLinkTagInfo = (params) => {
|
|
|
386
366
|
return {
|
|
387
367
|
label,
|
|
388
368
|
type,
|
|
389
|
-
|
|
390
|
-
|
|
369
|
+
status: TAG_STATUS.ERROR,
|
|
370
|
+
statusMsg: translate(translations._PER_TAG_LINK_ERR, 'This shortener is inactivated or removed'),
|
|
391
371
|
};
|
|
392
372
|
}
|
|
393
373
|
};
|
|
@@ -403,7 +403,7 @@ export const isPersonalizeTagType = (type) => [
|
|
|
403
403
|
CUSTOM_FN,
|
|
404
404
|
CONTENT_SOURCE_GROUP,
|
|
405
405
|
ALLOCATED_CODE,
|
|
406
|
-
CUSTOM_TAG,
|
|
406
|
+
// CUSTOM_TAG,
|
|
407
407
|
].includes(type);
|
|
408
408
|
export const isShortLinkTagType = (type) => [SHORT_LINK_V2].includes(type);
|
|
409
409
|
export const isCustomTagType = (type) => type === CUSTOM_TAG;
|