@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
package/package.json
CHANGED
|
@@ -8,10 +8,6 @@ import CapStepsAccordian from '@capillarytech/cap-ui-library/CapStepsAccordian';
|
|
|
8
8
|
import CapTreeSelect from '@capillarytech/cap-ui-library/CapTreeSelect';
|
|
9
9
|
import isEmpty from 'lodash/isEmpty';
|
|
10
10
|
import messages from './messages';
|
|
11
|
-
import DeliverySettings from './DeliverySettings';
|
|
12
|
-
import { CHANNELS } from './constants';
|
|
13
|
-
|
|
14
|
-
const CHANNELS_WITH_DELIVERY_SETTINGS = [CHANNELS.SMS, CHANNELS.EMAIL, CHANNELS.WHATSAPP];
|
|
15
11
|
|
|
16
12
|
const SendTestMessage = ({
|
|
17
13
|
isFetchingTestCustomers,
|
|
@@ -21,16 +17,8 @@ const SendTestMessage = ({
|
|
|
21
17
|
selectedTestEntities,
|
|
22
18
|
handleSendTestMessage,
|
|
23
19
|
formData,
|
|
24
|
-
channel,
|
|
25
20
|
isSendingTestMessage,
|
|
26
21
|
formatMessage,
|
|
27
|
-
deliverySettings,
|
|
28
|
-
senderDetailsOptions,
|
|
29
|
-
wecrmAccounts,
|
|
30
|
-
onSaveDeliverySettings,
|
|
31
|
-
isLoadingSenderDetails,
|
|
32
|
-
smsTraiDltEnabled,
|
|
33
|
-
registeredSenderIds,
|
|
34
22
|
}) => (
|
|
35
23
|
<CapStepsAccordian
|
|
36
24
|
showNumberSteps={false}
|
|
@@ -55,24 +43,6 @@ const SendTestMessage = ({
|
|
|
55
43
|
multiple
|
|
56
44
|
placeholder={formatMessage(messages.testCustomersPlaceholder)}
|
|
57
45
|
/>
|
|
58
|
-
{CHANNELS_WITH_DELIVERY_SETTINGS.includes(channel) && (
|
|
59
|
-
<DeliverySettings
|
|
60
|
-
channel={channel}
|
|
61
|
-
deliverySettings={deliverySettings || {}}
|
|
62
|
-
senderDetailsOptions={senderDetailsOptions || []}
|
|
63
|
-
wecrmAccounts={wecrmAccounts || []}
|
|
64
|
-
onSaveDeliverySettings={onSaveDeliverySettings}
|
|
65
|
-
isLoadingSenderDetails={isLoadingSenderDetails}
|
|
66
|
-
formatMessage={formatMessage}
|
|
67
|
-
smsTraiDltEnabled={smsTraiDltEnabled}
|
|
68
|
-
registeredSenderIds={registeredSenderIds}
|
|
69
|
-
whatsappAccountFromForm={
|
|
70
|
-
channel === CHANNELS.WHATSAPP && formData?.accountName
|
|
71
|
-
? { accountName: formData.accountName }
|
|
72
|
-
: undefined
|
|
73
|
-
}
|
|
74
|
-
/>
|
|
75
|
-
)}
|
|
76
46
|
<CapButton onClick={handleSendTestMessage} disabled={isEmpty(selectedTestEntities) || isSendingTestMessage}>
|
|
77
47
|
<FormattedMessage {...messages.sendTestButton} />
|
|
78
48
|
</CapButton>
|
|
@@ -90,29 +60,9 @@ SendTestMessage.propTypes = {
|
|
|
90
60
|
handleTestEntitiesChange: PropTypes.func.isRequired,
|
|
91
61
|
selectedTestEntities: PropTypes.array.isRequired,
|
|
92
62
|
handleSendTestMessage: PropTypes.func.isRequired,
|
|
93
|
-
formData: PropTypes.object,
|
|
94
|
-
channel: PropTypes.string,
|
|
63
|
+
formData: PropTypes.object.isRequired,
|
|
95
64
|
isSendingTestMessage: PropTypes.bool.isRequired,
|
|
96
65
|
formatMessage: PropTypes.func.isRequired,
|
|
97
|
-
deliverySettings: PropTypes.object,
|
|
98
|
-
senderDetailsOptions: PropTypes.array,
|
|
99
|
-
wecrmAccounts: PropTypes.array,
|
|
100
|
-
onSaveDeliverySettings: PropTypes.func,
|
|
101
|
-
isLoadingSenderDetails: PropTypes.bool,
|
|
102
|
-
smsTraiDltEnabled: PropTypes.bool,
|
|
103
|
-
registeredSenderIds: PropTypes.array,
|
|
104
|
-
};
|
|
105
|
-
|
|
106
|
-
SendTestMessage.defaultProps = {
|
|
107
|
-
formData: undefined,
|
|
108
|
-
channel: undefined,
|
|
109
|
-
deliverySettings: {},
|
|
110
|
-
senderDetailsOptions: [],
|
|
111
|
-
wecrmAccounts: [],
|
|
112
|
-
onSaveDeliverySettings: undefined,
|
|
113
|
-
isLoadingSenderDetails: false,
|
|
114
|
-
smsTraiDltEnabled: false,
|
|
115
|
-
registeredSenderIds: [],
|
|
116
66
|
};
|
|
117
67
|
|
|
118
68
|
export default SendTestMessage;
|
|
@@ -18,8 +18,6 @@ import {
|
|
|
18
18
|
GET_PREFILLED_VALUES_REQUESTED,
|
|
19
19
|
CLEAR_PREFILLED_VALUES,
|
|
20
20
|
CLEAR_PREVIEW_ERRORS,
|
|
21
|
-
GET_SENDER_DETAILS_REQUESTED,
|
|
22
|
-
GET_WECRM_ACCOUNTS_REQUESTED,
|
|
23
21
|
} from './constants';
|
|
24
22
|
|
|
25
23
|
// ============================================
|
|
@@ -127,21 +125,3 @@ export const clearPrefilledValues = () => ({
|
|
|
127
125
|
export const clearPreviewErrors = () => ({
|
|
128
126
|
type: CLEAR_PREVIEW_ERRORS,
|
|
129
127
|
});
|
|
130
|
-
|
|
131
|
-
/**
|
|
132
|
-
* Request sender details for a channel (SMS, EMAIL, WHATSAPP) for delivery settings
|
|
133
|
-
* @param {Object} payload - { channel, orgUnitId }
|
|
134
|
-
*/
|
|
135
|
-
export const getSenderDetailsRequested = (payload) => ({
|
|
136
|
-
type: GET_SENDER_DETAILS_REQUESTED,
|
|
137
|
-
payload,
|
|
138
|
-
});
|
|
139
|
-
|
|
140
|
-
/**
|
|
141
|
-
* Request WeCRM accounts (e.g. for WhatsApp account dropdown)
|
|
142
|
-
* @param {Object} payload - { sourceName } e.g. { sourceName: 'WHATSAPP' }
|
|
143
|
-
*/
|
|
144
|
-
export const getWeCrmAccountsRequested = (payload) => ({
|
|
145
|
-
type: GET_WECRM_ACCOUNTS_REQUESTED,
|
|
146
|
-
payload,
|
|
147
|
-
});
|
|
@@ -55,16 +55,6 @@ export const CLEAR_SEARCH_RESULTS = 'app/CommonTestAndPreview/CLEAR_SEARCH_RESUL
|
|
|
55
55
|
export const CLEAR_PREFILLED_VALUES = 'app/CommonTestAndPreview/CLEAR_PREFILLED_VALUES';
|
|
56
56
|
export const CLEAR_PREVIEW_ERRORS = 'app/CommonTestAndPreview/CLEAR_PREVIEW_ERRORS';
|
|
57
57
|
|
|
58
|
-
// Get Sender Details (delivery settings for Test and Preview)
|
|
59
|
-
export const GET_SENDER_DETAILS_REQUESTED = 'app/CommonTestAndPreview/GET_SENDER_DETAILS_REQUESTED';
|
|
60
|
-
export const GET_SENDER_DETAILS_SUCCESS = 'app/CommonTestAndPreview/GET_SENDER_DETAILS_SUCCESS';
|
|
61
|
-
export const GET_SENDER_DETAILS_FAILURE = 'app/CommonTestAndPreview/GET_SENDER_DETAILS_FAILURE';
|
|
62
|
-
|
|
63
|
-
// Get WeCRM Accounts (WhatsApp account list)
|
|
64
|
-
export const GET_WECRM_ACCOUNTS_REQUESTED = 'app/CommonTestAndPreview/GET_WECRM_ACCOUNTS_REQUESTED';
|
|
65
|
-
export const GET_WECRM_ACCOUNTS_SUCCESS = 'app/CommonTestAndPreview/GET_WECRM_ACCOUNTS_SUCCESS';
|
|
66
|
-
export const GET_WECRM_ACCOUNTS_FAILURE = 'app/CommonTestAndPreview/GET_WECRM_ACCOUNTS_FAILURE';
|
|
67
|
-
|
|
68
58
|
// ============================================
|
|
69
59
|
// CHANNEL CONSTANTS
|
|
70
60
|
// ============================================
|
|
@@ -105,10 +105,6 @@ const CommonTestAndPreview = (props) => {
|
|
|
105
105
|
updatePreviewErrors,
|
|
106
106
|
fetchPrefilledValuesError,
|
|
107
107
|
fetchPrefilledValuesErrors,
|
|
108
|
-
senderDetailsByChannel = {},
|
|
109
|
-
wecrmAccounts = [],
|
|
110
|
-
isLoadingSenderDetails = false,
|
|
111
|
-
orgUnitId = -1,
|
|
112
108
|
// Email-specific props
|
|
113
109
|
beeInstance,
|
|
114
110
|
currentTab = 1,
|
|
@@ -150,100 +146,6 @@ const CommonTestAndPreview = (props) => {
|
|
|
150
146
|
const [selectedTestEntities, setSelectedTestEntities] = useState([]);
|
|
151
147
|
const [beeContent, setBeeContent] = useState(''); // Track BEE editor content separately (EMAIL only)
|
|
152
148
|
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
|
-
const formDataForSendTest = formData ?? (content && typeof content === 'object' && !Array.isArray(content) ? content : formData);
|
|
168
|
-
const smsTemplateConfigs = formDataForSendTest?.templateConfigs || {};
|
|
169
|
-
const smsTraiDltEnabled = !!smsTemplateConfigs?.traiDltEnabled;
|
|
170
|
-
const registeredSenderIds = smsTemplateConfigs?.registeredSenderIds || [];
|
|
171
|
-
|
|
172
|
-
// Fetch sender details and WeCRM accounts when Test & Preview opens for SMS/Email/WhatsApp
|
|
173
|
-
useEffect(() => {
|
|
174
|
-
if (!show || !channel) {
|
|
175
|
-
return;
|
|
176
|
-
}
|
|
177
|
-
if (channelsWithDeliverySettings.includes(channel)) {
|
|
178
|
-
if (actions.getSenderDetailsRequested) {
|
|
179
|
-
actions.getSenderDetailsRequested({ channel, orgUnitId: orgUnitId ?? -1 });
|
|
180
|
-
}
|
|
181
|
-
if (channel === CHANNELS.WHATSAPP && actions.getWeCrmAccountsRequested) {
|
|
182
|
-
actions.getWeCrmAccountsRequested({ sourceName: CHANNELS.WHATSAPP });
|
|
183
|
-
}
|
|
184
|
-
}
|
|
185
|
-
}, [show, channel, orgUnitId, actions]);
|
|
186
|
-
|
|
187
|
-
const findDefault = (arr) => (arr && arr.find((x) => x.default)) || (arr && arr[0]) || {};
|
|
188
|
-
|
|
189
|
-
// Auto-set default delivery setting when sender details load (campaigns-style: first domain + default/first sender)
|
|
190
|
-
useEffect(() => {
|
|
191
|
-
if (!channel || !channelsWithDeliverySettings.includes(channel)) return;
|
|
192
|
-
const domains = senderDetailsByChannel[channel];
|
|
193
|
-
if (!domains || domains.length === 0) return;
|
|
194
|
-
const current = testPreviewDeliverySettings[channel];
|
|
195
|
-
const isEmptySelection = !current?.domainId && !current?.gsmSenderId && !current?.senderEmail && !current?.senderMobNum;
|
|
196
|
-
if (!isEmptySelection) return;
|
|
197
|
-
|
|
198
|
-
const whatsappAccountFromForm = channel === CHANNELS.WHATSAPP ? formData?.accountName : undefined;
|
|
199
|
-
const matchedWhatsappAccount = whatsappAccountFromForm
|
|
200
|
-
? (wecrmAccounts || []).find((account) => account?.name === whatsappAccountFromForm)
|
|
201
|
-
: null;
|
|
202
|
-
const smsDomains = channel === CHANNELS.SMS && smsTraiDltEnabled
|
|
203
|
-
? domains.filter((domain) => (domain.gsmSenders || []).some((gsm) => registeredSenderIds.includes(gsm.value)))
|
|
204
|
-
: domains;
|
|
205
|
-
const [defaultDomain] = domains;
|
|
206
|
-
const [firstSmsDomain] = smsDomains;
|
|
207
|
-
let firstDomain = defaultDomain;
|
|
208
|
-
if (channel === CHANNELS.WHATSAPP && matchedWhatsappAccount?.sourceAccountIdentifier) {
|
|
209
|
-
firstDomain = domains.find((domain) => domain?.sourceAccountIdentifier === matchedWhatsappAccount.sourceAccountIdentifier) || defaultDomain;
|
|
210
|
-
} else if (channel === CHANNELS.SMS) {
|
|
211
|
-
firstDomain = firstSmsDomain;
|
|
212
|
-
}
|
|
213
|
-
if (!firstDomain) return;
|
|
214
|
-
setTestPreviewDeliverySettings((prev) => {
|
|
215
|
-
const next = { ...prev };
|
|
216
|
-
if (channel === CHANNELS.SMS) {
|
|
217
|
-
const smsGsmSenders = smsTraiDltEnabled
|
|
218
|
-
? (firstDomain.gsmSenders || []).filter((gsm) => registeredSenderIds.includes(gsm.value))
|
|
219
|
-
: firstDomain.gsmSenders;
|
|
220
|
-
next[channel] = {
|
|
221
|
-
domainId: firstDomain.domainId,
|
|
222
|
-
domainGatewayMapId: firstDomain.dgmId,
|
|
223
|
-
gsmSenderId: findDefault(smsGsmSenders)?.value || smsGsmSenders?.[0]?.value || '',
|
|
224
|
-
cdmaSenderId: findDefault(firstDomain.cdmaSenders)?.value || '',
|
|
225
|
-
};
|
|
226
|
-
} else if (channel === CHANNELS.EMAIL) {
|
|
227
|
-
const defSender = findDefault(firstDomain.emailSenders);
|
|
228
|
-
const defReply = findDefault(firstDomain.emailRepliers);
|
|
229
|
-
next[channel] = {
|
|
230
|
-
domainId: firstDomain.domainId,
|
|
231
|
-
domainGatewayMapId: firstDomain.dgmId,
|
|
232
|
-
senderEmail: defSender?.value || '',
|
|
233
|
-
senderLabel: defSender?.label || '',
|
|
234
|
-
senderReplyTo: defReply?.value || '',
|
|
235
|
-
};
|
|
236
|
-
} else if (channel === CHANNELS.WHATSAPP) {
|
|
237
|
-
const accId = firstDomain.sourceAccountIdentifier;
|
|
238
|
-
next[channel] = {
|
|
239
|
-
domainId: firstDomain.domainId,
|
|
240
|
-
senderMobNum: firstDomain.gsmSenders?.[0]?.value || '',
|
|
241
|
-
sourceAccountIdentifier: matchedWhatsappAccount?.sourceAccountIdentifier || accId || '',
|
|
242
|
-
};
|
|
243
|
-
}
|
|
244
|
-
return next;
|
|
245
|
-
});
|
|
246
|
-
}, [channel, formData?.accountName, senderDetailsByChannel, smsTraiDltEnabled, registeredSenderIds, wecrmAccounts]);
|
|
247
149
|
|
|
248
150
|
// ============================================
|
|
249
151
|
// MEMOIZED VALUES
|
|
@@ -540,7 +442,7 @@ const CommonTestAndPreview = (props) => {
|
|
|
540
442
|
* Prepare payload for test message sending based on channel
|
|
541
443
|
* Updated to match API structure with ouId, sourceEntityId, module, deliverySettings, etc.
|
|
542
444
|
*/
|
|
543
|
-
const prepareTestMessagePayload = (channelType, formDataObj, contentStr, customValuesObj, recipientDetails, previewDataObj
|
|
445
|
+
const prepareTestMessagePayload = (channelType, formDataObj, contentStr, customValuesObj, recipientDetails, previewDataObj) => {
|
|
544
446
|
// Base payload structure common to all channels
|
|
545
447
|
const basePayload = {
|
|
546
448
|
ouId: -1,
|
|
@@ -566,14 +468,6 @@ const CommonTestAndPreview = (props) => {
|
|
|
566
468
|
? resolveTagsInText(subject, customValuesObj)
|
|
567
469
|
: subject;
|
|
568
470
|
|
|
569
|
-
const emailChannelSettings = {
|
|
570
|
-
channel: CHANNELS.EMAIL,
|
|
571
|
-
senderLabel: deliverySettingsOverride?.senderLabel ?? '',
|
|
572
|
-
senderId: deliverySettingsOverride?.senderEmail ?? '',
|
|
573
|
-
replyToId: deliverySettingsOverride?.senderReplyTo ?? '',
|
|
574
|
-
domainGatewayMapId: deliverySettingsOverride?.domainGatewayMapId ?? '',
|
|
575
|
-
domainId: deliverySettingsOverride?.domainId ?? '',
|
|
576
|
-
};
|
|
577
471
|
return {
|
|
578
472
|
...basePayload,
|
|
579
473
|
emailDeliverySettings: {
|
|
@@ -584,7 +478,12 @@ const CommonTestAndPreview = (props) => {
|
|
|
584
478
|
skipRateLimit: false,
|
|
585
479
|
bypassControlUser: false,
|
|
586
480
|
},
|
|
587
|
-
channelSettings:
|
|
481
|
+
channelSettings: {
|
|
482
|
+
channel: CHANNELS.EMAIL,
|
|
483
|
+
senderLabel: '',
|
|
484
|
+
senderId: '',
|
|
485
|
+
replyToId: '',
|
|
486
|
+
},
|
|
588
487
|
},
|
|
589
488
|
emailMessageContent: {
|
|
590
489
|
channel: CHANNELS.EMAIL,
|
|
@@ -621,12 +520,8 @@ const CommonTestAndPreview = (props) => {
|
|
|
621
520
|
},
|
|
622
521
|
smsDeliverySettings: {
|
|
623
522
|
channelSettings: {
|
|
624
|
-
gsmSenderId:
|
|
625
|
-
domainId:
|
|
626
|
-
domainGatewayMapId: deliverySettingsOverride?.domainGatewayMapId ?? '',
|
|
627
|
-
targetNdnc: false,
|
|
628
|
-
cdmaSenderId: deliverySettingsOverride?.cdmaSenderId ?? '',
|
|
629
|
-
channel: CHANNELS.SMS,
|
|
523
|
+
gsmSenderId: '',
|
|
524
|
+
domainId: null,
|
|
630
525
|
},
|
|
631
526
|
additionalSettings: {
|
|
632
527
|
useTinyUrl: false,
|
|
@@ -762,17 +657,16 @@ const CommonTestAndPreview = (props) => {
|
|
|
762
657
|
templateConfigs.mediaType = formDataObj?.carouselMediaType?.toUpperCase() || MEDIA_TYPE_IMAGE;
|
|
763
658
|
}
|
|
764
659
|
|
|
765
|
-
// Extract delivery settings
|
|
766
|
-
const senderMobNum =
|
|
767
|
-
const domainId =
|
|
768
|
-
const sourceAccountIdentifier = deliverySettingsOverride?.sourceAccountIdentifier ?? formDataObj?.sourceAccountIdentifier ?? '';
|
|
660
|
+
// Extract delivery settings
|
|
661
|
+
const senderMobNum = formDataObj?.senderMobNum || additionalProps?.senderMobNum || '';
|
|
662
|
+
const domainId = formDataObj?.domainId || additionalProps?.domainId || null;
|
|
769
663
|
|
|
770
664
|
return {
|
|
771
665
|
...basePayload,
|
|
772
666
|
whatsappMessageContent: {
|
|
773
667
|
messageBody: templateEditorValue || '',
|
|
774
668
|
accountId: formDataObj?.accountId || '',
|
|
775
|
-
sourceAccountIdentifier:
|
|
669
|
+
sourceAccountIdentifier: formDataObj?.sourceAccountIdentifier || '',
|
|
776
670
|
accountName: formDataObj?.accountName || '',
|
|
777
671
|
templateConfigs,
|
|
778
672
|
channel: CHANNELS.WHATSAPP,
|
|
@@ -2476,10 +2370,6 @@ const CommonTestAndPreview = (props) => {
|
|
|
2476
2370
|
});
|
|
2477
2371
|
const uniqueUserIds = [...new Set(allUserIds)];
|
|
2478
2372
|
|
|
2479
|
-
const deliveryOverride = [CHANNELS.SMS, CHANNELS.EMAIL, CHANNELS.WHATSAPP].includes(channel)
|
|
2480
|
-
? testPreviewDeliverySettings[channel]
|
|
2481
|
-
: null;
|
|
2482
|
-
|
|
2483
2373
|
// Create initial payload based on channel
|
|
2484
2374
|
const initialPayload = prepareTestMessagePayload(
|
|
2485
2375
|
channel,
|
|
@@ -2487,8 +2377,7 @@ const CommonTestAndPreview = (props) => {
|
|
|
2487
2377
|
getCurrentContent,
|
|
2488
2378
|
customValues,
|
|
2489
2379
|
uniqueUserIds,
|
|
2490
|
-
previewData
|
|
2491
|
-
deliveryOverride
|
|
2380
|
+
previewData
|
|
2492
2381
|
);
|
|
2493
2382
|
|
|
2494
2383
|
actions.createMessageMetaRequested(
|
|
@@ -2560,13 +2449,6 @@ const CommonTestAndPreview = (props) => {
|
|
|
2560
2449
|
/>
|
|
2561
2450
|
);
|
|
2562
2451
|
|
|
2563
|
-
const handleSaveDeliverySettings = (values) => {
|
|
2564
|
-
setTestPreviewDeliverySettings((prev) => ({
|
|
2565
|
-
...prev,
|
|
2566
|
-
[channel]: values,
|
|
2567
|
-
}));
|
|
2568
|
-
};
|
|
2569
|
-
|
|
2570
2452
|
const renderSendTestMessage = () => (
|
|
2571
2453
|
<SendTestMessage
|
|
2572
2454
|
isFetchingTestCustomers={isFetchingTestCustomers}
|
|
@@ -2575,18 +2457,11 @@ const CommonTestAndPreview = (props) => {
|
|
|
2575
2457
|
handleTestEntitiesChange={handleTestEntitiesChange}
|
|
2576
2458
|
selectedTestEntities={selectedTestEntities}
|
|
2577
2459
|
handleSendTestMessage={handleSendTestMessage}
|
|
2578
|
-
formData={
|
|
2460
|
+
formData={formData}
|
|
2579
2461
|
content={getCurrentContent}
|
|
2580
2462
|
channel={channel}
|
|
2581
2463
|
isSendingTestMessage={isSendingTestMessage}
|
|
2582
2464
|
formatMessage={formatMessage}
|
|
2583
|
-
deliverySettings={testPreviewDeliverySettings[channel]}
|
|
2584
|
-
senderDetailsOptions={senderDetailsByChannel[channel]}
|
|
2585
|
-
wecrmAccounts={wecrmAccounts}
|
|
2586
|
-
onSaveDeliverySettings={handleSaveDeliverySettings}
|
|
2587
|
-
isLoadingSenderDetails={isLoadingSenderDetails}
|
|
2588
|
-
smsTraiDltEnabled={smsTraiDltEnabled}
|
|
2589
|
-
registeredSenderIds={registeredSenderIds}
|
|
2590
2465
|
/>
|
|
2591
2466
|
);
|
|
2592
2467
|
|
|
@@ -2687,10 +2562,6 @@ CommonTestAndPreview.propTypes = {
|
|
|
2687
2562
|
})),
|
|
2688
2563
|
isSendingTestMessage: PropTypes.bool.isRequired,
|
|
2689
2564
|
intl: PropTypes.object.isRequired,
|
|
2690
|
-
senderDetailsByChannel: PropTypes.object,
|
|
2691
|
-
wecrmAccounts: PropTypes.array,
|
|
2692
|
-
isLoadingSenderDetails: PropTypes.bool,
|
|
2693
|
-
orgUnitId: PropTypes.number,
|
|
2694
2565
|
|
|
2695
2566
|
// Email-specific props
|
|
2696
2567
|
beeInstance: PropTypes.object,
|
|
@@ -2726,10 +2597,6 @@ CommonTestAndPreview.defaultProps = {
|
|
|
2726
2597
|
rcsOrientation: null,
|
|
2727
2598
|
rcsIosPreview: false,
|
|
2728
2599
|
templateLayoutType: null,
|
|
2729
|
-
senderDetailsByChannel: {},
|
|
2730
|
-
wecrmAccounts: [],
|
|
2731
|
-
isLoadingSenderDetails: false,
|
|
2732
|
-
orgUnitId: -1,
|
|
2733
2600
|
};
|
|
2734
2601
|
|
|
2735
2602
|
// ============================================
|
|
@@ -31,13 +31,6 @@ 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,
|
|
41
34
|
} from './constants';
|
|
42
35
|
|
|
43
36
|
const initialState = fromJS({
|
|
@@ -92,16 +85,6 @@ const initialState = fromJS({
|
|
|
92
85
|
isFetchingPrefilledValues: false,
|
|
93
86
|
fetchPrefilledValuesError: null,
|
|
94
87
|
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,
|
|
105
88
|
});
|
|
106
89
|
|
|
107
90
|
const previewAndTestReducer = (state = initialState, action) => {
|
|
@@ -267,36 +250,6 @@ const previewAndTestReducer = (state = initialState, action) => {
|
|
|
267
250
|
.set('fetchPrefilledValuesError', null)
|
|
268
251
|
.set('fetchPrefilledValuesErrors', fromJS([]));
|
|
269
252
|
|
|
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
|
-
|
|
300
253
|
default:
|
|
301
254
|
return state;
|
|
302
255
|
}
|
|
@@ -35,15 +35,8 @@ 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,
|
|
44
38
|
ERROR_MESSAGES,
|
|
45
39
|
} from './constants';
|
|
46
|
-
import { parseSenderDetailsResponse } from './DeliverySettings/utils/parseSenderDetailsResponse';
|
|
47
40
|
|
|
48
41
|
// Search Customers Saga
|
|
49
42
|
export function* searchCustomersSaga(action) {
|
|
@@ -292,57 +285,6 @@ export function* watchGetPrefilledValues() {
|
|
|
292
285
|
yield takeLatest(GET_PREFILLED_VALUES_REQUESTED, getPrefilledValuesSaga);
|
|
293
286
|
}
|
|
294
287
|
|
|
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
|
-
|
|
346
288
|
// Root saga
|
|
347
289
|
export function* commonTestAndPreviewSaga() {
|
|
348
290
|
yield all([
|
|
@@ -354,7 +296,5 @@ export function* commonTestAndPreviewSaga() {
|
|
|
354
296
|
watchFetchTestGroups(),
|
|
355
297
|
watchCreateMessageMeta(),
|
|
356
298
|
watchGetPrefilledValues(),
|
|
357
|
-
watchGetSenderDetails(),
|
|
358
|
-
watchGetWeCrmAccounts(),
|
|
359
299
|
]);
|
|
360
300
|
}
|
|
@@ -144,51 +144,6 @@ 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
|
-
|
|
192
147
|
export {
|
|
193
148
|
makeSelectCommonTestAndPreview,
|
|
194
149
|
makeSelectCustomers,
|
|
@@ -216,10 +171,4 @@ export {
|
|
|
216
171
|
makeSelectUpdatePreviewErrors,
|
|
217
172
|
makeSelectFetchPrefilledValuesError,
|
|
218
173
|
makeSelectFetchPrefilledValuesErrors,
|
|
219
|
-
makeSelectSenderDetailsForChannel,
|
|
220
|
-
makeSelectSenderDetailsByChannel,
|
|
221
|
-
makeSelectWeCrmAccounts,
|
|
222
|
-
makeSelectIsLoadingSenderDetails,
|
|
223
|
-
makeSelectFetchSenderDetailsError,
|
|
224
|
-
makeSelectFetchWeCrmAccountsError,
|
|
225
174
|
};
|