@capillarytech/creatives-library 8.0.329 → 8.0.330
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/constants/unified.js +0 -14
- package/package.json +1 -1
- package/services/api.js +0 -17
- package/services/tests/api.test.js +0 -85
- package/utils/commonUtils.js +0 -10
- package/utils/tests/commonUtil.test.js +0 -169
- package/v2Components/CapTagList/index.js +0 -10
- package/v2Components/CommonTestAndPreview/CustomValuesEditor.js +49 -70
- package/v2Components/CommonTestAndPreview/DeliverySettings/DeliverySettings.scss +2 -8
- package/v2Components/CommonTestAndPreview/DeliverySettings/ModifyDeliverySettings.js +21 -207
- package/v2Components/CommonTestAndPreview/DeliverySettings/constants.js +0 -16
- package/v2Components/CommonTestAndPreview/DeliverySettings/index.js +10 -85
- package/v2Components/CommonTestAndPreview/DeliverySettings/messages.js +0 -30
- package/v2Components/CommonTestAndPreview/DeliverySettings/utils/parseSenderDetailsResponse.js +11 -79
- package/v2Components/CommonTestAndPreview/SendTestMessage.js +53 -87
- package/v2Components/CommonTestAndPreview/UnifiedPreview/_unifiedPreview.scss +1 -20
- package/v2Components/CommonTestAndPreview/UnifiedPreview/index.js +4 -133
- package/v2Components/CommonTestAndPreview/_commonTestAndPreview.scss +34 -145
- package/v2Components/CommonTestAndPreview/actions.js +0 -10
- package/v2Components/CommonTestAndPreview/constants.js +1 -53
- package/v2Components/CommonTestAndPreview/index.js +168 -1006
- package/v2Components/CommonTestAndPreview/messages.js +3 -147
- package/v2Components/CommonTestAndPreview/reducer.js +0 -10
- package/v2Components/CommonTestAndPreview/sagas.js +6 -15
- package/v2Components/CommonTestAndPreview/tests/CustomValuesEditor.test.js +286 -328
- package/v2Components/CommonTestAndPreview/tests/DeliverySettings/ModifyDeliverySettings.test.js +65 -231
- package/v2Components/CommonTestAndPreview/tests/DeliverySettings/index.test.js +5 -118
- package/v2Components/CommonTestAndPreview/tests/DeliverySettings/utils/parseSenderDetailsResponse.test.js +0 -341
- package/v2Components/CommonTestAndPreview/tests/SendTestMessage.test.js +24 -65
- package/v2Components/CommonTestAndPreview/tests/UnifiedPreview/index.test.js +1 -199
- package/v2Components/CommonTestAndPreview/tests/constants.test.js +1 -31
- package/v2Components/CommonTestAndPreview/tests/index.test.js +4 -168
- package/v2Components/CommonTestAndPreview/tests/reducer.test.js +0 -71
- package/v2Components/CommonTestAndPreview/tests/sagas.test.js +2 -2
- package/v2Components/CommonTestAndPreview/tests/selectors.test.js +0 -17
- package/v2Components/FormBuilder/index.js +1 -7
- package/v2Components/TestAndPreviewSlidebox/index.js +1 -8
- package/v2Components/TestAndPreviewSlidebox/sagas.js +4 -11
- package/v2Components/TestAndPreviewSlidebox/tests/saga.test.js +1 -3
- package/v2Containers/CreativesContainer/SlideBoxContent.js +4 -36
- package/v2Containers/CreativesContainer/SlideBoxFooter.js +1 -10
- package/v2Containers/CreativesContainer/SlideBoxHeader.js +4 -29
- package/v2Containers/CreativesContainer/constants.js +0 -9
- package/v2Containers/CreativesContainer/index.js +93 -286
- package/v2Containers/CreativesContainer/index.scss +1 -51
- package/v2Containers/CreativesContainer/tests/SlideBoxFooter.test.js +34 -78
- package/v2Containers/CreativesContainer/tests/SlideBoxHeader.test.js +16 -79
- package/v2Containers/CreativesContainer/tests/__snapshots__/SlideBoxContent.test.js.snap +0 -8
- package/v2Containers/CreativesContainer/tests/__snapshots__/SlideBoxHeader.test.js.snap +98 -357
- package/v2Containers/CreativesContainer/tests/__snapshots__/index.test.js.snap +10 -20
- package/v2Containers/CreativesContainer/tests/index.test.js +9 -71
- package/v2Containers/Rcs/constants.js +1 -34
- package/v2Containers/Rcs/index.js +884 -999
- package/v2Containers/Rcs/index.scss +6 -85
- package/v2Containers/Rcs/messages.js +1 -10
- package/v2Containers/Rcs/tests/__snapshots__/index.test.js.snap +2453 -41456
- package/v2Containers/Rcs/tests/__snapshots__/utils.test.js.snap +5 -0
- package/v2Containers/Rcs/tests/index.test.js +38 -41
- package/v2Containers/Rcs/tests/mockData.js +0 -38
- package/v2Containers/Rcs/tests/utils.test.js +1 -379
- package/v2Containers/Rcs/utils.js +10 -358
- package/v2Containers/Sms/Create/index.js +38 -100
- package/v2Containers/SmsTrai/Create/index.js +4 -9
- package/v2Containers/SmsTrai/Edit/constants.js +0 -2
- package/v2Containers/SmsTrai/Edit/index.js +128 -609
- package/v2Containers/SmsTrai/Edit/messages.js +4 -9
- package/v2Containers/SmsTrai/Edit/tests/__snapshots__/index.test.js.snap +2600 -4586
- package/v2Containers/SmsWrapper/index.js +8 -37
- package/v2Containers/TagList/index.js +0 -6
- package/v2Containers/Templates/_templates.scss +2 -63
- package/v2Containers/Templates/actions.js +0 -11
- package/v2Containers/Templates/constants.js +0 -2
- package/v2Containers/Templates/index.js +40 -90
- package/v2Containers/Templates/sagas.js +12 -57
- package/v2Containers/Templates/tests/__snapshots__/index.test.js.snap +1079 -1043
- package/v2Containers/Templates/tests/sagas.test.js +123 -193
- package/v2Containers/TemplatesV2/TemplatesV2.style.js +1 -72
- package/v2Containers/TemplatesV2/index.js +23 -86
- package/v2Containers/Whatsapp/index.js +20 -3
- package/v2Containers/Whatsapp/tests/__snapshots__/index.test.js.snap +4872 -5790
- package/utils/templateVarUtils.js +0 -172
- package/utils/tests/templateVarUtils.test.js +0 -160
- package/v2Components/CommonTestAndPreview/AddTestCustomer.js +0 -42
- package/v2Components/CommonTestAndPreview/CustomerCreationModal.js +0 -155
- package/v2Components/CommonTestAndPreview/ExistingCustomerModal.js +0 -93
- package/v2Components/CommonTestAndPreview/previewApiUtils.js +0 -59
- package/v2Components/CommonTestAndPreview/tests/AddTestCustomer.test.js +0 -66
- package/v2Components/CommonTestAndPreview/tests/CommonTestAndPreview.addTestCustomer.test.js +0 -648
- package/v2Components/CommonTestAndPreview/tests/CustomerCreationModal.test.js +0 -174
- package/v2Components/CommonTestAndPreview/tests/ExistingCustomerModal.test.js +0 -114
- package/v2Components/CommonTestAndPreview/tests/previewApiUtils.test.js +0 -67
- package/v2Components/SmsFallback/SmsFallbackLocalSelector.js +0 -87
- package/v2Components/SmsFallback/constants.js +0 -73
- package/v2Components/SmsFallback/index.js +0 -955
- package/v2Components/SmsFallback/index.scss +0 -265
- package/v2Components/SmsFallback/messages.js +0 -78
- package/v2Components/SmsFallback/smsFallbackUtils.js +0 -107
- package/v2Components/SmsFallback/tests/SmsFallbackLocalSelector.test.js +0 -50
- package/v2Components/SmsFallback/tests/rcsSmsFallback.acceptance.test.js +0 -147
- package/v2Components/SmsFallback/tests/smsFallbackHandlers.test.js +0 -304
- package/v2Components/SmsFallback/tests/smsFallbackUi.test.js +0 -197
- package/v2Components/SmsFallback/tests/smsFallbackUtils.test.js +0 -261
- package/v2Components/SmsFallback/tests/useLocalTemplateList.test.js +0 -422
- package/v2Components/SmsFallback/useLocalTemplateList.js +0 -92
- package/v2Components/VarSegmentMessageEditor/constants.js +0 -2
- package/v2Components/VarSegmentMessageEditor/index.js +0 -125
- package/v2Components/VarSegmentMessageEditor/index.scss +0 -46
- package/v2Containers/CreativesContainer/CreativesSlideBoxWrapper.js +0 -43
- package/v2Containers/CreativesContainer/embeddedSlideboxUtils.js +0 -67
- package/v2Containers/CreativesContainer/tests/SlideBoxContent.localTemplates.test.js +0 -90
- package/v2Containers/CreativesContainer/tests/embeddedSlideboxUtils.test.js +0 -258
- package/v2Containers/CreativesContainer/tests/useLocalTemplatesProp.test.js +0 -125
- package/v2Containers/Rcs/rcsLibraryHydrationUtils.js +0 -205
- package/v2Containers/Rcs/tests/rcsLibraryHydrationUtils.test.js +0 -251
- package/v2Containers/Sms/smsFormDataHelpers.js +0 -67
- package/v2Containers/Sms/tests/smsFormDataHelpers.test.js +0 -253
- package/v2Containers/SmsTrai/Edit/index.scss +0 -121
- package/v2Containers/Templates/TemplatesActionBar.js +0 -101
- package/v2Containers/Templates/tests/TemplatesActionBar.test.js +0 -120
- package/v2Containers/Templates/tests/smsTemplatesListApi.test.js +0 -180
- package/v2Containers/Templates/utils/smsTemplatesListApi.js +0 -79
- package/v2Containers/TemplatesV2/tests/TemplatesV2.localTemplates.test.js +0 -131
package/v2Components/CommonTestAndPreview/DeliverySettings/utils/parseSenderDetailsResponse.js
CHANGED
|
@@ -9,91 +9,29 @@
|
|
|
9
9
|
|
|
10
10
|
import get from 'lodash/get';
|
|
11
11
|
import { CHANNELS } from '../../constants';
|
|
12
|
-
import { RCS_CONTACT_INFO_GSM_TYPE_KEYS } from '../constants';
|
|
13
12
|
|
|
14
|
-
/** Match API contactInfo.type (some envs use different casing). */
|
|
15
|
-
const typeMatches = (itemType, expectedKey) => {
|
|
16
|
-
if (!itemType || !expectedKey) return false;
|
|
17
|
-
const a = String(itemType).toLowerCase().replace(/-/g, '_');
|
|
18
|
-
const b = String(expectedKey).toLowerCase().replace(/-/g, '_');
|
|
19
|
-
return a === b;
|
|
20
|
-
};
|
|
21
|
-
|
|
22
|
-
/**
|
|
23
|
-
* Include row unless explicitly invalid — many APIs omit `valid`, which would
|
|
24
|
-
* otherwise filter out every sender (RCS/SMS lists empty in UI).
|
|
25
|
-
*/
|
|
26
13
|
const getSenderOptions = (contactInfo, key) =>
|
|
27
14
|
(contactInfo || [])
|
|
28
|
-
.filter((contactInfoItem) =>
|
|
15
|
+
.filter((contactInfoItem) => contactInfoItem.type === key && contactInfoItem.valid)
|
|
29
16
|
.sort((contact) => (contact.default ? -1 : 0));
|
|
30
17
|
|
|
31
|
-
/** RCS APIs may label senders under several `contactInfo.type` keys — see `RCS_CONTACT_INFO_GSM_TYPE_KEYS`. */
|
|
32
|
-
const getRcsLikeGsmSenders = (contactInfo) => {
|
|
33
|
-
const seen = new Set();
|
|
34
|
-
const merged = [];
|
|
35
|
-
RCS_CONTACT_INFO_GSM_TYPE_KEYS.forEach((key) => {
|
|
36
|
-
getSenderOptions(contactInfo, key).forEach((row) => {
|
|
37
|
-
const v = row?.value;
|
|
38
|
-
// Skip empty/whitespace — they still pass `v != null` for "" and pollute RCS sender dropdowns.
|
|
39
|
-
if (v == null || String(v).trim() === '' || seen.has(v)) return;
|
|
40
|
-
seen.add(v);
|
|
41
|
-
merged.push(row);
|
|
42
|
-
});
|
|
43
|
-
});
|
|
44
|
-
return merged.sort((a, b) => (a.default ? -1 : 0) - (b.default ? -1 : 0));
|
|
45
|
-
};
|
|
46
|
-
|
|
47
|
-
/**
|
|
48
|
-
* Campaigns domainProperties may return { entity } or { result: { entity } } / { data: { entity } }.
|
|
49
|
-
*/
|
|
50
|
-
function unwrapEntity(response) {
|
|
51
|
-
if (!response || typeof response !== 'object') return null;
|
|
52
|
-
if (response.entity != null) return response.entity;
|
|
53
|
-
const nested = get(response, 'result.entity') ?? get(response, 'data.entity');
|
|
54
|
-
if (nested != null) return nested;
|
|
55
|
-
if (response.entity === null) return null;
|
|
56
|
-
return response;
|
|
57
|
-
}
|
|
58
|
-
|
|
59
18
|
/**
|
|
60
19
|
* Parse raw API response for one channel into { domains: [...] }
|
|
61
|
-
* @param {string} channel - SMS | EMAIL | WHATSAPP
|
|
20
|
+
* @param {string} channel - SMS | EMAIL | WHATSAPP
|
|
62
21
|
* @param {Object} response - API response (e.g. { entity: { SMS: [...] } } or { entity: [...] })
|
|
63
22
|
* @returns {{ domains: Array }} - domains array compatible with campaigns DeliverySettingsV2
|
|
64
23
|
*/
|
|
65
24
|
export function parseSenderDetailsResponse(channel, response) {
|
|
66
|
-
const entity =
|
|
67
|
-
if (entity
|
|
25
|
+
const entity = get(response, 'entity', response);
|
|
26
|
+
if (!entity) {
|
|
68
27
|
return { domains: [] };
|
|
69
28
|
}
|
|
70
29
|
|
|
71
|
-
//
|
|
72
|
-
|
|
73
|
-
channel == null || String(channel).trim() === ''
|
|
74
|
-
? ''
|
|
75
|
-
: String(channel).trim().toUpperCase();
|
|
76
|
-
|
|
77
|
-
// Single-channel API: entity may be { [channel]: [...] } or direct array.
|
|
78
|
-
// Some responses use different casing (e.g. rcs vs RCS) or a single domain object instead of an array.
|
|
79
|
-
let channelSenderDetails =
|
|
80
|
-
get(entity, channel, null)
|
|
81
|
-
?? (normalizedChannel ? get(entity, normalizedChannel, null) : null)
|
|
82
|
-
?? (normalizedChannel ? get(entity, normalizedChannel.toLowerCase(), null) : null);
|
|
83
|
-
|
|
30
|
+
// Single-channel API: entity may be { [channel]: [...] } or direct array
|
|
31
|
+
let channelSenderDetails = get(entity, channel, null);
|
|
84
32
|
if (channelSenderDetails == null && Array.isArray(entity)) {
|
|
85
33
|
channelSenderDetails = entity;
|
|
86
34
|
}
|
|
87
|
-
|
|
88
|
-
if (channelSenderDetails != null && !Array.isArray(channelSenderDetails)) {
|
|
89
|
-
const single = channelSenderDetails;
|
|
90
|
-
if (single && typeof single === 'object' && single.domainProperties) {
|
|
91
|
-
channelSenderDetails = [single];
|
|
92
|
-
} else {
|
|
93
|
-
return { domains: [] };
|
|
94
|
-
}
|
|
95
|
-
}
|
|
96
|
-
|
|
97
35
|
if (!Array.isArray(channelSenderDetails)) {
|
|
98
36
|
return { domains: [] };
|
|
99
37
|
}
|
|
@@ -104,7 +42,6 @@ export function parseSenderDetailsResponse(channel, response) {
|
|
|
104
42
|
const { id: dgmId, priority, domainProperties = {} } = element;
|
|
105
43
|
const {
|
|
106
44
|
domainName,
|
|
107
|
-
hostName,
|
|
108
45
|
id = -1,
|
|
109
46
|
contactInfo,
|
|
110
47
|
connectionProperties: {
|
|
@@ -114,25 +51,21 @@ export function parseSenderDetailsResponse(channel, response) {
|
|
|
114
51
|
} = {},
|
|
115
52
|
} = domainProperties;
|
|
116
53
|
|
|
117
|
-
const resolvedDomainName = domainName || hostName;
|
|
118
|
-
|
|
119
54
|
const domain = {
|
|
120
55
|
dgmId,
|
|
121
|
-
domainName
|
|
56
|
+
domainName,
|
|
122
57
|
domainId: id,
|
|
123
58
|
priority: priority != null ? priority : 0,
|
|
124
59
|
};
|
|
125
60
|
|
|
126
|
-
if ([CHANNELS.SMS, CHANNELS.WHATSAPP
|
|
61
|
+
if ([CHANNELS.SMS, CHANNELS.WHATSAPP].includes(channel)) {
|
|
127
62
|
domain.cdmaSenders = getSenderOptions(contactInfo, 'cdma_sender_id');
|
|
128
|
-
domain.gsmSenders =
|
|
129
|
-
? getRcsLikeGsmSenders(contactInfo)
|
|
130
|
-
: getSenderOptions(contactInfo, 'gsm_sender_id');
|
|
63
|
+
domain.gsmSenders = getSenderOptions(contactInfo, 'gsm_sender_id');
|
|
131
64
|
domain.sourceAccountIdentifier =
|
|
132
65
|
sourceAccountIdentifier || wabaId || userid || '';
|
|
133
66
|
}
|
|
134
67
|
|
|
135
|
-
if (
|
|
68
|
+
if (channel === CHANNELS.EMAIL) {
|
|
136
69
|
domain.emailSenders = getSenderOptions(contactInfo, 'sender_id');
|
|
137
70
|
domain.emailRepliers = getSenderOptions(contactInfo, 'reply_to_id');
|
|
138
71
|
}
|
|
@@ -143,8 +76,7 @@ export function parseSenderDetailsResponse(channel, response) {
|
|
|
143
76
|
// Sort by priority and dedupe by domainName (match campaigns behaviour)
|
|
144
77
|
domains.sort((a, b) => (a.priority || 0) - (b.priority || 0));
|
|
145
78
|
const deduped = domains.reduce((acc, domain) => {
|
|
146
|
-
|
|
147
|
-
if (!acc.find((existing) => (existing.domainName ?? existing.domainId) === key)) {
|
|
79
|
+
if (!acc.find((d) => d.domainName === domain.domainName)) {
|
|
148
80
|
acc.push(domain);
|
|
149
81
|
}
|
|
150
82
|
return acc;
|
|
@@ -6,13 +6,12 @@ import CapButton from '@capillarytech/cap-ui-library/CapButton';
|
|
|
6
6
|
import CapHeader from '@capillarytech/cap-ui-library/CapHeader';
|
|
7
7
|
import CapStepsAccordian from '@capillarytech/cap-ui-library/CapStepsAccordian';
|
|
8
8
|
import CapTreeSelect from '@capillarytech/cap-ui-library/CapTreeSelect';
|
|
9
|
-
import CapSelect from '@capillarytech/cap-ui-library/CapSelect';
|
|
10
9
|
import isEmpty from 'lodash/isEmpty';
|
|
11
10
|
import messages from './messages';
|
|
12
11
|
import DeliverySettings from './DeliverySettings';
|
|
13
12
|
import { CHANNELS } from './constants';
|
|
14
13
|
|
|
15
|
-
const CHANNELS_WITH_DELIVERY_SETTINGS = [CHANNELS.SMS, CHANNELS.EMAIL, CHANNELS.WHATSAPP
|
|
14
|
+
const CHANNELS_WITH_DELIVERY_SETTINGS = [CHANNELS.SMS, CHANNELS.EMAIL, CHANNELS.WHATSAPP];
|
|
16
15
|
|
|
17
16
|
const SendTestMessage = ({
|
|
18
17
|
isFetchingTestCustomers,
|
|
@@ -25,89 +24,64 @@ const SendTestMessage = ({
|
|
|
25
24
|
channel,
|
|
26
25
|
isSendingTestMessage,
|
|
27
26
|
formatMessage,
|
|
28
|
-
renderAddTestCustomerButton,
|
|
29
|
-
searchValue,
|
|
30
|
-
setSearchValue,
|
|
31
27
|
deliverySettings,
|
|
32
|
-
|
|
28
|
+
senderDetailsOptions,
|
|
33
29
|
wecrmAccounts,
|
|
34
30
|
onSaveDeliverySettings,
|
|
35
31
|
isLoadingSenderDetails,
|
|
36
32
|
smsTraiDltEnabled,
|
|
37
33
|
registeredSenderIds,
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
34
|
+
}) => (
|
|
35
|
+
<CapStepsAccordian
|
|
36
|
+
showNumberSteps={false}
|
|
37
|
+
isChevronIcon
|
|
38
|
+
expandIconPosition="right"
|
|
39
|
+
items={[
|
|
40
|
+
{
|
|
41
|
+
header: <CapHeader
|
|
42
|
+
size="regular"
|
|
43
|
+
description={<FormattedMessage {...messages.testMessageDescription} />}
|
|
44
|
+
title={<FormattedMessage {...messages.sendTestMessage} />}
|
|
45
|
+
/>,
|
|
46
|
+
content: (
|
|
47
|
+
<CapRow className="send-test-content">
|
|
48
|
+
<CapHeader size="label1" title={<FormattedMessage {...messages.testCustomers} />} />
|
|
49
|
+
<CapTreeSelect
|
|
50
|
+
className="test-customers-tree-select"
|
|
51
|
+
loading={isFetchingTestCustomers || isFetchingTestGroups}
|
|
52
|
+
treeData={testEntitiesTreeData}
|
|
53
|
+
onChange={handleTestEntitiesChange}
|
|
54
|
+
value={selectedTestEntities}
|
|
55
|
+
multiple
|
|
56
|
+
placeholder={formatMessage(messages.testCustomersPlaceholder)}
|
|
53
57
|
/>
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
treeNodeFilterProp="title"
|
|
71
|
-
{...(addCustomerContent ? { notFoundContent: addCustomerContent } : {})}
|
|
72
|
-
multiple
|
|
73
|
-
placeholder={formatMessage(messages.testCustomersPlaceholder)}
|
|
74
|
-
dropdownStyle={{ zIndex: 900, maxHeight: 320 }}
|
|
75
|
-
placement="bottomLeft"
|
|
76
|
-
getPopupContainer={(node) => node.closest('.send-test-section') || document.body}
|
|
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
|
+
}
|
|
77
74
|
/>
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
registeredSenderIds={registeredSenderIds}
|
|
89
|
-
isChannelSmsFallbackPreviewEnabled={isChannelSmsFallbackPreviewEnabled}
|
|
90
|
-
whatsappAccountFromForm={
|
|
91
|
-
channel === CHANNELS.WHATSAPP && formData?.accountName
|
|
92
|
-
? { accountName: formData.accountName }
|
|
93
|
-
: undefined
|
|
94
|
-
}
|
|
95
|
-
/>
|
|
96
|
-
)}
|
|
97
|
-
<CapButton
|
|
98
|
-
onClick={handleSendTestMessage}
|
|
99
|
-
disabled={isEmpty(selectedTestEntities) || isSendingTestMessage}
|
|
100
|
-
>
|
|
101
|
-
<FormattedMessage {...messages.sendTestButton} />
|
|
102
|
-
</CapButton>
|
|
103
|
-
</CapRow>
|
|
104
|
-
),
|
|
105
|
-
key: 1,
|
|
106
|
-
},
|
|
107
|
-
]}
|
|
108
|
-
/>
|
|
109
|
-
);
|
|
110
|
-
};
|
|
75
|
+
)}
|
|
76
|
+
<CapButton onClick={handleSendTestMessage} disabled={isEmpty(selectedTestEntities) || isSendingTestMessage}>
|
|
77
|
+
<FormattedMessage {...messages.sendTestButton} />
|
|
78
|
+
</CapButton>
|
|
79
|
+
</CapRow>),
|
|
80
|
+
key: 1,
|
|
81
|
+
},
|
|
82
|
+
]}
|
|
83
|
+
/>
|
|
84
|
+
);
|
|
111
85
|
|
|
112
86
|
SendTestMessage.propTypes = {
|
|
113
87
|
isFetchingTestCustomers: PropTypes.bool.isRequired,
|
|
@@ -120,33 +94,25 @@ SendTestMessage.propTypes = {
|
|
|
120
94
|
channel: PropTypes.string,
|
|
121
95
|
isSendingTestMessage: PropTypes.bool.isRequired,
|
|
122
96
|
formatMessage: PropTypes.func.isRequired,
|
|
123
|
-
renderAddTestCustomerButton: PropTypes.func,
|
|
124
|
-
searchValue: PropTypes.string,
|
|
125
|
-
setSearchValue: PropTypes.func,
|
|
126
97
|
deliverySettings: PropTypes.object,
|
|
127
|
-
|
|
98
|
+
senderDetailsOptions: PropTypes.array,
|
|
128
99
|
wecrmAccounts: PropTypes.array,
|
|
129
100
|
onSaveDeliverySettings: PropTypes.func,
|
|
130
101
|
isLoadingSenderDetails: PropTypes.bool,
|
|
131
102
|
smsTraiDltEnabled: PropTypes.bool,
|
|
132
103
|
registeredSenderIds: PropTypes.array,
|
|
133
|
-
isChannelSmsFallbackPreviewEnabled: PropTypes.bool,
|
|
134
104
|
};
|
|
135
105
|
|
|
136
106
|
SendTestMessage.defaultProps = {
|
|
137
107
|
formData: undefined,
|
|
138
108
|
channel: undefined,
|
|
139
|
-
renderAddTestCustomerButton: undefined,
|
|
140
|
-
searchValue: '',
|
|
141
|
-
setSearchValue: () => {}, // no-op when not provided; required by TreeSelect when showSearch is true
|
|
142
109
|
deliverySettings: {},
|
|
143
|
-
|
|
110
|
+
senderDetailsOptions: [],
|
|
144
111
|
wecrmAccounts: [],
|
|
145
112
|
onSaveDeliverySettings: undefined,
|
|
146
113
|
isLoadingSenderDetails: false,
|
|
147
114
|
smsTraiDltEnabled: false,
|
|
148
115
|
registeredSenderIds: [],
|
|
149
|
-
isChannelSmsFallbackPreviewEnabled: false,
|
|
150
116
|
};
|
|
151
117
|
|
|
152
118
|
export default SendTestMessage;
|
|
@@ -11,6 +11,7 @@
|
|
|
11
11
|
height: 100%;
|
|
12
12
|
display: flex;
|
|
13
13
|
flex-direction: column;
|
|
14
|
+
background: $CAP_WHITE;
|
|
14
15
|
overflow: hidden;
|
|
15
16
|
|
|
16
17
|
// Preview Chrome wrapper (matches old TestAndPreviewSlidebox design)
|
|
@@ -61,27 +62,7 @@
|
|
|
61
62
|
}
|
|
62
63
|
}
|
|
63
64
|
}
|
|
64
|
-
|
|
65
|
-
.unified-preview.unified-preview-rcs-tabs {
|
|
66
|
-
.ant-tabs-nav {
|
|
67
|
-
margin: 0;
|
|
68
|
-
padding: 0 $CAP_SPACE_16;
|
|
69
|
-
}
|
|
70
65
|
|
|
71
|
-
// Prevent white hover/active backgrounds from default antd styles
|
|
72
|
-
.ant-tabs-tab,
|
|
73
|
-
.ant-tabs-tab:hover,
|
|
74
|
-
.ant-tabs-tab-active {
|
|
75
|
-
background: transparent;
|
|
76
|
-
}
|
|
77
|
-
|
|
78
|
-
.ant-tabs-tab-btn,
|
|
79
|
-
.ant-tabs-tab-btn:hover,
|
|
80
|
-
.ant-tabs-tab-btn:active {
|
|
81
|
-
background: transparent;
|
|
82
|
-
}
|
|
83
|
-
}
|
|
84
|
-
|
|
85
66
|
// Preview Content Container
|
|
86
67
|
.preview-content-container {
|
|
87
68
|
flex: 1;
|
|
@@ -21,21 +21,8 @@ import InAppPreviewContent from './InAppPreviewContent';
|
|
|
21
21
|
import MobilePushPreviewContent from './MobilePushPreviewContent';
|
|
22
22
|
import ViberPreviewContent from './ViberPreviewContent';
|
|
23
23
|
import ZaloPreviewContent from './ZaloPreviewContent';
|
|
24
|
-
import
|
|
25
|
-
import {
|
|
26
|
-
CHANNELS,
|
|
27
|
-
DESKTOP,
|
|
28
|
-
TABLET,
|
|
29
|
-
MOBILE,
|
|
30
|
-
ANDROID,
|
|
31
|
-
IOS,
|
|
32
|
-
PREVIEW_TAB_RCS,
|
|
33
|
-
PREVIEW_TAB_SMS_FALLBACK,
|
|
34
|
-
PREVIEW_TAB_KEYS,
|
|
35
|
-
RCS_SMS_FALLBACK_VAR_MAPPED_PROP,
|
|
36
|
-
} from '../constants';
|
|
24
|
+
import { CHANNELS, DESKTOP, TABLET, MOBILE, ANDROID, IOS } from '../constants';
|
|
37
25
|
import messages from '../messages';
|
|
38
|
-
import { getFallbackResolvedContent } from '../../../utils/templateVarUtils';
|
|
39
26
|
import './_unifiedPreview.scss';
|
|
40
27
|
|
|
41
28
|
const UnifiedPreview = ({
|
|
@@ -51,24 +38,7 @@ const UnifiedPreview = ({
|
|
|
51
38
|
lastModified,
|
|
52
39
|
updatedByName,
|
|
53
40
|
showHeader, // Default to true for Test and Preview flow, false for channel component previews
|
|
54
|
-
smsFallbackContent,
|
|
55
|
-
smsFallbackResolvedText,
|
|
56
|
-
activePreviewTab,
|
|
57
|
-
onPreviewTabChange,
|
|
58
41
|
}) => {
|
|
59
|
-
const hasFallbackSmsTemplate = !!(smsFallbackContent?.templateContent || smsFallbackContent?.content);
|
|
60
|
-
const showRcsSmsFallbackTabs = channel === CHANNELS.RCS && hasFallbackSmsTemplate;
|
|
61
|
-
const rawFallbackTemplate = smsFallbackContent?.templateContent ?? smsFallbackContent?.content ?? '';
|
|
62
|
-
const rcsFallbackVarMapped = smsFallbackContent?.[RCS_SMS_FALLBACK_VAR_MAPPED_PROP] ?? {};
|
|
63
|
-
const hasRcsFallbackVarMapped = Object.keys(rcsFallbackVarMapped).length > 0;
|
|
64
|
-
// When no varmap is present, show raw template so {{tags}} remain visible in the preview.
|
|
65
|
-
// Only apply slot substitution when varmap entries exist or a resolved text is available.
|
|
66
|
-
const smsFallbackDisplayContent =
|
|
67
|
-
smsFallbackResolvedText != null && smsFallbackResolvedText !== ''
|
|
68
|
-
? smsFallbackResolvedText
|
|
69
|
-
: hasRcsFallbackVarMapped
|
|
70
|
-
? getFallbackResolvedContent(rawFallbackTemplate, rcsFallbackVarMapped)
|
|
71
|
-
: rawFallbackTemplate;
|
|
72
42
|
/**
|
|
73
43
|
* Render channel-specific preview content
|
|
74
44
|
* For Phase 5, we'll render placeholders
|
|
@@ -154,21 +124,6 @@ const UnifiedPreview = ({
|
|
|
154
124
|
case CHANNELS.RCS: {
|
|
155
125
|
// RCS content is an object with rcsTitle, rcsDesc, rcsImageSrc, suggestions, etc.
|
|
156
126
|
const rcsContent = typeof content === 'object' ? content : {};
|
|
157
|
-
|
|
158
|
-
if (showRcsSmsFallbackTabs && activePreviewTab === PREVIEW_TAB_SMS_FALLBACK) {
|
|
159
|
-
return (
|
|
160
|
-
<SmsPreviewContent
|
|
161
|
-
content={smsFallbackDisplayContent}
|
|
162
|
-
device={ANDROID}
|
|
163
|
-
isUpdating={isUpdating}
|
|
164
|
-
error={error}
|
|
165
|
-
formatMessage={formatMessage}
|
|
166
|
-
senderId={smsFallbackContent?.senderId}
|
|
167
|
-
showHeader={showHeader}
|
|
168
|
-
/>
|
|
169
|
-
);
|
|
170
|
-
}
|
|
171
|
-
|
|
172
127
|
return (
|
|
173
128
|
<RcsPreviewContent
|
|
174
129
|
content={rcsContent}
|
|
@@ -313,79 +268,6 @@ const UnifiedPreview = ({
|
|
|
313
268
|
* PreviewHeader is shown only when showHeader is true (for Test and Preview flow)
|
|
314
269
|
* Channel-specific content will be in separate files in future phases
|
|
315
270
|
*/
|
|
316
|
-
if (showRcsSmsFallbackTabs) {
|
|
317
|
-
const renderPane = ({ paneChannel, paneDevice, paneShowDeviceToggle, paneContent }) => (
|
|
318
|
-
<CapRow className="unified-preview-tab-pane">
|
|
319
|
-
{showHeader && (
|
|
320
|
-
<PreviewHeader
|
|
321
|
-
selectedCustomer={selectedCustomer}
|
|
322
|
-
device={paneDevice}
|
|
323
|
-
showDeviceToggle={paneShowDeviceToggle}
|
|
324
|
-
onDeviceChange={onDeviceChange}
|
|
325
|
-
channel={paneChannel}
|
|
326
|
-
/>
|
|
327
|
-
)}
|
|
328
|
-
|
|
329
|
-
<CapRow className={`preview-content-container ${!showHeader ? 'preview-content-container-no-header' : ''}`}>
|
|
330
|
-
{paneContent}
|
|
331
|
-
</CapRow>
|
|
332
|
-
|
|
333
|
-
|
|
334
|
-
</CapRow>
|
|
335
|
-
);
|
|
336
|
-
|
|
337
|
-
return (
|
|
338
|
-
<CapRow className="unified-preview unified-preview-rcs-tabs">
|
|
339
|
-
<CapTab
|
|
340
|
-
activeKey={activePreviewTab}
|
|
341
|
-
onChange={onPreviewTabChange}
|
|
342
|
-
panes={[
|
|
343
|
-
{
|
|
344
|
-
tab: formatMessage(messages.rcsTab),
|
|
345
|
-
key: PREVIEW_TAB_RCS,
|
|
346
|
-
content: renderPane({
|
|
347
|
-
paneChannel: CHANNELS.RCS,
|
|
348
|
-
paneDevice: device,
|
|
349
|
-
paneShowDeviceToggle: showDeviceToggle,
|
|
350
|
-
paneContent: (
|
|
351
|
-
<RcsPreviewContent
|
|
352
|
-
content={typeof content === 'object' ? content : {}}
|
|
353
|
-
device={device}
|
|
354
|
-
isUpdating={isUpdating}
|
|
355
|
-
error={error}
|
|
356
|
-
formatMessage={formatMessage}
|
|
357
|
-
senderId={content?.senderId}
|
|
358
|
-
showHeader={showHeader}
|
|
359
|
-
/>
|
|
360
|
-
),
|
|
361
|
-
}),
|
|
362
|
-
},
|
|
363
|
-
{
|
|
364
|
-
tab: formatMessage(messages.smsFallbackTab),
|
|
365
|
-
key: PREVIEW_TAB_SMS_FALLBACK,
|
|
366
|
-
content: renderPane({
|
|
367
|
-
paneChannel: CHANNELS.SMS,
|
|
368
|
-
paneDevice: device,
|
|
369
|
-
paneShowDeviceToggle: showDeviceToggle,
|
|
370
|
-
paneContent: (
|
|
371
|
-
<SmsPreviewContent
|
|
372
|
-
content={smsFallbackDisplayContent}
|
|
373
|
-
device={device}
|
|
374
|
-
isUpdating={isUpdating}
|
|
375
|
-
error={error}
|
|
376
|
-
formatMessage={formatMessage}
|
|
377
|
-
senderId={smsFallbackContent?.senderId}
|
|
378
|
-
showHeader={showHeader}
|
|
379
|
-
/>
|
|
380
|
-
),
|
|
381
|
-
}),
|
|
382
|
-
},
|
|
383
|
-
]}
|
|
384
|
-
/>
|
|
385
|
-
</CapRow>
|
|
386
|
-
);
|
|
387
|
-
}
|
|
388
|
-
|
|
389
271
|
return (
|
|
390
272
|
<CapRow className="unified-preview">
|
|
391
273
|
{/* PreviewHeader - shown only in Test and Preview flow, hidden in channel component previews */}
|
|
@@ -423,7 +305,9 @@ const UnifiedPreview = ({
|
|
|
423
305
|
)}
|
|
424
306
|
{updatedByName && (
|
|
425
307
|
<span className="metadata-item">
|
|
426
|
-
{formatMessage(messages.
|
|
308
|
+
{formatMessage(messages.by)}
|
|
309
|
+
{' '}
|
|
310
|
+
{updatedByName}
|
|
427
311
|
</span>
|
|
428
312
|
)}
|
|
429
313
|
</CapRow>
|
|
@@ -464,15 +348,6 @@ UnifiedPreview.propTypes = {
|
|
|
464
348
|
|
|
465
349
|
// Header display
|
|
466
350
|
showHeader: PropTypes.bool, // Show PreviewHeader (true for Test and Preview flow, false for channel component previews)
|
|
467
|
-
|
|
468
|
-
// RCS: SMS fallback preview support (same shape as SmsFallback / RCS smsFallbackData)
|
|
469
|
-
smsFallbackContent: PropTypes.shape({
|
|
470
|
-
templateContent: PropTypes.string,
|
|
471
|
-
senderId: PropTypes.string,
|
|
472
|
-
templateName: PropTypes.string,
|
|
473
|
-
}),
|
|
474
|
-
activePreviewTab: PropTypes.oneOf(PREVIEW_TAB_KEYS),
|
|
475
|
-
onPreviewTabChange: PropTypes.func,
|
|
476
351
|
};
|
|
477
352
|
|
|
478
353
|
UnifiedPreview.defaultProps = {
|
|
@@ -485,10 +360,6 @@ UnifiedPreview.defaultProps = {
|
|
|
485
360
|
lastModified: null,
|
|
486
361
|
updatedByName: null,
|
|
487
362
|
showHeader: true, // Default to true for Test and Preview flow
|
|
488
|
-
smsFallbackContent: null,
|
|
489
|
-
smsFallbackResolvedText: undefined,
|
|
490
|
-
activePreviewTab: PREVIEW_TAB_RCS,
|
|
491
|
-
onPreviewTabChange: () => {},
|
|
492
363
|
};
|
|
493
364
|
|
|
494
365
|
export default UnifiedPreview;
|