@capillarytech/creatives-library 8.0.290 → 8.0.291

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.
Files changed (32) hide show
  1. package/package.json +1 -1
  2. package/v2Components/CommonTestAndPreview/SendTestMessage.js +1 -33
  3. package/v2Components/CommonTestAndPreview/actions.js +0 -20
  4. package/v2Components/CommonTestAndPreview/constants.js +0 -10
  5. package/v2Components/CommonTestAndPreview/index.js +15 -133
  6. package/v2Components/CommonTestAndPreview/reducer.js +0 -47
  7. package/v2Components/CommonTestAndPreview/sagas.js +0 -60
  8. package/v2Components/CommonTestAndPreview/selectors.js +0 -51
  9. package/v2Components/CommonTestAndPreview/tests/SendTestMessage.test.js +0 -127
  10. package/v2Components/CommonTestAndPreview/tests/actions.test.js +0 -50
  11. package/v2Components/CommonTestAndPreview/tests/constants.test.js +0 -18
  12. package/v2Components/CommonTestAndPreview/tests/index.test.js +1 -214
  13. package/v2Components/CommonTestAndPreview/tests/reducer.test.js +0 -118
  14. package/v2Components/CommonTestAndPreview/tests/sagas.test.js +0 -145
  15. package/v2Components/CommonTestAndPreview/tests/selectors.test.js +0 -146
  16. package/v2Components/TestAndPreviewSlidebox/index.js +0 -14
  17. package/v2Containers/CreativesContainer/index.js +8 -0
  18. package/v2Containers/Rcs/tests/__snapshots__/index.test.js.snap +12 -649
  19. package/v2Containers/SmsTrai/Edit/tests/__snapshots__/index.test.js.snap +0 -141
  20. package/v2Containers/Whatsapp/index.js +1 -1
  21. package/v2Containers/Whatsapp/tests/__snapshots__/index.test.js.snap +4225 -26174
  22. package/v2Components/CommonTestAndPreview/DeliverySettings/DeliverySettings.scss +0 -33
  23. package/v2Components/CommonTestAndPreview/DeliverySettings/ModifyDeliverySettings.js +0 -397
  24. package/v2Components/CommonTestAndPreview/DeliverySettings/ModifyDeliverySettings.scss +0 -35
  25. package/v2Components/CommonTestAndPreview/DeliverySettings/TECH_DETAILING_DELIVERY_SETTINGS.md +0 -725
  26. package/v2Components/CommonTestAndPreview/DeliverySettings/constants.js +0 -92
  27. package/v2Components/CommonTestAndPreview/DeliverySettings/index.js +0 -243
  28. package/v2Components/CommonTestAndPreview/DeliverySettings/messages.js +0 -111
  29. package/v2Components/CommonTestAndPreview/DeliverySettings/utils/parseSenderDetailsResponse.js +0 -91
  30. package/v2Components/CommonTestAndPreview/tests/DeliverySettings/ModifyDeliverySettings.test.js +0 -782
  31. package/v2Components/CommonTestAndPreview/tests/DeliverySettings/index.test.js +0 -200
  32. package/v2Components/CommonTestAndPreview/tests/DeliverySettings/utils/parseSenderDetailsResponse.test.js +0 -235
