@capillarytech/creatives-library 8.0.291 → 8.0.292
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/DeliverySettings.scss +33 -0
- package/v2Components/CommonTestAndPreview/DeliverySettings/ModifyDeliverySettings.js +422 -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 +251 -0
- package/v2Components/CommonTestAndPreview/DeliverySettings/messages.js +111 -0
- package/v2Components/CommonTestAndPreview/DeliverySettings/utils/parseSenderDetailsResponse.js +91 -0
- package/v2Components/CommonTestAndPreview/SendTestMessage.js +51 -1
- package/v2Components/CommonTestAndPreview/actions.js +20 -0
- package/v2Components/CommonTestAndPreview/constants.js +10 -0
- package/v2Components/CommonTestAndPreview/index.js +148 -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 +889 -0
- package/v2Components/CommonTestAndPreview/tests/DeliverySettings/index.test.js +222 -0
- package/v2Components/CommonTestAndPreview/tests/DeliverySettings/utils/parseSenderDetailsResponse.test.js +235 -0
- package/v2Components/CommonTestAndPreview/tests/SendTestMessage.test.js +135 -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 +342 -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/TestAndPreviewSlidebox/index.js +14 -0
- package/v2Containers/CreativesContainer/index.js +0 -8
- package/v2Containers/Rcs/tests/__snapshots__/index.test.js.snap +697 -12
- package/v2Containers/SmsTrai/Edit/index.js +5 -1
- package/v2Containers/SmsTrai/Edit/tests/__snapshots__/index.test.js.snap +201 -0
- package/v2Containers/Whatsapp/index.js +1 -1
- package/v2Containers/Whatsapp/tests/__snapshots__/index.test.js.snap +26242 -4225
|
@@ -0,0 +1,92 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* DeliverySettings constants for Test and Preview (SMS, Email, WhatsApp).
|
|
3
|
+
* Aligned with cap-campaigns-v2 DeliverySettingsV2/ModifyDeliverySettings field names.
|
|
4
|
+
*/
|
|
5
|
+
|
|
6
|
+
import { CHANNELS } from '../constants';
|
|
7
|
+
|
|
8
|
+
/** Fallback label when no dropdown options (used when formatMessage unavailable) */
|
|
9
|
+
export const NO_OPTIONS_LABEL = 'No options';
|
|
10
|
+
|
|
11
|
+
/** Fallback label when delivery settings are not configured (used when formatMessage unavailable) */
|
|
12
|
+
export const NOT_CONFIGURED_LABEL = 'Not configured';
|
|
13
|
+
|
|
14
|
+
/** Placeholder shown in summary when a value is empty */
|
|
15
|
+
export const SUMMARY_EMPTY_PLACEHOLDER = '—';
|
|
16
|
+
|
|
17
|
+
/** CapHeading type for delivery settings section title */
|
|
18
|
+
export const HEADING_TYPE_H10 = 'h10';
|
|
19
|
+
|
|
20
|
+
/** CapRow type for flex layout */
|
|
21
|
+
export const ROW_TYPE_FLEX = 'flex';
|
|
22
|
+
|
|
23
|
+
/** Channel names — use CHANNELS.SMS, CHANNELS.EMAIL, CHANNELS.WHATSAPP from parent constants */
|
|
24
|
+
export { CHANNELS } from '../constants';
|
|
25
|
+
|
|
26
|
+
/** Delivery settings object keys (for get(deliverySettings, key) / updateSetting(key, value)) */
|
|
27
|
+
export const DELIVERY_SETTING_KEY_DOMAIN_ID = 'domainId';
|
|
28
|
+
export const DELIVERY_SETTING_KEY_DOMAIN_GATEWAY_MAP_ID = 'domainGatewayMapId';
|
|
29
|
+
export const DELIVERY_SETTING_KEY_GSM_SENDER_ID = 'gsmSenderId';
|
|
30
|
+
export const DELIVERY_SETTING_KEY_CDMA_SENDER_ID = 'cdmaSenderId';
|
|
31
|
+
export const DELIVERY_SETTING_KEY_SENDER_EMAIL = 'senderEmail';
|
|
32
|
+
export const DELIVERY_SETTING_KEY_SENDER_LABEL = 'senderLabel';
|
|
33
|
+
export const DELIVERY_SETTING_KEY_SENDER_REPLY_TO = 'senderReplyTo';
|
|
34
|
+
export const DELIVERY_SETTING_KEY_SOURCE_ACCOUNT_IDENTIFIER = 'sourceAccountIdentifier';
|
|
35
|
+
export const DELIVERY_SETTING_KEY_SENDER_MOB_NUM = 'senderMobNum';
|
|
36
|
+
|
|
37
|
+
/** CapLabel type props */
|
|
38
|
+
export const LABEL_TYPE_LABEL1 = 'label1';
|
|
39
|
+
export const LABEL_TYPE_LABEL2 = 'label2';
|
|
40
|
+
export const LABEL_TYPE_LABEL9 = 'label9';
|
|
41
|
+
|
|
42
|
+
/** CapIcon type for edit action */
|
|
43
|
+
export const ICON_TYPE_EDIT = 'edit';
|
|
44
|
+
|
|
45
|
+
/** CapSlideBox size prop */
|
|
46
|
+
export const SLIDE_BOX_SIZE_L = 'size-l';
|
|
47
|
+
|
|
48
|
+
/** data-testid for delivery settings edit icon */
|
|
49
|
+
export const TEST_ID_DELIVERY_SETTINGS_EDIT = 'delivery-settings-edit';
|
|
50
|
+
|
|
51
|
+
/** CapHeader size prop for form labels */
|
|
52
|
+
export const HEADER_SIZE_LABEL = 'label';
|
|
53
|
+
|
|
54
|
+
/** CapButton type for primary action */
|
|
55
|
+
export const BUTTON_TYPE_PRIMARY = 'primary';
|
|
56
|
+
|
|
57
|
+
/** Prefix for row keys in field list map */
|
|
58
|
+
export const ROW_KEY_PREFIX = 'row-';
|
|
59
|
+
|
|
60
|
+
export const CHANNELS_WITH_DELIVERY_SETTINGS = [
|
|
61
|
+
CHANNELS.SMS,
|
|
62
|
+
CHANNELS.EMAIL,
|
|
63
|
+
CHANNELS.WHATSAPP,
|
|
64
|
+
];
|
|
65
|
+
|
|
66
|
+
/** Default empty delivery setting per channel (campaigns-style shape) */
|
|
67
|
+
export const DEFAULT_DELIVERY_SETTING_SMS = {
|
|
68
|
+
domainId: null,
|
|
69
|
+
domainGatewayMapId: null,
|
|
70
|
+
gsmSenderId: '',
|
|
71
|
+
cdmaSenderId: '',
|
|
72
|
+
};
|
|
73
|
+
|
|
74
|
+
export const DEFAULT_DELIVERY_SETTING_EMAIL = {
|
|
75
|
+
domainId: null,
|
|
76
|
+
domainGatewayMapId: null,
|
|
77
|
+
senderEmail: '',
|
|
78
|
+
senderLabel: '',
|
|
79
|
+
senderReplyTo: '',
|
|
80
|
+
};
|
|
81
|
+
|
|
82
|
+
export const DEFAULT_DELIVERY_SETTING_WHATSAPP = {
|
|
83
|
+
domainId: null,
|
|
84
|
+
senderMobNum: '',
|
|
85
|
+
sourceAccountIdentifier: '',
|
|
86
|
+
};
|
|
87
|
+
|
|
88
|
+
export const DEFAULT_DELIVERY_SETTINGS_BY_CHANNEL = {
|
|
89
|
+
[CHANNELS.SMS]: DEFAULT_DELIVERY_SETTING_SMS,
|
|
90
|
+
[CHANNELS.EMAIL]: DEFAULT_DELIVERY_SETTING_EMAIL,
|
|
91
|
+
[CHANNELS.WHATSAPP]: DEFAULT_DELIVERY_SETTING_WHATSAPP,
|
|
92
|
+
};
|
|
@@ -0,0 +1,251 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* DeliverySettings — summary row + CapSlideBox trigger for Test and Preview.
|
|
3
|
+
* Rendered only for SMS, Email, WhatsApp. Uses cap-ui-library only.
|
|
4
|
+
*
|
|
5
|
+
* Reference: cap-campaigns-v2 DeliverySettingsV2 (summary + modify panel).
|
|
6
|
+
*/
|
|
7
|
+
|
|
8
|
+
import React, { useState, useCallback } from "react";
|
|
9
|
+
import PropTypes from "prop-types";
|
|
10
|
+
import {
|
|
11
|
+
CapRow,
|
|
12
|
+
CapHeading,
|
|
13
|
+
CapIcon,
|
|
14
|
+
CapLabel,
|
|
15
|
+
CapSlideBox,
|
|
16
|
+
} from "@capillarytech/cap-ui-library";
|
|
17
|
+
import { FormattedMessage } from "react-intl";
|
|
18
|
+
import get from "lodash/get";
|
|
19
|
+
import messages from "./messages";
|
|
20
|
+
import ModifyDeliverySettings from "./ModifyDeliverySettings";
|
|
21
|
+
import {
|
|
22
|
+
CHANNELS,
|
|
23
|
+
CHANNELS_WITH_DELIVERY_SETTINGS,
|
|
24
|
+
NOT_CONFIGURED_LABEL,
|
|
25
|
+
SUMMARY_EMPTY_PLACEHOLDER,
|
|
26
|
+
HEADING_TYPE_H10,
|
|
27
|
+
ROW_TYPE_FLEX,
|
|
28
|
+
DELIVERY_SETTING_KEY_DOMAIN_ID,
|
|
29
|
+
DELIVERY_SETTING_KEY_GSM_SENDER_ID,
|
|
30
|
+
DELIVERY_SETTING_KEY_SENDER_EMAIL,
|
|
31
|
+
DELIVERY_SETTING_KEY_SENDER_LABEL,
|
|
32
|
+
DELIVERY_SETTING_KEY_SENDER_REPLY_TO,
|
|
33
|
+
DELIVERY_SETTING_KEY_SOURCE_ACCOUNT_IDENTIFIER,
|
|
34
|
+
DELIVERY_SETTING_KEY_SENDER_MOB_NUM,
|
|
35
|
+
LABEL_TYPE_LABEL1,
|
|
36
|
+
LABEL_TYPE_LABEL2,
|
|
37
|
+
LABEL_TYPE_LABEL9,
|
|
38
|
+
ICON_TYPE_EDIT,
|
|
39
|
+
SLIDE_BOX_SIZE_L,
|
|
40
|
+
TEST_ID_DELIVERY_SETTINGS_EDIT,
|
|
41
|
+
} from "./constants";
|
|
42
|
+
import "./DeliverySettings.scss";
|
|
43
|
+
|
|
44
|
+
const DeliverySettings = (props) => {
|
|
45
|
+
const {
|
|
46
|
+
channel,
|
|
47
|
+
deliverySettings = {},
|
|
48
|
+
senderDetailsOptions = [],
|
|
49
|
+
wecrmAccounts = [],
|
|
50
|
+
onSaveDeliverySettings,
|
|
51
|
+
isLoadingSenderDetails,
|
|
52
|
+
formatMessage,
|
|
53
|
+
smsTraiDltEnabled,
|
|
54
|
+
registeredSenderIds,
|
|
55
|
+
whatsappAccountFromForm,
|
|
56
|
+
} = props;
|
|
57
|
+
|
|
58
|
+
const [isSlideBoxOpen, setSlideBoxOpen] = useState(false);
|
|
59
|
+
|
|
60
|
+
const openSlideBox = useCallback(() => setSlideBoxOpen(true), []);
|
|
61
|
+
const closeSlideBox = useCallback(() => setSlideBoxOpen(false), []);
|
|
62
|
+
|
|
63
|
+
const handleSave = useCallback(
|
|
64
|
+
(values) => {
|
|
65
|
+
onSaveDeliverySettings(values);
|
|
66
|
+
closeSlideBox();
|
|
67
|
+
},
|
|
68
|
+
[onSaveDeliverySettings, closeSlideBox]
|
|
69
|
+
);
|
|
70
|
+
|
|
71
|
+
if (!CHANNELS_WITH_DELIVERY_SETTINGS.includes(channel)) {
|
|
72
|
+
return null;
|
|
73
|
+
}
|
|
74
|
+
|
|
75
|
+
const notConfiguredLabel = formatMessage
|
|
76
|
+
? formatMessage(messages.notConfigured)
|
|
77
|
+
: NOT_CONFIGURED_LABEL;
|
|
78
|
+
|
|
79
|
+
const getSummaryText = () => {
|
|
80
|
+
const empty = SUMMARY_EMPTY_PLACEHOLDER;
|
|
81
|
+
if (channel === CHANNELS.SMS) {
|
|
82
|
+
const domain = (senderDetailsOptions || []).find(
|
|
83
|
+
(d) => d.domainId === get(deliverySettings, DELIVERY_SETTING_KEY_DOMAIN_ID),
|
|
84
|
+
);
|
|
85
|
+
const domainName = domain?.domainName || empty;
|
|
86
|
+
const senderId = get(deliverySettings, DELIVERY_SETTING_KEY_GSM_SENDER_ID) || empty;
|
|
87
|
+
return { senderDomain: domainName, senderId };
|
|
88
|
+
}
|
|
89
|
+
if (channel === CHANNELS.EMAIL) {
|
|
90
|
+
const domain = (senderDetailsOptions || []).find(
|
|
91
|
+
(d) => d.domainId === get(deliverySettings, DELIVERY_SETTING_KEY_DOMAIN_ID),
|
|
92
|
+
);
|
|
93
|
+
const emailDomain = domain?.domainName || empty;
|
|
94
|
+
const senderEmail = get(deliverySettings, DELIVERY_SETTING_KEY_SENDER_EMAIL) || empty;
|
|
95
|
+
const senderLabel = get(deliverySettings, DELIVERY_SETTING_KEY_SENDER_LABEL) || empty;
|
|
96
|
+
const replyToId = get(deliverySettings, DELIVERY_SETTING_KEY_SENDER_REPLY_TO) || empty;
|
|
97
|
+
return {
|
|
98
|
+
emailDomain,
|
|
99
|
+
senderEmail,
|
|
100
|
+
senderLabel,
|
|
101
|
+
replyToId,
|
|
102
|
+
};
|
|
103
|
+
}
|
|
104
|
+
if (channel === CHANNELS.WHATSAPP) {
|
|
105
|
+
const account = (wecrmAccounts || []).find(
|
|
106
|
+
(a) => a.sourceAccountIdentifier
|
|
107
|
+
=== get(deliverySettings, DELIVERY_SETTING_KEY_SOURCE_ACCOUNT_IDENTIFIER),
|
|
108
|
+
);
|
|
109
|
+
const accountName = account?.name || empty;
|
|
110
|
+
const senderNumber = get(deliverySettings, DELIVERY_SETTING_KEY_SENDER_MOB_NUM) || empty;
|
|
111
|
+
return { account: accountName, senderNumber };
|
|
112
|
+
}
|
|
113
|
+
return { account: empty, sender: empty };
|
|
114
|
+
};
|
|
115
|
+
|
|
116
|
+
const summary = getSummaryText();
|
|
117
|
+
let hasValues = false;
|
|
118
|
+
if (channel === CHANNELS.SMS) {
|
|
119
|
+
hasValues = summary.senderDomain !== SUMMARY_EMPTY_PLACEHOLDER
|
|
120
|
+
|| summary.senderId !== SUMMARY_EMPTY_PLACEHOLDER;
|
|
121
|
+
} else if (channel === CHANNELS.EMAIL) {
|
|
122
|
+
hasValues = summary.emailDomain !== SUMMARY_EMPTY_PLACEHOLDER
|
|
123
|
+
|| summary.senderEmail !== SUMMARY_EMPTY_PLACEHOLDER
|
|
124
|
+
|| summary.senderLabel !== SUMMARY_EMPTY_PLACEHOLDER
|
|
125
|
+
|| summary.replyToId !== SUMMARY_EMPTY_PLACEHOLDER;
|
|
126
|
+
} else if (channel === CHANNELS.WHATSAPP) {
|
|
127
|
+
hasValues = summary.account !== SUMMARY_EMPTY_PLACEHOLDER
|
|
128
|
+
|| summary.senderNumber !== SUMMARY_EMPTY_PLACEHOLDER;
|
|
129
|
+
} else {
|
|
130
|
+
hasValues = summary.account !== SUMMARY_EMPTY_PLACEHOLDER
|
|
131
|
+
|| summary.sender !== SUMMARY_EMPTY_PLACEHOLDER;
|
|
132
|
+
}
|
|
133
|
+
|
|
134
|
+
const getSummaryObject = () => {
|
|
135
|
+
if (!hasValues) return null;
|
|
136
|
+
const label = (msg) => formatMessage ? formatMessage(msg) : msg.defaultMessage;
|
|
137
|
+
if (channel === CHANNELS.SMS) {
|
|
138
|
+
return {
|
|
139
|
+
[label(messages.senderDomainSummary)]: summary.senderDomain,
|
|
140
|
+
[label(messages.senderId)]: summary.senderId,
|
|
141
|
+
};
|
|
142
|
+
}
|
|
143
|
+
if (channel === CHANNELS.EMAIL) {
|
|
144
|
+
return {
|
|
145
|
+
[label(messages.emailDomain)]: summary.emailDomain,
|
|
146
|
+
[label(messages.senderId)]: summary.senderEmail,
|
|
147
|
+
[label(messages.senderName)]: summary.senderLabel,
|
|
148
|
+
[label(messages.replyToId)]: summary.replyToId,
|
|
149
|
+
};
|
|
150
|
+
}
|
|
151
|
+
if (channel === CHANNELS.WHATSAPP) {
|
|
152
|
+
return {
|
|
153
|
+
[label(messages.account)]: summary.account,
|
|
154
|
+
[label(messages.senderNumber)]: summary.senderNumber,
|
|
155
|
+
};
|
|
156
|
+
}
|
|
157
|
+
return {
|
|
158
|
+
[label(messages.account)]: summary.account,
|
|
159
|
+
[label(messages.senderNumber)]: summary.sender,
|
|
160
|
+
};
|
|
161
|
+
};
|
|
162
|
+
|
|
163
|
+
const summaryObject = getSummaryObject();
|
|
164
|
+
|
|
165
|
+
return (
|
|
166
|
+
<div className="delivery-settings">
|
|
167
|
+
<CapRow className="delivery-settings__heading-row">
|
|
168
|
+
<CapHeading type={HEADING_TYPE_H10}>
|
|
169
|
+
<FormattedMessage {...messages.deliverySettings} />
|
|
170
|
+
</CapHeading>
|
|
171
|
+
</CapRow>
|
|
172
|
+
<CapRow type={ROW_TYPE_FLEX} className="delivery-settings__summary-row">
|
|
173
|
+
<CapRow type={ROW_TYPE_FLEX} className="delivery-settings__summary-inner">
|
|
174
|
+
{summaryObject == null ? (
|
|
175
|
+
<CapLabel type={LABEL_TYPE_LABEL2}>{notConfiguredLabel}</CapLabel>
|
|
176
|
+
) : (
|
|
177
|
+
Object.entries(summaryObject).map(([key, value]) => (
|
|
178
|
+
<CapRow type={ROW_TYPE_FLEX} key={key} className="delivery-settings__summary-entry">
|
|
179
|
+
<CapLabel type={LABEL_TYPE_LABEL1} className="delivery-settings__summary-key">{key}</CapLabel>
|
|
180
|
+
<CapLabel type={LABEL_TYPE_LABEL9}>
|
|
181
|
+
:
|
|
182
|
+
{' '}
|
|
183
|
+
{value}
|
|
184
|
+
</CapLabel>
|
|
185
|
+
</CapRow>
|
|
186
|
+
))
|
|
187
|
+
)}
|
|
188
|
+
</CapRow>
|
|
189
|
+
<CapIcon
|
|
190
|
+
type={ICON_TYPE_EDIT}
|
|
191
|
+
onClick={openSlideBox}
|
|
192
|
+
className="delivery-settings__edit-icon"
|
|
193
|
+
data-testid={TEST_ID_DELIVERY_SETTINGS_EDIT}
|
|
194
|
+
size="s"
|
|
195
|
+
/>
|
|
196
|
+
</CapRow>
|
|
197
|
+
|
|
198
|
+
{isSlideBoxOpen && (
|
|
199
|
+
<CapSlideBox
|
|
200
|
+
show
|
|
201
|
+
size={SLIDE_BOX_SIZE_L}
|
|
202
|
+
header={<FormattedMessage {...messages.deliverySettings} />}
|
|
203
|
+
handleClose={closeSlideBox}
|
|
204
|
+
content={(
|
|
205
|
+
<ModifyDeliverySettings
|
|
206
|
+
channel={channel}
|
|
207
|
+
deliverySettings={deliverySettings}
|
|
208
|
+
senderDetailsOptions={senderDetailsOptions}
|
|
209
|
+
wecrmAccounts={wecrmAccounts}
|
|
210
|
+
onSaveDeliverySettings={handleSave}
|
|
211
|
+
onClose={closeSlideBox}
|
|
212
|
+
isLoading={isLoadingSenderDetails}
|
|
213
|
+
formatMessage={formatMessage}
|
|
214
|
+
smsTraiDltEnabled={smsTraiDltEnabled}
|
|
215
|
+
registeredSenderIds={registeredSenderIds}
|
|
216
|
+
whatsappAccountFromForm={whatsappAccountFromForm}
|
|
217
|
+
/>
|
|
218
|
+
)}
|
|
219
|
+
/>
|
|
220
|
+
)}
|
|
221
|
+
</div>
|
|
222
|
+
);
|
|
223
|
+
};
|
|
224
|
+
|
|
225
|
+
DeliverySettings.propTypes = {
|
|
226
|
+
channel: PropTypes.string.isRequired,
|
|
227
|
+
deliverySettings: PropTypes.object,
|
|
228
|
+
senderDetailsOptions: PropTypes.array,
|
|
229
|
+
wecrmAccounts: PropTypes.array,
|
|
230
|
+
onSaveDeliverySettings: PropTypes.func.isRequired,
|
|
231
|
+
isLoadingSenderDetails: PropTypes.bool,
|
|
232
|
+
formatMessage: PropTypes.func,
|
|
233
|
+
smsTraiDltEnabled: PropTypes.bool,
|
|
234
|
+
registeredSenderIds: PropTypes.array,
|
|
235
|
+
whatsappAccountFromForm: PropTypes.shape({
|
|
236
|
+
accountName: PropTypes.string,
|
|
237
|
+
}),
|
|
238
|
+
};
|
|
239
|
+
|
|
240
|
+
DeliverySettings.defaultProps = {
|
|
241
|
+
deliverySettings: {},
|
|
242
|
+
senderDetailsOptions: [],
|
|
243
|
+
wecrmAccounts: [],
|
|
244
|
+
isLoadingSenderDetails: false,
|
|
245
|
+
formatMessage: undefined,
|
|
246
|
+
smsTraiDltEnabled: false,
|
|
247
|
+
registeredSenderIds: [],
|
|
248
|
+
whatsappAccountFromForm: undefined,
|
|
249
|
+
};
|
|
250
|
+
|
|
251
|
+
export default DeliverySettings;
|
|
@@ -0,0 +1,111 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* DeliverySettings messages for Test and Preview.
|
|
3
|
+
* Aligned with cap-campaigns-v2 DeliverySettingsV2 and ModifyDeliverySettings messages.
|
|
4
|
+
*/
|
|
5
|
+
|
|
6
|
+
import { defineMessages } from 'react-intl';
|
|
7
|
+
|
|
8
|
+
const prefix = 'creatives.CommonTestAndPreview.DeliverySettings';
|
|
9
|
+
|
|
10
|
+
export default defineMessages({
|
|
11
|
+
deliverySettings: {
|
|
12
|
+
id: `${prefix}.deliverySettings`,
|
|
13
|
+
defaultMessage: 'Delivery settings',
|
|
14
|
+
},
|
|
15
|
+
notConfigured: {
|
|
16
|
+
id: `${prefix}.notConfigured`,
|
|
17
|
+
defaultMessage: 'Not configured',
|
|
18
|
+
},
|
|
19
|
+
account: {
|
|
20
|
+
id: `${prefix}.account`,
|
|
21
|
+
defaultMessage: 'Account',
|
|
22
|
+
},
|
|
23
|
+
senderNumber: {
|
|
24
|
+
id: `${prefix}.senderNumber`,
|
|
25
|
+
defaultMessage: 'Sender number',
|
|
26
|
+
},
|
|
27
|
+
senderDomain: {
|
|
28
|
+
id: `${prefix}.senderDomain`,
|
|
29
|
+
defaultMessage: 'Sender domain',
|
|
30
|
+
},
|
|
31
|
+
senderId: {
|
|
32
|
+
id: `${prefix}.senderId`,
|
|
33
|
+
defaultMessage: 'Sender ID',
|
|
34
|
+
},
|
|
35
|
+
senderName: {
|
|
36
|
+
id: `${prefix}.senderName`,
|
|
37
|
+
defaultMessage: 'Sender name',
|
|
38
|
+
},
|
|
39
|
+
replyToId: {
|
|
40
|
+
id: `${prefix}.replyToId`,
|
|
41
|
+
defaultMessage: 'Reply-to ID',
|
|
42
|
+
},
|
|
43
|
+
done: {
|
|
44
|
+
id: `${prefix}.done`,
|
|
45
|
+
defaultMessage: 'Done',
|
|
46
|
+
},
|
|
47
|
+
smsDomain: {
|
|
48
|
+
id: `${prefix}.smsDomain`,
|
|
49
|
+
defaultMessage: 'SMS Domain',
|
|
50
|
+
},
|
|
51
|
+
/** SMS summary & form: "Sender Domain" (capital D) for summary line */
|
|
52
|
+
senderDomainSummary: {
|
|
53
|
+
id: `${prefix}.senderDomainSummary`,
|
|
54
|
+
defaultMessage: 'Sender Domain',
|
|
55
|
+
},
|
|
56
|
+
/** SMS form label with colon: "Sender domain:" */
|
|
57
|
+
senderDomainLabel: {
|
|
58
|
+
id: `${prefix}.senderDomainLabel`,
|
|
59
|
+
defaultMessage: 'Sender domain:',
|
|
60
|
+
},
|
|
61
|
+
/** SMS form label with colon: "Sender ID:" */
|
|
62
|
+
senderIdLabel: {
|
|
63
|
+
id: `${prefix}.senderIdLabel`,
|
|
64
|
+
defaultMessage: 'Sender ID:',
|
|
65
|
+
},
|
|
66
|
+
emailDomain: {
|
|
67
|
+
id: `${prefix}.emailDomain`,
|
|
68
|
+
defaultMessage: 'Email Domain',
|
|
69
|
+
},
|
|
70
|
+
/** Email form/summary: "Email domain:" (with colon) */
|
|
71
|
+
emailDomainLabel: {
|
|
72
|
+
id: `${prefix}.emailDomainLabel`,
|
|
73
|
+
defaultMessage: 'Email domain:',
|
|
74
|
+
},
|
|
75
|
+
/** Email form: "Sender ID:" (with colon) */
|
|
76
|
+
senderNameLabelEmail: {
|
|
77
|
+
id: `${prefix}.senderIdLabelEmail`,
|
|
78
|
+
defaultMessage: 'Sender Name:',
|
|
79
|
+
},
|
|
80
|
+
/** Email form/summary: "Reply-to ID:" (with colon) */
|
|
81
|
+
replyToIdLabel: {
|
|
82
|
+
id: `${prefix}.replyToIdLabel`,
|
|
83
|
+
defaultMessage: 'Reply-to ID:',
|
|
84
|
+
},
|
|
85
|
+
whatsappBusinessAcc: {
|
|
86
|
+
id: `${prefix}.whatsappBusinessAcc`,
|
|
87
|
+
defaultMessage: 'WhatsApp business account',
|
|
88
|
+
},
|
|
89
|
+
whatsappSenderNum: {
|
|
90
|
+
id: `${prefix}.whatsappSenderNum`,
|
|
91
|
+
defaultMessage: 'WhatsApp sender number',
|
|
92
|
+
},
|
|
93
|
+
/** WhatsApp form/summary: "Account:" (with colon) */
|
|
94
|
+
accountLabel: {
|
|
95
|
+
id: `${prefix}.accountLabel`,
|
|
96
|
+
defaultMessage: 'Account:',
|
|
97
|
+
},
|
|
98
|
+
/** WhatsApp form/summary: "Sender number:" (with colon) */
|
|
99
|
+
senderNumberLabel: {
|
|
100
|
+
id: `${prefix}.senderNumberLabel`,
|
|
101
|
+
defaultMessage: 'Sender number:',
|
|
102
|
+
},
|
|
103
|
+
noOptions: {
|
|
104
|
+
id: `${prefix}.noOptions`,
|
|
105
|
+
defaultMessage: 'No options',
|
|
106
|
+
},
|
|
107
|
+
disabledMessage: {
|
|
108
|
+
id: `${prefix}.disabledMessage`,
|
|
109
|
+
defaultMessage: 'Message template selected belongs to this account',
|
|
110
|
+
},
|
|
111
|
+
});
|
package/v2Components/CommonTestAndPreview/DeliverySettings/utils/parseSenderDetailsResponse.js
ADDED
|
@@ -0,0 +1,91 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Normalize getSenderDetails(channel, orgUnitId) API response for a single channel.
|
|
3
|
+
* Output shape matches cap-campaigns-v2 parseSenderDetails so UI can consume
|
|
4
|
+
* domains with domainId, domainName, gsmSenders, emailSenders, emailRepliers, etc.
|
|
5
|
+
*
|
|
6
|
+
* Reference: cap-campaigns-v2 app/utils/parseSenderDetails.js
|
|
7
|
+
* No cross-repo imports; logic aligned with campaigns domain structure.
|
|
8
|
+
*/
|
|
9
|
+
|
|
10
|
+
import { get } from 'lodash';
|
|
11
|
+
|
|
12
|
+
const SMS = 'SMS';
|
|
13
|
+
const EMAIL = 'EMAIL';
|
|
14
|
+
const WHATSAPP = 'WHATSAPP';
|
|
15
|
+
|
|
16
|
+
const getSenderOptions = (contactInfo, key) =>
|
|
17
|
+
(contactInfo || [])
|
|
18
|
+
.filter((c) => c.type === key && c.valid)
|
|
19
|
+
.sort((a) => (a.default ? -1 : 0));
|
|
20
|
+
|
|
21
|
+
/**
|
|
22
|
+
* Parse raw API response for one channel into { domains: [...] }
|
|
23
|
+
* @param {string} channel - SMS | EMAIL | WHATSAPP
|
|
24
|
+
* @param {Object} response - API response (e.g. { entity: { SMS: [...] } } or { entity: [...] })
|
|
25
|
+
* @returns {{ domains: Array }} - domains array compatible with campaigns DeliverySettingsV2
|
|
26
|
+
*/
|
|
27
|
+
export function parseSenderDetailsResponse(channel, response) {
|
|
28
|
+
const entity = get(response, 'entity', response);
|
|
29
|
+
if (!entity) {
|
|
30
|
+
return { domains: [] };
|
|
31
|
+
}
|
|
32
|
+
|
|
33
|
+
// Single-channel API: entity may be { [channel]: [...] } or direct array
|
|
34
|
+
let channelSenderDetails = get(entity, channel, null);
|
|
35
|
+
if (channelSenderDetails == null && Array.isArray(entity)) {
|
|
36
|
+
channelSenderDetails = entity;
|
|
37
|
+
}
|
|
38
|
+
if (!Array.isArray(channelSenderDetails)) {
|
|
39
|
+
return { domains: [] };
|
|
40
|
+
}
|
|
41
|
+
|
|
42
|
+
const domains = [];
|
|
43
|
+
|
|
44
|
+
channelSenderDetails.forEach((element) => {
|
|
45
|
+
const { id: dgmId, priority, domainProperties = {} } = element;
|
|
46
|
+
const {
|
|
47
|
+
domainName,
|
|
48
|
+
id = -1,
|
|
49
|
+
contactInfo,
|
|
50
|
+
connectionProperties: {
|
|
51
|
+
sourceAccountIdentifier = '',
|
|
52
|
+
wabaId = '',
|
|
53
|
+
userid = '',
|
|
54
|
+
} = {},
|
|
55
|
+
} = domainProperties;
|
|
56
|
+
|
|
57
|
+
const domain = {
|
|
58
|
+
dgmId,
|
|
59
|
+
domainName,
|
|
60
|
+
domainId: id,
|
|
61
|
+
priority: priority != null ? priority : 0,
|
|
62
|
+
};
|
|
63
|
+
|
|
64
|
+
if ([SMS, WHATSAPP].includes(channel)) {
|
|
65
|
+
domain.cdmaSenders = getSenderOptions(contactInfo, 'cdma_sender_id');
|
|
66
|
+
domain.gsmSenders = getSenderOptions(contactInfo, 'gsm_sender_id');
|
|
67
|
+
domain.sourceAccountIdentifier =
|
|
68
|
+
sourceAccountIdentifier || wabaId || userid || '';
|
|
69
|
+
}
|
|
70
|
+
|
|
71
|
+
if (channel === EMAIL) {
|
|
72
|
+
domain.emailSenders = getSenderOptions(contactInfo, 'sender_id');
|
|
73
|
+
domain.emailRepliers = getSenderOptions(contactInfo, 'reply_to_id');
|
|
74
|
+
}
|
|
75
|
+
|
|
76
|
+
domains.push(domain);
|
|
77
|
+
});
|
|
78
|
+
|
|
79
|
+
// Sort by priority and dedupe by domainName (match campaigns behaviour)
|
|
80
|
+
domains.sort((a, b) => (a.priority || 0) - (b.priority || 0));
|
|
81
|
+
const deduped = domains.reduce((acc, domain) => {
|
|
82
|
+
if (!acc.find((d) => d.domainName === domain.domainName)) {
|
|
83
|
+
acc.push(domain);
|
|
84
|
+
}
|
|
85
|
+
return acc;
|
|
86
|
+
}, []);
|
|
87
|
+
|
|
88
|
+
return { domains: deduped };
|
|
89
|
+
}
|
|
90
|
+
|
|
91
|
+
export default parseSenderDetailsResponse;
|
|
@@ -8,6 +8,10 @@ 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];
|
|
11
15
|
|
|
12
16
|
const SendTestMessage = ({
|
|
13
17
|
isFetchingTestCustomers,
|
|
@@ -17,8 +21,16 @@ const SendTestMessage = ({
|
|
|
17
21
|
selectedTestEntities,
|
|
18
22
|
handleSendTestMessage,
|
|
19
23
|
formData,
|
|
24
|
+
channel,
|
|
20
25
|
isSendingTestMessage,
|
|
21
26
|
formatMessage,
|
|
27
|
+
deliverySettings,
|
|
28
|
+
senderDetailsOptions,
|
|
29
|
+
wecrmAccounts,
|
|
30
|
+
onSaveDeliverySettings,
|
|
31
|
+
isLoadingSenderDetails,
|
|
32
|
+
smsTraiDltEnabled,
|
|
33
|
+
registeredSenderIds,
|
|
22
34
|
}) => (
|
|
23
35
|
<CapStepsAccordian
|
|
24
36
|
showNumberSteps={false}
|
|
@@ -43,6 +55,24 @@ const SendTestMessage = ({
|
|
|
43
55
|
multiple
|
|
44
56
|
placeholder={formatMessage(messages.testCustomersPlaceholder)}
|
|
45
57
|
/>
|
|
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
|
+
)}
|
|
46
76
|
<CapButton onClick={handleSendTestMessage} disabled={isEmpty(selectedTestEntities) || isSendingTestMessage}>
|
|
47
77
|
<FormattedMessage {...messages.sendTestButton} />
|
|
48
78
|
</CapButton>
|
|
@@ -60,9 +90,29 @@ SendTestMessage.propTypes = {
|
|
|
60
90
|
handleTestEntitiesChange: PropTypes.func.isRequired,
|
|
61
91
|
selectedTestEntities: PropTypes.array.isRequired,
|
|
62
92
|
handleSendTestMessage: PropTypes.func.isRequired,
|
|
63
|
-
formData: PropTypes.object
|
|
93
|
+
formData: PropTypes.object,
|
|
94
|
+
channel: PropTypes.string,
|
|
64
95
|
isSendingTestMessage: PropTypes.bool.isRequired,
|
|
65
96
|
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: [],
|
|
66
116
|
};
|
|
67
117
|
|
|
68
118
|
export default SendTestMessage;
|
|
@@ -18,6 +18,8 @@ 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,
|
|
21
23
|
} from './constants';
|
|
22
24
|
|
|
23
25
|
// ============================================
|
|
@@ -125,3 +127,21 @@ export const clearPrefilledValues = () => ({
|
|
|
125
127
|
export const clearPreviewErrors = () => ({
|
|
126
128
|
type: CLEAR_PREVIEW_ERRORS,
|
|
127
129
|
});
|
|
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,6 +55,16 @@ 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
|
+
|
|
58
68
|
// ============================================
|
|
59
69
|
// CHANNEL CONSTANTS
|
|
60
70
|
// ============================================
|