@capillarytech/creatives-library 9.2.4-alpha.feature-rcs-multi-account.51 → 9.2.4-alpha.feature-rcs-multi-account.52
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/DeliverySettings/ModifyDeliverySettings.js +9 -0
- package/v2Components/CommonTestAndPreview/DeliverySettings/index.js +44 -3
- package/v2Components/CommonTestAndPreview/DeliverySettings/messages.js +14 -0
- package/v2Components/CommonTestAndPreview/SendTestMessage.js +14 -0
- package/v2Components/CommonTestAndPreview/index.js +117 -16
- package/v2Components/CommonTestAndPreview/reducer.js +8 -2
- package/v2Components/CommonTestAndPreview/selectors.js +6 -0
- package/v2Components/CommonTestAndPreview/tests/DeliverySettings/ModifyDeliverySettings.test.js +11 -0
- package/v2Components/CommonTestAndPreview/tests/DeliverySettings/index.test.js +92 -0
- package/v2Components/CommonTestAndPreview/tests/index.test.js +155 -13
- package/v2Components/CommonTestAndPreview/tests/reducer.test.js +4 -0
- package/v2Components/CommonTestAndPreview/tests/selectors.test.js +10 -0
- package/v2Components/TestAndPreviewSlidebox/index.js +8 -2
- package/v2Containers/CommunicationFlow/CommunicationFlow.js +9 -1
- package/v2Containers/CommunicationFlow/Tests/CommunicationFlow.test.js +76 -1
- package/v2Containers/CommunicationFlow/messages.js +12 -0
- package/v2Containers/CommunicationFlow/steps/ChannelSelectionStep/ChannelSelectionStep.js +5 -0
- package/v2Containers/CommunicationFlow/steps/DeliverySettingsStep/DeliverySettingsSection.js +189 -26
- package/v2Containers/CommunicationFlow/steps/DeliverySettingsStep/SenderDetails.js +31 -3
- package/v2Containers/CommunicationFlow/steps/DeliverySettingsStep/Tests/DeliverySettingsSection.test.js +360 -0
- package/v2Containers/CommunicationFlow/steps/DeliverySettingsStep/Tests/SenderDetails.test.js +25 -0
- package/v2Containers/CommunicationFlow/steps/DeliverySettingsStep/Tests/deliverySettingsConfig.test.js +40 -4
- package/v2Containers/CommunicationFlow/steps/DeliverySettingsStep/deliverySettingsConfig.js +26 -8
- package/v2Containers/CreativesContainer/index.js +15 -7
- package/v2Containers/CreativesContainer/tests/index.test.js +18 -2
- package/v2Containers/Rcs/accountUtils.js +110 -4
- package/v2Containers/Rcs/index.js +30 -21
- package/v2Containers/Rcs/tests/__snapshots__/index.test.js.snap +108 -0
- package/v2Containers/Rcs/tests/accountUtils.test.js +155 -1
- package/v2Containers/Rcs/tests/index.test.js +0 -23
- package/v2Containers/Rcs/tests/testAndPreviewAccount.test.js +193 -0
- package/v2Containers/SmsTrai/Edit/tests/__snapshots__/index.test.js.snap +27 -0
- package/v2Containers/Templates/index.js +3 -2
- package/v2Containers/Templates/tests/index.test.js +11 -0
- package/v2Containers/Whatsapp/tests/__snapshots__/index.test.js.snap +2 -2
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@capillarytech/creatives-library",
|
|
3
3
|
"author": "meharaj",
|
|
4
|
-
"version": "9.2.4-alpha.feature-rcs-multi-account.
|
|
4
|
+
"version": "9.2.4-alpha.feature-rcs-multi-account.52",
|
|
5
5
|
"description": "Capillary creatives ui",
|
|
6
6
|
"main": "./index.js",
|
|
7
7
|
"module": "./index.es.js",
|
|
@@ -71,6 +71,7 @@ const ModifyDeliverySettings = (props) => {
|
|
|
71
71
|
smsTraiDltEnabled,
|
|
72
72
|
registeredSenderIds = [],
|
|
73
73
|
whatsappAccountFromForm,
|
|
74
|
+
isRcsAccountNotConfigured = false,
|
|
74
75
|
} = props;
|
|
75
76
|
|
|
76
77
|
const defaultForChannel = DEFAULT_DELIVERY_SETTINGS_BY_CHANNEL[channel] || {};
|
|
@@ -566,6 +567,11 @@ const ModifyDeliverySettings = (props) => {
|
|
|
566
567
|
|
|
567
568
|
return (
|
|
568
569
|
<CapRow useLegacy className="modify-delivery-settings">
|
|
570
|
+
{isRcsAccountNotConfigured && (
|
|
571
|
+
<CapLabel type="label2" className="modify-delivery-settings__rcs-account-not-configured">
|
|
572
|
+
<FormattedMessage {...messages.rcsAccountNotConfigured} />
|
|
573
|
+
</CapLabel>
|
|
574
|
+
)}
|
|
569
575
|
{getChannelFields().map((field, idx) => renderSelectRow({
|
|
570
576
|
...field,
|
|
571
577
|
rowKey: field.titleMessage?.id || `${ROW_KEY_PREFIX}${idx}`,
|
|
@@ -595,6 +601,8 @@ ModifyDeliverySettings.propTypes = {
|
|
|
595
601
|
whatsappAccountFromForm: PropTypes.shape({
|
|
596
602
|
accountName: PropTypes.string,
|
|
597
603
|
}),
|
|
604
|
+
/** RCS multi-account: the template's RCS account has no RCS domain of its own (domain list is empty). */
|
|
605
|
+
isRcsAccountNotConfigured: PropTypes.bool,
|
|
598
606
|
};
|
|
599
607
|
|
|
600
608
|
ModifyDeliverySettings.defaultProps = {
|
|
@@ -608,6 +616,7 @@ ModifyDeliverySettings.defaultProps = {
|
|
|
608
616
|
smsTraiDltEnabled: false,
|
|
609
617
|
registeredSenderIds: [],
|
|
610
618
|
whatsappAccountFromForm: undefined,
|
|
619
|
+
isRcsAccountNotConfigured: false,
|
|
611
620
|
};
|
|
612
621
|
|
|
613
622
|
export default ModifyDeliverySettings;
|
|
@@ -12,10 +12,12 @@ import CapHeading from "@capillarytech/cap-ui-library/CapHeading";
|
|
|
12
12
|
import CapIcon from "@capillarytech/cap-ui-library/CapIcon";
|
|
13
13
|
import CapLabel from "@capillarytech/cap-ui-library/CapLabel";
|
|
14
14
|
import CapSlideBox from "@capillarytech/cap-ui-library/CapSlideBox";
|
|
15
|
+
import CapLink from "@capillarytech/cap-ui-library/CapLink";
|
|
15
16
|
import { FormattedMessage } from "react-intl";
|
|
16
17
|
import get from "lodash/get";
|
|
17
18
|
import messages from "./messages";
|
|
18
19
|
import ModifyDeliverySettings from "./ModifyDeliverySettings";
|
|
20
|
+
import { getRcsDomainsForAccount, getParsedRcsDomainAccountId } from "../../../v2Containers/Rcs/accountUtils";
|
|
19
21
|
import {
|
|
20
22
|
CHANNELS,
|
|
21
23
|
CHANNELS_WITH_DELIVERY_SETTINGS,
|
|
@@ -38,6 +40,9 @@ const DeliverySettings = (props) => {
|
|
|
38
40
|
deliverySettings = {},
|
|
39
41
|
senderDetailsByChannel = {},
|
|
40
42
|
wecrmAccounts = [],
|
|
43
|
+
rcsSourceAccountIdentifier = '',
|
|
44
|
+
isRcsAccountLookupFailed = false,
|
|
45
|
+
onRetryRcsAccountLookup,
|
|
41
46
|
onSaveDeliverySettings,
|
|
42
47
|
isLoadingSenderDetails,
|
|
43
48
|
formatMessage,
|
|
@@ -60,10 +65,19 @@ const DeliverySettings = (props) => {
|
|
|
60
65
|
[onSaveDeliverySettings, closeSlideBox]
|
|
61
66
|
);
|
|
62
67
|
|
|
63
|
-
const
|
|
68
|
+
const allSenderDetailsOptions = useMemo(
|
|
64
69
|
() => (senderDetailsByChannel[channel] || []),
|
|
65
70
|
[senderDetailsByChannel, channel],
|
|
66
71
|
);
|
|
72
|
+
// RCS multi-account (same as WhatsApp): only the template account's RCS domains (all when the account is unknown).
|
|
73
|
+
const senderDetailsOptions = useMemo(
|
|
74
|
+
() => (channel === CHANNELS.RCS
|
|
75
|
+
? getRcsDomainsForAccount(allSenderDetailsOptions, rcsSourceAccountIdentifier, getParsedRcsDomainAccountId)
|
|
76
|
+
: allSenderDetailsOptions),
|
|
77
|
+
[channel, allSenderDetailsOptions, rcsSourceAccountIdentifier],
|
|
78
|
+
);
|
|
79
|
+
const isRcsAccountNotConfigured = channel === CHANNELS.RCS && !!rcsSourceAccountIdentifier
|
|
80
|
+
&& allSenderDetailsOptions.length > 0 && senderDetailsOptions.length === 0;
|
|
67
81
|
const smsDomainsForRcs = useMemo(
|
|
68
82
|
() => (channel === CHANNELS.RCS ? (senderDetailsByChannel[CHANNELS.SMS] || []) : []),
|
|
69
83
|
[channel, senderDetailsByChannel],
|
|
@@ -226,9 +240,27 @@ const DeliverySettings = (props) => {
|
|
|
226
240
|
</CapRow>
|
|
227
241
|
<CapRow type="flex" className="delivery-settings__summary-row">
|
|
228
242
|
<CapRow type="flex" className="delivery-settings__summary-inner">
|
|
229
|
-
{
|
|
243
|
+
{isRcsAccountLookupFailed && (
|
|
244
|
+
<CapRow type="flex" className="delivery-settings__rcs-account-lookup-failed">
|
|
245
|
+
<CapLabel type="label2">{formatMessage(messages.rcsAccountLookupFailed)}</CapLabel>
|
|
246
|
+
<CapLink
|
|
247
|
+
type="false"
|
|
248
|
+
fontWeight="m"
|
|
249
|
+
className="delivery-settings__retry-link"
|
|
250
|
+
title={formatMessage(messages.retry)}
|
|
251
|
+
onClick={onRetryRcsAccountLookup}
|
|
252
|
+
/>
|
|
253
|
+
</CapRow>
|
|
254
|
+
)}
|
|
255
|
+
{isRcsAccountNotConfigured && (
|
|
256
|
+
<CapLabel type="label2" className="delivery-settings__rcs-account-not-configured">
|
|
257
|
+
{formatMessage(messages.rcsAccountNotConfigured)}
|
|
258
|
+
</CapLabel>
|
|
259
|
+
)}
|
|
260
|
+
{!isRcsAccountLookupFailed && !isRcsAccountNotConfigured && summaryObject == null && (
|
|
230
261
|
<CapLabel type="label2">{notConfiguredLabel}</CapLabel>
|
|
231
|
-
)
|
|
262
|
+
)}
|
|
263
|
+
{!isRcsAccountNotConfigured && summaryObject != null && (
|
|
232
264
|
Object.entries(summaryObject).map(([key, value]) => (
|
|
233
265
|
<CapRow type="flex" key={key} className="delivery-settings__summary-entry">
|
|
234
266
|
<CapLabel type="label1" className="delivery-settings__summary-key">{key}</CapLabel>
|
|
@@ -274,6 +306,7 @@ const DeliverySettings = (props) => {
|
|
|
274
306
|
smsTraiDltEnabled={smsTraiDltEnabled}
|
|
275
307
|
registeredSenderIds={registeredSenderIds}
|
|
276
308
|
whatsappAccountFromForm={whatsappAccountFromForm}
|
|
309
|
+
isRcsAccountNotConfigured={isRcsAccountNotConfigured}
|
|
277
310
|
/>
|
|
278
311
|
)}
|
|
279
312
|
/>
|
|
@@ -287,6 +320,11 @@ DeliverySettings.propTypes = {
|
|
|
287
320
|
deliverySettings: PropTypes.object,
|
|
288
321
|
senderDetailsByChannel: PropTypes.object,
|
|
289
322
|
wecrmAccounts: PropTypes.array,
|
|
323
|
+
/** RCS multi-account: template account's sourceAccountIdentifier ('' when unknown). */
|
|
324
|
+
rcsSourceAccountIdentifier: PropTypes.string,
|
|
325
|
+
/** RCS: the template account lookup failed (shows an error with retry). */
|
|
326
|
+
isRcsAccountLookupFailed: PropTypes.bool,
|
|
327
|
+
onRetryRcsAccountLookup: PropTypes.func,
|
|
290
328
|
onSaveDeliverySettings: PropTypes.func.isRequired,
|
|
291
329
|
isLoadingSenderDetails: PropTypes.bool,
|
|
292
330
|
formatMessage: PropTypes.func,
|
|
@@ -302,6 +340,9 @@ DeliverySettings.defaultProps = {
|
|
|
302
340
|
deliverySettings: {},
|
|
303
341
|
senderDetailsByChannel: {},
|
|
304
342
|
wecrmAccounts: [],
|
|
343
|
+
rcsSourceAccountIdentifier: '',
|
|
344
|
+
isRcsAccountLookupFailed: false,
|
|
345
|
+
onRetryRcsAccountLookup: undefined,
|
|
305
346
|
isLoadingSenderDetails: false,
|
|
306
347
|
formatMessage: undefined,
|
|
307
348
|
smsTraiDltEnabled: false,
|
|
@@ -133,6 +133,20 @@ export default defineMessages({
|
|
|
133
133
|
id: `${prefix}.domainLabel`,
|
|
134
134
|
defaultMessage: 'Domain',
|
|
135
135
|
},
|
|
136
|
+
/** RCS multi-account: the WeCRM RCS accounts request failed, so the template's account is unknown */
|
|
137
|
+
rcsAccountLookupFailed: {
|
|
138
|
+
id: `${prefix}.rcsAccountLookupFailed`,
|
|
139
|
+
defaultMessage: 'Could not load the RCS account of this template.',
|
|
140
|
+
},
|
|
141
|
+
retry: {
|
|
142
|
+
id: `${prefix}.retry`,
|
|
143
|
+
defaultMessage: 'Retry',
|
|
144
|
+
},
|
|
145
|
+
/** RCS multi-account: the template's RCS account has no RCS domain of its own */
|
|
146
|
+
rcsAccountNotConfigured: {
|
|
147
|
+
id: `${prefix}.rcsAccountNotConfigured`,
|
|
148
|
+
defaultMessage: 'RCS account is not configured. Please contact your Customer Success Manager to fix the issue.',
|
|
149
|
+
},
|
|
136
150
|
/** RCS: placeholder for sender ID dropdown */
|
|
137
151
|
selectSenderId: {
|
|
138
152
|
id: `${prefix}.selectSenderId`,
|
|
@@ -31,6 +31,9 @@ const SendTestMessage = ({
|
|
|
31
31
|
deliverySettings,
|
|
32
32
|
senderDetailsByChannel = {},
|
|
33
33
|
wecrmAccounts,
|
|
34
|
+
rcsSourceAccountIdentifier,
|
|
35
|
+
isRcsAccountLookupFailed,
|
|
36
|
+
onRetryRcsAccountLookup,
|
|
34
37
|
onSaveDeliverySettings,
|
|
35
38
|
isLoadingSenderDetails,
|
|
36
39
|
smsTraiDltEnabled,
|
|
@@ -81,6 +84,9 @@ const SendTestMessage = ({
|
|
|
81
84
|
deliverySettings={deliverySettings || {}}
|
|
82
85
|
senderDetailsByChannel={senderDetailsByChannel}
|
|
83
86
|
wecrmAccounts={wecrmAccounts || []}
|
|
87
|
+
rcsSourceAccountIdentifier={channel === CHANNELS.RCS ? rcsSourceAccountIdentifier : ''}
|
|
88
|
+
isRcsAccountLookupFailed={channel === CHANNELS.RCS && !!isRcsAccountLookupFailed}
|
|
89
|
+
onRetryRcsAccountLookup={onRetryRcsAccountLookup}
|
|
84
90
|
onSaveDeliverySettings={onSaveDeliverySettings}
|
|
85
91
|
isLoadingSenderDetails={isLoadingSenderDetails}
|
|
86
92
|
formatMessage={formatMessage}
|
|
@@ -126,6 +132,11 @@ SendTestMessage.propTypes = {
|
|
|
126
132
|
deliverySettings: PropTypes.object,
|
|
127
133
|
senderDetailsByChannel: PropTypes.object,
|
|
128
134
|
wecrmAccounts: PropTypes.array,
|
|
135
|
+
/** RCS multi-account: template account's sourceAccountIdentifier ('' when unknown). */
|
|
136
|
+
rcsSourceAccountIdentifier: PropTypes.string,
|
|
137
|
+
/** RCS: the template account lookup failed (show error + retry). */
|
|
138
|
+
isRcsAccountLookupFailed: PropTypes.bool,
|
|
139
|
+
onRetryRcsAccountLookup: PropTypes.func,
|
|
129
140
|
onSaveDeliverySettings: PropTypes.func,
|
|
130
141
|
isLoadingSenderDetails: PropTypes.bool,
|
|
131
142
|
smsTraiDltEnabled: PropTypes.bool,
|
|
@@ -142,6 +153,9 @@ SendTestMessage.defaultProps = {
|
|
|
142
153
|
deliverySettings: {},
|
|
143
154
|
senderDetailsByChannel: {},
|
|
144
155
|
wecrmAccounts: [],
|
|
156
|
+
rcsSourceAccountIdentifier: '',
|
|
157
|
+
isRcsAccountLookupFailed: false,
|
|
158
|
+
onRetryRcsAccountLookup: undefined,
|
|
145
159
|
onSaveDeliverySettings: undefined,
|
|
146
160
|
isLoadingSenderDetails: false,
|
|
147
161
|
smsTraiDltEnabled: false,
|
|
@@ -115,6 +115,13 @@ import {
|
|
|
115
115
|
getSmsFallbackTextForTagExtraction,
|
|
116
116
|
} from './previewApiUtils';
|
|
117
117
|
import { pickFirstSmsFallbackTemplateString } from '../../v2Containers/Rcs/rcsLibraryHydrationUtils';
|
|
118
|
+
import {
|
|
119
|
+
pickRcsDomainForAccount,
|
|
120
|
+
getRcsDomainsForAccount,
|
|
121
|
+
getParsedRcsDomainAccountId,
|
|
122
|
+
resolveRcsAccountKey,
|
|
123
|
+
getRcsAccountIdFromCreativeForm,
|
|
124
|
+
} from '../../v2Containers/Rcs/accountUtils';
|
|
118
125
|
|
|
119
126
|
import { isValidEmail, isValidMobile, formatPhoneNumber } from '../../utils/commonUtils';
|
|
120
127
|
import { getMembersLookup } from '../../services/api';
|
|
@@ -217,6 +224,8 @@ const CommonTestAndPreview = (props) => {
|
|
|
217
224
|
fetchPrefilledValuesErrors,
|
|
218
225
|
senderDetailsByChannel = {},
|
|
219
226
|
wecrmAccounts = [],
|
|
227
|
+
isLoadingWeCrmAccounts = false,
|
|
228
|
+
fetchWeCrmAccountsError = null,
|
|
220
229
|
isLoadingSenderDetails = false,
|
|
221
230
|
orgUnitId = -1,
|
|
222
231
|
// notify/ui only:{commDefinitionId, referenceId} routes "Send test" to CCS's send/transaction endpoint.
|
|
@@ -229,8 +238,30 @@ const CommonTestAndPreview = (props) => {
|
|
|
229
238
|
} = props;
|
|
230
239
|
|
|
231
240
|
const smsFallbackContent = additionalProps?.smsFallbackContent;
|
|
232
|
-
// RCS multi-account (same as WhatsApp): the template's account
|
|
233
|
-
|
|
241
|
+
// RCS multi-account (same as WhatsApp): the template's account comes from its saved accountId (WeCRM id from
|
|
242
|
+
// campaigns / journeys / library, or sourceAccountIdentifier from the editor) matched against the RCS WeCRM
|
|
243
|
+
// accounts fetched below. '' = unknown account, which keeps every RCS domain (pre-multi-account behaviour).
|
|
244
|
+
// No saved account → '' (first-domain fallback). Same states as DeliverySettingsSection: while the WeCRM RCS lookup
|
|
245
|
+
// is pending or failed the RCS sender/domain stay unset (failed offers a retry); a completed lookup without the saved
|
|
246
|
+
// account → unavailable (not configured). Sending is blocked in all three states.
|
|
247
|
+
const rcsAccountIdFromForm = channel === CHANNELS.RCS ? getRcsAccountIdFromCreativeForm(formData || content) : '';
|
|
248
|
+
const [hasRequestedRcsWeCrmAccounts, setHasRequestedRcsWeCrmAccounts] = useState(false);
|
|
249
|
+
const isRcsWeCrmLookupCompleted = hasRequestedRcsWeCrmAccounts && !isLoadingWeCrmAccounts;
|
|
250
|
+
const rcsAccount = useMemo(() => resolveRcsAccountKey({
|
|
251
|
+
accountId: rcsAccountIdFromForm,
|
|
252
|
+
accounts: wecrmAccounts,
|
|
253
|
+
isLoaded: isRcsWeCrmLookupCompleted && !fetchWeCrmAccountsError,
|
|
254
|
+
hasFailed: isRcsWeCrmLookupCompleted && !!fetchWeCrmAccountsError,
|
|
255
|
+
}), [rcsAccountIdFromForm, wecrmAccounts, isRcsWeCrmLookupCompleted, fetchWeCrmAccountsError]);
|
|
256
|
+
const rcsSourceAccountIdentifier = rcsAccount.accountKey;
|
|
257
|
+
const isRcsAccountUnresolved = channel === CHANNELS.RCS && ['pending', 'failed'].includes(rcsAccount.status);
|
|
258
|
+
const isRcsAccountLookupFailed = channel === CHANNELS.RCS && rcsAccount.status === 'failed';
|
|
259
|
+
const isRcsSendBlocked = channel === CHANNELS.RCS && ['pending', 'failed', 'missing'].includes(rcsAccount.status);
|
|
260
|
+
const retryRcsAccountLookup = useCallback(() => {
|
|
261
|
+
if (typeof actions?.getWeCrmAccountsRequested === 'function') {
|
|
262
|
+
actions.getWeCrmAccountsRequested({ sourceName: CHANNELS.RCS });
|
|
263
|
+
}
|
|
264
|
+
}, [actions]);
|
|
234
265
|
|
|
235
266
|
const smsFallbackTextForTagExtraction = useMemo(
|
|
236
267
|
() => getSmsFallbackTextForTagExtraction(smsFallbackContent),
|
|
@@ -328,6 +359,11 @@ const CommonTestAndPreview = (props) => {
|
|
|
328
359
|
if (channel === CHANNELS.WHATSAPP && actions.getWeCrmAccountsRequested) {
|
|
329
360
|
actions.getWeCrmAccountsRequested({ sourceName: CHANNELS.WHATSAPP });
|
|
330
361
|
}
|
|
362
|
+
// RCS multi-account: WeCRM RCS accounts resolve the template's saved accountId to its account.
|
|
363
|
+
if (channel === CHANNELS.RCS && actions.getWeCrmAccountsRequested) {
|
|
364
|
+
actions.getWeCrmAccountsRequested({ sourceName: CHANNELS.RCS });
|
|
365
|
+
setHasRequestedRcsWeCrmAccounts(true);
|
|
366
|
+
}
|
|
331
367
|
}
|
|
332
368
|
}, [show, channel, orgUnitId, actions]);
|
|
333
369
|
|
|
@@ -341,6 +377,8 @@ const CommonTestAndPreview = (props) => {
|
|
|
341
377
|
const rcsDomainRows = senderDetailsByChannel?.[CHANNELS.RCS] || [];
|
|
342
378
|
const smsFallbackDomainRows = senderDetailsByChannel?.[CHANNELS.SMS] || [];
|
|
343
379
|
if (!rcsDomainRows.length) return;
|
|
380
|
+
// Saved account not resolved yet: leave the RCS sender/domain unset (no first-domain fallback).
|
|
381
|
+
if (isRcsAccountUnresolved) return;
|
|
344
382
|
|
|
345
383
|
const currentRcsDeliverySettings = testPreviewDeliverySettings?.[CHANNELS.RCS] || {};
|
|
346
384
|
const isRcsGsmSenderUnset = !currentRcsDeliverySettings?.gsmSenderId;
|
|
@@ -349,12 +387,62 @@ const CommonTestAndPreview = (props) => {
|
|
|
349
387
|
const shouldOnlyFillSmsFallbackSender =
|
|
350
388
|
!isRcsGsmSenderUnset && isSmsFallbackSenderUnset && smsFallbackDomainRows.length > 0;
|
|
351
389
|
|
|
390
|
+
// Account known (e.g. WeCRM accounts arrived after the default was set) but the selected RCS domain is
|
|
391
|
+
// another account's: re-pick the RCS sender from the template account's domain, or clear it when the
|
|
392
|
+
// account has no domain. SMS-fallback values are kept.
|
|
393
|
+
const accountRcsDomains = getRcsDomainsForAccount(
|
|
394
|
+
rcsDomainRows,
|
|
395
|
+
rcsSourceAccountIdentifier,
|
|
396
|
+
getParsedRcsDomainAccountId,
|
|
397
|
+
);
|
|
398
|
+
// Also restores an empty RCS sender (e.g. cleared before the account resolved) when the account has a domain,
|
|
399
|
+
// even if the SMS-fallback sender is already set; the SMS fallback is never touched here.
|
|
400
|
+
if (rcsSourceAccountIdentifier) {
|
|
401
|
+
const currentRcsGsmSender = String(currentRcsDeliverySettings?.gsmSenderId || '');
|
|
402
|
+
const currentRcsDomainId = currentRcsDeliverySettings?.domainId
|
|
403
|
+
?? (currentRcsGsmSender.includes('|') ? currentRcsGsmSender.split('|')[0] : null);
|
|
404
|
+
const isCurrentRcsDomainInAccount = accountRcsDomains.some(
|
|
405
|
+
(domain) => String(domain?.domainId) === String(currentRcsDomainId),
|
|
406
|
+
);
|
|
407
|
+
const shouldRepairRcsSender = isRcsGsmSenderUnset
|
|
408
|
+
? (!isSmsFallbackSenderUnset && accountRcsDomains.length > 0)
|
|
409
|
+
: !isCurrentRcsDomainInAccount;
|
|
410
|
+
if (shouldRepairRcsSender) {
|
|
411
|
+
const accountRcsDomain = accountRcsDomains[0];
|
|
412
|
+
const accountRcsGsmSender = accountRcsDomain
|
|
413
|
+
? filterUsableGsmSendersForDomain(accountRcsDomain, accountRcsDomain?.gsmSenders, {
|
|
414
|
+
skipDomainNameEchoFilter: true,
|
|
415
|
+
})[0]
|
|
416
|
+
: null;
|
|
417
|
+
const repairedRcsFields = {
|
|
418
|
+
domainId: accountRcsDomain?.domainId ?? null,
|
|
419
|
+
domainGatewayMapId: accountRcsDomain?.dgmId ?? null,
|
|
420
|
+
gsmSenderId: accountRcsDomain?.domainId != null && accountRcsGsmSender?.value != null
|
|
421
|
+
? `${accountRcsDomain.domainId}|${accountRcsGsmSender.value}`
|
|
422
|
+
: (accountRcsGsmSender?.value || ''),
|
|
423
|
+
};
|
|
424
|
+
setTestPreviewDeliverySettings((prev) => {
|
|
425
|
+
const previousRcsSettings = prev?.[CHANNELS.RCS] || {};
|
|
426
|
+
const isUnchanged = Object.keys(repairedRcsFields)
|
|
427
|
+
.every((key) => (previousRcsSettings[key] ?? null) === (repairedRcsFields[key] ?? null));
|
|
428
|
+
if (isUnchanged) return prev;
|
|
429
|
+
// SMS-fallback fields of the previous RCS settings are preserved.
|
|
430
|
+
return { ...prev, [CHANNELS.RCS]: { ...previousRcsSettings, ...repairedRcsFields } };
|
|
431
|
+
});
|
|
432
|
+
return;
|
|
433
|
+
}
|
|
434
|
+
}
|
|
435
|
+
|
|
352
436
|
if (!isRcsDeliveryFullyUnset && !shouldOnlyFillSmsFallbackSender) return;
|
|
353
437
|
|
|
354
|
-
//
|
|
355
|
-
|
|
356
|
-
|
|
357
|
-
|
|
438
|
+
// Default to the template account's domain (first domain when the account is unknown). A known account
|
|
439
|
+
// without a domain of its own gets no default RCS sender, never another account's sender.
|
|
440
|
+
const firstRcsDomain = pickRcsDomainForAccount(
|
|
441
|
+
rcsDomainRows,
|
|
442
|
+
rcsSourceAccountIdentifier,
|
|
443
|
+
getParsedRcsDomainAccountId,
|
|
444
|
+
);
|
|
445
|
+
if (!firstRcsDomain) return;
|
|
358
446
|
const firstSmsFallbackDomain = smsFallbackDomainRows[0];
|
|
359
447
|
const usableRcsGsmSenders = filterUsableGsmSendersForDomain(
|
|
360
448
|
firstRcsDomain,
|
|
@@ -388,16 +476,19 @@ const CommonTestAndPreview = (props) => {
|
|
|
388
476
|
},
|
|
389
477
|
};
|
|
390
478
|
}
|
|
391
|
-
|
|
392
|
-
|
|
393
|
-
|
|
394
|
-
|
|
395
|
-
|
|
396
|
-
|
|
397
|
-
smsFallbackDomainId: firstSmsFallbackDomain?.domainId ?? null,
|
|
398
|
-
cdmaSenderId: smsFallbackSenderCompositeValue,
|
|
399
|
-
},
|
|
479
|
+
const nextRcsSettings = {
|
|
480
|
+
domainId: firstRcsDomain?.domainId ?? null,
|
|
481
|
+
domainGatewayMapId: firstRcsDomain?.dgmId ?? null,
|
|
482
|
+
gsmSenderId: rcsSenderCompositeValue,
|
|
483
|
+
smsFallbackDomainId: firstSmsFallbackDomain?.domainId ?? null,
|
|
484
|
+
cdmaSenderId: smsFallbackSenderCompositeValue,
|
|
400
485
|
};
|
|
486
|
+
// Unchanged (e.g. no usable RCS / SMS-fallback sender): keep the same state object so the effect, which
|
|
487
|
+
// re-runs on every render (registeredSenderIds defaults to a new array), cannot cause repeated renders.
|
|
488
|
+
const isUnchanged = Object.keys(nextRcsSettings)
|
|
489
|
+
.every((key) => (previousRcsSettings[key] ?? null) === (nextRcsSettings[key] ?? null));
|
|
490
|
+
if (isUnchanged) return prev;
|
|
491
|
+
return { ...prev, [CHANNELS.RCS]: nextRcsSettings };
|
|
401
492
|
});
|
|
402
493
|
return;
|
|
403
494
|
}
|
|
@@ -459,7 +550,7 @@ const CommonTestAndPreview = (props) => {
|
|
|
459
550
|
}
|
|
460
551
|
return next;
|
|
461
552
|
});
|
|
462
|
-
}, [channel, formData?.accountName, senderDetailsByChannel, rcsSourceAccountIdentifier, smsTraiDltEnabled, registeredSenderIds, wecrmAccounts]);
|
|
553
|
+
}, [channel, formData?.accountName, senderDetailsByChannel, rcsSourceAccountIdentifier, isRcsAccountUnresolved, smsTraiDltEnabled, registeredSenderIds, wecrmAccounts]);
|
|
463
554
|
|
|
464
555
|
// ============================================
|
|
465
556
|
// MEMOIZED VALUES
|
|
@@ -3866,6 +3957,9 @@ const CommonTestAndPreview = (props) => {
|
|
|
3866
3957
|
};
|
|
3867
3958
|
|
|
3868
3959
|
const handleSendTestMessage = () => {
|
|
3960
|
+
// RCS: the template's saved account must resolve first (not pending, failed or unavailable), so the test never
|
|
3961
|
+
// goes out from another account.
|
|
3962
|
+
if (isRcsSendBlocked) return;
|
|
3869
3963
|
if (ccsSendTransaction) {
|
|
3870
3964
|
handleCcsSendTestMessage();
|
|
3871
3965
|
return;
|
|
@@ -4013,6 +4107,9 @@ const CommonTestAndPreview = (props) => {
|
|
|
4013
4107
|
deliverySettings={testPreviewDeliverySettings[channel]}
|
|
4014
4108
|
senderDetailsByChannel={senderDetailsByChannel}
|
|
4015
4109
|
wecrmAccounts={wecrmAccounts}
|
|
4110
|
+
rcsSourceAccountIdentifier={rcsSourceAccountIdentifier}
|
|
4111
|
+
isRcsAccountLookupFailed={isRcsAccountLookupFailed}
|
|
4112
|
+
onRetryRcsAccountLookup={retryRcsAccountLookup}
|
|
4016
4113
|
onSaveDeliverySettings={handleSaveDeliverySettings}
|
|
4017
4114
|
isLoadingSenderDetails={isLoadingSenderDetails}
|
|
4018
4115
|
smsTraiDltEnabled={smsTraiDltEnabled}
|
|
@@ -4161,6 +4258,8 @@ CommonTestAndPreview.propTypes = {
|
|
|
4161
4258
|
intl: PropTypes.object.isRequired,
|
|
4162
4259
|
senderDetailsByChannel: PropTypes.object,
|
|
4163
4260
|
wecrmAccounts: PropTypes.array,
|
|
4261
|
+
isLoadingWeCrmAccounts: PropTypes.bool,
|
|
4262
|
+
fetchWeCrmAccountsError: PropTypes.any,
|
|
4164
4263
|
isLoadingSenderDetails: PropTypes.bool,
|
|
4165
4264
|
orgUnitId: PropTypes.number,
|
|
4166
4265
|
ccsSendTransaction: PropTypes.shape({
|
|
@@ -4204,6 +4303,8 @@ CommonTestAndPreview.defaultProps = {
|
|
|
4204
4303
|
templateLayoutType: null,
|
|
4205
4304
|
senderDetailsByChannel: {},
|
|
4206
4305
|
wecrmAccounts: [],
|
|
4306
|
+
isLoadingWeCrmAccounts: false,
|
|
4307
|
+
fetchWeCrmAccountsError: null,
|
|
4207
4308
|
isLoadingSenderDetails: false,
|
|
4208
4309
|
orgUnitId: -1,
|
|
4209
4310
|
ccsSendTransaction: null,
|
|
@@ -107,6 +107,7 @@ const initialState = fromJS({
|
|
|
107
107
|
[CHANNELS.WHATSAPP]: [],
|
|
108
108
|
}),
|
|
109
109
|
wecrmAccounts: fromJS([]),
|
|
110
|
+
isLoadingWeCrmAccounts: false,
|
|
110
111
|
isLoadingSenderDetails: false,
|
|
111
112
|
fetchSenderDetailsError: null,
|
|
112
113
|
fetchWeCrmAccountsError: null,
|
|
@@ -319,15 +320,20 @@ const previewAndTestReducer = (state = initialState, action) => {
|
|
|
319
320
|
.set('fetchSenderDetailsError', action.payload?.error ?? action.payload);
|
|
320
321
|
|
|
321
322
|
case GET_WECRM_ACCOUNTS_REQUESTED:
|
|
322
|
-
return state
|
|
323
|
+
return state
|
|
324
|
+
.set('isLoadingWeCrmAccounts', true)
|
|
325
|
+
.set('fetchWeCrmAccountsError', null);
|
|
323
326
|
|
|
324
327
|
case GET_WECRM_ACCOUNTS_SUCCESS:
|
|
325
328
|
return state
|
|
326
329
|
.set('wecrmAccounts', fromJS(action.payload?.accounts || []))
|
|
330
|
+
.set('isLoadingWeCrmAccounts', false)
|
|
327
331
|
.set('fetchWeCrmAccountsError', null);
|
|
328
332
|
|
|
329
333
|
case GET_WECRM_ACCOUNTS_FAILURE:
|
|
330
|
-
return state
|
|
334
|
+
return state
|
|
335
|
+
.set('isLoadingWeCrmAccounts', false)
|
|
336
|
+
.set('fetchWeCrmAccountsError', action.payload?.error ?? action.payload);
|
|
331
337
|
|
|
332
338
|
default:
|
|
333
339
|
return state;
|
|
@@ -179,6 +179,11 @@ const makeSelectWeCrmAccounts = () => createSelector(
|
|
|
179
179
|
},
|
|
180
180
|
);
|
|
181
181
|
|
|
182
|
+
const makeSelectIsLoadingWeCrmAccounts = () => createSelector(
|
|
183
|
+
selectCommonTestAndPreviewDomain,
|
|
184
|
+
(substate) => (substate ? substate.get('isLoadingWeCrmAccounts') || false : false),
|
|
185
|
+
);
|
|
186
|
+
|
|
182
187
|
const makeSelectIsLoadingSenderDetails = () => createSelector(
|
|
183
188
|
selectCommonTestAndPreviewDomain,
|
|
184
189
|
(substate) => substate.get('isLoadingSenderDetails') || false,
|
|
@@ -225,6 +230,7 @@ export {
|
|
|
225
230
|
makeSelectSenderDetailsForChannel,
|
|
226
231
|
makeSelectSenderDetailsByChannel,
|
|
227
232
|
makeSelectWeCrmAccounts,
|
|
233
|
+
makeSelectIsLoadingWeCrmAccounts,
|
|
228
234
|
makeSelectIsLoadingSenderDetails,
|
|
229
235
|
makeSelectFetchSenderDetailsError,
|
|
230
236
|
makeSelectFetchWeCrmAccountsError,
|
package/v2Components/CommonTestAndPreview/tests/DeliverySettings/ModifyDeliverySettings.test.js
CHANGED
|
@@ -1261,4 +1261,15 @@ describe('ModifyDeliverySettings', () => {
|
|
|
1261
1261
|
);
|
|
1262
1262
|
});
|
|
1263
1263
|
});
|
|
1264
|
+
describe('RCS multi-account', () => {
|
|
1265
|
+
it('shows "RCS account is not configured" when the template account has no RCS domain', () => {
|
|
1266
|
+
renderComponent({ channel: CHANNELS.RCS, senderDetailsOptions: [], isRcsAccountNotConfigured: true });
|
|
1267
|
+
expect(screen.getByText(/RCS account is not configured/)).toBeTruthy();
|
|
1268
|
+
});
|
|
1269
|
+
|
|
1270
|
+
it('does not show the message otherwise', () => {
|
|
1271
|
+
renderComponent({ channel: CHANNELS.RCS, senderDetailsOptions: [] });
|
|
1272
|
+
expect(screen.queryByText(/RCS account is not configured/)).toBeNull();
|
|
1273
|
+
});
|
|
1274
|
+
});
|
|
1264
1275
|
});
|
|
@@ -16,6 +16,8 @@ jest.mock('@capillarytech/cap-ui-library/CapRow', () => ({ children, className,
|
|
|
16
16
|
jest.mock('@capillarytech/cap-ui-library/CapHeading', () => ({ children }) => <div data-testid="cap-heading">{children}</div>);
|
|
17
17
|
jest.mock('@capillarytech/cap-ui-library/CapIcon', () => ({ onClick, className, 'data-testid': testId }) => <button type="button" onClick={onClick} className={className} data-testid={testId || 'cap-icon'} aria-label="edit" />);
|
|
18
18
|
jest.mock('@capillarytech/cap-ui-library/CapLabel', () => ({ children, type }) => <span data-type={type}>{children}</span>);
|
|
19
|
+
// eslint-disable-next-line react/prop-types
|
|
20
|
+
jest.mock('@capillarytech/cap-ui-library/CapLink', () => ({ title, onClick }) => <button type="button" onClick={onClick}>{title}</button>);
|
|
19
21
|
jest.mock('@capillarytech/cap-ui-library/CapSlideBox', () => ({ show, content, handleClose }) => (show ? (
|
|
20
22
|
<div data-testid="cap-slidebox">
|
|
21
23
|
<button type="button" onClick={handleClose} data-testid="slidebox-close">Close</button>
|
|
@@ -331,4 +333,94 @@ describe('DeliverySettings', () => {
|
|
|
331
333
|
);
|
|
332
334
|
});
|
|
333
335
|
});
|
|
336
|
+
describe('RCS multi-account (same as WhatsApp)', () => {
|
|
337
|
+
const rcsDomainA = {
|
|
338
|
+
domainId: 1, domainName: 'RCS A', sourceAccountIdentifier: 'acc-A', gsmSenders: [{ value: 'RCS_A' }],
|
|
339
|
+
};
|
|
340
|
+
const rcsDomainB = {
|
|
341
|
+
domainId: 2, domainName: 'RCS B', sourceAccountIdentifier: 'acc-B', gsmSenders: [{ value: 'RCS_B' }],
|
|
342
|
+
};
|
|
343
|
+
const senderDetailsByChannel = { [CHANNELS.RCS]: [rcsDomainA, rcsDomainB] };
|
|
344
|
+
const openSlideBox = () => fireEvent.click(screen.getByLabelText('edit'));
|
|
345
|
+
|
|
346
|
+
it('offers only the template account RCS domains', () => {
|
|
347
|
+
render(
|
|
348
|
+
<DeliverySettings
|
|
349
|
+
{...defaultProps}
|
|
350
|
+
channel={CHANNELS.RCS}
|
|
351
|
+
senderDetailsByChannel={senderDetailsByChannel}
|
|
352
|
+
rcsSourceAccountIdentifier="acc-B"
|
|
353
|
+
/>,
|
|
354
|
+
);
|
|
355
|
+
openSlideBox();
|
|
356
|
+
const props = mockModifyDeliverySettings.mock.calls[mockModifyDeliverySettings.mock.calls.length - 1][0];
|
|
357
|
+
expect(props.senderDetailsOptions).toEqual([rcsDomainB]);
|
|
358
|
+
expect(props.isRcsAccountNotConfigured).toBe(false);
|
|
359
|
+
});
|
|
360
|
+
|
|
361
|
+
it('offers every RCS domain when the account is unknown', () => {
|
|
362
|
+
render(
|
|
363
|
+
<DeliverySettings
|
|
364
|
+
{...defaultProps}
|
|
365
|
+
channel={CHANNELS.RCS}
|
|
366
|
+
senderDetailsByChannel={senderDetailsByChannel}
|
|
367
|
+
rcsSourceAccountIdentifier=""
|
|
368
|
+
/>,
|
|
369
|
+
);
|
|
370
|
+
openSlideBox();
|
|
371
|
+
const props = mockModifyDeliverySettings.mock.calls[mockModifyDeliverySettings.mock.calls.length - 1][0];
|
|
372
|
+
expect(props.senderDetailsOptions).toEqual([rcsDomainA, rcsDomainB]);
|
|
373
|
+
});
|
|
374
|
+
|
|
375
|
+
it('shows "RCS account is not configured" and offers no domain when the account has none', () => {
|
|
376
|
+
render(
|
|
377
|
+
<DeliverySettings
|
|
378
|
+
{...defaultProps}
|
|
379
|
+
channel={CHANNELS.RCS}
|
|
380
|
+
senderDetailsByChannel={senderDetailsByChannel}
|
|
381
|
+
rcsSourceAccountIdentifier="acc-C"
|
|
382
|
+
deliverySettings={{ gsmSenderId: '1|RCS_A' }}
|
|
383
|
+
/>,
|
|
384
|
+
);
|
|
385
|
+
expect(screen.getByText(/RCS account is not configured/)).toBeTruthy();
|
|
386
|
+
expect(screen.queryByText(/RCS_A/)).toBeNull();
|
|
387
|
+
openSlideBox();
|
|
388
|
+
const props = mockModifyDeliverySettings.mock.calls[mockModifyDeliverySettings.mock.calls.length - 1][0];
|
|
389
|
+
expect(props.senderDetailsOptions).toEqual([]);
|
|
390
|
+
expect(props.isRcsAccountNotConfigured).toBe(true);
|
|
391
|
+
});
|
|
392
|
+
|
|
393
|
+
it('shows the account lookup failure with a Retry action', () => {
|
|
394
|
+
const onRetryRcsAccountLookup = jest.fn();
|
|
395
|
+
render(
|
|
396
|
+
<DeliverySettings
|
|
397
|
+
{...defaultProps}
|
|
398
|
+
channel={CHANNELS.RCS}
|
|
399
|
+
senderDetailsByChannel={senderDetailsByChannel}
|
|
400
|
+
rcsSourceAccountIdentifier=""
|
|
401
|
+
isRcsAccountLookupFailed
|
|
402
|
+
onRetryRcsAccountLookup={onRetryRcsAccountLookup}
|
|
403
|
+
/>,
|
|
404
|
+
);
|
|
405
|
+
expect(screen.getByText('Could not load the RCS account of this template.')).toBeTruthy();
|
|
406
|
+
fireEvent.click(screen.getByText('Retry'));
|
|
407
|
+
expect(onRetryRcsAccountLookup).toHaveBeenCalledTimes(1);
|
|
408
|
+
});
|
|
409
|
+
|
|
410
|
+
it('does not filter WhatsApp domains by the RCS account', () => {
|
|
411
|
+
const waDomains = [{ domainId: 5, sourceAccountIdentifier: 'waba-1', gsmSenders: [] }];
|
|
412
|
+
render(
|
|
413
|
+
<DeliverySettings
|
|
414
|
+
{...defaultProps}
|
|
415
|
+
channel={CHANNELS.WHATSAPP}
|
|
416
|
+
senderDetailsByChannel={{ [CHANNELS.WHATSAPP]: waDomains }}
|
|
417
|
+
rcsSourceAccountIdentifier="acc-C"
|
|
418
|
+
/>,
|
|
419
|
+
);
|
|
420
|
+
openSlideBox();
|
|
421
|
+
const props = mockModifyDeliverySettings.mock.calls[mockModifyDeliverySettings.mock.calls.length - 1][0];
|
|
422
|
+
expect(props.senderDetailsOptions).toEqual(waDomains);
|
|
423
|
+
expect(props.isRcsAccountNotConfigured).toBe(false);
|
|
424
|
+
});
|
|
425
|
+
});
|
|
334
426
|
});
|