@@ -1,33 +0,0 @@
1
- /**
2
- * DeliverySettings — summary row + edit icon for Test and Preview (SMS, Email, WhatsApp).
3
- */
4
- @import '~@capillarytech/cap-ui-library/styles/_variables.scss';
5
-
6
- .delivery-settings {
7
- &__heading-row {
8
- margin-bottom: $CAP_SPACE_08;
9
- }
10
-
11
- &__summary-row {
12
- margin-bottom: $CAP_SPACE_04;
13
- }
14
-
15
- &__summary-inner {
16
- align-items: center;
17
- margin-bottom: $CAP_SPACE_08;
18
- }
19
-
20
- &__summary-entry {
21
- margin-right: $CAP_SPACE_18;
22
- }
23
-
24
- &__summary-key {
25
- line-height: $CAP_SPACE_16;
26
- }
27
-
28
- &__edit-icon {
29
- cursor: pointer;
30
- position: absolute;
31
- right: 0;
32
- }
33
- }
@@ -1,397 +0,0 @@
1
- /**
2
- * ModifyDeliverySettings — CapSlideBox content for Test and Preview delivery settings.
3
- * Channel-specific dropdowns (SMS: domain + sender number; Email: domain + sender + reply-to; WhatsApp: account + sender number).
4
- * Reference: cap-campaigns-v2 ModifyDeliverySettings + SenderDetails (field layout and options shape).
5
- */
6
-
7
- import React, {
8
- useState, useCallback, useMemo, useEffect,
9
- } from 'react';
10
- import PropTypes from 'prop-types';
11
- import {
12
- CapRow,
13
- CapHeader,
14
- CapSelect,
15
- CapButton,
16
- CapSpin,
17
- CapLabel,
18
- } from '@capillarytech/cap-ui-library';
19
- import { FormattedMessage } from 'react-intl';
20
- import get from 'lodash/get';
21
- import find from 'lodash/find';
22
- import cloneDeep from 'lodash/cloneDeep';
23
- import messages from './messages';
24
- import {
25
- CHANNELS,
26
- DEFAULT_DELIVERY_SETTINGS_BY_CHANNEL,
27
- NO_OPTIONS_LABEL,
28
- HEADER_SIZE_LABEL,
29
- BUTTON_TYPE_PRIMARY,
30
- ROW_KEY_PREFIX,
31
- DELIVERY_SETTING_KEY_DOMAIN_ID,
32
- DELIVERY_SETTING_KEY_DOMAIN_GATEWAY_MAP_ID,
33
- DELIVERY_SETTING_KEY_GSM_SENDER_ID,
34
- DELIVERY_SETTING_KEY_CDMA_SENDER_ID,
35
- DELIVERY_SETTING_KEY_SENDER_EMAIL,
36
- DELIVERY_SETTING_KEY_SENDER_LABEL,
37
- DELIVERY_SETTING_KEY_SENDER_REPLY_TO,
38
- DELIVERY_SETTING_KEY_SOURCE_ACCOUNT_IDENTIFIER,
39
- DELIVERY_SETTING_KEY_SENDER_MOB_NUM,
40
- } from './constants';
41
- import './ModifyDeliverySettings.scss';
42
-
43
- const findDefault = (array) => find(array, { default: true }) || (array && array[0]) || {};
44
-
45
- const ModifyDeliverySettings = (props) => {
46
- const {
47
- channel,
48
- deliverySettings: initialSettings = {},
49
- senderDetailsOptions = [],
50
- wecrmAccounts = [],
51
- onSaveDeliverySettings,
52
- onClose,
53
- isLoading,
54
- formatMessage,
55
- whatsappAccountFromForm,
56
- } = props;
57
-
58
- const defaultForChannel = DEFAULT_DELIVERY_SETTINGS_BY_CHANNEL[channel] || {};
59
- const [localSettings, setLocalSettings] = useState(() => ({
60
- ...defaultForChannel,
61
- ...initialSettings,
62
- }));
63
-
64
- const isWhatsappAccountLocked = channel === CHANNELS.WHATSAPP && !!whatsappAccountFromForm?.accountName;
65
-
66
- useEffect(() => {
67
- if (!isWhatsappAccountLocked || !whatsappAccountFromForm?.accountName) return;
68
- const accountByName = (wecrmAccounts || []).find(
69
- (a) => (a.name || '') === whatsappAccountFromForm.accountName,
70
- );
71
- const sourceAccountId = accountByName?.sourceAccountIdentifier;
72
- if (!sourceAccountId) return;
73
- setLocalSettings((prev) => {
74
- if (prev[DELIVERY_SETTING_KEY_SOURCE_ACCOUNT_IDENTIFIER] === sourceAccountId) return prev;
75
- const next = cloneDeep(prev);
76
- next[DELIVERY_SETTING_KEY_SOURCE_ACCOUNT_IDENTIFIER] = sourceAccountId;
77
- const domain = (senderDetailsOptions || []).find(
78
- (d) => d.sourceAccountIdentifier === sourceAccountId,
79
- );
80
- const first = domain?.gsmSenders?.[0];
81
- if (first?.value != null) {
82
- next[DELIVERY_SETTING_KEY_SENDER_MOB_NUM] = first.value;
83
- }
84
- return next;
85
- });
86
- }, [
87
- isWhatsappAccountLocked,
88
- whatsappAccountFromForm?.accountName,
89
- wecrmAccounts,
90
- senderDetailsOptions,
91
- ]);
92
-
93
- const noOptionsLabel = formatMessage
94
- ? formatMessage(messages.noOptions)
95
- : NO_OPTIONS_LABEL;
96
-
97
- const domainOptions = useMemo(
98
- () => (senderDetailsOptions || []).map((d) => ({
99
- label: d.domainName || d.domainId,
100
- value: d.domainId,
101
- ...d,
102
- })),
103
- [senderDetailsOptions],
104
- );
105
-
106
- const selectedDomain = useMemo(
107
- () => (senderDetailsOptions || []).find(
108
- (d) => d.domainId === get(localSettings, DELIVERY_SETTING_KEY_DOMAIN_ID),
109
- ) || {},
110
- [senderDetailsOptions, localSettings.domainId],
111
- );
112
-
113
- const gsmOptions = useMemo(
114
- () => (selectedDomain.gsmSenders || []).map((o) => ({
115
- label: o.value || o.label,
116
- value: o.value,
117
- })),
118
- [selectedDomain.gsmSenders],
119
- );
120
-
121
- const emailSenderOptions = useMemo(
122
- () => (selectedDomain.emailSenders || []).map((o) => ({
123
- label: o.value || o.label,
124
- value: o.value,
125
- senderLabel: o.label,
126
- })),
127
- [selectedDomain.emailSenders],
128
- );
129
-
130
- const emailSenderIdOptions = useMemo(
131
- () => (selectedDomain.emailSenders || []).map((o) => ({
132
- label: o.label || o.value,
133
- value: o.label || o.value,
134
- senderEmail: o.value,
135
- })),
136
- [selectedDomain.emailSenders],
137
- );
138
-
139
- const emailReplyToOptions = useMemo(
140
- () => (selectedDomain.emailRepliers || []).map((o) => ({
141
- label: o.value || o.label,
142
- value: o.value,
143
- })),
144
- [selectedDomain.emailRepliers],
145
- );
146
-
147
- const wecrmAccountOptions = useMemo(
148
- () => (wecrmAccounts || []).map((a) => ({
149
- label: a.name || a.sourceAccountIdentifier,
150
- value: a.sourceAccountIdentifier,
151
- ...a,
152
- })),
153
- [wecrmAccounts],
154
- );
155
-
156
- const whatsappAccountOptionsForDisplay = useMemo(() => {
157
- if (!isWhatsappAccountLocked || !whatsappAccountFromForm?.accountName) return wecrmAccountOptions;
158
- const name = whatsappAccountFromForm.accountName;
159
- const match = wecrmAccountOptions.find(
160
- (a) => (a.label === name || a.name === name),
161
- );
162
- if (match) return [match];
163
- return [{ label: name, value: name }];
164
- }, [isWhatsappAccountLocked, whatsappAccountFromForm?.accountName, wecrmAccountOptions]);
165
-
166
- const whatsappSenderOptions = useMemo(() => {
167
- const selectedAccId = get(localSettings, DELIVERY_SETTING_KEY_SOURCE_ACCOUNT_IDENTIFIER);
168
- if (!selectedAccId) {
169
- return (senderDetailsOptions || []).flatMap((d) => (d.gsmSenders || []).map((o) => ({
170
- label: o.value,
171
- value: o.value,
172
- })));
173
- }
174
- const domainForAccount = (senderDetailsOptions || []).find(
175
- (d) => d.sourceAccountIdentifier === selectedAccId,
176
- );
177
- return (domainForAccount?.gsmSenders || []).map((o) => ({
178
- label: o.value,
179
- value: o.value,
180
- }));
181
- }, [senderDetailsOptions, localSettings.sourceAccountIdentifier]);
182
-
183
- const updateSetting = useCallback((key, value) => {
184
- setLocalSettings((prev) => {
185
- const next = cloneDeep(prev);
186
- next[key] = value;
187
- return next;
188
- });
189
- }, []);
190
-
191
- const onDomainChange = useCallback(
192
- (value) => {
193
- const domain = domainOptions.find((d) => d.value === value);
194
- updateSetting(DELIVERY_SETTING_KEY_DOMAIN_ID, value);
195
- if (domain?.dgmId != null) updateSetting(DELIVERY_SETTING_KEY_DOMAIN_GATEWAY_MAP_ID, domain.dgmId);
196
- if (channel === CHANNELS.SMS && domain) {
197
- const def = findDefault(domain.gsmSenders);
198
- updateSetting(DELIVERY_SETTING_KEY_GSM_SENDER_ID, def?.value || '');
199
- const defCdma = findDefault(domain.cdmaSenders);
200
- updateSetting(DELIVERY_SETTING_KEY_CDMA_SENDER_ID, defCdma?.value || '');
201
- }
202
- if (channel === CHANNELS.EMAIL && domain) {
203
- const defSender = findDefault(domain.emailSenders);
204
- const defReply = findDefault(domain.emailRepliers);
205
- updateSetting(DELIVERY_SETTING_KEY_SENDER_EMAIL, defSender?.value || '');
206
- updateSetting(DELIVERY_SETTING_KEY_SENDER_LABEL, defSender?.label || '');
207
- updateSetting(DELIVERY_SETTING_KEY_SENDER_REPLY_TO, defReply?.value || '');
208
- }
209
- },
210
- [channel, domainOptions, updateSetting],
211
- );
212
-
213
- const handleDone = useCallback(() => {
214
- onSaveDeliverySettings(localSettings);
215
- if (onClose) onClose();
216
- }, [localSettings, onSaveDeliverySettings, onClose]);
217
-
218
- const renderSelectRow = useCallback(
219
- ({
220
- titleMessage, options, value, onChange, rowKey, disabled,
221
- }) => (
222
- <CapRow className="modify-delivery-settings__field-row" key={rowKey}>
223
- <CapHeader
224
- size={HEADER_SIZE_LABEL}
225
- title={<FormattedMessage {...titleMessage} />}
226
- className="modify-delivery-settings__field-header"
227
- />
228
- <CapSelect
229
- options={options}
230
- value={value}
231
- onChange={onChange}
232
- placeholder={noOptionsLabel}
233
- componentClassName={`modify-delivery-settings__select${disabled ? ' modify-delivery-settings__select--disabled' : ''}`}
234
- disabled={disabled}
235
- />
236
- {disabled && <CapLabel type="label3">{formatMessage(messages.disabledMessage)}</CapLabel>}
237
- </CapRow>
238
- ),
239
- [noOptionsLabel],
240
- );
241
-
242
- const getChannelFields = useCallback(() => {
243
- const smsFields = [
244
- {
245
- titleMessage: messages.senderDomainLabel,
246
- options: domainOptions,
247
- value: get(localSettings, DELIVERY_SETTING_KEY_DOMAIN_ID),
248
- onChange: (val) => onDomainChange(val),
249
- },
250
- {
251
- titleMessage: messages.senderIdLabel,
252
- options: gsmOptions,
253
- value: get(localSettings, DELIVERY_SETTING_KEY_GSM_SENDER_ID),
254
- onChange: (val) => updateSetting(DELIVERY_SETTING_KEY_GSM_SENDER_ID, val),
255
- },
256
- ];
257
- const emailFields = [
258
- {
259
- titleMessage: messages.emailDomainLabel,
260
- options: domainOptions,
261
- value: get(localSettings, DELIVERY_SETTING_KEY_DOMAIN_ID),
262
- onChange: (val) => onDomainChange(val),
263
- },
264
- {
265
- titleMessage: messages.senderIdLabel,
266
- options: emailSenderOptions,
267
- value: get(localSettings, DELIVERY_SETTING_KEY_SENDER_EMAIL),
268
- onChange: (val) => {
269
- const sender = (selectedDomain.emailSenders || []).find(
270
- (s) => s.value === val,
271
- );
272
- updateSetting(DELIVERY_SETTING_KEY_SENDER_EMAIL, val);
273
- updateSetting(DELIVERY_SETTING_KEY_SENDER_LABEL, sender?.label || val);
274
- },
275
- },
276
- {
277
- titleMessage: messages.senderNameLabelEmail,
278
- options: emailSenderIdOptions,
279
- value: get(localSettings, DELIVERY_SETTING_KEY_SENDER_LABEL) || '',
280
- onChange: (val) => {
281
- const sender = (selectedDomain.emailSenders || []).find(
282
- (s) => (s.label || s.value) === val,
283
- );
284
- if (sender) {
285
- updateSetting(DELIVERY_SETTING_KEY_SENDER_EMAIL, sender.value);
286
- updateSetting(DELIVERY_SETTING_KEY_SENDER_LABEL, sender.label || sender.value);
287
- } else {
288
- updateSetting(DELIVERY_SETTING_KEY_SENDER_LABEL, val);
289
- }
290
- },
291
- },
292
- {
293
- titleMessage: messages.replyToIdLabel,
294
- options: emailReplyToOptions,
295
- value: get(localSettings, DELIVERY_SETTING_KEY_SENDER_REPLY_TO),
296
- onChange: (val) => updateSetting(DELIVERY_SETTING_KEY_SENDER_REPLY_TO, val),
297
- },
298
- ];
299
- const whatsappAccountValue = isWhatsappAccountLocked && whatsappAccountOptionsForDisplay.length > 0
300
- ? whatsappAccountOptionsForDisplay[0].value
301
- : get(localSettings, DELIVERY_SETTING_KEY_SOURCE_ACCOUNT_IDENTIFIER);
302
- const whatsappFields = [
303
- {
304
- titleMessage: messages.accountLabel,
305
- options: whatsappAccountOptionsForDisplay,
306
- value: whatsappAccountValue,
307
- onChange: (val) => {
308
- updateSetting(DELIVERY_SETTING_KEY_SOURCE_ACCOUNT_IDENTIFIER, val);
309
- const domain = (senderDetailsOptions || []).find(
310
- (d) => d.sourceAccountIdentifier === val,
311
- );
312
- const first = domain?.gsmSenders?.[0];
313
- updateSetting(DELIVERY_SETTING_KEY_SENDER_MOB_NUM, first?.value || '');
314
- },
315
- disabled: isWhatsappAccountLocked,
316
- },
317
- {
318
- titleMessage: messages.senderNumberLabel,
319
- options: whatsappSenderOptions,
320
- value: get(localSettings, DELIVERY_SETTING_KEY_SENDER_MOB_NUM),
321
- onChange: (val) => updateSetting(DELIVERY_SETTING_KEY_SENDER_MOB_NUM, val),
322
- },
323
- ];
324
- const byChannel = {
325
- [CHANNELS.SMS]: smsFields,
326
- [CHANNELS.EMAIL]: emailFields,
327
- [CHANNELS.WHATSAPP]: whatsappFields,
328
- };
329
- return byChannel[channel] || [];
330
- }, [
331
- channel,
332
- domainOptions,
333
- gsmOptions,
334
- emailSenderOptions,
335
- emailSenderIdOptions,
336
- emailReplyToOptions,
337
- wecrmAccountOptions,
338
- whatsappAccountOptionsForDisplay,
339
- whatsappSenderOptions,
340
- localSettings,
341
- selectedDomain.emailSenders,
342
- senderDetailsOptions,
343
- onDomainChange,
344
- updateSetting,
345
- isWhatsappAccountLocked,
346
- whatsappAccountFromForm,
347
- ]);
348
-
349
- if (isLoading) {
350
- return (
351
- <CapRow className="modify-delivery-settings__loading-row">
352
- <CapSpin spinning />
353
- </CapRow>
354
- );
355
- }
356
-
357
- return (
358
- <div className="modify-delivery-settings">
359
- {getChannelFields().map((field, idx) => renderSelectRow({
360
- ...field,
361
- rowKey: field.titleMessage?.id || `${ROW_KEY_PREFIX}${idx}`,
362
- disabled: field.disabled,
363
- }))}
364
- <CapRow className="modify-delivery-settings__actions">
365
- <CapButton type={BUTTON_TYPE_PRIMARY} onClick={handleDone}>
366
- <FormattedMessage {...messages.done} />
367
- </CapButton>
368
- </CapRow>
369
- </div>
370
- );
371
- };
372
-
373
- ModifyDeliverySettings.propTypes = {
374
- channel: PropTypes.oneOf([CHANNELS.SMS, CHANNELS.EMAIL, CHANNELS.WHATSAPP]).isRequired,
375
- deliverySettings: PropTypes.object,
376
- senderDetailsOptions: PropTypes.array,
377
- wecrmAccounts: PropTypes.array,
378
- onSaveDeliverySettings: PropTypes.func.isRequired,
379
- onClose: PropTypes.func,
380
- isLoading: PropTypes.bool,
381
- formatMessage: PropTypes.func,
382
- whatsappAccountFromForm: PropTypes.shape({
383
- accountName: PropTypes.string,
384
- }),
385
- };
386
-
387
- ModifyDeliverySettings.defaultProps = {
388
- deliverySettings: {},
389
- senderDetailsOptions: [],
390
- wecrmAccounts: [],
391
- onClose: undefined,
392
- isLoading: false,
393
- formatMessage: undefined,
394
- whatsappAccountFromForm: undefined,
395
- };
396
-
397
- export default ModifyDeliverySettings;
@@ -1,35 +0,0 @@
1
- /**
2
- * ModifyDeliverySettings — styles for delivery settings form (SMS, Email, WhatsApp).
3
- * Field rows, select width, and actions row.
4
- */
5
- @import '~@capillarytech/cap-ui-library/styles/_variables.scss';
6
-
7
- .modify-delivery-settings {
8
- &__field-row {
9
- margin-bottom: $CAP_SPACE_24;
10
- }
11
-
12
- &__field-header {
13
- margin-bottom: $CAP_SPACE_08;
14
- }
15
-
16
- &__select {
17
- width: 22.85rem;
18
-
19
- &--disabled {
20
- background-color: #ebecf0;
21
- pointer-events: none;
22
- }
23
- }
24
-
25
- &__actions {
26
- margin-top: $CAP_SPACE_24;
27
- position: absolute;
28
- bottom: 0;
29
- margin-bottom: $CAP_SPACE_16;
30
- }
31
-
32
- &__loading-row {
33
- display: block;
34
- }
35
- }