@capillarytech/creatives-library 8.0.290 → 8.0.291

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.
Files changed (32) hide show
  1. package/package.json +1 -1
  2. package/v2Components/CommonTestAndPreview/SendTestMessage.js +1 -33
  3. package/v2Components/CommonTestAndPreview/actions.js +0 -20
  4. package/v2Components/CommonTestAndPreview/constants.js +0 -10
  5. package/v2Components/CommonTestAndPreview/index.js +15 -133
  6. package/v2Components/CommonTestAndPreview/reducer.js +0 -47
  7. package/v2Components/CommonTestAndPreview/sagas.js +0 -60
  8. package/v2Components/CommonTestAndPreview/selectors.js +0 -51
  9. package/v2Components/CommonTestAndPreview/tests/SendTestMessage.test.js +0 -127
  10. package/v2Components/CommonTestAndPreview/tests/actions.test.js +0 -50
  11. package/v2Components/CommonTestAndPreview/tests/constants.test.js +0 -18
  12. package/v2Components/CommonTestAndPreview/tests/index.test.js +1 -214
  13. package/v2Components/CommonTestAndPreview/tests/reducer.test.js +0 -118
  14. package/v2Components/CommonTestAndPreview/tests/sagas.test.js +0 -145
  15. package/v2Components/CommonTestAndPreview/tests/selectors.test.js +0 -146
  16. package/v2Components/TestAndPreviewSlidebox/index.js +0 -14
  17. package/v2Containers/CreativesContainer/index.js +8 -0
  18. package/v2Containers/Rcs/tests/__snapshots__/index.test.js.snap +12 -649
  19. package/v2Containers/SmsTrai/Edit/tests/__snapshots__/index.test.js.snap +0 -141
  20. package/v2Containers/Whatsapp/index.js +1 -1
  21. package/v2Containers/Whatsapp/tests/__snapshots__/index.test.js.snap +4225 -26174
  22. package/v2Components/CommonTestAndPreview/DeliverySettings/DeliverySettings.scss +0 -33
  23. package/v2Components/CommonTestAndPreview/DeliverySettings/ModifyDeliverySettings.js +0 -397
  24. package/v2Components/CommonTestAndPreview/DeliverySettings/ModifyDeliverySettings.scss +0 -35
  25. package/v2Components/CommonTestAndPreview/DeliverySettings/TECH_DETAILING_DELIVERY_SETTINGS.md +0 -725
  26. package/v2Components/CommonTestAndPreview/DeliverySettings/constants.js +0 -92
  27. package/v2Components/CommonTestAndPreview/DeliverySettings/index.js +0 -243
  28. package/v2Components/CommonTestAndPreview/DeliverySettings/messages.js +0 -111
  29. package/v2Components/CommonTestAndPreview/DeliverySettings/utils/parseSenderDetailsResponse.js +0 -91
  30. package/v2Components/CommonTestAndPreview/tests/DeliverySettings/ModifyDeliverySettings.test.js +0 -782
  31. package/v2Components/CommonTestAndPreview/tests/DeliverySettings/index.test.js +0 -200
  32. package/v2Components/CommonTestAndPreview/tests/DeliverySettings/utils/parseSenderDetailsResponse.test.js +0 -235
