@capillarytech/creatives-library 9.2.2 → 9.2.4-alpha.feature-rcs-multi-account.51
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 -1
- package/package.json +1 -1
- package/utils/common.js +0 -6
- package/utils/createMobilePushPayload.js +50 -56
- package/utils/tests/createMobilePushPayload.test.js +177 -168
- package/v2Components/CapMpushCTA/index.js +47 -57
- package/v2Components/CapMpushCTA/index.scss +43 -5
- package/v2Components/CapMpushCTA/tests/index.test.js +150 -0
- package/v2Components/CommonTestAndPreview/UnifiedPreview/MobilePushPreviewContent.js +11 -8
- package/v2Components/CommonTestAndPreview/UnifiedPreview/_unifiedPreview.scss +13 -1
- package/v2Components/CommonTestAndPreview/constants.js +2 -0
- package/v2Components/CommonTestAndPreview/index.js +59 -14
- package/v2Components/CommonTestAndPreview/tests/UnifiedPreview/MobilePushPreviewContent.test.js +83 -5
- package/v2Components/CommonTestAndPreview/tests/index.test.js +158 -0
- package/v2Components/MobilePushPreviewV2/_mobilePushPreviewV2.scss +7 -0
- package/v2Components/MobilePushPreviewV2/index.js +22 -9
- package/v2Components/MobilePushPreviewV2/tests/index.test.js +55 -0
- package/v2Components/TemplatePreview/_mobilePushPhone.scss +72 -0
- package/v2Components/TemplatePreview/_templatePreview.scss +18 -2
- package/v2Components/TemplatePreview/index.js +20 -18
- package/v2Components/TemplatePreview/tests/index.test.js +69 -0
- package/v2Components/TestAndPreviewSlidebox/index.js +2 -0
- package/v2Containers/CommunicationFlow/steps/ChannelSelectionStep/Tests/extractContentForPreview.test.js +45 -0
- package/v2Containers/CommunicationFlow/steps/ChannelSelectionStep/extractContentForPreview.js +12 -2
- package/v2Containers/CommunicationFlow/steps/DeliverySettingsStep/DeliverySettingsSection.js +16 -3
- package/v2Containers/CommunicationFlow/steps/DeliverySettingsStep/SenderDetails.js +7 -2
- package/v2Containers/CommunicationFlow/steps/DeliverySettingsStep/Tests/deliverySettingsConfig.test.js +44 -0
- package/v2Containers/CommunicationFlow/steps/DeliverySettingsStep/deliverySettingsConfig.js +21 -8
- package/v2Containers/CreativesContainer/SlideBoxContent.js +4 -6
- package/v2Containers/CreativesContainer/index.js +18 -1
- package/v2Containers/CreativesContainer/tests/SlideBoxContent.test.js +43 -0
- package/v2Containers/CreativesContainer/tests/index.test.js +66 -0
- package/v2Containers/MobilePushNew/components/CtaButtons.js +52 -47
- package/v2Containers/MobilePushNew/components/MediaUploaders.js +105 -345
- package/v2Containers/MobilePushNew/components/PlatformContentFields.js +127 -105
- package/v2Containers/MobilePushNew/components/TapLinkActions.js +76 -0
- package/v2Containers/MobilePushNew/components/tests/CtaButtons.test.js +30 -208
- package/v2Containers/MobilePushNew/components/tests/MediaUploaders.test.js +305 -1482
- package/v2Containers/MobilePushNew/components/tests/PlatformContentFields.test.js +165 -59
- package/v2Containers/MobilePushNew/constants.js +12 -0
- package/v2Containers/MobilePushNew/hooks/tests/usePlatformSync.test.js +63 -1
- package/v2Containers/MobilePushNew/hooks/tests/useUpload.test.js +78 -0
- package/v2Containers/MobilePushNew/hooks/usePlatformSync.js +40 -1
- package/v2Containers/MobilePushNew/hooks/useUpload.js +42 -46
- package/v2Containers/MobilePushNew/index.js +498 -289
- package/v2Containers/MobilePushNew/index.scss +151 -4
- package/v2Containers/MobilePushNew/messages.js +106 -6
- package/v2Containers/MobilePushNew/tests/index.test.js +483 -1
- package/v2Containers/MobilePushNew/tests/utils.test.js +110 -0
- package/v2Containers/MobilePushNew/utils.js +83 -0
- package/v2Containers/Rcs/accountUtils.js +20 -0
- package/v2Containers/Rcs/index.js +18 -1
- package/v2Containers/Rcs/tests/accountUtils.test.js +24 -0
- package/v2Containers/Rcs/tests/index.test.js +23 -0
- package/v2Containers/Templates/ChannelTypeIllustration.js +12 -0
- package/v2Containers/Templates/_templates.scss +10 -2
- package/v2Containers/Templates/index.js +94 -85
- package/v2Containers/Templates/messages.js +4 -0
- package/v2Containers/Templates/tests/ChannelTypeIllustration.test.js +14 -2
- package/v2Containers/Templates/tests/index.test.js +182 -0
|
@@ -1,4 +1,79 @@
|
|
|
1
1
|
import { isUrl } from "../Line/Container/Wrapper/utils";
|
|
2
|
+
import { VIDEO } from "./constants";
|
|
3
|
+
|
|
4
|
+
// Deep link option for a saved value; falls back to matching without query params
|
|
5
|
+
export const findSelectedDeepLink = (links, value) => {
|
|
6
|
+
if (!links || !value) return undefined;
|
|
7
|
+
const exactMatch = links.find((link) => link?.value === value);
|
|
8
|
+
if (exactMatch || !value.includes('?')) return exactMatch;
|
|
9
|
+
const baseDeepLinkValue = value.split('?')[0];
|
|
10
|
+
return links.find((link) => link?.value === baseDeepLinkValue);
|
|
11
|
+
};
|
|
12
|
+
|
|
13
|
+
// Deep link params are kept as "key=value" entries, e.g. "testing_purpose=androidDeeplink"
|
|
14
|
+
const toEntryArray = (entries) => {
|
|
15
|
+
if (Array.isArray(entries)) return entries;
|
|
16
|
+
return entries ? [entries] : [];
|
|
17
|
+
};
|
|
18
|
+
|
|
19
|
+
// Splits at the first "=". Old entries saved as just the key mean key=key
|
|
20
|
+
export const splitDeepLinkParam = (entry) => {
|
|
21
|
+
const text = String(entry ?? '');
|
|
22
|
+
const index = text.indexOf('=');
|
|
23
|
+
return index === -1 ? [text, text] : [text.slice(0, index), text.slice(index + 1)];
|
|
24
|
+
};
|
|
25
|
+
|
|
26
|
+
export const getDeepLinkParamValue = (entries, key) => {
|
|
27
|
+
const match = toEntryArray(entries).find((entry) => splitDeepLinkParam(entry)[0] === key);
|
|
28
|
+
return match === undefined ? '' : splitDeepLinkParam(match)[1];
|
|
29
|
+
};
|
|
30
|
+
|
|
31
|
+
// New entries after typing `value` for `key`, in configured-key order; empty values are dropped
|
|
32
|
+
export const setDeepLinkParamValue = (entries, configuredKeys, key, value) => toEntryArray(configuredKeys)
|
|
33
|
+
.map((configuredKey) => [configuredKey, configuredKey === key ? value : getDeepLinkParamValue(entries, configuredKey)])
|
|
34
|
+
.filter(([, paramValue]) => paramValue !== '' && paramValue !== undefined && paramValue !== null)
|
|
35
|
+
.map(([paramKey, paramValue]) => `${paramKey}=${paramValue}`);
|
|
36
|
+
|
|
37
|
+
export const hasAllDeepLinkParams = (entries, configuredKeys) => toEntryArray(configuredKeys)
|
|
38
|
+
.every((key) => getDeepLinkParamValue(entries, key).trim() !== '');
|
|
39
|
+
|
|
40
|
+
// Every "key=value" in the URL's query, raw (not decoded) so tags like {{x}} round-trip
|
|
41
|
+
export const extractDeepLinkParams = (url) => {
|
|
42
|
+
if (typeof url !== 'string' || !url.includes('?')) return [];
|
|
43
|
+
return url.slice(url.indexOf('?') + 1).split('&').filter((param) => param.indexOf('=') > 0);
|
|
44
|
+
};
|
|
45
|
+
|
|
46
|
+
// Adds the entries to the URL; a key already in the URL is replaced, not repeated
|
|
47
|
+
export const appendDeepLinkParams = (url, entries) => {
|
|
48
|
+
if (!url) return url;
|
|
49
|
+
const pairs = toEntryArray(entries)
|
|
50
|
+
.filter((entry) => typeof entry === 'string' && entry.length > 0)
|
|
51
|
+
.map(splitDeepLinkParam)
|
|
52
|
+
.filter(([key]) => key.length > 0);
|
|
53
|
+
if (pairs.length === 0) return url;
|
|
54
|
+
const keys = new Set(pairs.map(([key]) => key));
|
|
55
|
+
const queryIndex = url.indexOf('?');
|
|
56
|
+
const base = queryIndex === -1 ? url : url.slice(0, queryIndex);
|
|
57
|
+
const kept = queryIndex === -1 ? [] : url.slice(queryIndex + 1).split('&')
|
|
58
|
+
.filter((param) => param && !keys.has(splitDeepLinkParam(param)[0]));
|
|
59
|
+
const params = [...kept, ...pairs.map(([key, value]) => `${key}=${value}`)];
|
|
60
|
+
return `${base}?${params.join('&')}`;
|
|
61
|
+
};
|
|
62
|
+
|
|
63
|
+
export const CAROUSEL_CARD_ISSUE = {
|
|
64
|
+
MEDIA: 'media',
|
|
65
|
+
};
|
|
66
|
+
|
|
67
|
+
/**
|
|
68
|
+
* What a carousel card still needs before it can be saved. The notification tap is for the whole
|
|
69
|
+
* notification, so a card only needs its media.
|
|
70
|
+
* @param {Object} card - Editor carousel card
|
|
71
|
+
* @returns {string|null} - A CAROUSEL_CARD_ISSUE value, or null when the card is complete
|
|
72
|
+
*/
|
|
73
|
+
export const getCarouselCardIssue = (card) => {
|
|
74
|
+
const isMediaMissing = card?.mediaType === VIDEO.toLowerCase() ? !card?.videoSrc : !card?.imageUrl;
|
|
75
|
+
return isMediaMissing ? CAROUSEL_CARD_ISSUE.MEDIA : null;
|
|
76
|
+
};
|
|
2
77
|
|
|
3
78
|
/**
|
|
4
79
|
* Validate deep link format - supports custom schemes, HTTP/HTTPS, and relative paths
|
|
@@ -119,3 +194,11 @@ export const computeIsContentEmpty = ({
|
|
|
119
194
|
const isIosMissing = isPlatformFieldsMissing(isIosSupported, iosContent);
|
|
120
195
|
return (!isAndroidSupported || isAndroidMissing) && (!isIosSupported || isIosMissing);
|
|
121
196
|
};
|
|
197
|
+
|
|
198
|
+
// Android and iOS title + message joined, for the create GA event
|
|
199
|
+
export const getContent = (obj) => {
|
|
200
|
+
const base = obj?.versions?.base || {};
|
|
201
|
+
const android = base.ANDROID || {};
|
|
202
|
+
const ios = base.IOS || {};
|
|
203
|
+
return `${android.title || ''} ${android.message || ''} ${ios.title || ''} ${ios.message || ''}`;
|
|
204
|
+
};
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* RCS multi-account helpers.
|
|
3
|
+
*
|
|
4
|
+
* A saved RCS template stores its account in `rcsContent.accountId`: the WeCRM account's
|
|
5
|
+
* sourceAccountIdentifier (full mode) or its WeCRM id (library mode).
|
|
6
|
+
*/
|
|
7
|
+
|
|
8
|
+
const toTrimmedString = (value) => (value == null ? '' : String(value).trim());
|
|
9
|
+
|
|
10
|
+
/**
|
|
11
|
+
* Whether a WeCRM RCS account is the one referenced by a saved `rcsContent.accountId`.
|
|
12
|
+
* @param {Object} account - WeCRM RCS account ({ id, sourceAccountIdentifier, ... })
|
|
13
|
+
* @param {string|number} accountId - saved rcsContent.accountId
|
|
14
|
+
* @returns {boolean}
|
|
15
|
+
*/
|
|
16
|
+
export const isRcsAccountForAccountId = (account, accountId) => {
|
|
17
|
+
const id = toTrimmedString(accountId);
|
|
18
|
+
if (!account || !id) return false;
|
|
19
|
+
return [account.sourceAccountIdentifier, account.id].map(toTrimmedString).includes(id);
|
|
20
|
+
};
|
|
@@ -162,6 +162,7 @@ import {
|
|
|
162
162
|
checkSmsFallbackBlocksDone,
|
|
163
163
|
isSmsFallbackContentTooLong,
|
|
164
164
|
} from './utils';
|
|
165
|
+
import { isRcsAccountForAccountId } from './accountUtils';
|
|
165
166
|
import {
|
|
166
167
|
getCarouselImageAssetIndex,
|
|
167
168
|
getCarouselVideoAssetIndex,
|
|
@@ -374,6 +375,22 @@ export const Rcs = (props) => {
|
|
|
374
375
|
setSuggestions(isHostIcs ? INITIAL_SUGGESTIONS_DATA_STOP : []);
|
|
375
376
|
}, [isHostIcs]);
|
|
376
377
|
const [rcsAccount, setRcsAccount] = useState('');
|
|
378
|
+
|
|
379
|
+
/**
|
|
380
|
+
* Test & Preview options. `sourceAccountIdentifier` scopes RCS senders to this template's account
|
|
381
|
+
* (multi-account orgs). It is sent only when the selected account is the template's own account,
|
|
382
|
+
* so a stale selection from another account never narrows the sender list.
|
|
383
|
+
*/
|
|
384
|
+
const rcsTestPreviewOptions = useMemo(() => {
|
|
385
|
+
const selectedRcsAccount = accountData?.selectedRcsAccount;
|
|
386
|
+
const isSelectedAccountForTemplate = !isEmpty(selectedRcsAccount)
|
|
387
|
+
&& (!rcsAccount || isRcsAccountForAccountId(selectedRcsAccount, rcsAccount));
|
|
388
|
+
return {
|
|
389
|
+
isLibraryMode: !isFullMode,
|
|
390
|
+
...(isSelectedAccountForTemplate && accountId && { sourceAccountIdentifier: accountId }),
|
|
391
|
+
};
|
|
392
|
+
}, [isFullMode, accountData?.selectedRcsAccount, rcsAccount, accountId]);
|
|
393
|
+
|
|
377
394
|
useEffect(() => {
|
|
378
395
|
const accountObj = accountData.selectedRcsAccount || {};
|
|
379
396
|
if (!isEmpty(accountObj)) {
|
|
@@ -3507,7 +3524,7 @@ const onTitleAddVar = () => {
|
|
|
3507
3524
|
content={testAndPreviewContent}
|
|
3508
3525
|
currentChannel={RCS}
|
|
3509
3526
|
orgUnitId={orgUnitId}
|
|
3510
|
-
rcsTestPreviewOptions={
|
|
3527
|
+
rcsTestPreviewOptions={rcsTestPreviewOptions}
|
|
3511
3528
|
smsFallbackContent={
|
|
3512
3529
|
smsFallbackData && (smsFallbackData.templateContent || smsFallbackData.content)
|
|
3513
3530
|
? {
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
import { isRcsAccountForAccountId } from '../accountUtils';
|
|
2
|
+
|
|
3
|
+
describe('Rcs/accountUtils', () => {
|
|
4
|
+
describe('isRcsAccountForAccountId', () => {
|
|
5
|
+
const account = { id: 101, sourceAccountIdentifier: 'acc-A' };
|
|
6
|
+
|
|
7
|
+
it('matches sourceAccountIdentifier or WeCRM id', () => {
|
|
8
|
+
expect(isRcsAccountForAccountId(account, 'acc-A')).toBe(true);
|
|
9
|
+
expect(isRcsAccountForAccountId(account, 101)).toBe(true);
|
|
10
|
+
expect(isRcsAccountForAccountId(account, '101')).toBe(true);
|
|
11
|
+
expect(isRcsAccountForAccountId(account, ' acc-A ')).toBe(true);
|
|
12
|
+
});
|
|
13
|
+
|
|
14
|
+
it('does not match a different id', () => {
|
|
15
|
+
expect(isRcsAccountForAccountId(account, 'acc-B')).toBe(false);
|
|
16
|
+
});
|
|
17
|
+
|
|
18
|
+
it('returns false for empty id or account', () => {
|
|
19
|
+
expect(isRcsAccountForAccountId(account, '')).toBe(false);
|
|
20
|
+
expect(isRcsAccountForAccountId(account, undefined)).toBe(false);
|
|
21
|
+
expect(isRcsAccountForAccountId(null, 'acc-A')).toBe(false);
|
|
22
|
+
});
|
|
23
|
+
});
|
|
24
|
+
});
|
|
@@ -1663,6 +1663,29 @@ describe('botId in create payload', () => {
|
|
|
1663
1663
|
wrapper.update();
|
|
1664
1664
|
};
|
|
1665
1665
|
|
|
1666
|
+
it('passes the selected account sourceAccountIdentifier to Test & Preview (multi-account sender scoping)', () => {
|
|
1667
|
+
const wrapper = mountRcs({
|
|
1668
|
+
selectedRcsAccount: {
|
|
1669
|
+
id: 'acc-wecrm-1',
|
|
1670
|
+
sourceAccountIdentifier: 'acc-src-1',
|
|
1671
|
+
configs: { accessToken: 'token-1' },
|
|
1672
|
+
hostName: 'rcsvaluefirstbulk',
|
|
1673
|
+
name: 'Brand A',
|
|
1674
|
+
},
|
|
1675
|
+
});
|
|
1676
|
+
const slidebox = wrapper.find('TestAndPreviewSlidebox').at(0);
|
|
1677
|
+
expect(slidebox.props().rcsTestPreviewOptions).toEqual({
|
|
1678
|
+
isLibraryMode: false,
|
|
1679
|
+
sourceAccountIdentifier: 'acc-src-1',
|
|
1680
|
+
});
|
|
1681
|
+
});
|
|
1682
|
+
|
|
1683
|
+
it('does not scope Test & Preview senders when no account is selected', () => {
|
|
1684
|
+
const wrapper = mountRcs({});
|
|
1685
|
+
const slidebox = wrapper.find('TestAndPreviewSlidebox').at(0);
|
|
1686
|
+
expect(slidebox.props().rcsTestPreviewOptions).toEqual({ isLibraryMode: false });
|
|
1687
|
+
});
|
|
1688
|
+
|
|
1666
1689
|
it('includes botId from connectionProperties.agentid for ValueFirst accounts', async () => {
|
|
1667
1690
|
const createRcsTemplate = jest.fn();
|
|
1668
1691
|
const accountData = {
|
|
@@ -152,6 +152,18 @@ function ChannelTypeIllustration(props) {
|
|
|
152
152
|
};
|
|
153
153
|
}
|
|
154
154
|
|
|
155
|
+
// RCS (same as WhatsApp): no hostName means the selected account has no matching domain.
|
|
156
|
+
if (type === RCS && !hostName) {
|
|
157
|
+
return {
|
|
158
|
+
illustrationImage: whatsappOrZaloAccountIllustration,
|
|
159
|
+
title: <FormattedMessage {...messages.rcsAccountNotConfiguredTitle} />,
|
|
160
|
+
description: <FormattedMessage {...messages.accountNotConfiguredDescription} />,
|
|
161
|
+
descriptionPosition: 'bottom',
|
|
162
|
+
descriptionClassName: 'illustration-desc zalo-illustration',
|
|
163
|
+
buttonClassName: 'zalo-illustration-button',
|
|
164
|
+
};
|
|
165
|
+
}
|
|
166
|
+
|
|
155
167
|
if (type === WEBPUSH) {
|
|
156
168
|
return {
|
|
157
169
|
buttonLabel: <FormattedMessage {...messages.newWebPushTemplate} values={{ template: templateText }} />,
|
|
@@ -495,15 +495,23 @@
|
|
|
495
495
|
padding: $CAP_SPACE_08;
|
|
496
496
|
text-align: center;
|
|
497
497
|
display: flex;
|
|
498
|
-
flex-direction: column;
|
|
499
498
|
align-items: center;
|
|
500
499
|
justify-content: center;
|
|
501
500
|
gap: $CAP_SPACE_08;
|
|
501
|
+
// Same as the editor previews: one button centred, two as halves split by a divider
|
|
502
502
|
.action{
|
|
503
|
+
flex: 1 1 0;
|
|
504
|
+
min-width: 0;
|
|
505
|
+
white-space: nowrap;
|
|
506
|
+
overflow: hidden;
|
|
507
|
+
text-overflow: ellipsis;
|
|
503
508
|
font-size: $FONT_SIZE_S;
|
|
504
509
|
font-weight: 600;
|
|
505
|
-
color:
|
|
510
|
+
color: $FONT_COLOR_01;
|
|
506
511
|
height: 1.25rem;
|
|
512
|
+
& + .action {
|
|
513
|
+
border-left: 1px solid $CAP_G07;
|
|
514
|
+
}
|
|
507
515
|
}
|
|
508
516
|
}
|
|
509
517
|
}
|
|
@@ -164,7 +164,7 @@ import { makeSelectRcs } from '../Rcs/selectors';
|
|
|
164
164
|
import { getRcsStatusType } from '../Rcs/utils';
|
|
165
165
|
import { makeSelectWebPush } from '../WebPush/selectors';
|
|
166
166
|
import { v2MobilePushSagas } from '../MobilePushNew/sagas';
|
|
167
|
-
import { AUTO_CAROUSEL, BIG_PICTURE, FILMSTRIP_CAROUSEL, MANUAL_CAROUSEL } from '../MobilePushNew/constants';
|
|
167
|
+
import { AUTO_CAROUSEL, BIG_PICTURE, FILMSTRIP_CAROUSEL, MANUAL_CAROUSEL, VIDEO as MPUSH_VIDEO } from '../MobilePushNew/constants';
|
|
168
168
|
import CapPageSpinner from '../../v2Components/CapPageSpinner';
|
|
169
169
|
import webPushSagas from '../WebPush/sagas';
|
|
170
170
|
import { DLT_LEGACY_VAR_REGEX } from '../SmsTrai/Edit/dltVarTypes';
|
|
@@ -1426,14 +1426,21 @@ export class Templates extends React.Component { // eslint-disable-line react/pr
|
|
|
1426
1426
|
|
|
1427
1427
|
const expandableDetailsAndroid = androidContent.expandableDetails || {};
|
|
1428
1428
|
const expandableDetailsIos = iosContent.expandableDetails || {};
|
|
1429
|
+
// Saved media[0] is { url, type, videoPreviewUrl }; the preview reads { videoSrc, videoPreview }
|
|
1430
|
+
const toPreviewVideo = (media) => {
|
|
1431
|
+
const { type, url, videoPreviewUrl } = media?.[0] || {};
|
|
1432
|
+
return type === MPUSH_VIDEO && url ? { videoSrc: url, videoPreview: videoPreviewUrl || '' } : {};
|
|
1433
|
+
};
|
|
1429
1434
|
// Extract Android content
|
|
1430
1435
|
const androidPreview = {
|
|
1431
1436
|
header: androidContent.title || '',
|
|
1432
1437
|
bodyText: androidContent.message || '',
|
|
1433
1438
|
bodyImage: expandableDetailsAndroid.image || '',
|
|
1434
|
-
bodyVideo: expandableDetailsAndroid.media
|
|
1439
|
+
bodyVideo: toPreviewVideo(expandableDetailsAndroid.media),
|
|
1435
1440
|
bodyGif: '',
|
|
1436
1441
|
actions: expandableDetailsAndroid.ctas || [],
|
|
1442
|
+
// Notification tap, read by the test send
|
|
1443
|
+
cta: androidContent.cta,
|
|
1437
1444
|
carouselData: expandableDetailsAndroid.carouselData || [],
|
|
1438
1445
|
};
|
|
1439
1446
|
|
|
@@ -1442,9 +1449,10 @@ export class Templates extends React.Component { // eslint-disable-line react/pr
|
|
|
1442
1449
|
header: iosContent.title || '',
|
|
1443
1450
|
bodyText: iosContent.message || '',
|
|
1444
1451
|
bodyImage: expandableDetailsIos.image || '',
|
|
1445
|
-
bodyVideo: expandableDetailsIos.media
|
|
1452
|
+
bodyVideo: toPreviewVideo(expandableDetailsIos.media),
|
|
1446
1453
|
bodyGif: '',
|
|
1447
1454
|
actions: expandableDetailsIos.ctas || [],
|
|
1455
|
+
cta: iosContent.cta,
|
|
1448
1456
|
carouselData: expandableDetailsIos.carouselData || [],
|
|
1449
1457
|
};
|
|
1450
1458
|
|
|
@@ -2135,7 +2143,8 @@ export class Templates extends React.Component { // eslint-disable-line react/pr
|
|
|
2135
2143
|
isTraiDltFeature = this.checkDLTfeatureEnable();
|
|
2136
2144
|
break;
|
|
2137
2145
|
case RCS:
|
|
2138
|
-
|
|
2146
|
+
// Same as WhatsApp: no hostName means the account's domain is not configured, so no templates are shown.
|
|
2147
|
+
filteredTemplates = this.state?.hostName ? this.filterRcsTemplates(templates) : [];
|
|
2139
2148
|
break;
|
|
2140
2149
|
case ZALO:
|
|
2141
2150
|
filteredTemplates = this.filterZaloTemplates(templates);
|
|
@@ -2405,94 +2414,91 @@ export class Templates extends React.Component { // eslint-disable-line react/pr
|
|
|
2405
2414
|
}
|
|
2406
2415
|
break;
|
|
2407
2416
|
}
|
|
2408
|
-
case MOBILE_PUSH:
|
|
2409
|
-
|
|
2410
|
-
|
|
2411
|
-
|
|
2412
|
-
|
|
2413
|
-
|
|
2414
|
-
|
|
2415
|
-
|
|
2416
|
-
|
|
2417
|
-
|
|
2418
|
-
|
|
2419
|
-
|
|
2420
|
-
|
|
2421
|
-
|
|
2422
|
-
|
|
2423
|
-
|
|
2424
|
-
<div className="app-header-left">
|
|
2425
|
-
<span className="app-icon">{""}</span>
|
|
2426
|
-
<CapLabel type="label4">{title}</CapLabel>
|
|
2427
|
-
</div>
|
|
2417
|
+
case MOBILE_PUSH: {
|
|
2418
|
+
const mpushData = get(template, 'versions.base', template);
|
|
2419
|
+
const androidData = get(mpushData, 'ANDROID') || get(mpushData, 'androidContent');
|
|
2420
|
+
const iosData = get(mpushData, 'IOS') || get(mpushData, 'iosContent');
|
|
2421
|
+
let mpushListingData = androidData;
|
|
2422
|
+
if (isEmpty(androidData) || !androidData?.title) {
|
|
2423
|
+
mpushListingData = iosData;
|
|
2424
|
+
};
|
|
2425
|
+
const { title, message, expandableDetails: { style = '', image, carouselData = [], ctas = [], media = [] } = {} } = mpushListingData || {};
|
|
2426
|
+
const {url = ''} = media?.[0] || {};
|
|
2427
|
+
templateData.content = (
|
|
2428
|
+
<div className='mobilepush-container'>
|
|
2429
|
+
<div className="app-header">
|
|
2430
|
+
<div className="app-header-left">
|
|
2431
|
+
<span className="app-icon">{""}</span>
|
|
2432
|
+
<CapLabel type="label4">{title}</CapLabel>
|
|
2428
2433
|
</div>
|
|
2429
|
-
|
|
2430
|
-
|
|
2431
|
-
|
|
2432
|
-
|
|
2433
|
-
|
|
2434
|
-
|
|
2435
|
-
|
|
2436
|
-
|
|
2437
|
-
|
|
2438
|
-
|
|
2439
|
-
|
|
2440
|
-
|
|
2434
|
+
</div>
|
|
2435
|
+
<CapLabel className="mobilepush-message" type="label1">{message}</CapLabel>
|
|
2436
|
+
{style === BIG_PICTURE && (
|
|
2437
|
+
<CapImage src={image} className="mobilepush-image mobilepush-image-padding" />
|
|
2438
|
+
)}
|
|
2439
|
+
{style === VIDEO && (
|
|
2440
|
+
<div className="video-preview">
|
|
2441
|
+
<video aria-label="Template video preview" controls={false} tabIndex="0">
|
|
2442
|
+
<source src={url} type="video/mp4" />
|
|
2443
|
+
</video>
|
|
2444
|
+
<div className="icon-position">
|
|
2445
|
+
<CapImage className="video-icon" src={videoPlay} />
|
|
2441
2446
|
</div>
|
|
2442
|
-
|
|
2443
|
-
|
|
2444
|
-
|
|
2445
|
-
|
|
2446
|
-
|
|
2447
|
-
|
|
2448
|
-
|
|
2449
|
-
|
|
2450
|
-
|
|
2451
|
-
|
|
2452
|
-
|
|
2453
|
-
|
|
2447
|
+
</div>
|
|
2448
|
+
)}
|
|
2449
|
+
{[MANUAL_CAROUSEL, AUTO_CAROUSEL, FILMSTRIP_CAROUSEL].includes(style) && (
|
|
2450
|
+
<div className="scroll-container">
|
|
2451
|
+
{carouselData?.map((data, index) => {
|
|
2452
|
+
return (
|
|
2453
|
+
<div
|
|
2454
|
+
key={`carousel-${index + 1}`}
|
|
2455
|
+
className="whatsapp-carousel-container"
|
|
2456
|
+
role="group"
|
|
2457
|
+
>
|
|
2458
|
+
<div className="whatsapp-carousel-card">
|
|
2459
|
+
{data?.mediaType === IMAGE.toLowerCase() && (
|
|
2460
|
+
<CapImage
|
|
2461
|
+
src={data?.imageUrl ? data?.imageUrl : data?.url ? data?.url : whatsappImageEmptyPreview}
|
|
2462
|
+
className="whatsapp-image"
|
|
2463
|
+
/>
|
|
2464
|
+
)}
|
|
2465
|
+
{data?.mediaType === VIDEO.toLowerCase() && (
|
|
2466
|
+
<div className="video-preview">
|
|
2454
2467
|
<CapImage
|
|
2455
|
-
src={data?.
|
|
2468
|
+
src={data?.videoPreviewImg ? data?.videoPreviewImg : data?.url ? data?.url : whatsappVideoEmptyPreview}
|
|
2456
2469
|
className="whatsapp-image"
|
|
2457
2470
|
/>
|
|
2458
|
-
|
|
2459
|
-
{data?.mediaType === VIDEO.toLowerCase() && (
|
|
2460
|
-
<div className="video-preview">
|
|
2471
|
+
<div className="icon-position">
|
|
2461
2472
|
<CapImage
|
|
2462
|
-
|
|
2463
|
-
|
|
2473
|
+
className="video-icon"
|
|
2474
|
+
src={videoPlay}
|
|
2464
2475
|
/>
|
|
2465
|
-
<div className="icon-position">
|
|
2466
|
-
<CapImage
|
|
2467
|
-
className="video-icon"
|
|
2468
|
-
src={videoPlay}
|
|
2469
|
-
/>
|
|
2470
|
-
</div>
|
|
2471
2476
|
</div>
|
|
2472
|
-
|
|
2473
|
-
|
|
2474
|
-
|
|
2475
|
-
|
|
2476
|
-
|
|
2477
|
-
|
|
2478
|
-
)}
|
|
2479
|
-
{ctas.length > 0 && (
|
|
2480
|
-
<div className="actions">
|
|
2481
|
-
{ctas.map((cta) => (
|
|
2482
|
-
<span
|
|
2483
|
-
className="action"
|
|
2484
|
-
key={`action-${cta?.actionText}`}
|
|
2485
|
-
>
|
|
2486
|
-
{cta?.actionText && cta?.actionText.toUpperCase()}
|
|
2487
|
-
</span>
|
|
2488
|
-
))}
|
|
2489
|
-
</div>
|
|
2490
|
-
)}
|
|
2477
|
+
</div>
|
|
2478
|
+
)}
|
|
2479
|
+
</div>
|
|
2480
|
+
</div>
|
|
2481
|
+
)
|
|
2482
|
+
})}
|
|
2491
2483
|
</div>
|
|
2492
|
-
|
|
2493
|
-
|
|
2494
|
-
|
|
2484
|
+
)}
|
|
2485
|
+
{ctas.length > 0 && (
|
|
2486
|
+
<CapRow type="flex" align="middle" justify="center" className="actions">
|
|
2487
|
+
{ctas.map((cta, index) => (
|
|
2488
|
+
<CapLabel.CapLabelInline
|
|
2489
|
+
className="action"
|
|
2490
|
+
key={`action-${index}`}
|
|
2491
|
+
>
|
|
2492
|
+
{cta?.actionText}
|
|
2493
|
+
</CapLabel.CapLabelInline>
|
|
2494
|
+
))}
|
|
2495
|
+
</CapRow>
|
|
2496
|
+
)}
|
|
2497
|
+
</div>
|
|
2498
|
+
);
|
|
2499
|
+
templateData.isNewMobilePush = true;
|
|
2495
2500
|
break;
|
|
2501
|
+
}
|
|
2496
2502
|
case INAPP: {
|
|
2497
2503
|
// Pass the full template object to CapCustomCard so getInAppContent can extract the data
|
|
2498
2504
|
// Similar to how MOBILE_PUSH passes the full template when new feature is enabled
|
|
@@ -2929,6 +2935,9 @@ export class Templates extends React.Component { // eslint-disable-line react/pr
|
|
|
2929
2935
|
const noApprovedWhatsappZaloTemplates = filteredEmptyAndFullModeAs(false) && !isEmpty(this.state?.hostName);
|
|
2930
2936
|
const showWhatsappIllustration = accountWithNoHostWhatsapp(WHATSAPP_LOWERCASE);
|
|
2931
2937
|
const showZaloIllustration = accountWithNoHostZalo(ZALO_LOWERCASE)
|
|
2938
|
+
// RCS (same as WhatsApp): the selected account has no matching domain, so it is not configured.
|
|
2939
|
+
const showRcsAccountNotConfigured = channelLowerCase === RCS_LOWERCASE && !this.state?.hostName
|
|
2940
|
+
&& isEmpty(this.state.searchText) && !isLoading && !get(this.props, 'Templates.isArchivedMode', false);
|
|
2932
2941
|
|
|
2933
2942
|
const noLoaderAndSearchText = isEmpty(this.state.searchText) && !isLoading;
|
|
2934
2943
|
|
|
@@ -3022,10 +3031,10 @@ export class Templates extends React.Component { // eslint-disable-line react/pr
|
|
|
3022
3031
|
</div>
|
|
3023
3032
|
)
|
|
3024
3033
|
}
|
|
3025
|
-
{showIllustrationForChannel(RCS_LOWERCASE) &&
|
|
3034
|
+
{(showIllustrationForChannel(RCS_LOWERCASE) || showRcsAccountNotConfigured) &&
|
|
3026
3035
|
<div style={this.isFullMode() ? { height: "calc(100vh - 325px)", overflow: 'auto' } : {}}>
|
|
3027
|
-
<ChannelTypeIllustration isFullMode={this.props.isFullMode} createTemplate={this.createTemplate} canCreate={this.canPerform(PERMISSIONS.CREATIVE_CREATE)} currentChannel={currentChannel}/>
|
|
3028
|
-
{filteredEmptyAndFullModeAs(false) && this.whatsappZaloIllustrationText(noApprovedRcsTemplatesTitle, noApprovedRcsTemplatesDesc)}
|
|
3036
|
+
<ChannelTypeIllustration isFullMode={this.props.isFullMode} createTemplate={this.createTemplate} canCreate={this.canPerform(PERMISSIONS.CREATIVE_CREATE)} currentChannel={currentChannel} hostName={this.state?.hostName}/>
|
|
3037
|
+
{!showRcsAccountNotConfigured && filteredEmptyAndFullModeAs(false) && this.whatsappZaloIllustrationText(noApprovedRcsTemplatesTitle, noApprovedRcsTemplatesDesc)}
|
|
3029
3038
|
</div>
|
|
3030
3039
|
}
|
|
3031
3040
|
{showIllustrationForChannel(INAPP_LOWERCASE) &&
|
|
@@ -410,6 +410,10 @@ export default defineMessages({
|
|
|
410
410
|
id: `${scope}.accountNotConfiguredDescription`,
|
|
411
411
|
defaultMessage: 'Please contact your Customer Success Manager to fix the issue.',
|
|
412
412
|
},
|
|
413
|
+
"rcsAccountNotConfiguredTitle": {
|
|
414
|
+
id: `${scope}.rcsAccountNotConfiguredTitle`,
|
|
415
|
+
defaultMessage: 'RCS account is not configured',
|
|
416
|
+
},
|
|
413
417
|
"zaloAccountNotConfiguredTitle": {
|
|
414
418
|
id: `${scope}.zaloAccountNotConfiguredTitle`,
|
|
415
419
|
defaultMessage: 'Zalo account is not configured',
|
|
@@ -152,8 +152,8 @@ describe('ChannelTypeIllustration', () => {
|
|
|
152
152
|
});
|
|
153
153
|
|
|
154
154
|
describe('RCS Channel', () => {
|
|
155
|
-
it('should return correct illustration info for RCS channel', () => {
|
|
156
|
-
const component = renderComponent({ currentChannel: RCS });
|
|
155
|
+
it('should return correct illustration info for RCS channel when hostName is available', () => {
|
|
156
|
+
const component = renderComponent({ currentChannel: RCS, hostName: 'ics' });
|
|
157
157
|
const capIllustration = component.find('CapIllustration');
|
|
158
158
|
|
|
159
159
|
expect(capIllustration.prop('illustrationImage')).toBe('test-file-stub');
|
|
@@ -164,6 +164,18 @@ describe('ChannelTypeIllustration', () => {
|
|
|
164
164
|
expect(capIllustration.prop('descriptionPosition')).toBe('bottom');
|
|
165
165
|
expect(capIllustration.prop('descriptionClassName')).toBe('illustration-desc rcs-illustration');
|
|
166
166
|
});
|
|
167
|
+
|
|
168
|
+
it('should return account not configured info for RCS when hostName is not available (same as WhatsApp)', () => {
|
|
169
|
+
const component = renderComponent({ currentChannel: RCS, hostName: '' });
|
|
170
|
+
const capIllustration = component.find('CapIllustration');
|
|
171
|
+
|
|
172
|
+
expect(capIllustration.prop('title').props.id).toBe('creatives.containersV2.Templates.rcsAccountNotConfiguredTitle');
|
|
173
|
+
expect(capIllustration.prop('description').props.id).toBe('creatives.containersV2.Templates.accountNotConfiguredDescription');
|
|
174
|
+
expect(capIllustration.prop('descriptionClassName')).toBe('illustration-desc zalo-illustration');
|
|
175
|
+
expect(capIllustration.prop('buttonClassName')).toBe('zalo-illustration-button');
|
|
176
|
+
expect(capIllustration.prop('onClick')).toBeUndefined();
|
|
177
|
+
expect(capIllustration.prop('buttonLabel')).toBeUndefined();
|
|
178
|
+
});
|
|
167
179
|
});
|
|
168
180
|
|
|
169
181
|
describe('ZALO Channel', () => {
|