@capillarytech/creatives-library 8.0.290-alpha.4 → 8.0.290
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 +1 -3
- package/initialState.js +2 -0
- package/package.json +1 -1
- package/utils/common.js +8 -5
- package/utils/commonUtils.js +85 -4
- package/utils/tagValidations.js +223 -83
- package/utils/tests/commonUtil.test.js +124 -147
- package/utils/tests/tagValidations.test.js +358 -441
- package/v2Components/CommonTestAndPreview/DeliverySettings/DeliverySettings.scss +33 -0
- package/v2Components/CommonTestAndPreview/DeliverySettings/ModifyDeliverySettings.js +397 -0
- package/v2Components/CommonTestAndPreview/DeliverySettings/ModifyDeliverySettings.scss +35 -0
- package/v2Components/CommonTestAndPreview/DeliverySettings/TECH_DETAILING_DELIVERY_SETTINGS.md +725 -0
- package/v2Components/CommonTestAndPreview/DeliverySettings/constants.js +92 -0
- package/v2Components/CommonTestAndPreview/DeliverySettings/index.js +243 -0
- package/v2Components/CommonTestAndPreview/DeliverySettings/messages.js +111 -0
- package/v2Components/CommonTestAndPreview/DeliverySettings/utils/parseSenderDetailsResponse.js +91 -0
- package/v2Components/CommonTestAndPreview/SendTestMessage.js +33 -1
- package/v2Components/CommonTestAndPreview/actions.js +20 -0
- package/v2Components/CommonTestAndPreview/constants.js +10 -0
- package/v2Components/CommonTestAndPreview/index.js +133 -15
- package/v2Components/CommonTestAndPreview/reducer.js +47 -0
- package/v2Components/CommonTestAndPreview/sagas.js +60 -0
- package/v2Components/CommonTestAndPreview/selectors.js +51 -0
- package/v2Components/CommonTestAndPreview/tests/DeliverySettings/ModifyDeliverySettings.test.js +782 -0
- package/v2Components/CommonTestAndPreview/tests/DeliverySettings/index.test.js +200 -0
- package/v2Components/CommonTestAndPreview/tests/DeliverySettings/utils/parseSenderDetailsResponse.test.js +235 -0
- package/v2Components/CommonTestAndPreview/tests/SendTestMessage.test.js +127 -0
- package/v2Components/CommonTestAndPreview/tests/actions.test.js +50 -0
- package/v2Components/CommonTestAndPreview/tests/constants.test.js +18 -0
- package/v2Components/CommonTestAndPreview/tests/index.test.js +214 -1
- package/v2Components/CommonTestAndPreview/tests/reducer.test.js +118 -0
- package/v2Components/CommonTestAndPreview/tests/sagas.test.js +145 -0
- package/v2Components/CommonTestAndPreview/tests/selectors.test.js +146 -0
- package/v2Components/ErrorInfoNote/index.js +5 -2
- package/v2Components/FormBuilder/index.js +201 -132
- package/v2Components/FormBuilder/messages.js +8 -0
- package/v2Components/HtmlEditor/HTMLEditor.js +5 -0
- package/v2Components/HtmlEditor/__tests__/HTMLEditor.apiErrors.test.js +1 -0
- package/v2Components/HtmlEditor/__tests__/HTMLEditor.test.js +15 -0
- package/v2Components/HtmlEditor/components/CodeEditorPane/index.js +2 -1
- package/v2Components/TestAndPreviewSlidebox/index.js +14 -0
- package/v2Containers/Cap/mockData.js +14 -0
- package/v2Containers/Cap/reducer.js +55 -3
- package/v2Containers/Cap/tests/reducer.test.js +102 -0
- package/v2Containers/CreativesContainer/SlideBoxContent.js +1 -5
- package/v2Containers/CreativesContainer/SlideBoxFooter.js +5 -13
- package/v2Containers/CreativesContainer/index.js +7 -30
- package/v2Containers/Email/index.js +5 -1
- package/v2Containers/EmailWrapper/components/EmailHTMLEditor.js +70 -23
- package/v2Containers/EmailWrapper/components/__tests__/EmailHTMLEditor.test.js +137 -29
- package/v2Containers/FTP/index.js +51 -2
- package/v2Containers/FTP/messages.js +4 -0
- package/v2Containers/InApp/index.js +104 -4
- package/v2Containers/InApp/tests/index.test.js +6 -17
- package/v2Containers/InappAdvance/index.js +108 -4
- package/v2Containers/InappAdvance/tests/index.test.js +0 -2
- package/v2Containers/Line/Container/Text/index.js +1 -0
- package/v2Containers/MobilePush/Create/index.js +19 -42
- package/v2Containers/MobilePush/Edit/index.js +19 -42
- package/v2Containers/MobilePushNew/index.js +32 -12
- package/v2Containers/MobilepushWrapper/index.js +1 -3
- package/v2Containers/Rcs/index.js +37 -12
- package/v2Containers/Rcs/tests/__snapshots__/index.test.js.snap +649 -12
- package/v2Containers/Sms/Create/index.js +3 -39
- package/v2Containers/Sms/Create/messages.js +0 -4
- package/v2Containers/Sms/Edit/index.js +3 -35
- package/v2Containers/Sms/commonMethods.js +6 -3
- package/v2Containers/SmsTrai/Edit/index.js +47 -11
- package/v2Containers/SmsTrai/Edit/tests/__snapshots__/index.test.js.snap +147 -6
- package/v2Containers/SmsWrapper/index.js +0 -2
- package/v2Containers/Viber/index.js +1 -0
- package/v2Containers/WebPush/Create/hooks/useTagManagement.js +3 -1
- package/v2Containers/WebPush/Create/hooks/useTagManagement.test.js +7 -0
- package/v2Containers/WebPush/Create/index.js +2 -2
- package/v2Containers/WebPush/Create/utils/validation.js +2 -17
- package/v2Containers/WebPush/Create/utils/validation.test.js +24 -59
- package/v2Containers/Whatsapp/index.js +18 -10
- package/v2Containers/Whatsapp/tests/__snapshots__/index.test.js.snap +26174 -4225
- package/v2Containers/Zalo/index.js +11 -3
- package/v2Containers/Sms/tests/commonMethods.test.js +0 -122
|
@@ -105,6 +105,10 @@ const CommonTestAndPreview = (props) => {
|
|
|
105
105
|
updatePreviewErrors,
|
|
106
106
|
fetchPrefilledValuesError,
|
|
107
107
|
fetchPrefilledValuesErrors,
|
|
108
|
+
senderDetailsByChannel = {},
|
|
109
|
+
wecrmAccounts = [],
|
|
110
|
+
isLoadingSenderDetails = false,
|
|
111
|
+
orgUnitId = -1,
|
|
108
112
|
// Email-specific props
|
|
109
113
|
beeInstance,
|
|
110
114
|
currentTab = 1,
|
|
@@ -146,6 +150,84 @@ const CommonTestAndPreview = (props) => {
|
|
|
146
150
|
const [selectedTestEntities, setSelectedTestEntities] = useState([]);
|
|
147
151
|
const [beeContent, setBeeContent] = useState(''); // Track BEE editor content separately (EMAIL only)
|
|
148
152
|
const previousBeeContentRef = useRef(''); // Track previous BEE content (EMAIL only)
|
|
153
|
+
// Delivery settings for Test and Preview (SMS, Email, WhatsApp) — user selection only
|
|
154
|
+
const [testPreviewDeliverySettings, setTestPreviewDeliverySettings] = useState({
|
|
155
|
+
[CHANNELS.SMS]: {
|
|
156
|
+
domainId: null, domainGatewayMapId: null, gsmSenderId: '', cdmaSenderId: '',
|
|
157
|
+
},
|
|
158
|
+
[CHANNELS.EMAIL]: {
|
|
159
|
+
domainId: null, domainGatewayMapId: null, senderEmail: '', senderLabel: '', senderReplyTo: '',
|
|
160
|
+
},
|
|
161
|
+
[CHANNELS.WHATSAPP]: {
|
|
162
|
+
domainId: null, senderMobNum: '', sourceAccountIdentifier: '',
|
|
163
|
+
},
|
|
164
|
+
});
|
|
165
|
+
|
|
166
|
+
const channelsWithDeliverySettings = [CHANNELS.SMS, CHANNELS.EMAIL, CHANNELS.WHATSAPP];
|
|
167
|
+
|
|
168
|
+
// Fetch sender details and WeCRM accounts when Test & Preview opens for SMS/Email/WhatsApp
|
|
169
|
+
useEffect(() => {
|
|
170
|
+
if (!show || !channel) {
|
|
171
|
+
return;
|
|
172
|
+
}
|
|
173
|
+
if (channelsWithDeliverySettings.includes(channel)) {
|
|
174
|
+
if (actions.getSenderDetailsRequested) {
|
|
175
|
+
actions.getSenderDetailsRequested({ channel, orgUnitId: orgUnitId ?? -1 });
|
|
176
|
+
}
|
|
177
|
+
if (channel === CHANNELS.WHATSAPP && actions.getWeCrmAccountsRequested) {
|
|
178
|
+
actions.getWeCrmAccountsRequested({ sourceName: CHANNELS.WHATSAPP });
|
|
179
|
+
}
|
|
180
|
+
}
|
|
181
|
+
}, [show, channel, orgUnitId, actions]);
|
|
182
|
+
|
|
183
|
+
const findDefault = (arr) => (arr && arr.find((x) => x.default)) || (arr && arr[0]) || {};
|
|
184
|
+
|
|
185
|
+
// Auto-set default delivery setting when sender details load (campaigns-style: first domain + default/first sender)
|
|
186
|
+
useEffect(() => {
|
|
187
|
+
if (!channel || !channelsWithDeliverySettings.includes(channel)) return;
|
|
188
|
+
const domains = senderDetailsByChannel[channel];
|
|
189
|
+
if (!domains || domains.length === 0) return;
|
|
190
|
+
const current = testPreviewDeliverySettings[channel];
|
|
191
|
+
const isEmptySelection = !current?.domainId && !current?.gsmSenderId && !current?.senderEmail && !current?.senderMobNum;
|
|
192
|
+
if (!isEmptySelection) return;
|
|
193
|
+
|
|
194
|
+
const whatsappAccountFromForm = channel === CHANNELS.WHATSAPP ? formData?.accountName : undefined;
|
|
195
|
+
const matchedWhatsappAccount = whatsappAccountFromForm
|
|
196
|
+
? (wecrmAccounts || []).find((account) => account?.name === whatsappAccountFromForm)
|
|
197
|
+
: null;
|
|
198
|
+
const firstDomain = channel === CHANNELS.WHATSAPP && matchedWhatsappAccount?.sourceAccountIdentifier
|
|
199
|
+
? domains.find((domain) => domain?.sourceAccountIdentifier === matchedWhatsappAccount.sourceAccountIdentifier) || domains[0]
|
|
200
|
+
: domains[0];
|
|
201
|
+
setTestPreviewDeliverySettings((prev) => {
|
|
202
|
+
const next = { ...prev };
|
|
203
|
+
if (channel === CHANNELS.SMS) {
|
|
204
|
+
next[channel] = {
|
|
205
|
+
domainId: firstDomain.domainId,
|
|
206
|
+
domainGatewayMapId: firstDomain.dgmId,
|
|
207
|
+
gsmSenderId: findDefault(firstDomain.gsmSenders)?.value || firstDomain.gsmSenders?.[0]?.value || '',
|
|
208
|
+
cdmaSenderId: findDefault(firstDomain.cdmaSenders)?.value || '',
|
|
209
|
+
};
|
|
210
|
+
} else if (channel === CHANNELS.EMAIL) {
|
|
211
|
+
const defSender = findDefault(firstDomain.emailSenders);
|
|
212
|
+
const defReply = findDefault(firstDomain.emailRepliers);
|
|
213
|
+
next[channel] = {
|
|
214
|
+
domainId: firstDomain.domainId,
|
|
215
|
+
domainGatewayMapId: firstDomain.dgmId,
|
|
216
|
+
senderEmail: defSender?.value || '',
|
|
217
|
+
senderLabel: defSender?.label || '',
|
|
218
|
+
senderReplyTo: defReply?.value || '',
|
|
219
|
+
};
|
|
220
|
+
} else if (channel === CHANNELS.WHATSAPP) {
|
|
221
|
+
const accId = firstDomain.sourceAccountIdentifier;
|
|
222
|
+
next[channel] = {
|
|
223
|
+
domainId: firstDomain.domainId,
|
|
224
|
+
senderMobNum: firstDomain.gsmSenders?.[0]?.value || '',
|
|
225
|
+
sourceAccountIdentifier: matchedWhatsappAccount?.sourceAccountIdentifier || accId || '',
|
|
226
|
+
};
|
|
227
|
+
}
|
|
228
|
+
return next;
|
|
229
|
+
});
|
|
230
|
+
}, [channel, formData?.accountName, senderDetailsByChannel, wecrmAccounts]);
|
|
149
231
|
|
|
150
232
|
// ============================================
|
|
151
233
|
// MEMOIZED VALUES
|
|
@@ -442,7 +524,7 @@ const CommonTestAndPreview = (props) => {
|
|
|
442
524
|
* Prepare payload for test message sending based on channel
|
|
443
525
|
* Updated to match API structure with ouId, sourceEntityId, module, deliverySettings, etc.
|
|
444
526
|
*/
|
|
445
|
-
const prepareTestMessagePayload = (channelType, formDataObj, contentStr, customValuesObj, recipientDetails, previewDataObj) => {
|
|
527
|
+
const prepareTestMessagePayload = (channelType, formDataObj, contentStr, customValuesObj, recipientDetails, previewDataObj, deliverySettingsOverride) => {
|
|
446
528
|
// Base payload structure common to all channels
|
|
447
529
|
const basePayload = {
|
|
448
530
|
ouId: -1,
|
|
@@ -468,6 +550,14 @@ const CommonTestAndPreview = (props) => {
|
|
|
468
550
|
? resolveTagsInText(subject, customValuesObj)
|
|
469
551
|
: subject;
|
|
470
552
|
|
|
553
|
+
const emailChannelSettings = {
|
|
554
|
+
channel: CHANNELS.EMAIL,
|
|
555
|
+
senderLabel: deliverySettingsOverride?.senderLabel ?? '',
|
|
556
|
+
senderId: deliverySettingsOverride?.senderEmail ?? '',
|
|
557
|
+
replyToId: deliverySettingsOverride?.senderReplyTo ?? '',
|
|
558
|
+
domainGatewayMapId: deliverySettingsOverride?.domainGatewayMapId ?? '',
|
|
559
|
+
domainId: deliverySettingsOverride?.domainId ?? '',
|
|
560
|
+
};
|
|
471
561
|
return {
|
|
472
562
|
...basePayload,
|
|
473
563
|
emailDeliverySettings: {
|
|
@@ -478,12 +568,7 @@ const CommonTestAndPreview = (props) => {
|
|
|
478
568
|
skipRateLimit: false,
|
|
479
569
|
bypassControlUser: false,
|
|
480
570
|
},
|
|
481
|
-
channelSettings:
|
|
482
|
-
channel: CHANNELS.EMAIL,
|
|
483
|
-
senderLabel: '',
|
|
484
|
-
senderId: '',
|
|
485
|
-
replyToId: '',
|
|
486
|
-
},
|
|
571
|
+
channelSettings: emailChannelSettings,
|
|
487
572
|
},
|
|
488
573
|
emailMessageContent: {
|
|
489
574
|
channel: CHANNELS.EMAIL,
|
|
@@ -520,8 +605,12 @@ const CommonTestAndPreview = (props) => {
|
|
|
520
605
|
},
|
|
521
606
|
smsDeliverySettings: {
|
|
522
607
|
channelSettings: {
|
|
523
|
-
gsmSenderId: '',
|
|
524
|
-
domainId: null,
|
|
608
|
+
gsmSenderId: deliverySettingsOverride?.gsmSenderId ?? '',
|
|
609
|
+
domainId: deliverySettingsOverride?.domainId ?? null,
|
|
610
|
+
domainGatewayMapId: deliverySettingsOverride?.domainGatewayMapId ?? '',
|
|
611
|
+
targetNdnc: false,
|
|
612
|
+
cdmaSenderId: deliverySettingsOverride?.cdmaSenderId ?? '',
|
|
613
|
+
channel: CHANNELS.SMS,
|
|
525
614
|
},
|
|
526
615
|
additionalSettings: {
|
|
527
616
|
useTinyUrl: false,
|
|
@@ -657,16 +746,17 @@ const CommonTestAndPreview = (props) => {
|
|
|
657
746
|
templateConfigs.mediaType = formDataObj?.carouselMediaType?.toUpperCase() || MEDIA_TYPE_IMAGE;
|
|
658
747
|
}
|
|
659
748
|
|
|
660
|
-
// Extract delivery settings
|
|
661
|
-
const senderMobNum = formDataObj?.senderMobNum
|
|
662
|
-
const domainId = formDataObj?.domainId
|
|
749
|
+
// Extract delivery settings (override from Test & Preview delivery settings when present)
|
|
750
|
+
const senderMobNum = deliverySettingsOverride?.senderMobNum ?? formDataObj?.senderMobNum ?? additionalProps?.senderMobNum ?? '';
|
|
751
|
+
const domainId = deliverySettingsOverride?.domainId ?? formDataObj?.domainId ?? additionalProps?.domainId ?? null;
|
|
752
|
+
const sourceAccountIdentifier = deliverySettingsOverride?.sourceAccountIdentifier ?? formDataObj?.sourceAccountIdentifier ?? '';
|
|
663
753
|
|
|
664
754
|
return {
|
|
665
755
|
...basePayload,
|
|
666
756
|
whatsappMessageContent: {
|
|
667
757
|
messageBody: templateEditorValue || '',
|
|
668
758
|
accountId: formDataObj?.accountId || '',
|
|
669
|
-
sourceAccountIdentifier: formDataObj?.sourceAccountIdentifier || '',
|
|
759
|
+
sourceAccountIdentifier: sourceAccountIdentifier || formDataObj?.sourceAccountIdentifier || '',
|
|
670
760
|
accountName: formDataObj?.accountName || '',
|
|
671
761
|
templateConfigs,
|
|
672
762
|
channel: CHANNELS.WHATSAPP,
|
|
@@ -2370,6 +2460,10 @@ const CommonTestAndPreview = (props) => {
|
|
|
2370
2460
|
});
|
|
2371
2461
|
const uniqueUserIds = [...new Set(allUserIds)];
|
|
2372
2462
|
|
|
2463
|
+
const deliveryOverride = [CHANNELS.SMS, CHANNELS.EMAIL, CHANNELS.WHATSAPP].includes(channel)
|
|
2464
|
+
? testPreviewDeliverySettings[channel]
|
|
2465
|
+
: null;
|
|
2466
|
+
|
|
2373
2467
|
// Create initial payload based on channel
|
|
2374
2468
|
const initialPayload = prepareTestMessagePayload(
|
|
2375
2469
|
channel,
|
|
@@ -2377,7 +2471,8 @@ const CommonTestAndPreview = (props) => {
|
|
|
2377
2471
|
getCurrentContent,
|
|
2378
2472
|
customValues,
|
|
2379
2473
|
uniqueUserIds,
|
|
2380
|
-
previewData
|
|
2474
|
+
previewData,
|
|
2475
|
+
deliveryOverride
|
|
2381
2476
|
);
|
|
2382
2477
|
|
|
2383
2478
|
actions.createMessageMetaRequested(
|
|
@@ -2449,6 +2544,16 @@ const CommonTestAndPreview = (props) => {
|
|
|
2449
2544
|
/>
|
|
2450
2545
|
);
|
|
2451
2546
|
|
|
2547
|
+
const handleSaveDeliverySettings = (values) => {
|
|
2548
|
+
setTestPreviewDeliverySettings((prev) => ({
|
|
2549
|
+
...prev,
|
|
2550
|
+
[channel]: values,
|
|
2551
|
+
}));
|
|
2552
|
+
};
|
|
2553
|
+
|
|
2554
|
+
// Use formData when present; for WhatsApp (and others) parent may pass template via content only
|
|
2555
|
+
const formDataForSendTest = formData ?? (content && typeof content === 'object' && !Array.isArray(content) ? content : formData);
|
|
2556
|
+
|
|
2452
2557
|
const renderSendTestMessage = () => (
|
|
2453
2558
|
<SendTestMessage
|
|
2454
2559
|
isFetchingTestCustomers={isFetchingTestCustomers}
|
|
@@ -2457,11 +2562,16 @@ const CommonTestAndPreview = (props) => {
|
|
|
2457
2562
|
handleTestEntitiesChange={handleTestEntitiesChange}
|
|
2458
2563
|
selectedTestEntities={selectedTestEntities}
|
|
2459
2564
|
handleSendTestMessage={handleSendTestMessage}
|
|
2460
|
-
formData={
|
|
2565
|
+
formData={formDataForSendTest}
|
|
2461
2566
|
content={getCurrentContent}
|
|
2462
2567
|
channel={channel}
|
|
2463
2568
|
isSendingTestMessage={isSendingTestMessage}
|
|
2464
2569
|
formatMessage={formatMessage}
|
|
2570
|
+
deliverySettings={testPreviewDeliverySettings[channel]}
|
|
2571
|
+
senderDetailsOptions={senderDetailsByChannel[channel]}
|
|
2572
|
+
wecrmAccounts={wecrmAccounts}
|
|
2573
|
+
onSaveDeliverySettings={handleSaveDeliverySettings}
|
|
2574
|
+
isLoadingSenderDetails={isLoadingSenderDetails}
|
|
2465
2575
|
/>
|
|
2466
2576
|
);
|
|
2467
2577
|
|
|
@@ -2562,6 +2672,10 @@ CommonTestAndPreview.propTypes = {
|
|
|
2562
2672
|
})),
|
|
2563
2673
|
isSendingTestMessage: PropTypes.bool.isRequired,
|
|
2564
2674
|
intl: PropTypes.object.isRequired,
|
|
2675
|
+
senderDetailsByChannel: PropTypes.object,
|
|
2676
|
+
wecrmAccounts: PropTypes.array,
|
|
2677
|
+
isLoadingSenderDetails: PropTypes.bool,
|
|
2678
|
+
orgUnitId: PropTypes.number,
|
|
2565
2679
|
|
|
2566
2680
|
// Email-specific props
|
|
2567
2681
|
beeInstance: PropTypes.object,
|
|
@@ -2597,6 +2711,10 @@ CommonTestAndPreview.defaultProps = {
|
|
|
2597
2711
|
rcsOrientation: null,
|
|
2598
2712
|
rcsIosPreview: false,
|
|
2599
2713
|
templateLayoutType: null,
|
|
2714
|
+
senderDetailsByChannel: {},
|
|
2715
|
+
wecrmAccounts: [],
|
|
2716
|
+
isLoadingSenderDetails: false,
|
|
2717
|
+
orgUnitId: -1,
|
|
2600
2718
|
};
|
|
2601
2719
|
|
|
2602
2720
|
// ============================================
|
|
@@ -31,6 +31,13 @@ import {
|
|
|
31
31
|
GET_PREFILLED_VALUES_FAILURE,
|
|
32
32
|
CLEAR_PREFILLED_VALUES,
|
|
33
33
|
CLEAR_PREVIEW_ERRORS,
|
|
34
|
+
GET_SENDER_DETAILS_REQUESTED,
|
|
35
|
+
GET_SENDER_DETAILS_SUCCESS,
|
|
36
|
+
GET_SENDER_DETAILS_FAILURE,
|
|
37
|
+
GET_WECRM_ACCOUNTS_REQUESTED,
|
|
38
|
+
GET_WECRM_ACCOUNTS_SUCCESS,
|
|
39
|
+
GET_WECRM_ACCOUNTS_FAILURE,
|
|
40
|
+
CHANNELS,
|
|
34
41
|
} from './constants';
|
|
35
42
|
|
|
36
43
|
const initialState = fromJS({
|
|
@@ -85,6 +92,16 @@ const initialState = fromJS({
|
|
|
85
92
|
isFetchingPrefilledValues: false,
|
|
86
93
|
fetchPrefilledValuesError: null,
|
|
87
94
|
fetchPrefilledValuesErrors: [],
|
|
95
|
+
|
|
96
|
+
senderDetailsByChannel: fromJS({
|
|
97
|
+
[CHANNELS.SMS]: [],
|
|
98
|
+
[CHANNELS.EMAIL]: [],
|
|
99
|
+
[CHANNELS.WHATSAPP]: [],
|
|
100
|
+
}),
|
|
101
|
+
wecrmAccounts: fromJS([]),
|
|
102
|
+
isLoadingSenderDetails: false,
|
|
103
|
+
fetchSenderDetailsError: null,
|
|
104
|
+
fetchWeCrmAccountsError: null,
|
|
88
105
|
});
|
|
89
106
|
|
|
90
107
|
const previewAndTestReducer = (state = initialState, action) => {
|
|
@@ -250,6 +267,36 @@ const previewAndTestReducer = (state = initialState, action) => {
|
|
|
250
267
|
.set('fetchPrefilledValuesError', null)
|
|
251
268
|
.set('fetchPrefilledValuesErrors', fromJS([]));
|
|
252
269
|
|
|
270
|
+
case GET_SENDER_DETAILS_REQUESTED:
|
|
271
|
+
return state
|
|
272
|
+
.set('isLoadingSenderDetails', true)
|
|
273
|
+
.set('fetchSenderDetailsError', null);
|
|
274
|
+
|
|
275
|
+
case GET_SENDER_DETAILS_SUCCESS: {
|
|
276
|
+
const { channel, domains } = action.payload || {};
|
|
277
|
+
if (!channel) return state;
|
|
278
|
+
return state
|
|
279
|
+
.setIn(['senderDetailsByChannel', channel], fromJS(domains || []))
|
|
280
|
+
.set('isLoadingSenderDetails', false)
|
|
281
|
+
.set('fetchSenderDetailsError', null);
|
|
282
|
+
}
|
|
283
|
+
|
|
284
|
+
case GET_SENDER_DETAILS_FAILURE:
|
|
285
|
+
return state
|
|
286
|
+
.set('isLoadingSenderDetails', false)
|
|
287
|
+
.set('fetchSenderDetailsError', action.payload?.error ?? action.payload);
|
|
288
|
+
|
|
289
|
+
case GET_WECRM_ACCOUNTS_REQUESTED:
|
|
290
|
+
return state.set('fetchWeCrmAccountsError', null);
|
|
291
|
+
|
|
292
|
+
case GET_WECRM_ACCOUNTS_SUCCESS:
|
|
293
|
+
return state
|
|
294
|
+
.set('wecrmAccounts', fromJS(action.payload?.accounts || []))
|
|
295
|
+
.set('fetchWeCrmAccountsError', null);
|
|
296
|
+
|
|
297
|
+
case GET_WECRM_ACCOUNTS_FAILURE:
|
|
298
|
+
return state.set('fetchWeCrmAccountsError', action.payload?.error ?? action.payload);
|
|
299
|
+
|
|
253
300
|
default:
|
|
254
301
|
return state;
|
|
255
302
|
}
|
|
@@ -35,8 +35,15 @@ import {
|
|
|
35
35
|
GET_PREFILLED_VALUES_REQUESTED,
|
|
36
36
|
GET_PREFILLED_VALUES_SUCCESS,
|
|
37
37
|
GET_PREFILLED_VALUES_FAILURE,
|
|
38
|
+
GET_SENDER_DETAILS_REQUESTED,
|
|
39
|
+
GET_SENDER_DETAILS_SUCCESS,
|
|
40
|
+
GET_SENDER_DETAILS_FAILURE,
|
|
41
|
+
GET_WECRM_ACCOUNTS_REQUESTED,
|
|
42
|
+
GET_WECRM_ACCOUNTS_SUCCESS,
|
|
43
|
+
GET_WECRM_ACCOUNTS_FAILURE,
|
|
38
44
|
ERROR_MESSAGES,
|
|
39
45
|
} from './constants';
|
|
46
|
+
import { parseSenderDetailsResponse } from './DeliverySettings/utils/parseSenderDetailsResponse';
|
|
40
47
|
|
|
41
48
|
// Search Customers Saga
|
|
42
49
|
export function* searchCustomersSaga(action) {
|
|
@@ -285,6 +292,57 @@ export function* watchGetPrefilledValues() {
|
|
|
285
292
|
yield takeLatest(GET_PREFILLED_VALUES_REQUESTED, getPrefilledValuesSaga);
|
|
286
293
|
}
|
|
287
294
|
|
|
295
|
+
export function* getSenderDetailsSaga(action) {
|
|
296
|
+
const { channel, orgUnitId } = action.payload || {};
|
|
297
|
+
if (!channel) return;
|
|
298
|
+
try {
|
|
299
|
+
const response = yield call(Api.getSenderDetails, channel, orgUnitId ?? -1);
|
|
300
|
+
if (response?.errors?.length) {
|
|
301
|
+
yield put({
|
|
302
|
+
type: GET_SENDER_DETAILS_FAILURE,
|
|
303
|
+
payload: { channel, error: response.errors },
|
|
304
|
+
});
|
|
305
|
+
return;
|
|
306
|
+
}
|
|
307
|
+
const parsed = parseSenderDetailsResponse(channel, response);
|
|
308
|
+
yield put({
|
|
309
|
+
type: GET_SENDER_DETAILS_SUCCESS,
|
|
310
|
+
payload: { channel, domains: parsed.domains || [] },
|
|
311
|
+
});
|
|
312
|
+
} catch (error) {
|
|
313
|
+
yield put({
|
|
314
|
+
type: GET_SENDER_DETAILS_FAILURE,
|
|
315
|
+
payload: { channel, error: error.message || error },
|
|
316
|
+
});
|
|
317
|
+
}
|
|
318
|
+
}
|
|
319
|
+
|
|
320
|
+
export function* getWeCrmAccountsSaga(action) {
|
|
321
|
+
const { sourceName } = action.payload || {};
|
|
322
|
+
try {
|
|
323
|
+
const result = yield call(Api.fetchWeCrmAccounts, sourceName || 'WHATSAPP');
|
|
324
|
+
const accounts = get(result, 'response') || get(result, 'entity') || (result?.success ? result.response : null) || [];
|
|
325
|
+
const list = Array.isArray(accounts) ? accounts : (accounts && accounts.data) || [];
|
|
326
|
+
yield put({
|
|
327
|
+
type: GET_WECRM_ACCOUNTS_SUCCESS,
|
|
328
|
+
payload: { accounts: list },
|
|
329
|
+
});
|
|
330
|
+
} catch (error) {
|
|
331
|
+
yield put({
|
|
332
|
+
type: GET_WECRM_ACCOUNTS_FAILURE,
|
|
333
|
+
payload: { error: error.message || error },
|
|
334
|
+
});
|
|
335
|
+
}
|
|
336
|
+
}
|
|
337
|
+
|
|
338
|
+
export function* watchGetSenderDetails() {
|
|
339
|
+
yield takeLatest(GET_SENDER_DETAILS_REQUESTED, getSenderDetailsSaga);
|
|
340
|
+
}
|
|
341
|
+
|
|
342
|
+
export function* watchGetWeCrmAccounts() {
|
|
343
|
+
yield takeLatest(GET_WECRM_ACCOUNTS_REQUESTED, getWeCrmAccountsSaga);
|
|
344
|
+
}
|
|
345
|
+
|
|
288
346
|
// Root saga
|
|
289
347
|
export function* commonTestAndPreviewSaga() {
|
|
290
348
|
yield all([
|
|
@@ -296,5 +354,7 @@ export function* commonTestAndPreviewSaga() {
|
|
|
296
354
|
watchFetchTestGroups(),
|
|
297
355
|
watchCreateMessageMeta(),
|
|
298
356
|
watchGetPrefilledValues(),
|
|
357
|
+
watchGetSenderDetails(),
|
|
358
|
+
watchGetWeCrmAccounts(),
|
|
299
359
|
]);
|
|
300
360
|
}
|
|
@@ -144,6 +144,51 @@ const makeSelectFetchPrefilledValuesErrors = () => createSelector(
|
|
|
144
144
|
(substate) => substate.get('fetchPrefilledValuesErrors')?.toJS() || [],
|
|
145
145
|
);
|
|
146
146
|
|
|
147
|
+
const makeSelectSenderDetailsForChannel = (channel) => createSelector(
|
|
148
|
+
selectCommonTestAndPreviewDomain,
|
|
149
|
+
(substate) => {
|
|
150
|
+
if (!substate) return [];
|
|
151
|
+
const byChannel = substate.get('senderDetailsByChannel');
|
|
152
|
+
if (!byChannel) return [];
|
|
153
|
+
const list = byChannel.get(channel);
|
|
154
|
+
return list ? list.toJS() : [];
|
|
155
|
+
},
|
|
156
|
+
);
|
|
157
|
+
|
|
158
|
+
const makeSelectSenderDetailsByChannel = () => createSelector(
|
|
159
|
+
selectCommonTestAndPreviewDomain,
|
|
160
|
+
(substate) => {
|
|
161
|
+
if (!substate) return {};
|
|
162
|
+
const byChannel = substate.get('senderDetailsByChannel');
|
|
163
|
+
if (!byChannel) return {};
|
|
164
|
+
return byChannel.toJS ? byChannel.toJS() : {};
|
|
165
|
+
},
|
|
166
|
+
);
|
|
167
|
+
|
|
168
|
+
const makeSelectWeCrmAccounts = () => createSelector(
|
|
169
|
+
selectCommonTestAndPreviewDomain,
|
|
170
|
+
(substate) => {
|
|
171
|
+
if (!substate) return [];
|
|
172
|
+
const list = substate.get('wecrmAccounts');
|
|
173
|
+
return list ? list.toJS() : [];
|
|
174
|
+
},
|
|
175
|
+
);
|
|
176
|
+
|
|
177
|
+
const makeSelectIsLoadingSenderDetails = () => createSelector(
|
|
178
|
+
selectCommonTestAndPreviewDomain,
|
|
179
|
+
(substate) => substate.get('isLoadingSenderDetails') || false,
|
|
180
|
+
);
|
|
181
|
+
|
|
182
|
+
const makeSelectFetchSenderDetailsError = () => createSelector(
|
|
183
|
+
selectCommonTestAndPreviewDomain,
|
|
184
|
+
(substate) => substate.get('fetchSenderDetailsError'),
|
|
185
|
+
);
|
|
186
|
+
|
|
187
|
+
const makeSelectFetchWeCrmAccountsError = () => createSelector(
|
|
188
|
+
selectCommonTestAndPreviewDomain,
|
|
189
|
+
(substate) => substate.get('fetchWeCrmAccountsError'),
|
|
190
|
+
);
|
|
191
|
+
|
|
147
192
|
export {
|
|
148
193
|
makeSelectCommonTestAndPreview,
|
|
149
194
|
makeSelectCustomers,
|
|
@@ -171,4 +216,10 @@ export {
|
|
|
171
216
|
makeSelectUpdatePreviewErrors,
|
|
172
217
|
makeSelectFetchPrefilledValuesError,
|
|
173
218
|
makeSelectFetchPrefilledValuesErrors,
|
|
219
|
+
makeSelectSenderDetailsForChannel,
|
|
220
|
+
makeSelectSenderDetailsByChannel,
|
|
221
|
+
makeSelectWeCrmAccounts,
|
|
222
|
+
makeSelectIsLoadingSenderDetails,
|
|
223
|
+
makeSelectFetchSenderDetailsError,
|
|
224
|
+
makeSelectFetchWeCrmAccountsError,
|
|
174
225
|
};
|