@@ -1,92 +0,0 @@
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
- };
@@ -1,243 +0,0 @@
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
- whatsappAccountFromForm,
54
- } = props;
55
-
56
- const [isSlideBoxOpen, setSlideBoxOpen] = useState(false);
57
-
58
- const openSlideBox = useCallback(() => setSlideBoxOpen(true), []);
59
- const closeSlideBox = useCallback(() => setSlideBoxOpen(false), []);
60
-
61
- const handleSave = useCallback(
62
- (values) => {
63
- onSaveDeliverySettings(values);
64
- closeSlideBox();
65
- },
66
- [onSaveDeliverySettings, closeSlideBox]
67
- );
68
-
69
- if (!CHANNELS_WITH_DELIVERY_SETTINGS.includes(channel)) {
70
- return null;
71
- }
72
-
73
- const notConfiguredLabel = formatMessage
74
- ? formatMessage(messages.notConfigured)
75
- : NOT_CONFIGURED_LABEL;
76
-
77
- const getSummaryText = () => {
78
- const empty = SUMMARY_EMPTY_PLACEHOLDER;
79
- if (channel === CHANNELS.SMS) {
80
- const domain = (senderDetailsOptions || []).find(
81
- (d) => d.domainId === get(deliverySettings, DELIVERY_SETTING_KEY_DOMAIN_ID),
82
- );
83
- const domainName = domain?.domainName || empty;
84
- const senderId = get(deliverySettings, DELIVERY_SETTING_KEY_GSM_SENDER_ID) || empty;
85
- return { senderDomain: domainName, senderId };
86
- }
87
- if (channel === CHANNELS.EMAIL) {
88
- const domain = (senderDetailsOptions || []).find(
89
- (d) => d.domainId === get(deliverySettings, DELIVERY_SETTING_KEY_DOMAIN_ID),
90
- );
91
- const emailDomain = domain?.domainName || empty;
92
- const senderEmail = get(deliverySettings, DELIVERY_SETTING_KEY_SENDER_EMAIL) || empty;
93
- const senderLabel = get(deliverySettings, DELIVERY_SETTING_KEY_SENDER_LABEL) || empty;
94
- const replyToId = get(deliverySettings, DELIVERY_SETTING_KEY_SENDER_REPLY_TO) || empty;
95
- return {
96
- emailDomain,
97
- senderEmail,
98
- senderLabel,
99
- replyToId,
100
- };
101
- }
102
- if (channel === CHANNELS.WHATSAPP) {
103
- const account = (wecrmAccounts || []).find(
104
- (a) => a.sourceAccountIdentifier
105
- === get(deliverySettings, DELIVERY_SETTING_KEY_SOURCE_ACCOUNT_IDENTIFIER),
106
- );
107
- const accountName = account?.name || empty;
108
- const senderNumber = get(deliverySettings, DELIVERY_SETTING_KEY_SENDER_MOB_NUM) || empty;
109
- return { account: accountName, senderNumber };
110
- }
111
- return { account: empty, sender: empty };
112
- };
113
-
114
- const summary = getSummaryText();
115
- let hasValues = false;
116
- if (channel === CHANNELS.SMS) {
117
- hasValues = summary.senderDomain !== SUMMARY_EMPTY_PLACEHOLDER
118
- || summary.senderId !== SUMMARY_EMPTY_PLACEHOLDER;
119
- } else if (channel === CHANNELS.EMAIL) {
120
- hasValues = summary.emailDomain !== SUMMARY_EMPTY_PLACEHOLDER
121
- || summary.senderEmail !== SUMMARY_EMPTY_PLACEHOLDER
122
- || summary.senderLabel !== SUMMARY_EMPTY_PLACEHOLDER
123
- || summary.replyToId !== SUMMARY_EMPTY_PLACEHOLDER;
124
- } else if (channel === CHANNELS.WHATSAPP) {
125
- hasValues = summary.account !== SUMMARY_EMPTY_PLACEHOLDER
126
- || summary.senderNumber !== SUMMARY_EMPTY_PLACEHOLDER;
127
- } else {
128
- hasValues = summary.account !== SUMMARY_EMPTY_PLACEHOLDER
129
- || summary.sender !== SUMMARY_EMPTY_PLACEHOLDER;
130
- }
131
-
132
- const getSummaryObject = () => {
133
- if (!hasValues) return null;
134
- const label = (msg) => formatMessage ? formatMessage(msg) : msg.defaultMessage;
135
- if (channel === CHANNELS.SMS) {
136
- return {
137
- [label(messages.senderDomainSummary)]: summary.senderDomain,
138
- [label(messages.senderId)]: summary.senderId,
139
- };
140
- }
141
- if (channel === CHANNELS.EMAIL) {
142
- return {
143
- [label(messages.emailDomain)]: summary.emailDomain,
144
- [label(messages.senderId)]: summary.senderEmail,
145
- [label(messages.senderName)]: summary.senderLabel,
146
- [label(messages.replyToId)]: summary.replyToId,
147
- };
148
- }
149
- if (channel === CHANNELS.WHATSAPP) {
150
- return {
151
- [label(messages.account)]: summary.account,
152
- [label(messages.senderNumber)]: summary.senderNumber,
153
- };
154
- }
155
- return {
156
- [label(messages.account)]: summary.account,
157
- [label(messages.senderNumber)]: summary.sender,
158
- };
159
- };
160
-
161
- const summaryObject = getSummaryObject();
162
-
163
- return (
164
- <div className="delivery-settings">
165
- <CapRow className="delivery-settings__heading-row">
166
- <CapHeading type={HEADING_TYPE_H10}>
167
- <FormattedMessage {...messages.deliverySettings} />
168
- </CapHeading>
169
- </CapRow>
170
- <CapRow type={ROW_TYPE_FLEX} className="delivery-settings__summary-row">
171
- <CapRow type={ROW_TYPE_FLEX} className="delivery-settings__summary-inner">
172
- {summaryObject == null ? (
173
- <CapLabel type={LABEL_TYPE_LABEL2}>{notConfiguredLabel}</CapLabel>
174
- ) : (
175
- Object.entries(summaryObject).map(([key, value]) => (
176
- <CapRow type={ROW_TYPE_FLEX} key={key} className="delivery-settings__summary-entry">
177
- <CapLabel type={LABEL_TYPE_LABEL1} className="delivery-settings__summary-key">{key}</CapLabel>
178
- <CapLabel type={LABEL_TYPE_LABEL9}>
179
- :
180
- {' '}
181
- {value}
182
- </CapLabel>
183
- </CapRow>
184
- ))
185
- )}
186
- </CapRow>
187
- <CapIcon
188
- type={ICON_TYPE_EDIT}
189
- onClick={openSlideBox}
190
- className="delivery-settings__edit-icon"
191
- data-testid={TEST_ID_DELIVERY_SETTINGS_EDIT}
192
- size="s"
193
- />
194
- </CapRow>
195
-
196
- {isSlideBoxOpen && (
197
- <CapSlideBox
198
- show
199
- size={SLIDE_BOX_SIZE_L}
200
- header={<FormattedMessage {...messages.deliverySettings} />}
201
- handleClose={closeSlideBox}
202
- content={(
203
- <ModifyDeliverySettings
204
- channel={channel}
205
- deliverySettings={deliverySettings}
206
- senderDetailsOptions={senderDetailsOptions}
207
- wecrmAccounts={wecrmAccounts}
208
- onSaveDeliverySettings={handleSave}
209
- onClose={closeSlideBox}
210
- isLoading={isLoadingSenderDetails}
211
- formatMessage={formatMessage}
212
- whatsappAccountFromForm={whatsappAccountFromForm}
213
- />
214
- )}
215
- />
216
- )}
217
- </div>
218
- );
219
- };
220
-
221
- DeliverySettings.propTypes = {
222
- channel: PropTypes.string.isRequired,
223
- deliverySettings: PropTypes.object,
224
- senderDetailsOptions: PropTypes.array,
225
- wecrmAccounts: PropTypes.array,
226
- onSaveDeliverySettings: PropTypes.func.isRequired,
227
- isLoadingSenderDetails: PropTypes.bool,
228
- formatMessage: PropTypes.func,
229
- whatsappAccountFromForm: PropTypes.shape({
230
- accountName: PropTypes.string,
231
- }),
232
- };
233
-
234
- DeliverySettings.defaultProps = {
235
- deliverySettings: {},
236
- senderDetailsOptions: [],
237
- wecrmAccounts: [],
238
- isLoadingSenderDetails: false,
239
- formatMessage: undefined,
240
- whatsappAccountFromForm: undefined,
241
- };
242
-
243
- export default DeliverySettings;
@@ -1,111 +0,0 @@
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
- });
@@ -1,91 +0,0 @@
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;