@capillarytech/creatives-library 8.0.293 → 8.0.295
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/package.json +1 -1
- package/v2Components/CommonTestAndPreview/SendTestMessage.js +1 -51
- package/v2Components/CommonTestAndPreview/actions.js +0 -20
- package/v2Components/CommonTestAndPreview/constants.js +0 -10
- package/v2Components/CommonTestAndPreview/index.js +15 -148
- package/v2Components/CommonTestAndPreview/reducer.js +0 -47
- package/v2Components/CommonTestAndPreview/sagas.js +0 -60
- package/v2Components/CommonTestAndPreview/selectors.js +0 -51
- package/v2Components/CommonTestAndPreview/tests/SendTestMessage.test.js +0 -135
- package/v2Components/CommonTestAndPreview/tests/actions.test.js +0 -50
- package/v2Components/CommonTestAndPreview/tests/constants.test.js +0 -18
- package/v2Components/CommonTestAndPreview/tests/index.test.js +1 -342
- package/v2Components/CommonTestAndPreview/tests/reducer.test.js +0 -118
- package/v2Components/CommonTestAndPreview/tests/sagas.test.js +0 -145
- package/v2Components/CommonTestAndPreview/tests/selectors.test.js +0 -146
- package/v2Components/FormBuilder/index.js +1 -1
- package/v2Components/HtmlEditor/HTMLEditor.js +1 -0
- package/v2Components/HtmlEditor/__tests__/HTMLEditor.test.js +1 -0
- package/v2Components/HtmlEditor/hooks/__tests__/useValidation.test.js +132 -3
- package/v2Components/HtmlEditor/hooks/useValidation.js +12 -9
- package/v2Components/HtmlEditor/utils/htmlValidator.js +4 -2
- package/v2Components/TestAndPreviewSlidebox/index.js +0 -14
- package/v2Containers/EmailWrapper/components/EmailHTMLEditor.js +2 -2
- package/v2Containers/EmailWrapper/components/__tests__/EmailHTMLEditor.test.js +110 -18
- package/v2Containers/Rcs/tests/__snapshots__/index.test.js.snap +12 -697
- package/v2Containers/SmsTrai/Edit/index.js +1 -5
- package/v2Containers/SmsTrai/Edit/tests/__snapshots__/index.test.js.snap +0 -201
- package/v2Containers/Whatsapp/index.js +1 -1
- package/v2Containers/Whatsapp/tests/__snapshots__/index.test.js.snap +4225 -26242
- package/v2Components/CommonTestAndPreview/DeliverySettings/DeliverySettings.scss +0 -33
- package/v2Components/CommonTestAndPreview/DeliverySettings/ModifyDeliverySettings.js +0 -422
- package/v2Components/CommonTestAndPreview/DeliverySettings/ModifyDeliverySettings.scss +0 -35
- package/v2Components/CommonTestAndPreview/DeliverySettings/TECH_DETAILING_DELIVERY_SETTINGS.md +0 -725
- package/v2Components/CommonTestAndPreview/DeliverySettings/constants.js +0 -92
- package/v2Components/CommonTestAndPreview/DeliverySettings/index.js +0 -251
- package/v2Components/CommonTestAndPreview/DeliverySettings/messages.js +0 -111
- package/v2Components/CommonTestAndPreview/DeliverySettings/utils/parseSenderDetailsResponse.js +0 -91
- package/v2Components/CommonTestAndPreview/tests/DeliverySettings/ModifyDeliverySettings.test.js +0 -889
- package/v2Components/CommonTestAndPreview/tests/DeliverySettings/index.test.js +0 -222
- 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,422 +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
|
-
smsTraiDltEnabled,
|
|
56
|
-
registeredSenderIds = [],
|
|
57
|
-
whatsappAccountFromForm,
|
|
58
|
-
} = props;
|
|
59
|
-
|
|
60
|
-
const defaultForChannel = DEFAULT_DELIVERY_SETTINGS_BY_CHANNEL[channel] || {};
|
|
61
|
-
const [localSettings, setLocalSettings] = useState(() => ({
|
|
62
|
-
...defaultForChannel,
|
|
63
|
-
...initialSettings,
|
|
64
|
-
}));
|
|
65
|
-
|
|
66
|
-
const isWhatsappAccountLocked = channel === CHANNELS.WHATSAPP && !!whatsappAccountFromForm?.accountName;
|
|
67
|
-
|
|
68
|
-
useEffect(() => {
|
|
69
|
-
if (!isWhatsappAccountLocked || !whatsappAccountFromForm?.accountName) return;
|
|
70
|
-
const accountByName = (wecrmAccounts || []).find(
|
|
71
|
-
(a) => (a.name || '') === whatsappAccountFromForm.accountName,
|
|
72
|
-
);
|
|
73
|
-
const sourceAccountId = accountByName?.sourceAccountIdentifier;
|
|
74
|
-
if (!sourceAccountId) return;
|
|
75
|
-
setLocalSettings((prev) => {
|
|
76
|
-
if (prev[DELIVERY_SETTING_KEY_SOURCE_ACCOUNT_IDENTIFIER] === sourceAccountId) return prev;
|
|
77
|
-
const next = cloneDeep(prev);
|
|
78
|
-
next[DELIVERY_SETTING_KEY_SOURCE_ACCOUNT_IDENTIFIER] = sourceAccountId;
|
|
79
|
-
const domain = (senderDetailsOptions || []).find(
|
|
80
|
-
(d) => d.sourceAccountIdentifier === sourceAccountId,
|
|
81
|
-
);
|
|
82
|
-
const first = domain?.gsmSenders?.[0];
|
|
83
|
-
if (first?.value != null) {
|
|
84
|
-
next[DELIVERY_SETTING_KEY_SENDER_MOB_NUM] = first.value;
|
|
85
|
-
}
|
|
86
|
-
return next;
|
|
87
|
-
});
|
|
88
|
-
}, [
|
|
89
|
-
isWhatsappAccountLocked,
|
|
90
|
-
whatsappAccountFromForm?.accountName,
|
|
91
|
-
wecrmAccounts,
|
|
92
|
-
senderDetailsOptions,
|
|
93
|
-
]);
|
|
94
|
-
|
|
95
|
-
const noOptionsLabel = formatMessage
|
|
96
|
-
? formatMessage(messages.noOptions)
|
|
97
|
-
: NO_OPTIONS_LABEL;
|
|
98
|
-
|
|
99
|
-
const allDomainOptions = useMemo(
|
|
100
|
-
() => (senderDetailsOptions || []).map((d) => ({
|
|
101
|
-
label: d.domainName || d.domainId,
|
|
102
|
-
value: d.domainId,
|
|
103
|
-
...d,
|
|
104
|
-
})),
|
|
105
|
-
[senderDetailsOptions],
|
|
106
|
-
);
|
|
107
|
-
|
|
108
|
-
const domainOptions = useMemo(() => {
|
|
109
|
-
if (!(channel === CHANNELS.SMS && smsTraiDltEnabled)) {
|
|
110
|
-
return allDomainOptions;
|
|
111
|
-
}
|
|
112
|
-
|
|
113
|
-
return allDomainOptions.filter((domain) => (domain.gsmSenders || []).some(
|
|
114
|
-
(gsmId) => registeredSenderIds.includes(gsmId.value),
|
|
115
|
-
));
|
|
116
|
-
}, [allDomainOptions, channel, registeredSenderIds, smsTraiDltEnabled]);
|
|
117
|
-
|
|
118
|
-
const selectedDomain = useMemo(
|
|
119
|
-
() => (senderDetailsOptions || []).find(
|
|
120
|
-
(d) => d.domainId === get(localSettings, DELIVERY_SETTING_KEY_DOMAIN_ID),
|
|
121
|
-
) || {},
|
|
122
|
-
[senderDetailsOptions, localSettings.domainId],
|
|
123
|
-
);
|
|
124
|
-
|
|
125
|
-
const gsmOptions = useMemo(
|
|
126
|
-
() => {
|
|
127
|
-
const smsGsmSenders = channel === CHANNELS.SMS && smsTraiDltEnabled
|
|
128
|
-
? (selectedDomain.gsmSenders || []).filter((gsmId) => registeredSenderIds.includes(gsmId.value))
|
|
129
|
-
: (selectedDomain.gsmSenders || []);
|
|
130
|
-
|
|
131
|
-
return smsGsmSenders.map((o) => ({
|
|
132
|
-
label: o.value || o.label,
|
|
133
|
-
value: o.value,
|
|
134
|
-
}));
|
|
135
|
-
},
|
|
136
|
-
[channel, registeredSenderIds, selectedDomain.gsmSenders, smsTraiDltEnabled],
|
|
137
|
-
);
|
|
138
|
-
|
|
139
|
-
const emailSenderOptions = useMemo(
|
|
140
|
-
() => (selectedDomain.emailSenders || []).map((o) => ({
|
|
141
|
-
label: o.value || o.label,
|
|
142
|
-
value: o.value,
|
|
143
|
-
senderLabel: o.label,
|
|
144
|
-
})),
|
|
145
|
-
[selectedDomain.emailSenders],
|
|
146
|
-
);
|
|
147
|
-
|
|
148
|
-
const emailSenderIdOptions = useMemo(
|
|
149
|
-
() => (selectedDomain.emailSenders || []).map((o) => ({
|
|
150
|
-
label: o.label || o.value,
|
|
151
|
-
value: o.label || o.value,
|
|
152
|
-
senderEmail: o.value,
|
|
153
|
-
})),
|
|
154
|
-
[selectedDomain.emailSenders],
|
|
155
|
-
);
|
|
156
|
-
|
|
157
|
-
const emailReplyToOptions = useMemo(
|
|
158
|
-
() => (selectedDomain.emailRepliers || []).map((o) => ({
|
|
159
|
-
label: o.value || o.label,
|
|
160
|
-
value: o.value,
|
|
161
|
-
})),
|
|
162
|
-
[selectedDomain.emailRepliers],
|
|
163
|
-
);
|
|
164
|
-
|
|
165
|
-
const wecrmAccountOptions = useMemo(
|
|
166
|
-
() => (wecrmAccounts || []).map((a) => ({
|
|
167
|
-
label: a.name || a.sourceAccountIdentifier,
|
|
168
|
-
value: a.sourceAccountIdentifier,
|
|
169
|
-
...a,
|
|
170
|
-
})),
|
|
171
|
-
[wecrmAccounts],
|
|
172
|
-
);
|
|
173
|
-
|
|
174
|
-
const whatsappAccountOptionsForDisplay = useMemo(() => {
|
|
175
|
-
if (!isWhatsappAccountLocked || !whatsappAccountFromForm?.accountName) return wecrmAccountOptions;
|
|
176
|
-
const name = whatsappAccountFromForm.accountName;
|
|
177
|
-
const match = wecrmAccountOptions.find(
|
|
178
|
-
(a) => (a.label === name || a.name === name),
|
|
179
|
-
);
|
|
180
|
-
if (match) return [match];
|
|
181
|
-
return [{ label: name, value: name }];
|
|
182
|
-
}, [isWhatsappAccountLocked, whatsappAccountFromForm?.accountName, wecrmAccountOptions]);
|
|
183
|
-
|
|
184
|
-
const whatsappSenderOptions = useMemo(() => {
|
|
185
|
-
const selectedAccId = get(localSettings, DELIVERY_SETTING_KEY_SOURCE_ACCOUNT_IDENTIFIER);
|
|
186
|
-
if (!selectedAccId) {
|
|
187
|
-
return (senderDetailsOptions || []).flatMap((d) => (d.gsmSenders || []).map((o) => ({
|
|
188
|
-
label: o.value,
|
|
189
|
-
value: o.value,
|
|
190
|
-
})));
|
|
191
|
-
}
|
|
192
|
-
const domainForAccount = (senderDetailsOptions || []).find(
|
|
193
|
-
(d) => d.sourceAccountIdentifier === selectedAccId,
|
|
194
|
-
);
|
|
195
|
-
return (domainForAccount?.gsmSenders || []).map((o) => ({
|
|
196
|
-
label: o.value,
|
|
197
|
-
value: o.value,
|
|
198
|
-
}));
|
|
199
|
-
}, [senderDetailsOptions, localSettings.sourceAccountIdentifier]);
|
|
200
|
-
|
|
201
|
-
const updateSetting = useCallback((key, value) => {
|
|
202
|
-
setLocalSettings((prev) => {
|
|
203
|
-
const next = cloneDeep(prev);
|
|
204
|
-
next[key] = value;
|
|
205
|
-
return next;
|
|
206
|
-
});
|
|
207
|
-
}, []);
|
|
208
|
-
|
|
209
|
-
const onDomainChange = useCallback(
|
|
210
|
-
(value) => {
|
|
211
|
-
const domain = domainOptions.find((d) => d.value === value);
|
|
212
|
-
updateSetting(DELIVERY_SETTING_KEY_DOMAIN_ID, value);
|
|
213
|
-
if (domain?.dgmId != null) updateSetting(DELIVERY_SETTING_KEY_DOMAIN_GATEWAY_MAP_ID, domain.dgmId);
|
|
214
|
-
if (channel === CHANNELS.SMS && domain) {
|
|
215
|
-
const smsGsmSenders = smsTraiDltEnabled
|
|
216
|
-
? (domain.gsmSenders || []).filter((gsmId) => registeredSenderIds.includes(gsmId.value))
|
|
217
|
-
: domain.gsmSenders;
|
|
218
|
-
const def = findDefault(smsGsmSenders);
|
|
219
|
-
updateSetting(DELIVERY_SETTING_KEY_GSM_SENDER_ID, def?.value || '');
|
|
220
|
-
const defCdma = findDefault(domain.cdmaSenders);
|
|
221
|
-
updateSetting(DELIVERY_SETTING_KEY_CDMA_SENDER_ID, defCdma?.value || '');
|
|
222
|
-
}
|
|
223
|
-
if (channel === CHANNELS.EMAIL && domain) {
|
|
224
|
-
const defSender = findDefault(domain.emailSenders);
|
|
225
|
-
const defReply = findDefault(domain.emailRepliers);
|
|
226
|
-
updateSetting(DELIVERY_SETTING_KEY_SENDER_EMAIL, defSender?.value || '');
|
|
227
|
-
updateSetting(DELIVERY_SETTING_KEY_SENDER_LABEL, defSender?.label || '');
|
|
228
|
-
updateSetting(DELIVERY_SETTING_KEY_SENDER_REPLY_TO, defReply?.value || '');
|
|
229
|
-
}
|
|
230
|
-
},
|
|
231
|
-
[channel, domainOptions, registeredSenderIds, smsTraiDltEnabled, updateSetting],
|
|
232
|
-
);
|
|
233
|
-
|
|
234
|
-
const handleDone = useCallback(() => {
|
|
235
|
-
onSaveDeliverySettings(localSettings);
|
|
236
|
-
if (onClose) onClose();
|
|
237
|
-
}, [localSettings, onSaveDeliverySettings, onClose]);
|
|
238
|
-
|
|
239
|
-
const renderSelectRow = useCallback(
|
|
240
|
-
({
|
|
241
|
-
titleMessage, options, value, onChange, rowKey, disabled,
|
|
242
|
-
}) => (
|
|
243
|
-
<CapRow className="modify-delivery-settings__field-row" key={rowKey}>
|
|
244
|
-
<CapHeader
|
|
245
|
-
size={HEADER_SIZE_LABEL}
|
|
246
|
-
title={<FormattedMessage {...titleMessage} />}
|
|
247
|
-
className="modify-delivery-settings__field-header"
|
|
248
|
-
/>
|
|
249
|
-
<CapSelect
|
|
250
|
-
options={options}
|
|
251
|
-
value={value}
|
|
252
|
-
onChange={onChange}
|
|
253
|
-
placeholder={noOptionsLabel}
|
|
254
|
-
componentClassName={`modify-delivery-settings__select${disabled ? ' modify-delivery-settings__select--disabled' : ''}`}
|
|
255
|
-
disabled={disabled}
|
|
256
|
-
/>
|
|
257
|
-
{disabled && <CapLabel type="label3">{formatMessage(messages.disabledMessage)}</CapLabel>}
|
|
258
|
-
</CapRow>
|
|
259
|
-
),
|
|
260
|
-
[noOptionsLabel],
|
|
261
|
-
);
|
|
262
|
-
|
|
263
|
-
const getChannelFields = useCallback(() => {
|
|
264
|
-
const smsFields = [
|
|
265
|
-
{
|
|
266
|
-
titleMessage: messages.senderDomainLabel,
|
|
267
|
-
options: domainOptions,
|
|
268
|
-
value: get(localSettings, DELIVERY_SETTING_KEY_DOMAIN_ID),
|
|
269
|
-
onChange: (val) => onDomainChange(val),
|
|
270
|
-
},
|
|
271
|
-
{
|
|
272
|
-
titleMessage: messages.senderIdLabel,
|
|
273
|
-
options: gsmOptions,
|
|
274
|
-
value: get(localSettings, DELIVERY_SETTING_KEY_GSM_SENDER_ID),
|
|
275
|
-
onChange: (val) => updateSetting(DELIVERY_SETTING_KEY_GSM_SENDER_ID, val),
|
|
276
|
-
},
|
|
277
|
-
];
|
|
278
|
-
const emailFields = [
|
|
279
|
-
{
|
|
280
|
-
titleMessage: messages.emailDomainLabel,
|
|
281
|
-
options: domainOptions,
|
|
282
|
-
value: get(localSettings, DELIVERY_SETTING_KEY_DOMAIN_ID),
|
|
283
|
-
onChange: (val) => onDomainChange(val),
|
|
284
|
-
},
|
|
285
|
-
{
|
|
286
|
-
titleMessage: messages.senderIdLabel,
|
|
287
|
-
options: emailSenderOptions,
|
|
288
|
-
value: get(localSettings, DELIVERY_SETTING_KEY_SENDER_EMAIL),
|
|
289
|
-
onChange: (val) => {
|
|
290
|
-
const sender = (selectedDomain.emailSenders || []).find(
|
|
291
|
-
(s) => s.value === val,
|
|
292
|
-
);
|
|
293
|
-
updateSetting(DELIVERY_SETTING_KEY_SENDER_EMAIL, val);
|
|
294
|
-
updateSetting(DELIVERY_SETTING_KEY_SENDER_LABEL, sender?.label || val);
|
|
295
|
-
},
|
|
296
|
-
},
|
|
297
|
-
{
|
|
298
|
-
titleMessage: messages.senderNameLabelEmail,
|
|
299
|
-
options: emailSenderIdOptions,
|
|
300
|
-
value: get(localSettings, DELIVERY_SETTING_KEY_SENDER_LABEL) || '',
|
|
301
|
-
onChange: (val) => {
|
|
302
|
-
const sender = (selectedDomain.emailSenders || []).find(
|
|
303
|
-
(s) => (s.label || s.value) === val,
|
|
304
|
-
);
|
|
305
|
-
if (sender) {
|
|
306
|
-
updateSetting(DELIVERY_SETTING_KEY_SENDER_EMAIL, sender.value);
|
|
307
|
-
updateSetting(DELIVERY_SETTING_KEY_SENDER_LABEL, sender.label || sender.value);
|
|
308
|
-
} else {
|
|
309
|
-
updateSetting(DELIVERY_SETTING_KEY_SENDER_LABEL, val);
|
|
310
|
-
}
|
|
311
|
-
},
|
|
312
|
-
},
|
|
313
|
-
{
|
|
314
|
-
titleMessage: messages.replyToIdLabel,
|
|
315
|
-
options: emailReplyToOptions,
|
|
316
|
-
value: get(localSettings, DELIVERY_SETTING_KEY_SENDER_REPLY_TO),
|
|
317
|
-
onChange: (val) => updateSetting(DELIVERY_SETTING_KEY_SENDER_REPLY_TO, val),
|
|
318
|
-
},
|
|
319
|
-
];
|
|
320
|
-
const whatsappAccountValue = isWhatsappAccountLocked && whatsappAccountOptionsForDisplay.length > 0
|
|
321
|
-
? whatsappAccountOptionsForDisplay[0].value
|
|
322
|
-
: get(localSettings, DELIVERY_SETTING_KEY_SOURCE_ACCOUNT_IDENTIFIER);
|
|
323
|
-
const whatsappFields = [
|
|
324
|
-
{
|
|
325
|
-
titleMessage: messages.accountLabel,
|
|
326
|
-
options: whatsappAccountOptionsForDisplay,
|
|
327
|
-
value: whatsappAccountValue,
|
|
328
|
-
onChange: (val) => {
|
|
329
|
-
updateSetting(DELIVERY_SETTING_KEY_SOURCE_ACCOUNT_IDENTIFIER, val);
|
|
330
|
-
const domain = (senderDetailsOptions || []).find(
|
|
331
|
-
(d) => d.sourceAccountIdentifier === val,
|
|
332
|
-
);
|
|
333
|
-
const first = domain?.gsmSenders?.[0];
|
|
334
|
-
updateSetting(DELIVERY_SETTING_KEY_SENDER_MOB_NUM, first?.value || '');
|
|
335
|
-
},
|
|
336
|
-
disabled: isWhatsappAccountLocked,
|
|
337
|
-
},
|
|
338
|
-
{
|
|
339
|
-
titleMessage: messages.senderNumberLabel,
|
|
340
|
-
options: whatsappSenderOptions,
|
|
341
|
-
value: get(localSettings, DELIVERY_SETTING_KEY_SENDER_MOB_NUM),
|
|
342
|
-
onChange: (val) => updateSetting(DELIVERY_SETTING_KEY_SENDER_MOB_NUM, val),
|
|
343
|
-
},
|
|
344
|
-
];
|
|
345
|
-
const byChannel = {
|
|
346
|
-
[CHANNELS.SMS]: smsFields,
|
|
347
|
-
[CHANNELS.EMAIL]: emailFields,
|
|
348
|
-
[CHANNELS.WHATSAPP]: whatsappFields,
|
|
349
|
-
};
|
|
350
|
-
return byChannel[channel] || [];
|
|
351
|
-
}, [
|
|
352
|
-
channel,
|
|
353
|
-
domainOptions,
|
|
354
|
-
gsmOptions,
|
|
355
|
-
emailSenderOptions,
|
|
356
|
-
emailSenderIdOptions,
|
|
357
|
-
emailReplyToOptions,
|
|
358
|
-
wecrmAccountOptions,
|
|
359
|
-
whatsappAccountOptionsForDisplay,
|
|
360
|
-
whatsappSenderOptions,
|
|
361
|
-
localSettings,
|
|
362
|
-
selectedDomain.emailSenders,
|
|
363
|
-
senderDetailsOptions,
|
|
364
|
-
onDomainChange,
|
|
365
|
-
updateSetting,
|
|
366
|
-
isWhatsappAccountLocked,
|
|
367
|
-
whatsappAccountFromForm,
|
|
368
|
-
]);
|
|
369
|
-
|
|
370
|
-
if (isLoading) {
|
|
371
|
-
return (
|
|
372
|
-
<CapRow className="modify-delivery-settings__loading-row">
|
|
373
|
-
<CapSpin spinning />
|
|
374
|
-
</CapRow>
|
|
375
|
-
);
|
|
376
|
-
}
|
|
377
|
-
|
|
378
|
-
return (
|
|
379
|
-
<div className="modify-delivery-settings">
|
|
380
|
-
{getChannelFields().map((field, idx) => renderSelectRow({
|
|
381
|
-
...field,
|
|
382
|
-
rowKey: field.titleMessage?.id || `${ROW_KEY_PREFIX}${idx}`,
|
|
383
|
-
disabled: field.disabled,
|
|
384
|
-
}))}
|
|
385
|
-
<CapRow className="modify-delivery-settings__actions">
|
|
386
|
-
<CapButton type={BUTTON_TYPE_PRIMARY} onClick={handleDone}>
|
|
387
|
-
<FormattedMessage {...messages.done} />
|
|
388
|
-
</CapButton>
|
|
389
|
-
</CapRow>
|
|
390
|
-
</div>
|
|
391
|
-
);
|
|
392
|
-
};
|
|
393
|
-
|
|
394
|
-
ModifyDeliverySettings.propTypes = {
|
|
395
|
-
channel: PropTypes.oneOf([CHANNELS.SMS, CHANNELS.EMAIL, CHANNELS.WHATSAPP]).isRequired,
|
|
396
|
-
deliverySettings: PropTypes.object,
|
|
397
|
-
senderDetailsOptions: PropTypes.array,
|
|
398
|
-
wecrmAccounts: PropTypes.array,
|
|
399
|
-
onSaveDeliverySettings: PropTypes.func.isRequired,
|
|
400
|
-
onClose: PropTypes.func,
|
|
401
|
-
isLoading: PropTypes.bool,
|
|
402
|
-
formatMessage: PropTypes.func,
|
|
403
|
-
smsTraiDltEnabled: PropTypes.bool,
|
|
404
|
-
registeredSenderIds: PropTypes.array,
|
|
405
|
-
whatsappAccountFromForm: PropTypes.shape({
|
|
406
|
-
accountName: PropTypes.string,
|
|
407
|
-
}),
|
|
408
|
-
};
|
|
409
|
-
|
|
410
|
-
ModifyDeliverySettings.defaultProps = {
|
|
411
|
-
deliverySettings: {},
|
|
412
|
-
senderDetailsOptions: [],
|
|
413
|
-
wecrmAccounts: [],
|
|
414
|
-
onClose: undefined,
|
|
415
|
-
isLoading: false,
|
|
416
|
-
formatMessage: undefined,
|
|
417
|
-
smsTraiDltEnabled: false,
|
|
418
|
-
registeredSenderIds: [],
|
|
419
|
-
whatsappAccountFromForm: undefined,
|
|
420
|
-
};
|
|
421
|
-
|
|
422
|
-
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
|
-
}
|