@capillarytech/creatives-library 8.0.345-alpha.13 → 8.0.345-alpha.15
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/constants/unified.js +29 -0
- package/package.json +1 -1
- package/services/api.js +0 -20
- package/services/tests/api.test.js +13 -59
- package/utils/commonUtils.js +19 -1
- package/utils/rcsPayloadUtils.js +92 -0
- package/utils/templateVarUtils.js +201 -0
- package/utils/tests/templateVarUtils.test.js +204 -0
- package/v2Components/CapActionButton/constants.js +7 -0
- package/v2Components/CapActionButton/index.js +167 -109
- package/v2Components/CapActionButton/index.scss +157 -6
- package/v2Components/CapActionButton/messages.js +19 -3
- package/v2Components/CapActionButton/tests/index.test.js +41 -17
- package/v2Components/CapCustomSkeleton/index.js +1 -1
- package/v2Components/CapCustomSkeleton/tests/__snapshots__/index.test.js.snap +12 -12
- package/v2Components/CapTagList/index.js +10 -0
- package/v2Components/CommonTestAndPreview/CustomValuesEditor.js +70 -49
- package/v2Components/CommonTestAndPreview/DeliverySettings/DeliverySettings.scss +8 -2
- package/v2Components/CommonTestAndPreview/DeliverySettings/ModifyDeliverySettings.js +207 -21
- package/v2Components/CommonTestAndPreview/DeliverySettings/constants.js +16 -0
- package/v2Components/CommonTestAndPreview/DeliverySettings/index.js +85 -10
- package/v2Components/CommonTestAndPreview/DeliverySettings/messages.js +30 -0
- package/v2Components/CommonTestAndPreview/DeliverySettings/utils/parseSenderDetailsResponse.js +79 -11
- package/v2Components/CommonTestAndPreview/SendTestMessage.js +10 -5
- package/v2Components/CommonTestAndPreview/UnifiedPreview/RcsPreviewContent.js +160 -15
- package/v2Components/CommonTestAndPreview/UnifiedPreview/RcsPreviewContent.js.rej +18 -0
- package/v2Components/CommonTestAndPreview/UnifiedPreview/_unifiedPreview.scss +341 -76
- package/v2Components/CommonTestAndPreview/UnifiedPreview/index.js +133 -4
- package/v2Components/CommonTestAndPreview/_commonTestAndPreview.scss +11 -0
- package/v2Components/CommonTestAndPreview/constants.js +38 -2
- package/v2Components/CommonTestAndPreview/index.js +676 -186
- package/v2Components/CommonTestAndPreview/messages.js +49 -3
- package/v2Components/CommonTestAndPreview/previewApiUtils.js +59 -0
- package/v2Components/CommonTestAndPreview/sagas.js +15 -6
- package/v2Components/CommonTestAndPreview/tests/CustomValuesEditor.test.js +308 -284
- package/v2Components/CommonTestAndPreview/tests/DeliverySettings/ModifyDeliverySettings.test.js +231 -65
- package/v2Components/CommonTestAndPreview/tests/DeliverySettings/index.test.js +118 -5
- package/v2Components/CommonTestAndPreview/tests/DeliverySettings/utils/parseSenderDetailsResponse.test.js +341 -0
- package/v2Components/CommonTestAndPreview/tests/PreviewSection.test.js +8 -1
- package/v2Components/CommonTestAndPreview/tests/SendTestMessage.test.js +34 -13
- package/v2Components/CommonTestAndPreview/tests/UnifiedPreview/RcsPreviewContent.test.js +281 -283
- package/v2Components/CommonTestAndPreview/tests/UnifiedPreview/index.test.js +199 -1
- package/v2Components/CommonTestAndPreview/tests/index.test.js +132 -4
- package/v2Components/CommonTestAndPreview/tests/previewApiUtils.test.js +67 -0
- package/v2Components/CommonTestAndPreview/tests/sagas.test.js +2 -2
- package/v2Components/FormBuilder/index.js +8 -10
- package/v2Components/SmsFallback/SmsFallbackLocalSelector.js +87 -0
- package/v2Components/SmsFallback/constants.js +73 -0
- package/v2Components/SmsFallback/index.js +955 -0
- package/v2Components/SmsFallback/index.scss +265 -0
- package/v2Components/SmsFallback/messages.js +78 -0
- package/v2Components/SmsFallback/smsFallbackUtils.js +118 -0
- package/v2Components/SmsFallback/tests/SmsFallbackLocalSelector.test.js +50 -0
- package/v2Components/SmsFallback/tests/rcsSmsFallback.acceptance.test.js +147 -0
- package/v2Components/SmsFallback/tests/smsFallbackHandlers.test.js +304 -0
- package/v2Components/SmsFallback/tests/smsFallbackUi.test.js +197 -0
- package/v2Components/SmsFallback/tests/smsFallbackUtils.test.js +277 -0
- package/v2Components/SmsFallback/tests/useLocalTemplateList.test.js +422 -0
- package/v2Components/SmsFallback/useLocalTemplateList.js +92 -0
- package/v2Components/TemplatePreview/_templatePreview.scss +33 -23
- package/v2Components/TemplatePreview/constants.js +2 -0
- package/v2Components/TemplatePreview/index.js +143 -28
- package/v2Components/TemplatePreview/tests/index.test.js +142 -0
- package/v2Components/TestAndPreviewSlidebox/index.js +13 -1
- package/v2Components/TestAndPreviewSlidebox/sagas.js +11 -4
- package/v2Components/TestAndPreviewSlidebox/tests/saga.test.js +3 -1
- package/v2Components/VarSegmentMessageEditor/constants.js +2 -0
- package/v2Components/VarSegmentMessageEditor/index.js +125 -0
- package/v2Components/VarSegmentMessageEditor/index.scss +46 -0
- package/v2Containers/CreativesContainer/CreativesSlideBoxWrapper.js +43 -0
- package/v2Containers/CreativesContainer/SlideBoxContent.js +36 -4
- package/v2Containers/CreativesContainer/SlideBoxFooter.js +11 -4
- package/v2Containers/CreativesContainer/SlideBoxHeader.js +29 -4
- package/v2Containers/CreativesContainer/constants.js +9 -0
- package/v2Containers/CreativesContainer/embeddedSlideboxUtils.js +67 -0
- package/v2Containers/CreativesContainer/index.js +300 -108
- package/v2Containers/CreativesContainer/index.scss +51 -1
- package/v2Containers/CreativesContainer/messages.js +0 -4
- package/v2Containers/CreativesContainer/tests/SlideBoxContent.localTemplates.test.js +90 -0
- package/v2Containers/CreativesContainer/tests/SlideBoxFooter.test.js +78 -34
- package/v2Containers/CreativesContainer/tests/SlideBoxHeader.test.js +79 -16
- package/v2Containers/CreativesContainer/tests/__snapshots__/SlideBoxContent.test.js.snap +8 -0
- package/v2Containers/CreativesContainer/tests/__snapshots__/SlideBoxHeader.test.js.snap +357 -98
- package/v2Containers/CreativesContainer/tests/__snapshots__/index.test.js.snap +20 -18
- package/v2Containers/CreativesContainer/tests/embeddedSlideboxUtils.test.js +258 -0
- package/v2Containers/CreativesContainer/tests/index.test.js +71 -9
- package/v2Containers/CreativesContainer/tests/useLocalTemplatesProp.test.js +125 -0
- package/v2Containers/Rcs/constants.js +119 -8
- package/v2Containers/Rcs/index.js +2379 -807
- package/v2Containers/Rcs/index.js.rej +1336 -0
- package/v2Containers/Rcs/index.scss +276 -6
- package/v2Containers/Rcs/index.scss.rej +74 -0
- package/v2Containers/Rcs/messages.js +38 -3
- package/v2Containers/Rcs/rcsLibraryHydrationUtils.js +225 -0
- package/v2Containers/Rcs/tests/__snapshots__/index.test.js.snap +98018 -70073
- package/v2Containers/Rcs/tests/__snapshots__/utils.test.js.snap +0 -5
- package/v2Containers/Rcs/tests/__snapshots__/utils.test.js.snap.rej +128 -0
- package/v2Containers/Rcs/tests/index.test.js +152 -121
- package/v2Containers/Rcs/tests/mockData.js +38 -0
- package/v2Containers/Rcs/tests/rcsLibraryHydrationUtils.test.js +318 -0
- package/v2Containers/Rcs/tests/utils.test.js +646 -30
- package/v2Containers/Rcs/utils.js +478 -11
- package/v2Containers/Sms/Create/index.js +100 -40
- package/v2Containers/Sms/smsFormDataHelpers.js +67 -0
- package/v2Containers/Sms/tests/smsFormDataHelpers.test.js +253 -0
- package/v2Containers/SmsTrai/Create/index.js +9 -4
- package/v2Containers/SmsTrai/Edit/constants.js +2 -0
- package/v2Containers/SmsTrai/Edit/index.js +636 -130
- package/v2Containers/SmsTrai/Edit/index.scss +121 -0
- package/v2Containers/SmsTrai/Edit/messages.js +14 -4
- package/v2Containers/SmsTrai/Edit/tests/__snapshots__/index.test.js.snap +4328 -2375
- package/v2Containers/SmsWrapper/index.js +37 -8
- package/v2Containers/TagList/index.js +6 -0
- package/v2Containers/Templates/ChannelTypeIllustration.js +6 -23
- package/v2Containers/Templates/TemplatesActionBar.js +101 -0
- package/v2Containers/Templates/_templates.scss +181 -126
- package/v2Containers/Templates/actions.js +11 -36
- package/v2Containers/Templates/constants.js +2 -23
- package/v2Containers/Templates/index.js +142 -333
- package/v2Containers/Templates/messages.js +0 -68
- package/v2Containers/Templates/reducer.js +0 -68
- package/v2Containers/Templates/sagas.js +55 -98
- package/v2Containers/Templates/selectors.js +0 -12
- package/v2Containers/Templates/tests/ChannelTypeIllustration.test.js +0 -12
- package/v2Containers/Templates/tests/TemplatesActionBar.test.js +120 -0
- package/v2Containers/Templates/tests/__snapshots__/index.test.js.snap +1042 -1256
- package/v2Containers/Templates/tests/index.test.js +0 -6
- package/v2Containers/Templates/tests/reducer.test.js +0 -178
- package/v2Containers/Templates/tests/sagas.test.js +200 -436
- package/v2Containers/Templates/tests/selector.test.js +0 -32
- package/v2Containers/Templates/tests/smsTemplatesListApi.test.js +180 -0
- package/v2Containers/Templates/utils/smsTemplatesListApi.js +79 -0
- package/v2Containers/TemplatesV2/TemplatesV2.style.js +72 -1
- package/v2Containers/TemplatesV2/index.js +86 -23
- package/v2Containers/TemplatesV2/tests/TemplatesV2.localTemplates.test.js +131 -0
- package/v2Containers/Whatsapp/index.js +3 -20
- package/v2Containers/Whatsapp/tests/__snapshots__/index.test.js.snap +578 -34
- package/v2Containers/Assets/images/archive_Empty_Illustration.svg +0 -9
|
@@ -32,6 +32,13 @@ export const CTA_OPTIONS = [
|
|
|
32
32
|
];
|
|
33
33
|
|
|
34
34
|
export const invalidVarRegex = /{{(.*?)}}/g;
|
|
35
|
+
|
|
36
|
+
/** URL CTA subtype (Figma: URL type dropdown). */
|
|
37
|
+
export const RCS_CTA_URL_TYPE = {
|
|
38
|
+
STATIC: 'STATIC',
|
|
39
|
+
DYNAMIC: 'DYNAMIC',
|
|
40
|
+
};
|
|
41
|
+
|
|
35
42
|
export const BTN_MAX_LENGTH = 25;
|
|
36
43
|
export const PHONE_NUMBER_MAX_LENGTH = 15;
|
|
37
44
|
export const URL_MAX_LENGTH = 2000;
|
|
@@ -8,6 +8,7 @@ import CapRow from '@capillarytech/cap-ui-library/CapRow';
|
|
|
8
8
|
import CapColumn from '@capillarytech/cap-ui-library/CapColumn';
|
|
9
9
|
import CapHeading from '@capillarytech/cap-ui-library/CapHeading';
|
|
10
10
|
import CapHeader from "@capillarytech/cap-ui-library/CapHeader";
|
|
11
|
+
import CapRadioGroup from '@capillarytech/cap-ui-library/CapRadioGroup';
|
|
11
12
|
import CapSelect from '@capillarytech/cap-ui-library/CapSelect';
|
|
12
13
|
import CapInput from '@capillarytech/cap-ui-library/CapInput';
|
|
13
14
|
import CapIcon from '@capillarytech/cap-ui-library/CapIcon';
|
|
@@ -20,9 +21,16 @@ import globalMessages from '../../v2Containers/Cap/messages';import CapTagListWi
|
|
|
20
21
|
|
|
21
22
|
import { isUrl, isValidText } from '../../v2Containers/Line/Container/Wrapper/utils';
|
|
22
23
|
import messages from './messages';
|
|
23
|
-
import {
|
|
24
|
+
import {
|
|
25
|
+
BTN_MAX_LENGTH,
|
|
26
|
+
URL_MAX_LENGTH,
|
|
27
|
+
PHONE_NUMBER_MAX_LENGTH,
|
|
28
|
+
invalidVarRegex,
|
|
29
|
+
HANDLERS,
|
|
30
|
+
RCS_CTA_URL_TYPE,
|
|
31
|
+
} from './constants';
|
|
24
32
|
import './index.scss';
|
|
25
|
-
import { INITIAL_SUGGESTIONS, RCS_BUTTON_TYPES} from '../../v2Containers/Rcs/constants';
|
|
33
|
+
import { INITIAL_SUGGESTIONS, RCS_BUTTON_TYPES, HOST_ICS} from '../../v2Containers/Rcs/constants';
|
|
26
34
|
|
|
27
35
|
const { TextArea } = CapInput;
|
|
28
36
|
|
|
@@ -41,9 +49,12 @@ export const CapActionButton = (props) => {
|
|
|
41
49
|
injectedTags = {},
|
|
42
50
|
location = {},
|
|
43
51
|
selectedOfferDetails = [],
|
|
44
|
-
|
|
52
|
+
host = '',
|
|
45
53
|
onContextChange,
|
|
54
|
+
minSavedSuggestions = 0,
|
|
55
|
+
hideDeleteSuggestionIndexes = [],
|
|
46
56
|
} = props;
|
|
57
|
+
const isHostIcs = host === HOST_ICS;
|
|
47
58
|
const [urlError, setUrlError] = useState(false);
|
|
48
59
|
const [buttonError, setButtonError] = useState(false);
|
|
49
60
|
const updateHandler = (type, value, index) => {
|
|
@@ -66,6 +77,7 @@ export const CapActionButton = (props) => {
|
|
|
66
77
|
|
|
67
78
|
const onCtaTypeChange = (value, index) => {
|
|
68
79
|
let clonedCta = cloneDeep(suggestions[index]);
|
|
80
|
+
const isCta = value === RCS_BUTTON_TYPES.CTA;
|
|
69
81
|
clonedCta = {
|
|
70
82
|
...clonedCta,
|
|
71
83
|
type: value,
|
|
@@ -73,6 +85,7 @@ export const CapActionButton = (props) => {
|
|
|
73
85
|
phoneNumber: '',
|
|
74
86
|
postback: '',
|
|
75
87
|
url: value === RCS_BUTTON_TYPES.PHONE_NUMBER ? null : '',
|
|
88
|
+
urlType: isCta ? RCS_CTA_URL_TYPE.STATIC : undefined,
|
|
76
89
|
isSaved: false,
|
|
77
90
|
};
|
|
78
91
|
setUrlError(false);
|
|
@@ -92,39 +105,61 @@ export const CapActionButton = (props) => {
|
|
|
92
105
|
updateDisplayAndPostback(value, id);
|
|
93
106
|
};
|
|
94
107
|
|
|
95
|
-
const
|
|
96
|
-
<
|
|
97
|
-
{formatMessage(messages.
|
|
98
|
-
|
|
99
|
-
maxLength: max,
|
|
100
|
-
})}
|
|
101
|
-
</CapHeading>
|
|
108
|
+
const renderInnerCharCount = (len, max) => (
|
|
109
|
+
<span className="rcs-cta-inner-char-count">
|
|
110
|
+
{formatMessage(messages.ctaFieldCharCountInline, { current: len, max })}
|
|
111
|
+
</span>
|
|
102
112
|
);
|
|
103
113
|
|
|
104
|
-
const
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
114
|
+
const validateCtaUrlValue = (value, urlSubtype) => {
|
|
115
|
+
const v = String(value || '').trim();
|
|
116
|
+
if (!v) {
|
|
117
|
+
return formatMessage(messages.ctaWebsiteUrlErrorMessage);
|
|
118
|
+
}
|
|
119
|
+
if (v.length > URL_MAX_LENGTH) {
|
|
120
|
+
return formatMessage(messages.ctaWebsiteUrlErrorMessage);
|
|
121
|
+
}
|
|
122
|
+
if (urlSubtype === RCS_CTA_URL_TYPE.DYNAMIC) {
|
|
123
|
+
return false;
|
|
111
124
|
}
|
|
112
|
-
|
|
125
|
+
if (!isUrl(v)) {
|
|
126
|
+
return formatMessage(messages.ctaWebsiteUrlErrorMessage);
|
|
127
|
+
}
|
|
128
|
+
if (v.match(invalidVarRegex)?.length > 0) {
|
|
129
|
+
return formatMessage(messages.staticUrlWithVarErrorMessage);
|
|
130
|
+
}
|
|
131
|
+
return false;
|
|
132
|
+
};
|
|
133
|
+
|
|
134
|
+
const onUrlChange = ({ target }) => {
|
|
135
|
+
const { value, id } = target;
|
|
136
|
+
const row = suggestions[id] || {};
|
|
137
|
+
const subtype = row.urlType || RCS_CTA_URL_TYPE.STATIC;
|
|
138
|
+
setUrlError(validateCtaUrlValue(value, subtype));
|
|
113
139
|
updateHandler(HANDLERS.URL, value, id);
|
|
114
140
|
};
|
|
115
141
|
|
|
142
|
+
const onUrlSubtypeChange = (nextSubtype, index) => {
|
|
143
|
+
const cloned = cloneDeep(suggestions[index]);
|
|
144
|
+
cloned.urlType = nextSubtype;
|
|
145
|
+
cloned.isSaved = false;
|
|
146
|
+
setUrlError(validateCtaUrlValue(cloned.url || '', nextSubtype));
|
|
147
|
+
updateButtonChange(cloned, index);
|
|
148
|
+
};
|
|
149
|
+
|
|
116
150
|
const onPhoneNoChange = (value, index) => {
|
|
117
151
|
updateHandler(HANDLERS.PHONE_NUMBER, value, index);
|
|
118
152
|
};
|
|
119
153
|
|
|
120
154
|
const ctaSaveDisabled = (index) => {
|
|
121
|
-
const { type, text, phoneNumber, url } = suggestions[index] || {};
|
|
155
|
+
const { type, text, phoneNumber, url, urlType } = suggestions[index] || {};
|
|
122
156
|
if (text === '' || buttonError) {
|
|
123
157
|
return true;
|
|
124
|
-
} if (type === RCS_BUTTON_TYPES.PHONE_NUMBER && phoneNumber.length < 5) {
|
|
125
|
-
return true;
|
|
126
|
-
} if (type === RCS_BUTTON_TYPES.CTA && (url === '' || urlError)) {
|
|
158
|
+
} if (type === RCS_BUTTON_TYPES.PHONE_NUMBER && (phoneNumber || '').length < 5) {
|
|
127
159
|
return true;
|
|
160
|
+
} if (type === RCS_BUTTON_TYPES.CTA) {
|
|
161
|
+
const subtype = urlType || RCS_CTA_URL_TYPE.STATIC;
|
|
162
|
+
return !!validateCtaUrlValue(url, subtype);
|
|
128
163
|
}
|
|
129
164
|
return false;
|
|
130
165
|
};
|
|
@@ -143,64 +178,58 @@ export const CapActionButton = (props) => {
|
|
|
143
178
|
updateButtonChange(newSuggestion, suggestions?.length);
|
|
144
179
|
};
|
|
145
180
|
|
|
146
|
-
const renderCtaOptions = (label, tooltipLabel, isDisabled) => {
|
|
147
|
-
if (isDisabled) {
|
|
148
|
-
return (
|
|
149
|
-
<CapRow>
|
|
150
|
-
<CapColumn span={23}>{label}</CapColumn>
|
|
151
|
-
<CapColumn span={1}>
|
|
152
|
-
<CapTooltipWithInfo
|
|
153
|
-
// autoAdjustOverflow
|
|
154
|
-
placement="right"
|
|
155
|
-
title={tooltipLabel}
|
|
156
|
-
/>
|
|
157
|
-
</CapColumn>
|
|
158
|
-
</CapRow>
|
|
159
|
-
);
|
|
160
|
-
}
|
|
161
|
-
return label;
|
|
162
|
-
};
|
|
163
|
-
|
|
164
181
|
const { formatMessage } = intl;
|
|
165
182
|
const renderedContent = () => {
|
|
166
183
|
const renderArray = [];
|
|
167
|
-
const addBtnDisabled = suggestions.length >= maxButtons || !suggestions[suggestions.length - 1]?.isSaved;
|
|
184
|
+
const addBtnDisabled = suggestions?.length > 0 && (suggestions.length >= maxButtons || !suggestions[suggestions.length - 1]?.isSaved);
|
|
185
|
+
const savedSuggestionsCount = (suggestions || []).filter((s) => s && s.isSaved).length;
|
|
186
|
+
const cannotDeleteSavedMandatory = (idx) => {
|
|
187
|
+
const row = suggestions[idx];
|
|
188
|
+
if (!row || !row.isSaved) return false;
|
|
189
|
+
return minSavedSuggestions > 0 && savedSuggestionsCount <= minSavedSuggestions;
|
|
190
|
+
};
|
|
168
191
|
|
|
169
|
-
const
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
});
|
|
192
|
+
const hideDeleteForSuggestionIndex = (idx) =>
|
|
193
|
+
Array.isArray(hideDeleteSuggestionIndexes) && hideDeleteSuggestionIndexes.includes(idx);
|
|
194
|
+
|
|
195
|
+
const ctaTypeRadioOptions = [
|
|
196
|
+
{ label: formatMessage(messages.ctaPhoneNo), value: RCS_BUTTON_TYPES.PHONE_NUMBER },
|
|
197
|
+
{ label: formatMessage(messages.ctaUrlRadio), value: RCS_BUTTON_TYPES.CTA },
|
|
198
|
+
{ label: formatMessage(messages.ctaQr), value: RCS_BUTTON_TYPES.QUICK_REPLY },
|
|
199
|
+
];
|
|
178
200
|
|
|
179
|
-
|
|
201
|
+
const urlTypeSelectOptions = [
|
|
202
|
+
{ value: RCS_CTA_URL_TYPE.STATIC, label: formatMessage(messages.ctaWebsiteTypeStatic) },
|
|
203
|
+
{ value: RCS_CTA_URL_TYPE.DYNAMIC, label: formatMessage(messages.ctaWebsiteTypeDynamic) },
|
|
204
|
+
];
|
|
205
|
+
|
|
206
|
+
suggestions?.length > 0 && suggestions.forEach((cta) => {
|
|
180
207
|
const {
|
|
181
208
|
index, type, text, isSaved,
|
|
182
209
|
} = cta || {};
|
|
183
210
|
|
|
184
211
|
const url = type !== RCS_BUTTON_TYPES.CTA ? null : cta.url;
|
|
212
|
+
const urlSubtype = type === RCS_BUTTON_TYPES.CTA
|
|
213
|
+
? (cta.urlType || RCS_CTA_URL_TYPE.STATIC)
|
|
214
|
+
: RCS_CTA_URL_TYPE.STATIC;
|
|
185
215
|
const phoneNumber = type !== RCS_BUTTON_TYPES.PHONE_NUMBER ? null : cta.phoneNumber;
|
|
186
216
|
if (isFullMode && !isEditFlow && !isSaved) {
|
|
187
217
|
renderArray.push(
|
|
188
|
-
<
|
|
189
|
-
<CapRow className="rcs-button-cta-create
|
|
190
|
-
<CapColumn span={
|
|
191
|
-
|
|
192
|
-
<CapHeading type="h4" className="cta-label">
|
|
218
|
+
<CapRow className="rcs-button-cta-create-container" key={`cta-edit-${index}`} gutter={0}>
|
|
219
|
+
<CapRow className="rcs-button-cta-create" gutter={0}>
|
|
220
|
+
<CapColumn span={24}>
|
|
221
|
+
<CapHeading type="h4">
|
|
193
222
|
{formatMessage(messages.ctaType)}
|
|
194
223
|
</CapHeading>
|
|
195
|
-
<
|
|
196
|
-
id=
|
|
197
|
-
|
|
198
|
-
|
|
224
|
+
<CapRadioGroup
|
|
225
|
+
id={`rcs-cta-type-radio-${index}`}
|
|
226
|
+
className="cap-rcs-cta-type-radio"
|
|
227
|
+
options={ctaTypeRadioOptions}
|
|
199
228
|
value={type}
|
|
200
|
-
|
|
229
|
+
onChange={(e) => onCtaTypeChange(e.target.value, index)}
|
|
201
230
|
/>
|
|
202
231
|
</CapColumn>
|
|
203
|
-
<CapColumn span={
|
|
232
|
+
<CapColumn span={24}>
|
|
204
233
|
<CapHeading type="h4" className="cta-label">
|
|
205
234
|
{formatMessage(messages.ctaButtonText)}
|
|
206
235
|
<CapTooltipWithInfo
|
|
@@ -221,28 +250,34 @@ export const CapActionButton = (props) => {
|
|
|
221
250
|
size="large"
|
|
222
251
|
maxLength={BTN_MAX_LENGTH}
|
|
223
252
|
errorMessage={buttonError}
|
|
253
|
+
suffix={renderInnerCharCount((text || '').length, BTN_MAX_LENGTH)}
|
|
224
254
|
/>
|
|
225
|
-
{renderLength(text.length, BTN_MAX_LENGTH)}
|
|
226
255
|
</CapColumn>
|
|
227
256
|
</CapRow>
|
|
228
257
|
{type === RCS_BUTTON_TYPES.PHONE_NUMBER && (
|
|
229
258
|
<>
|
|
230
259
|
<CapRow>
|
|
231
|
-
<CapColumn span={
|
|
232
|
-
{/* phone number */}
|
|
260
|
+
<CapColumn span={24}>
|
|
233
261
|
<CapHeading type="h4" className="cta-label">
|
|
234
262
|
{formatMessage(messages.ctaPhoneNo)}
|
|
235
263
|
</CapHeading>
|
|
236
|
-
<
|
|
237
|
-
|
|
238
|
-
|
|
239
|
-
|
|
240
|
-
|
|
241
|
-
|
|
242
|
-
|
|
243
|
-
|
|
244
|
-
|
|
245
|
-
|
|
264
|
+
<CapRow
|
|
265
|
+
className="rcs-cta-input-with-inner-count rcs-cta-input-with-inner-count--phone"
|
|
266
|
+
gutter={0}
|
|
267
|
+
>
|
|
268
|
+
<CapColumn span={24}>
|
|
269
|
+
<PhoneInput
|
|
270
|
+
placeholder={formatMessage(messages.ctaPhoneNoPlaceholder)}
|
|
271
|
+
autoFormat={false}
|
|
272
|
+
countryCodeEditable={false}
|
|
273
|
+
value={phoneNumber}
|
|
274
|
+
onChange={(value) => onPhoneNoChange(value, index)}
|
|
275
|
+
country="in"
|
|
276
|
+
className="cta-phone-number rcs-cta-phone-input"
|
|
277
|
+
/>
|
|
278
|
+
{renderInnerCharCount((phoneNumber || '').length, PHONE_NUMBER_MAX_LENGTH)}
|
|
279
|
+
</CapColumn>
|
|
280
|
+
</CapRow>
|
|
246
281
|
</CapColumn>
|
|
247
282
|
</CapRow>
|
|
248
283
|
<CapRow className="rcs-cta-save-delete-btn">
|
|
@@ -250,7 +285,7 @@ export const CapActionButton = (props) => {
|
|
|
250
285
|
title={ctaSaveDisabled(index) && formatMessage(messages.ctaSaveDisabled)}
|
|
251
286
|
placement="bottom"
|
|
252
287
|
>
|
|
253
|
-
<
|
|
288
|
+
<CapRow className="button-disabled-tooltip-wrapper">
|
|
254
289
|
<CapButton
|
|
255
290
|
onClick={() => saveCta(index)}
|
|
256
291
|
disabled={ctaSaveDisabled(index)}
|
|
@@ -258,36 +293,49 @@ export const CapActionButton = (props) => {
|
|
|
258
293
|
>
|
|
259
294
|
{formatMessage(globalMessages.save)}
|
|
260
295
|
</CapButton>
|
|
261
|
-
</
|
|
296
|
+
</CapRow>
|
|
262
297
|
</CapTooltip>
|
|
263
|
-
|
|
264
|
-
|
|
265
|
-
|
|
266
|
-
|
|
267
|
-
|
|
268
|
-
|
|
269
|
-
|
|
298
|
+
{!hideDeleteForSuggestionIndex(index) && !cannotDeleteSavedMandatory(index) && (
|
|
299
|
+
<CapButton
|
|
300
|
+
onClick={() => deleteButtonHandler(index)}
|
|
301
|
+
className="rcs-cta-delete-btn"
|
|
302
|
+
type="secondary"
|
|
303
|
+
>
|
|
304
|
+
{formatMessage(globalMessages.delete)}
|
|
305
|
+
</CapButton>
|
|
306
|
+
)}
|
|
270
307
|
</CapRow>
|
|
271
308
|
</>
|
|
272
309
|
)}
|
|
273
310
|
{type === RCS_BUTTON_TYPES.CTA && (
|
|
274
311
|
<>
|
|
275
|
-
<CapRow>
|
|
276
|
-
<CapColumn span={
|
|
312
|
+
<CapRow className="rcs-cta-url-fields-row" gutter={8}>
|
|
313
|
+
<CapColumn span={6} className="rcs-cta-url-type-col">
|
|
314
|
+
<CapHeading type="h4" className="cta-label">
|
|
315
|
+
{formatMessage(messages.ctaWebsiteType)}
|
|
316
|
+
</CapHeading>
|
|
317
|
+
<CapSelect
|
|
318
|
+
id={`rcs-cta-url-type-${index}`}
|
|
319
|
+
options={urlTypeSelectOptions}
|
|
320
|
+
value={urlSubtype}
|
|
321
|
+
onChange={(value) => onUrlSubtypeChange(value, index)}
|
|
322
|
+
/>
|
|
323
|
+
</CapColumn>
|
|
324
|
+
<CapColumn span={18} className="rcs-cta-url-value-col">
|
|
277
325
|
<CapHeading type="h4" className="cta-label">
|
|
278
|
-
{formatMessage(messages.
|
|
326
|
+
{formatMessage(messages.ctaUrlField)}
|
|
279
327
|
</CapHeading>
|
|
280
328
|
<CapInput
|
|
281
329
|
id={index}
|
|
282
330
|
className="rcs-cta-url"
|
|
283
331
|
onChange={onUrlChange}
|
|
284
|
-
placeholder={formatMessage(messages.
|
|
285
|
-
value={url}
|
|
332
|
+
placeholder={formatMessage(messages.ctaEnterUrlPlaceholder)}
|
|
333
|
+
value={url || ''}
|
|
286
334
|
size="large"
|
|
287
335
|
maxLength={URL_MAX_LENGTH}
|
|
288
336
|
errorMessage={urlError}
|
|
337
|
+
suffix={renderInnerCharCount((url || '').length, URL_MAX_LENGTH)}
|
|
289
338
|
/>
|
|
290
|
-
{renderLength(url.length, URL_MAX_LENGTH)}
|
|
291
339
|
</CapColumn>
|
|
292
340
|
</CapRow>
|
|
293
341
|
<CapRow className="rcs-cta-save-delete-btn">
|
|
@@ -297,7 +345,7 @@ export const CapActionButton = (props) => {
|
|
|
297
345
|
}
|
|
298
346
|
placement="bottom"
|
|
299
347
|
>
|
|
300
|
-
<
|
|
348
|
+
<CapRow className="button-disabled-tooltip-wrapper">
|
|
301
349
|
<CapButton
|
|
302
350
|
onClick={() => saveCta(index)}
|
|
303
351
|
disabled={ctaSaveDisabled(index)}
|
|
@@ -305,15 +353,17 @@ export const CapActionButton = (props) => {
|
|
|
305
353
|
>
|
|
306
354
|
{formatMessage(globalMessages.save)}
|
|
307
355
|
</CapButton>
|
|
308
|
-
</
|
|
356
|
+
</CapRow>
|
|
309
357
|
</CapTooltip>
|
|
310
|
-
|
|
311
|
-
|
|
312
|
-
|
|
313
|
-
|
|
314
|
-
|
|
315
|
-
|
|
316
|
-
|
|
358
|
+
{!hideDeleteForSuggestionIndex(index) && !cannotDeleteSavedMandatory(index) && (
|
|
359
|
+
<CapButton
|
|
360
|
+
onClick={() => deleteButtonHandler(index)}
|
|
361
|
+
className="rcs-cta-delete-btn"
|
|
362
|
+
type="secondary"
|
|
363
|
+
>
|
|
364
|
+
{formatMessage(globalMessages.delete)}
|
|
365
|
+
</CapButton>
|
|
366
|
+
)}
|
|
317
367
|
</CapRow>
|
|
318
368
|
</>
|
|
319
369
|
)}
|
|
@@ -323,7 +373,7 @@ export const CapActionButton = (props) => {
|
|
|
323
373
|
title={ctaSaveDisabled(index) && formatMessage(messages.ctaSaveDisabled)}
|
|
324
374
|
placement="bottom"
|
|
325
375
|
>
|
|
326
|
-
<
|
|
376
|
+
<CapRow className="button-disabled-tooltip-wrapper">
|
|
327
377
|
<CapButton
|
|
328
378
|
onClick={() => saveCta(index)}
|
|
329
379
|
disabled={ctaSaveDisabled(index)}
|
|
@@ -331,9 +381,9 @@ export const CapActionButton = (props) => {
|
|
|
331
381
|
>
|
|
332
382
|
{formatMessage(globalMessages.save)}
|
|
333
383
|
</CapButton>
|
|
334
|
-
</
|
|
384
|
+
</CapRow>
|
|
335
385
|
</CapTooltip>
|
|
336
|
-
{index
|
|
386
|
+
{!(isHostIcs && index === 0) && !hideDeleteForSuggestionIndex(index) && !cannotDeleteSavedMandatory(index) && (
|
|
337
387
|
<CapButton
|
|
338
388
|
onClick={() => deleteButtonHandler(index)}
|
|
339
389
|
className="rcs-cta-delete-btn"
|
|
@@ -344,12 +394,12 @@ export const CapActionButton = (props) => {
|
|
|
344
394
|
)}
|
|
345
395
|
</CapRow>
|
|
346
396
|
)}
|
|
347
|
-
</
|
|
397
|
+
</CapRow>
|
|
348
398
|
);
|
|
349
399
|
} else {
|
|
350
400
|
const ctaIsPhone = type === RCS_BUTTON_TYPES.PHONE_NUMBER;
|
|
351
401
|
const ctaIsReply = type === RCS_BUTTON_TYPES.QUICK_REPLY;
|
|
352
|
-
renderArray
|
|
402
|
+
suggestions?.length > 0 && renderArray?.push(
|
|
353
403
|
<CapRow
|
|
354
404
|
key={`cta-saved-${index}`}
|
|
355
405
|
className="cap-rcs-saved-cta margin-t-12"
|
|
@@ -379,7 +429,9 @@ export const CapActionButton = (props) => {
|
|
|
379
429
|
<>
|
|
380
430
|
<CapColumn span={3}>
|
|
381
431
|
<CapLabel className="url-type" type="label2">
|
|
382
|
-
{
|
|
432
|
+
{(cta.urlType || RCS_CTA_URL_TYPE.STATIC) === RCS_CTA_URL_TYPE.DYNAMIC
|
|
433
|
+
? formatMessage(messages.ctaWebsiteTypeDynamic)
|
|
434
|
+
: formatMessage(messages.ctaWebsiteTypeStatic)}
|
|
383
435
|
</CapLabel>
|
|
384
436
|
</CapColumn>
|
|
385
437
|
<CapTooltip title={url} placement={'top'}>
|
|
@@ -398,7 +450,7 @@ export const CapActionButton = (props) => {
|
|
|
398
450
|
>
|
|
399
451
|
<CapIcon size="s" type="edit" />
|
|
400
452
|
</CapColumn>
|
|
401
|
-
{index
|
|
453
|
+
{!(isHostIcs && index === 0) && !hideDeleteForSuggestionIndex(index) && !cannotDeleteSavedMandatory(index) && (
|
|
402
454
|
<CapColumn className="rcs-saved-cta-delete-icon" span={1} onClick={() => deleteButtonHandler(index)}>
|
|
403
455
|
<CapIcon size="s" type="delete" />
|
|
404
456
|
</CapColumn>
|
|
@@ -410,7 +462,7 @@ export const CapActionButton = (props) => {
|
|
|
410
462
|
}
|
|
411
463
|
});
|
|
412
464
|
{
|
|
413
|
-
suggestions
|
|
465
|
+
suggestions?.length < maxButtons &&
|
|
414
466
|
(isFullMode && !isEditFlow)
|
|
415
467
|
&& renderArray.push(
|
|
416
468
|
<CapRow>
|
|
@@ -420,7 +472,7 @@ export const CapActionButton = (props) => {
|
|
|
420
472
|
}
|
|
421
473
|
placement={'right'}
|
|
422
474
|
>
|
|
423
|
-
<
|
|
475
|
+
<CapRow className="button-disabled-tooltip-wrapper">
|
|
424
476
|
<CapButton
|
|
425
477
|
type="flat"
|
|
426
478
|
id="rcs-cta-add-button"
|
|
@@ -431,7 +483,7 @@ export const CapActionButton = (props) => {
|
|
|
431
483
|
>
|
|
432
484
|
{formatMessage(messages.addButton)}
|
|
433
485
|
</CapButton>
|
|
434
|
-
</
|
|
486
|
+
</CapRow>
|
|
435
487
|
</CapTooltip>
|
|
436
488
|
</CapRow>,
|
|
437
489
|
);
|
|
@@ -444,6 +496,8 @@ export const CapActionButton = (props) => {
|
|
|
444
496
|
CapActionButton.propTypes = {
|
|
445
497
|
intl: intlShape.isRequired,
|
|
446
498
|
updateButtonChange: PropTypes.func,
|
|
499
|
+
minSavedSuggestions: PropTypes.number,
|
|
500
|
+
hideDeleteSuggestionIndexes: PropTypes.arrayOf(PropTypes.number),
|
|
447
501
|
suggestions: PropTypes.array,
|
|
448
502
|
tags: PropTypes.array,
|
|
449
503
|
injectedTags: PropTypes.object,
|
|
@@ -451,12 +505,15 @@ CapActionButton.propTypes = {
|
|
|
451
505
|
selectedOfferDetails: PropTypes.array,
|
|
452
506
|
onTagSelect: PropTypes.func,
|
|
453
507
|
onContextChange: PropTypes.func,
|
|
508
|
+
host: PropTypes.string,
|
|
454
509
|
};
|
|
455
510
|
|
|
456
511
|
CapActionButton.defaultProps = {
|
|
457
512
|
buttonTextlen: 20,
|
|
458
513
|
type: '',
|
|
459
514
|
updateButtonChange: () => {},
|
|
515
|
+
minSavedSuggestions: 0,
|
|
516
|
+
hideDeleteSuggestionIndexes: [],
|
|
460
517
|
suggestions: [],
|
|
461
518
|
tags: [],
|
|
462
519
|
injectedTags: {},
|
|
@@ -464,6 +521,7 @@ CapActionButton.defaultProps = {
|
|
|
464
521
|
selectedOfferDetails: [],
|
|
465
522
|
onTagSelect: () => {},
|
|
466
523
|
onContextChange: () => {},
|
|
524
|
+
host: '',
|
|
467
525
|
};
|
|
468
526
|
|
|
469
527
|
export default injectIntl(CapActionButton);
|