@capillarytech/creatives-library 8.0.294 → 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 -150
- package/v2Components/CommonTestAndPreview/reducer.js +0 -47
- package/v2Components/CommonTestAndPreview/sagas.js +0 -61
- 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 -425
- package/v2Components/CommonTestAndPreview/DeliverySettings/ModifyDeliverySettings.scss +0 -35
- 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 -88
- 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,102 +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 {
|
|
195
|
-
domainId = '', gsmSenderId = '', senderEmail = '', senderMobNum = '',
|
|
196
|
-
} = testPreviewDeliverySettings[channel] || {};
|
|
197
|
-
const isEmptySelection = !domainId && !gsmSenderId && !senderEmail && !senderMobNum;
|
|
198
|
-
if (!isEmptySelection) return;
|
|
199
|
-
|
|
200
|
-
const whatsappAccountFromForm = channel === CHANNELS.WHATSAPP ? formData?.accountName : undefined;
|
|
201
|
-
const matchedWhatsappAccount = whatsappAccountFromForm
|
|
202
|
-
? (wecrmAccounts || []).find((account) => account?.name === whatsappAccountFromForm)
|
|
203
|
-
: null;
|
|
204
|
-
const smsDomains = channel === CHANNELS.SMS && smsTraiDltEnabled
|
|
205
|
-
? domains.filter((domain) => (domain.gsmSenders || []).some((gsm) => registeredSenderIds.includes(gsm.value)))
|
|
206
|
-
: domains;
|
|
207
|
-
const [defaultDomain] = domains;
|
|
208
|
-
const [firstSmsDomain] = smsDomains;
|
|
209
|
-
let firstDomain = defaultDomain;
|
|
210
|
-
if (channel === CHANNELS.WHATSAPP && matchedWhatsappAccount?.sourceAccountIdentifier) {
|
|
211
|
-
firstDomain = domains.find((domain) => domain?.sourceAccountIdentifier === matchedWhatsappAccount.sourceAccountIdentifier) || defaultDomain;
|
|
212
|
-
} else if (channel === CHANNELS.SMS) {
|
|
213
|
-
firstDomain = firstSmsDomain;
|
|
214
|
-
}
|
|
215
|
-
if (!firstDomain) return;
|
|
216
|
-
setTestPreviewDeliverySettings((prev) => {
|
|
217
|
-
const next = { ...prev };
|
|
218
|
-
if (channel === CHANNELS.SMS) {
|
|
219
|
-
const smsGsmSenders = smsTraiDltEnabled
|
|
220
|
-
? (firstDomain.gsmSenders || []).filter((gsm) => registeredSenderIds.includes(gsm.value))
|
|
221
|
-
: firstDomain.gsmSenders;
|
|
222
|
-
next[channel] = {
|
|
223
|
-
domainId: firstDomain.domainId,
|
|
224
|
-
domainGatewayMapId: firstDomain.dgmId,
|
|
225
|
-
gsmSenderId: findDefault(smsGsmSenders)?.value || smsGsmSenders?.[0]?.value || '',
|
|
226
|
-
cdmaSenderId: findDefault(firstDomain.cdmaSenders)?.value || '',
|
|
227
|
-
};
|
|
228
|
-
} else if (channel === CHANNELS.EMAIL) {
|
|
229
|
-
const defSender = findDefault(firstDomain.emailSenders);
|
|
230
|
-
const defReply = findDefault(firstDomain.emailRepliers);
|
|
231
|
-
next[channel] = {
|
|
232
|
-
domainId: firstDomain.domainId,
|
|
233
|
-
domainGatewayMapId: firstDomain.dgmId,
|
|
234
|
-
senderEmail: defSender?.value || '',
|
|
235
|
-
senderLabel: defSender?.label || '',
|
|
236
|
-
senderReplyTo: defReply?.value || '',
|
|
237
|
-
};
|
|
238
|
-
} else if (channel === CHANNELS.WHATSAPP) {
|
|
239
|
-
const accId = firstDomain.sourceAccountIdentifier;
|
|
240
|
-
next[channel] = {
|
|
241
|
-
domainId: firstDomain.domainId,
|
|
242
|
-
senderMobNum: firstDomain.gsmSenders?.[0]?.value || '',
|
|
243
|
-
sourceAccountIdentifier: matchedWhatsappAccount?.sourceAccountIdentifier || accId || '',
|
|
244
|
-
};
|
|
245
|
-
}
|
|
246
|
-
return next;
|
|
247
|
-
});
|
|
248
|
-
}, [channel, formData?.accountName, senderDetailsByChannel, smsTraiDltEnabled, registeredSenderIds, wecrmAccounts]);
|
|
249
149
|
|
|
250
150
|
// ============================================
|
|
251
151
|
// MEMOIZED VALUES
|
|
@@ -542,7 +442,7 @@ const CommonTestAndPreview = (props) => {
|
|
|
542
442
|
* Prepare payload for test message sending based on channel
|
|
543
443
|
* Updated to match API structure with ouId, sourceEntityId, module, deliverySettings, etc.
|
|
544
444
|
*/
|
|
545
|
-
const prepareTestMessagePayload = (channelType, formDataObj, contentStr, customValuesObj, recipientDetails, previewDataObj
|
|
445
|
+
const prepareTestMessagePayload = (channelType, formDataObj, contentStr, customValuesObj, recipientDetails, previewDataObj) => {
|
|
546
446
|
// Base payload structure common to all channels
|
|
547
447
|
const basePayload = {
|
|
548
448
|
ouId: -1,
|
|
@@ -568,14 +468,6 @@ const CommonTestAndPreview = (props) => {
|
|
|
568
468
|
? resolveTagsInText(subject, customValuesObj)
|
|
569
469
|
: subject;
|
|
570
470
|
|
|
571
|
-
const emailChannelSettings = {
|
|
572
|
-
channel: CHANNELS.EMAIL,
|
|
573
|
-
senderLabel: deliverySettingsOverride?.senderLabel ?? '',
|
|
574
|
-
senderId: deliverySettingsOverride?.senderEmail ?? '',
|
|
575
|
-
replyToId: deliverySettingsOverride?.senderReplyTo ?? '',
|
|
576
|
-
domainGatewayMapId: deliverySettingsOverride?.domainGatewayMapId ?? '',
|
|
577
|
-
domainId: deliverySettingsOverride?.domainId ?? '',
|
|
578
|
-
};
|
|
579
471
|
return {
|
|
580
472
|
...basePayload,
|
|
581
473
|
emailDeliverySettings: {
|
|
@@ -586,7 +478,12 @@ const CommonTestAndPreview = (props) => {
|
|
|
586
478
|
skipRateLimit: false,
|
|
587
479
|
bypassControlUser: false,
|
|
588
480
|
},
|
|
589
|
-
channelSettings:
|
|
481
|
+
channelSettings: {
|
|
482
|
+
channel: CHANNELS.EMAIL,
|
|
483
|
+
senderLabel: '',
|
|
484
|
+
senderId: '',
|
|
485
|
+
replyToId: '',
|
|
486
|
+
},
|
|
590
487
|
},
|
|
591
488
|
emailMessageContent: {
|
|
592
489
|
channel: CHANNELS.EMAIL,
|
|
@@ -623,12 +520,8 @@ const CommonTestAndPreview = (props) => {
|
|
|
623
520
|
},
|
|
624
521
|
smsDeliverySettings: {
|
|
625
522
|
channelSettings: {
|
|
626
|
-
gsmSenderId:
|
|
627
|
-
domainId:
|
|
628
|
-
domainGatewayMapId: deliverySettingsOverride?.domainGatewayMapId ?? '',
|
|
629
|
-
targetNdnc: false,
|
|
630
|
-
cdmaSenderId: deliverySettingsOverride?.cdmaSenderId ?? '',
|
|
631
|
-
channel: CHANNELS.SMS,
|
|
523
|
+
gsmSenderId: '',
|
|
524
|
+
domainId: null,
|
|
632
525
|
},
|
|
633
526
|
additionalSettings: {
|
|
634
527
|
useTinyUrl: false,
|
|
@@ -764,17 +657,16 @@ const CommonTestAndPreview = (props) => {
|
|
|
764
657
|
templateConfigs.mediaType = formDataObj?.carouselMediaType?.toUpperCase() || MEDIA_TYPE_IMAGE;
|
|
765
658
|
}
|
|
766
659
|
|
|
767
|
-
// Extract delivery settings
|
|
768
|
-
const senderMobNum =
|
|
769
|
-
const domainId =
|
|
770
|
-
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;
|
|
771
663
|
|
|
772
664
|
return {
|
|
773
665
|
...basePayload,
|
|
774
666
|
whatsappMessageContent: {
|
|
775
667
|
messageBody: templateEditorValue || '',
|
|
776
668
|
accountId: formDataObj?.accountId || '',
|
|
777
|
-
sourceAccountIdentifier:
|
|
669
|
+
sourceAccountIdentifier: formDataObj?.sourceAccountIdentifier || '',
|
|
778
670
|
accountName: formDataObj?.accountName || '',
|
|
779
671
|
templateConfigs,
|
|
780
672
|
channel: CHANNELS.WHATSAPP,
|
|
@@ -2478,10 +2370,6 @@ const CommonTestAndPreview = (props) => {
|
|
|
2478
2370
|
});
|
|
2479
2371
|
const uniqueUserIds = [...new Set(allUserIds)];
|
|
2480
2372
|
|
|
2481
|
-
const deliveryOverride = [CHANNELS.SMS, CHANNELS.EMAIL, CHANNELS.WHATSAPP].includes(channel)
|
|
2482
|
-
? testPreviewDeliverySettings[channel]
|
|
2483
|
-
: null;
|
|
2484
|
-
|
|
2485
2373
|
// Create initial payload based on channel
|
|
2486
2374
|
const initialPayload = prepareTestMessagePayload(
|
|
2487
2375
|
channel,
|
|
@@ -2489,8 +2377,7 @@ const CommonTestAndPreview = (props) => {
|
|
|
2489
2377
|
getCurrentContent,
|
|
2490
2378
|
customValues,
|
|
2491
2379
|
uniqueUserIds,
|
|
2492
|
-
previewData
|
|
2493
|
-
deliveryOverride
|
|
2380
|
+
previewData
|
|
2494
2381
|
);
|
|
2495
2382
|
|
|
2496
2383
|
actions.createMessageMetaRequested(
|
|
@@ -2562,13 +2449,6 @@ const CommonTestAndPreview = (props) => {
|
|
|
2562
2449
|
/>
|
|
2563
2450
|
);
|
|
2564
2451
|
|
|
2565
|
-
const handleSaveDeliverySettings = (values) => {
|
|
2566
|
-
setTestPreviewDeliverySettings((prev) => ({
|
|
2567
|
-
...prev,
|
|
2568
|
-
[channel]: values,
|
|
2569
|
-
}));
|
|
2570
|
-
};
|
|
2571
|
-
|
|
2572
2452
|
const renderSendTestMessage = () => (
|
|
2573
2453
|
<SendTestMessage
|
|
2574
2454
|
isFetchingTestCustomers={isFetchingTestCustomers}
|
|
@@ -2577,18 +2457,11 @@ const CommonTestAndPreview = (props) => {
|
|
|
2577
2457
|
handleTestEntitiesChange={handleTestEntitiesChange}
|
|
2578
2458
|
selectedTestEntities={selectedTestEntities}
|
|
2579
2459
|
handleSendTestMessage={handleSendTestMessage}
|
|
2580
|
-
formData={
|
|
2460
|
+
formData={formData}
|
|
2581
2461
|
content={getCurrentContent}
|
|
2582
2462
|
channel={channel}
|
|
2583
2463
|
isSendingTestMessage={isSendingTestMessage}
|
|
2584
2464
|
formatMessage={formatMessage}
|
|
2585
|
-
deliverySettings={testPreviewDeliverySettings[channel]}
|
|
2586
|
-
senderDetailsOptions={senderDetailsByChannel[channel]}
|
|
2587
|
-
wecrmAccounts={wecrmAccounts}
|
|
2588
|
-
onSaveDeliverySettings={handleSaveDeliverySettings}
|
|
2589
|
-
isLoadingSenderDetails={isLoadingSenderDetails}
|
|
2590
|
-
smsTraiDltEnabled={smsTraiDltEnabled}
|
|
2591
|
-
registeredSenderIds={registeredSenderIds}
|
|
2592
2465
|
/>
|
|
2593
2466
|
);
|
|
2594
2467
|
|
|
@@ -2689,10 +2562,6 @@ CommonTestAndPreview.propTypes = {
|
|
|
2689
2562
|
})),
|
|
2690
2563
|
isSendingTestMessage: PropTypes.bool.isRequired,
|
|
2691
2564
|
intl: PropTypes.object.isRequired,
|
|
2692
|
-
senderDetailsByChannel: PropTypes.object,
|
|
2693
|
-
wecrmAccounts: PropTypes.array,
|
|
2694
|
-
isLoadingSenderDetails: PropTypes.bool,
|
|
2695
|
-
orgUnitId: PropTypes.number,
|
|
2696
2565
|
|
|
2697
2566
|
// Email-specific props
|
|
2698
2567
|
beeInstance: PropTypes.object,
|
|
@@ -2728,10 +2597,6 @@ CommonTestAndPreview.defaultProps = {
|
|
|
2728
2597
|
rcsOrientation: null,
|
|
2729
2598
|
rcsIosPreview: false,
|
|
2730
2599
|
templateLayoutType: null,
|
|
2731
|
-
senderDetailsByChannel: {},
|
|
2732
|
-
wecrmAccounts: [],
|
|
2733
|
-
isLoadingSenderDetails: false,
|
|
2734
|
-
orgUnitId: -1,
|
|
2735
2600
|
};
|
|
2736
2601
|
|
|
2737
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,16 +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
|
-
CHANNELS,
|
|
46
39
|
} from './constants';
|
|
47
|
-
import { parseSenderDetailsResponse } from './DeliverySettings/utils/parseSenderDetailsResponse';
|
|
48
40
|
|
|
49
41
|
// Search Customers Saga
|
|
50
42
|
export function* searchCustomersSaga(action) {
|
|
@@ -293,57 +285,6 @@ export function* watchGetPrefilledValues() {
|
|
|
293
285
|
yield takeLatest(GET_PREFILLED_VALUES_REQUESTED, getPrefilledValuesSaga);
|
|
294
286
|
}
|
|
295
287
|
|
|
296
|
-
export function* getSenderDetailsSaga(action) {
|
|
297
|
-
const { channel, orgUnitId } = action.payload || {};
|
|
298
|
-
if (!channel) return;
|
|
299
|
-
try {
|
|
300
|
-
const response = yield call(Api.getSenderDetails, channel, orgUnitId ?? -1);
|
|
301
|
-
if (response?.errors?.length) {
|
|
302
|
-
yield put({
|
|
303
|
-
type: GET_SENDER_DETAILS_FAILURE,
|
|
304
|
-
payload: { channel, error: response.errors },
|
|
305
|
-
});
|
|
306
|
-
return;
|
|
307
|
-
}
|
|
308
|
-
const parsed = parseSenderDetailsResponse(channel, response);
|
|
309
|
-
yield put({
|
|
310
|
-
type: GET_SENDER_DETAILS_SUCCESS,
|
|
311
|
-
payload: { channel, domains: parsed.domains || [] },
|
|
312
|
-
});
|
|
313
|
-
} catch (error) {
|
|
314
|
-
yield put({
|
|
315
|
-
type: GET_SENDER_DETAILS_FAILURE,
|
|
316
|
-
payload: { channel, error: error.message || error },
|
|
317
|
-
});
|
|
318
|
-
}
|
|
319
|
-
}
|
|
320
|
-
|
|
321
|
-
export function* getWeCrmAccountsSaga(action) {
|
|
322
|
-
const { sourceName } = action.payload || {};
|
|
323
|
-
try {
|
|
324
|
-
const result = yield call(Api.fetchWeCrmAccounts, sourceName || CHANNELS.WHATSAPP);
|
|
325
|
-
const accounts = get(result, 'response') || get(result, 'entity') || (result?.success ? result.response : null) || [];
|
|
326
|
-
const list = Array.isArray(accounts) ? accounts : (accounts && accounts.data) || [];
|
|
327
|
-
yield put({
|
|
328
|
-
type: GET_WECRM_ACCOUNTS_SUCCESS,
|
|
329
|
-
payload: { accounts: list },
|
|
330
|
-
});
|
|
331
|
-
} catch (error) {
|
|
332
|
-
yield put({
|
|
333
|
-
type: GET_WECRM_ACCOUNTS_FAILURE,
|
|
334
|
-
payload: { error: error.message || error },
|
|
335
|
-
});
|
|
336
|
-
}
|
|
337
|
-
}
|
|
338
|
-
|
|
339
|
-
export function* watchGetSenderDetails() {
|
|
340
|
-
yield takeLatest(GET_SENDER_DETAILS_REQUESTED, getSenderDetailsSaga);
|
|
341
|
-
}
|
|
342
|
-
|
|
343
|
-
export function* watchGetWeCrmAccounts() {
|
|
344
|
-
yield takeLatest(GET_WECRM_ACCOUNTS_REQUESTED, getWeCrmAccountsSaga);
|
|
345
|
-
}
|
|
346
|
-
|
|
347
288
|
// Root saga
|
|
348
289
|
export function* commonTestAndPreviewSaga() {
|
|
349
290
|
yield all([
|
|
@@ -355,7 +296,5 @@ export function* commonTestAndPreviewSaga() {
|
|
|
355
296
|
watchFetchTestGroups(),
|
|
356
297
|
watchCreateMessageMeta(),
|
|
357
298
|
watchGetPrefilledValues(),
|
|
358
|
-
watchGetSenderDetails(),
|
|
359
|
-
watchGetWeCrmAccounts(),
|
|
360
299
|
]);
|
|
361
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
|
};
|