@capillarytech/creatives-library 9.0.15-alpha.3 → 9.0.16-beta.0
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/AppRoot.js +80 -0
- package/app.js +5 -3
- package/constants/unified.js +0 -29
- package/entry.js +67 -1
- package/global-styles.js +1 -1
- package/mfe-exposed-components.js +2 -4
- package/package.json +2 -2
- package/services/api.js +1 -1
- package/services/tests/api.test.js +20 -35
- package/styles/containers/layout/_layoutPage.scss +8 -6
- package/utils/commonUtils.js +1 -19
- package/utils/getDataLayer.js +15 -0
- package/utils/gtmTrackers/gtmEvents/creativeDetails.js +2 -1
- package/utils/mfeDetect.js +1 -0
- package/v2Components/CapActionButton/constants.js +1 -8
- package/v2Components/CapActionButton/index.js +144 -202
- package/v2Components/CapActionButton/index.scss +14 -232
- package/v2Components/CapActionButton/messages.js +3 -19
- package/v2Components/CapActionButton/tests/index.test.js +18 -42
- package/v2Components/CapImageUpload/index.js +2 -2
- package/v2Components/CapTagList/index.js +0 -10
- package/v2Components/CommonTestAndPreview/CustomValuesEditor.js +48 -70
- package/v2Components/CommonTestAndPreview/DeliverySettings/DeliverySettings.scss +2 -8
- package/v2Components/CommonTestAndPreview/DeliverySettings/ModifyDeliverySettings.js +21 -214
- package/v2Components/CommonTestAndPreview/DeliverySettings/constants.js +0 -16
- package/v2Components/CommonTestAndPreview/DeliverySettings/index.js +9 -83
- package/v2Components/CommonTestAndPreview/DeliverySettings/messages.js +0 -30
- package/v2Components/CommonTestAndPreview/DeliverySettings/utils/parseSenderDetailsResponse.js +11 -60
- package/v2Components/CommonTestAndPreview/SendTestMessage.js +5 -10
- package/v2Components/CommonTestAndPreview/UnifiedPreview/RcsPreviewContent.js +22 -202
- package/v2Components/CommonTestAndPreview/UnifiedPreview/_unifiedPreview.scss +80 -381
- package/v2Components/CommonTestAndPreview/UnifiedPreview/index.js +8 -155
- package/v2Components/CommonTestAndPreview/_commonTestAndPreview.scss +0 -11
- package/v2Components/CommonTestAndPreview/constants.js +2 -38
- package/v2Components/CommonTestAndPreview/index.js +222 -761
- package/v2Components/CommonTestAndPreview/messages.js +3 -45
- package/v2Components/CommonTestAndPreview/sagas.js +6 -25
- package/v2Components/CommonTestAndPreview/tests/CommonTestAndPreview.addTestCustomer.test.js +0 -1
- package/v2Components/CommonTestAndPreview/tests/CustomValuesEditor.test.js +267 -284
- 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/PreviewSection.test.js +1 -8
- package/v2Components/CommonTestAndPreview/tests/SendTestMessage.test.js +13 -34
- package/v2Components/CommonTestAndPreview/tests/UnifiedPreview/RcsPreviewContent.test.js +283 -281
- package/v2Components/CommonTestAndPreview/tests/UnifiedPreview/index.test.js +1 -199
- package/v2Components/CommonTestAndPreview/tests/index.test.js +4 -133
- package/v2Components/CommonTestAndPreview/tests/sagas.test.js +24 -31
- package/v2Components/NavigationBar/index.js +9 -7
- package/v2Components/NavigationBar/mfeModuleHeader.config.js +16 -0
- package/v2Components/Pagination/_pagination.scss +2 -0
- package/v2Components/TemplatePreview/_templatePreview.scss +25 -45
- package/v2Components/TemplatePreview/index.js +32 -147
- package/v2Components/TemplatePreview/tests/index.test.js +0 -142
- package/v2Components/TestAndPreviewSlidebox/CustomValuesEditor.js +6 -6
- package/v2Components/TestAndPreviewSlidebox/index.js +1 -13
- package/v2Components/TestAndPreviewSlidebox/sagas.js +4 -11
- package/v2Components/TestAndPreviewSlidebox/tests/saga.test.js +1 -3
- package/v2Containers/Cap/constants.js +1 -0
- package/v2Containers/Cap/index.js +47 -21
- package/v2Containers/Cap/sagas.js +19 -0
- package/v2Containers/CommunicationFlow/Tests/CommunicationFlow.test.js +1 -4
- package/v2Containers/CommunicationFlow/steps/DeliverySettingsStep/Tests/DeliverySettingsSection.test.js +0 -4
- package/v2Containers/CommunicationFlow/steps/DeliverySettingsStep/Tests/SenderDetails.test.js +20 -20
- package/v2Containers/CreativesContainer/SlideBoxContent.js +7 -37
- package/v2Containers/CreativesContainer/SlideBoxFooter.js +5 -14
- package/v2Containers/CreativesContainer/SlideBoxHeader.js +5 -36
- package/v2Containers/CreativesContainer/constants.js +0 -11
- package/v2Containers/CreativesContainer/index.js +104 -323
- package/v2Containers/CreativesContainer/index.scss +1 -83
- package/v2Containers/CreativesContainer/tests/SlideBoxFooter.test.js +34 -79
- 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 +90 -333
- package/v2Containers/CreativesContainer/tests/__snapshots__/index.test.js.snap +15 -20
- package/v2Containers/CreativesContainer/tests/index.test.js +9 -71
- package/v2Containers/MobilePush/Create/test/saga.test.js +2 -2
- package/v2Containers/Rcs/constants.js +11 -131
- package/v2Containers/Rcs/index.js +829 -2682
- package/v2Containers/Rcs/index.scss +8 -443
- package/v2Containers/Rcs/messages.js +6 -45
- package/v2Containers/Rcs/tests/__snapshots__/index.test.js.snap +39409 -74176
- package/v2Containers/Rcs/tests/__snapshots__/utils.test.js.snap +74 -10
- package/v2Containers/Rcs/tests/index.test.js +40 -151
- package/v2Containers/Rcs/tests/mockData.js +0 -38
- package/v2Containers/Rcs/tests/utils.test.js +30 -643
- package/v2Containers/Rcs/utils.js +12 -466
- package/v2Containers/Sms/Create/index.js +48 -115
- package/v2Containers/SmsTrai/Create/index.js +4 -9
- package/v2Containers/SmsTrai/Edit/constants.js +0 -2
- package/v2Containers/SmsTrai/Edit/index.js +169 -678
- package/v2Containers/SmsTrai/Edit/messages.js +4 -14
- package/v2Containers/SmsTrai/Edit/tests/__snapshots__/index.test.js.snap +2854 -5455
- package/v2Containers/SmsWrapper/index.js +8 -37
- package/v2Containers/TagList/index.js +0 -6
- package/v2Containers/Templates/_templates.scss +11 -196
- package/v2Containers/Templates/actions.js +0 -11
- package/v2Containers/Templates/constants.js +0 -2
- package/v2Containers/Templates/index.js +60 -131
- package/v2Containers/Templates/sagas.js +13 -57
- package/v2Containers/Templates/tests/__snapshots__/index.test.js.snap +1015 -1060
- package/v2Containers/Templates/tests/sagas.test.js +16 -199
- package/v2Containers/TemplatesV2/TemplatesV2.style.js +10 -75
- package/v2Containers/TemplatesV2/index.js +43 -86
- package/v2Containers/WeChat/MapTemplates/test/saga.test.js +9 -9
- package/v2Containers/Whatsapp/index.js +25 -4
- package/v2Containers/Whatsapp/tests/__snapshots__/index.test.js.snap +34 -578
- package/utils/rcsPayloadUtils.js +0 -92
- package/utils/templateVarUtils.js +0 -201
- package/utils/tests/rcsPayloadUtils.test.js +0 -226
- package/utils/tests/templateVarUtils.test.js +0 -204
- package/v2Components/CommonTestAndPreview/previewApiUtils.js +0 -59
- package/v2Components/CommonTestAndPreview/tests/previewApiUtils.test.js +0 -67
- package/v2Components/CommonTestAndPreview/utils.js +0 -84
- package/v2Components/SmsFallback/SmsFallbackLocalSelector.js +0 -91
- package/v2Components/SmsFallback/constants.js +0 -94
- package/v2Components/SmsFallback/index.js +0 -958
- package/v2Components/SmsFallback/index.scss +0 -266
- package/v2Components/SmsFallback/messages.js +0 -78
- package/v2Components/SmsFallback/smsFallbackUtils.js +0 -120
- 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 -208
- package/v2Components/SmsFallback/tests/smsFallbackUtils.test.js +0 -309
- package/v2Components/SmsFallback/tests/useLocalTemplateList.test.js +0 -422
- package/v2Components/SmsFallback/useLocalTemplateList.js +0 -92
- package/v2Components/TemplatePreview/constants.js +0 -2
- 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 -17
- package/v2Containers/CreativesContainer/embeddedSlideboxUtils.js +0 -79
- 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 -227
- package/v2Containers/Rcs/tests/rcsLibraryHydrationUtils.test.js +0 -318
- package/v2Containers/Sms/smsFormDataHelpers.js +0 -67
- package/v2Containers/Sms/tests/smsFormDataHelpers.test.js +0 -253
- package/v2Containers/SmsTrai/Edit/index.scss +0 -126
- 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
|
@@ -126,7 +126,7 @@ import { INAPP_LAYOUT_DETAILS, INAPP_MESSAGE_LAYOUT_TYPES } from '../InApp/const
|
|
|
126
126
|
import { ZALO_STATUS_OPTIONS, ZALO_STATUSES } from '../Zalo/constants';
|
|
127
127
|
import { getWhatsappContent, getWhatsappStatus, getWhatsappCategory, getWhatsappCta, getWhatsappQuickReply, getWhatsappAutoFill, getWhatsappCarouselButtonView, getWhatsappDocPreview } from '../Whatsapp/utils';
|
|
128
128
|
import { getRCSContent } from '../Rcs/utils';
|
|
129
|
-
import {
|
|
129
|
+
import {RCS_STATUSES} from '../Rcs/constants';
|
|
130
130
|
import zaloMessages from '../Zalo/messages';
|
|
131
131
|
import rcsMessages from '../Rcs/messages';
|
|
132
132
|
import inAppMessages from '../InApp/messages';
|
|
@@ -432,13 +432,8 @@ export class Templates extends React.Component { // eslint-disable-line react/pr
|
|
|
432
432
|
channel = '';
|
|
433
433
|
}
|
|
434
434
|
this.setState({ channel, activeMode });
|
|
435
|
-
// Always reset archive mode and selection when mounting a new channel
|
|
436
|
-
|
|
437
|
-
// Templates.templates in the reducer, which would wipe the background RCS template list.
|
|
438
|
-
const useLocalTemplatesOnMount = get(this.props, 'localTemplatesConfig.useLocalTemplates', false);
|
|
439
|
-
if (!useLocalTemplatesOnMount) {
|
|
440
|
-
this.props.actions.setArchivedMode(false);
|
|
441
|
-
}
|
|
435
|
+
// Always reset archive mode and selection when mounting a new channel
|
|
436
|
+
this.props.actions.setArchivedMode(false);
|
|
442
437
|
this.props.actions.clearTemplateSelection();
|
|
443
438
|
// Clear templates when entering account selection mode to prevent showing old channel templates
|
|
444
439
|
if (activeMode === ACCOUNT_SELECTION_MODE) {
|
|
@@ -471,13 +466,7 @@ export class Templates extends React.Component { // eslint-disable-line react/pr
|
|
|
471
466
|
if (this.props.location.query.type === 'embedded') {
|
|
472
467
|
this.props.actions.resetAccount();
|
|
473
468
|
}
|
|
474
|
-
|
|
475
|
-
const useLocalTemplates = get(
|
|
476
|
-
this.props,
|
|
477
|
-
'localTemplatesConfig.useLocalTemplates',
|
|
478
|
-
get(this.props, 'useLocalTemplates', false),
|
|
479
|
-
);
|
|
480
|
-
if (!useLocalTemplates && [LINE_LOWERCASE, VIBER_CHANNEL, FACEBOOK_CHANNEL, SMS_LOWERCASE, EMAIL_LOWERCASE, EBILL_LOWERCASE].includes((this.state.channel || '').toLowerCase())) {
|
|
469
|
+
if (['line', VIBER_CHANNEL, FACEBOOK_CHANNEL, 'sms', 'email', 'ebill'].includes((this.state.channel || '').toLowerCase())) {
|
|
481
470
|
const queryParams = {
|
|
482
471
|
// name: this.state.searchText,
|
|
483
472
|
// sortBy: this.state.sortBy,
|
|
@@ -560,7 +549,7 @@ export class Templates extends React.Component { // eslint-disable-line react/pr
|
|
|
560
549
|
selectedTemplateForPreview: null,
|
|
561
550
|
testAndPreviewContent: null,
|
|
562
551
|
}, () => {
|
|
563
|
-
if ([
|
|
552
|
+
if (['line', VIBER_CHANNEL, FACEBOOK_CHANNEL, 'sms', 'email', 'ebill', RCS_LOWERCASE].includes(this.state.channel.toLowerCase()) || (this.state.channel.toLowerCase() === 'wechat' && !isEmpty(nextProps.Templates.selectedWeChatAccount))) {
|
|
564
553
|
if (this.state.channel.toLowerCase() === 'wechat' && !isEmpty(nextProps.Templates.selectedWeChatAccount)) {
|
|
565
554
|
params.wecrmId = (nextProps.Templates.selectedWeChatAccount.configs || {}).wecrm_app_id;
|
|
566
555
|
params.wecrmToken = (nextProps.Templates.selectedWeChatAccount.configs || {}).wecrm_token;
|
|
@@ -1023,16 +1012,8 @@ export class Templates extends React.Component { // eslint-disable-line react/pr
|
|
|
1023
1012
|
|
|
1024
1013
|
componentWillUnmount() {
|
|
1025
1014
|
window.removeEventListener("message", this.handleFrameTasks);
|
|
1026
|
-
|
|
1027
|
-
|
|
1028
|
-
this.props,
|
|
1029
|
-
'localTemplatesConfig.useLocalTemplates',
|
|
1030
|
-
get(this.props, 'useLocalTemplates', false),
|
|
1031
|
-
);
|
|
1032
|
-
if (!useLocalTemplates) {
|
|
1033
|
-
this.props.actions.resetTemplateStoreData();
|
|
1034
|
-
this.props.globalActions.clearMetaEntities();
|
|
1035
|
-
}
|
|
1015
|
+
this.props.actions.resetTemplateStoreData();
|
|
1016
|
+
this.props.globalActions.clearMetaEntities();
|
|
1036
1017
|
// Clear any pending timeouts to prevent memory leaks
|
|
1037
1018
|
if (this._clearEditTimeout) {
|
|
1038
1019
|
clearTimeout(this._clearEditTimeout);
|
|
@@ -1889,20 +1870,12 @@ export class Templates extends React.Component { // eslint-disable-line react/pr
|
|
|
1889
1870
|
}
|
|
1890
1871
|
|
|
1891
1872
|
filterRcsTemplates = (templates) => {
|
|
1892
|
-
|
|
1893
|
-
|
|
1894
|
-
|
|
1895
|
-
|
|
1896
|
-
nextTemplates = nextTemplates.filter(
|
|
1897
|
-
(t) => get(t, 'versions.base.content.RCS.rcsContent.accountName', '') === selectedRcsAccountName
|
|
1898
|
-
);
|
|
1873
|
+
let { selectedRcsStatus } = this.state;
|
|
1874
|
+
selectedRcsStatus = !this.props.isFullMode ? RCS_STATUSES.approved : '';
|
|
1875
|
+
if (selectedRcsStatus) {
|
|
1876
|
+
return templates?.filter((template) => template?.versions?.base?.content?.RCS?.rcsContent?.cardContent?.[0]?.Status === selectedRcsStatus);
|
|
1899
1877
|
}
|
|
1900
|
-
|
|
1901
|
-
return nextTemplates.filter(
|
|
1902
|
-
(t) => get(t, 'versions.base.content.RCS.rcsContent.cardContent[0].Status', 'unavailable') === RCS_STATUSES.approved
|
|
1903
|
-
);
|
|
1904
|
-
}
|
|
1905
|
-
return nextTemplates;
|
|
1878
|
+
return templates;
|
|
1906
1879
|
}
|
|
1907
1880
|
|
|
1908
1881
|
filterZaloTemplates = (templates) => {
|
|
@@ -2092,7 +2065,7 @@ export class Templates extends React.Component { // eslint-disable-line react/pr
|
|
|
2092
2065
|
style={{ marginRight: "16px" }}
|
|
2093
2066
|
type="eye"
|
|
2094
2067
|
onClick={() => {
|
|
2095
|
-
if (!this.props.isFullMode || this.props.isDltFromRcs
|
|
2068
|
+
if (!this.props.isFullMode || this.props.isDltFromRcs) {
|
|
2096
2069
|
if (!get(template, "versions.base.content.zalo.previewUrl", "")) {
|
|
2097
2070
|
this.setState({ zaloPreviewItemId: template?._id });
|
|
2098
2071
|
}
|
|
@@ -2572,20 +2545,17 @@ export class Templates extends React.Component { // eslint-disable-line react/pr
|
|
|
2572
2545
|
const name = get(template, "name", "");
|
|
2573
2546
|
const statusDisplay=getRcsStatusType(status);
|
|
2574
2547
|
templateData.title = (
|
|
2575
|
-
<
|
|
2576
|
-
|
|
2577
|
-
|
|
2578
|
-
|
|
2579
|
-
</CapRow>
|
|
2580
|
-
{this.state.hostName !== HOST_INFOBIP && <CapColumn type="flex" align="middle" className="rcs-status-container zalo-status-color">
|
|
2548
|
+
<CapRow type='flex' align="middle" justify="start" gap={12}>
|
|
2549
|
+
{isCardArchiveEligible && this.renderCardSelectionCheckbox({ templateId: template._id, selectedIds: selectedIdsArrayForCard, isDisabled: isAnyArchiveInProgress })}
|
|
2550
|
+
<CapLabel className="whatsapp-rcs-template-name">{name}</CapLabel>
|
|
2551
|
+
<CapColumn type="flex" align="middle" className="rcs-status-container zalo-status-color">
|
|
2581
2552
|
<CapStatus
|
|
2582
2553
|
type={statusDisplay}
|
|
2583
|
-
|
|
2584
|
-
|
|
2585
|
-
|
|
2586
|
-
|
|
2587
|
-
|
|
2588
|
-
</CapColumn>
|
|
2554
|
+
text={statusDisplay && this.props.intl.formatMessage(rcsMessages?.[`${statusDisplay}_STATUS`])}
|
|
2555
|
+
labelType="label3"
|
|
2556
|
+
/>
|
|
2557
|
+
</CapColumn>
|
|
2558
|
+
</CapRow>
|
|
2589
2559
|
);
|
|
2590
2560
|
|
|
2591
2561
|
templateData.content = getRCSContent(template);
|
|
@@ -3161,7 +3131,6 @@ export class Templates extends React.Component { // eslint-disable-line react/pr
|
|
|
3161
3131
|
let routeParams = {};
|
|
3162
3132
|
const {fbAdManager} = this.props;
|
|
3163
3133
|
const isLibraryMode = this.isEnabledInLibraryModule("callCreateFromProps");
|
|
3164
|
-
|
|
3165
3134
|
if (!isLibraryMode) {
|
|
3166
3135
|
timeTracker.startTimer(CHANNEL_CREATE_TRACK_MAPPING[channel]);
|
|
3167
3136
|
}
|
|
@@ -3511,13 +3480,6 @@ export class Templates extends React.Component { // eslint-disable-line react/pr
|
|
|
3511
3480
|
this.setState({modeType});
|
|
3512
3481
|
}
|
|
3513
3482
|
const { _id: id } = template;
|
|
3514
|
-
const {
|
|
3515
|
-
localTemplatesConfig,
|
|
3516
|
-
fbAdManager,
|
|
3517
|
-
isDltFromRcs,
|
|
3518
|
-
isSmsFallbackFromRcs,
|
|
3519
|
-
onSelectTemplate,
|
|
3520
|
-
} = this.props;
|
|
3521
3483
|
const type = this.props.location.query.type;
|
|
3522
3484
|
const module = this.props.location.query.module;
|
|
3523
3485
|
const isLanguageSupport = (this.props.location.query.isLanguageSupport) ? this.props.location.query.isLanguageSupport : false;
|
|
@@ -3603,12 +3565,10 @@ export class Templates extends React.Component { // eslint-disable-line react/pr
|
|
|
3603
3565
|
}
|
|
3604
3566
|
if (this.isEnabledInLibraryModule("callSelectFromProps")) {
|
|
3605
3567
|
let data = id;
|
|
3606
|
-
if (
|
|
3607
|
-
data = template;
|
|
3608
|
-
} else if (fbAdManager || isDltFromRcs || isSmsFallbackFromRcs) {
|
|
3568
|
+
if (this.props.fbAdManager || this.props.isDltFromRcs) {
|
|
3609
3569
|
data = this.selectTemplate(id);
|
|
3610
3570
|
}
|
|
3611
|
-
onSelectTemplate(data, fbAdManager);
|
|
3571
|
+
this.props.onSelectTemplate(data, this.props.fbAdManager);
|
|
3612
3572
|
} else {
|
|
3613
3573
|
timeTracker.startTimer(CHANNEL_EDIT_TRACK_MAPPING[this.state.channel.toLowerCase()]);
|
|
3614
3574
|
if (this.state.channel.toLowerCase() === 'ebill') {
|
|
@@ -4586,11 +4546,9 @@ export class Templates extends React.Component { // eslint-disable-line react/pr
|
|
|
4586
4546
|
const isWechatEmbedded = !this.props.isFullMode && channel.toUpperCase() === WECHAT;
|
|
4587
4547
|
const channelLowerCase = (channel || '').toLowerCase();
|
|
4588
4548
|
const isTraiDltFeature = this.checkDLTfeatureEnable();
|
|
4549
|
+
|
|
4589
4550
|
const createButton =
|
|
4590
|
-
(
|
|
4591
|
-
[WHATSAPP_LOWERCASE, RCS_LOWERCASE].includes(channelLowerCase)
|
|
4592
|
-
&& !this.props.isFullMode
|
|
4593
|
-
)
|
|
4551
|
+
( (channelLowerCase === WHATSAPP_LOWERCASE || channelLowerCase === RCS_LOWERCASE) && !this.props.isFullMode )
|
|
4594
4552
|
? (
|
|
4595
4553
|
<CapLink
|
|
4596
4554
|
onClick={this.openCreativesFullMode}
|
|
@@ -4603,6 +4561,7 @@ export class Templates extends React.Component { // eslint-disable-line react/pr
|
|
|
4603
4561
|
<CapButton
|
|
4604
4562
|
className={`create-new-${channelLowerCase} margin-l-8 margin-b-12`}
|
|
4605
4563
|
type={"primary"}
|
|
4564
|
+
isAddBtn
|
|
4606
4565
|
disabled={this.isCreateDisabled()}
|
|
4607
4566
|
onClick={this.createTemplate}
|
|
4608
4567
|
>
|
|
@@ -4622,22 +4581,17 @@ export class Templates extends React.Component { // eslint-disable-line react/pr
|
|
|
4622
4581
|
const _renderSelectedIdsArray = _renderSelectedIds && typeof _renderSelectedIds.toJS === 'function' ? _renderSelectedIds.toJS() : (Array.isArray(_renderSelectedIds) ? _renderSelectedIds : []);
|
|
4623
4582
|
const _renderHasSelection = _isArchivalEnabled && this.props.isFullMode && _renderSelectedIdsArray.length > 0;
|
|
4624
4583
|
|
|
4625
|
-
const
|
|
4626
|
-
|
|
4627
|
-
|
|
4628
|
-
|
|
4629
|
-
|
|
4630
|
-
|
|
4631
|
-
|
|
4632
|
-
|
|
4633
|
-
|
|
4634
|
-
|
|
4635
|
-
|
|
4636
|
-
onClear={() => this.searchTemplate('', this.state.channel)}
|
|
4637
|
-
onScroll={(e) => e.stopPropagation()}
|
|
4638
|
-
disabled={this.checkSearchDisabled()}
|
|
4639
|
-
/>
|
|
4640
|
-
) : null}
|
|
4584
|
+
const filterContent = (( isfilterContentVisisble || [WECHAT, MOBILE_PUSH, INAPP].includes(this.state.channel.toUpperCase())) && <div className="action-container">
|
|
4585
|
+
{isfilterContentVisisble && <CapInput.Search
|
|
4586
|
+
className="search-text"
|
|
4587
|
+
style={{width: '210px'}}
|
|
4588
|
+
placeholder={_isArchivedMode ? this.props.intl.formatMessage(messages.searchArchivedTemplates) : this.props.intl.formatMessage(messages.searchText)}
|
|
4589
|
+
value={this.state.searchText}
|
|
4590
|
+
onChange={(e) => this.searchTemplate(e.target.value, this.state.channel)}
|
|
4591
|
+
disabled={this.checkSearchDisabled()}
|
|
4592
|
+
onClear={() => this.searchTemplate('', this.state.channel)}
|
|
4593
|
+
onScroll={(e) => e.stopPropagation()}
|
|
4594
|
+
/>}
|
|
4641
4595
|
{
|
|
4642
4596
|
channel.toUpperCase() === WECHAT && <CapRadio.CapRadioGroup className="wechat-filters" defaultValue={wechatFilter} onChange={this.setWechatFilter}>
|
|
4643
4597
|
<CapRadio.Button value={WECHAT_FILTERS.ALL}><CapLabel type="label2">
|
|
@@ -4784,6 +4738,16 @@ export class Templates extends React.Component { // eslint-disable-line react/pr
|
|
|
4784
4738
|
)
|
|
4785
4739
|
}
|
|
4786
4740
|
<div className="template-listing-header-actions">
|
|
4741
|
+
{!_isArchivedMode && !_renderHasSelection && (
|
|
4742
|
+
this.state?.channel?.toLowerCase() === WHATSAPP_LOWERCASE && (isWhatsappCountExeeded) ? (
|
|
4743
|
+
<CapTooltip title={whatsappCountExceedText}>
|
|
4744
|
+
<div className="button-disabled-tooltip-wrapper">
|
|
4745
|
+
{createButton}
|
|
4746
|
+
</div>
|
|
4747
|
+
</CapTooltip>
|
|
4748
|
+
)
|
|
4749
|
+
: isfilterContentVisisble && !isWechatEmbedded && !this.props.isDltFromRcs && createButton
|
|
4750
|
+
)}
|
|
4787
4751
|
{/* More (⋯) menu: full mode only, not archived mode, not Zalo (no archive support), not when selection active, archive flag enabled */}
|
|
4788
4752
|
{commonUtil.hasCreativesArchivalEnabled() && !_isArchivedMode && !_renderHasSelection && this.props.isFullMode && this.props.location.query.type !== EMBEDDED && channelLowerCase !== ZALO_LOWERCASE && (
|
|
4789
4753
|
<CapDropdown
|
|
@@ -4806,28 +4770,7 @@ export class Templates extends React.Component { // eslint-disable-line react/pr
|
|
|
4806
4770
|
</CapDropdown>
|
|
4807
4771
|
)}
|
|
4808
4772
|
</div>
|
|
4809
|
-
</div>
|
|
4810
|
-
<div>
|
|
4811
|
-
<div className="action-container__create-row">
|
|
4812
|
-
{
|
|
4813
|
-
isfilterContentVisisble && !isWechatEmbedded && !this.props.isDltFromRcs && !this.props.isSmsFallbackFromRcs && (
|
|
4814
|
-
this.state?.channel?.toLowerCase() === WHATSAPP_LOWERCASE && isWhatsappCountExeeded ? (
|
|
4815
|
-
<CapTooltip title={whatsappCountExceedText}>
|
|
4816
|
-
<div className="button-disabled-tooltip-wrapper">
|
|
4817
|
-
{createButton}
|
|
4818
|
-
</div>
|
|
4819
|
-
</CapTooltip>
|
|
4820
|
-
) : createButton
|
|
4821
|
-
)
|
|
4822
|
-
}
|
|
4823
|
-
</div>
|
|
4824
|
-
</div>
|
|
4825
|
-
</div>
|
|
4826
|
-
));
|
|
4827
|
-
const localTemplatesFilterContent = get(this.props, 'localTemplatesConfig.localTemplatesFilterContent', null);
|
|
4828
|
-
const filterContent = (useLocalTemplates && localTemplatesFilterContent) != null
|
|
4829
|
-
? localTemplatesFilterContent
|
|
4830
|
-
: builtFilterContent;
|
|
4773
|
+
</div>);
|
|
4831
4774
|
let htmlPreviewContent = "";
|
|
4832
4775
|
if (this.state.channel.toLowerCase() === 'ebill') {
|
|
4833
4776
|
htmlPreviewContent = this.state.previewTemplate && this.state.previewTemplate.versions && this.state.previewTemplate.versions.base && this.state.previewTemplate.versions.base['ebill-editor'];
|
|
@@ -4837,10 +4780,7 @@ export class Templates extends React.Component { // eslint-disable-line react/pr
|
|
|
4837
4780
|
|
|
4838
4781
|
|
|
4839
4782
|
const creativesParams = this.getCreativesParams();
|
|
4840
|
-
const templates =
|
|
4841
|
-
? (this.props.localTemplatesConfig?.localTemplates || [])
|
|
4842
|
-
: (this.props.TemplatesList || []);
|
|
4843
|
-
const isLoadingWhenLocal = useLocalTemplates && !!this.props.localTemplatesConfig?.localTemplatesLoading;
|
|
4783
|
+
const templates = this.props.TemplatesList || [];
|
|
4844
4784
|
const {route} = this.props;
|
|
4845
4785
|
const loadingTipMap = {
|
|
4846
4786
|
sendingFile: 'uploadingFile',
|
|
@@ -4855,11 +4795,9 @@ export class Templates extends React.Component { // eslint-disable-line react/pr
|
|
|
4855
4795
|
(deleteRcsTemplateInProgress && 'deletingTemplate') ||
|
|
4856
4796
|
(this.props.EmailCreate.duplicateTemplateInProgress && 'duplicatingTemplate');
|
|
4857
4797
|
|
|
4858
|
-
const loadingTip =
|
|
4859
|
-
? this.props.localTemplatesConfig.localTemplatesLoadingTip
|
|
4860
|
-
: (messages[loadingTipIntl] ? this.props.intl.formatMessage(messages[loadingTipIntl]) : this.props.intl.formatMessage(messages.gettingAllTemplates));
|
|
4798
|
+
const loadingTip = messages[loadingTipIntl] ? this.props.intl.formatMessage(messages[loadingTipIntl]) : this.props.intl.formatMessage(messages.gettingAllTemplates);
|
|
4861
4799
|
const showNoTemplatesFoundZalo = this.state.channel.toUpperCase() === ZALO && isEmpty(this.state.searchedZaloTemplates) && this.state.searchingZaloTemplate;
|
|
4862
|
-
const showNoTemplatesFoundOther = ![ZALO].includes(this.state.channel.toUpperCase()) && isEmpty(
|
|
4800
|
+
const showNoTemplatesFoundOther = ![ZALO].includes(this.state.channel.toUpperCase()) && isEmpty(this.props.TemplatesList) && !this.props.Templates.getAllTemplatesInProgress && !isEmpty(this.state.searchText);
|
|
4863
4801
|
const showNoTemplatesFound = showNoTemplatesFoundZalo || showNoTemplatesFoundOther;
|
|
4864
4802
|
|
|
4865
4803
|
return (
|
|
@@ -4903,7 +4841,7 @@ export class Templates extends React.Component { // eslint-disable-line react/pr
|
|
|
4903
4841
|
/>
|
|
4904
4842
|
) : null}
|
|
4905
4843
|
|
|
4906
|
-
{channel.toLowerCase() === RCS_LOWERCASE && !isFullMode
|
|
4844
|
+
{channel.toLowerCase() === RCS_LOWERCASE && !isFullMode ? (
|
|
4907
4845
|
<CapInfoNote
|
|
4908
4846
|
message={formatMessage(messages.rcsOnlyApprovedTemplates)}
|
|
4909
4847
|
/>
|
|
@@ -4916,22 +4854,22 @@ export class Templates extends React.Component { // eslint-disable-line react/pr
|
|
|
4916
4854
|
) : null}
|
|
4917
4855
|
<CapRow useLegacy>
|
|
4918
4856
|
<Pagination
|
|
4919
|
-
templateInProgress={
|
|
4857
|
+
templateInProgress={
|
|
4858
|
+
this.props.Templates.getAllTemplatesInProgress
|
|
4859
|
+
}
|
|
4920
4860
|
onPageChange={
|
|
4921
|
-
templates.length
|
|
4922
|
-
? (useLocalTemplates ? (this.props.localTemplatesConfig?.localTemplatesOnPageChange || (() => {})) : this.onPaginationChange)
|
|
4923
|
-
: () => {}
|
|
4861
|
+
templates.length ? this.onPaginationChange : () => {}
|
|
4924
4862
|
}
|
|
4925
4863
|
>
|
|
4926
4864
|
{this.getTemplateDataForGrid({
|
|
4927
4865
|
previewTemplateId: this.state.zaloPreviewItemId,
|
|
4928
|
-
isLoading
|
|
4929
|
-
isInitialLoading
|
|
4866
|
+
isLoading,
|
|
4867
|
+
isInitialLoading,
|
|
4930
4868
|
loadingTip,
|
|
4931
4869
|
channel: this.state.channel,
|
|
4932
4870
|
templates: this.state.searchingZaloTemplate
|
|
4933
4871
|
? this.state.searchedZaloTemplates
|
|
4934
|
-
:
|
|
4872
|
+
: this.props.TemplatesList,
|
|
4935
4873
|
filterContent,
|
|
4936
4874
|
handlers: {
|
|
4937
4875
|
handlePreviewClick: this.handlePreviewClick,
|
|
@@ -5115,15 +5053,6 @@ Templates.propTypes = {
|
|
|
5115
5053
|
WebPush: PropTypes.object,
|
|
5116
5054
|
smsRegister: PropTypes.any,
|
|
5117
5055
|
isDltFromRcs: PropTypes.bool,
|
|
5118
|
-
isSmsFallbackFromRcs: PropTypes.bool,
|
|
5119
|
-
localTemplatesConfig: PropTypes.shape({
|
|
5120
|
-
useLocalTemplates: PropTypes.bool,
|
|
5121
|
-
localTemplates: PropTypes.arrayOf(PropTypes.object),
|
|
5122
|
-
localTemplatesLoading: PropTypes.bool,
|
|
5123
|
-
localTemplatesLoadingTip: PropTypes.string,
|
|
5124
|
-
localTemplatesFilterContent: PropTypes.node,
|
|
5125
|
-
localTemplatesOnPageChange: PropTypes.func,
|
|
5126
|
-
}),
|
|
5127
5056
|
};
|
|
5128
5057
|
|
|
5129
5058
|
const mapStateToProps = createStructuredSelector({
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import {
|
|
2
|
-
call, put, takeLatest,
|
|
2
|
+
call, put, takeLatest, all,
|
|
3
3
|
} from 'redux-saga/effects';
|
|
4
4
|
import get from 'lodash/get';
|
|
5
5
|
import { CapNotification } from '@capillarytech/cap-ui-library';
|
|
@@ -7,70 +7,33 @@ import { CapNotification } from '@capillarytech/cap-ui-library';
|
|
|
7
7
|
import * as Api from '../../services/api';
|
|
8
8
|
import * as types from './constants';
|
|
9
9
|
import { saveCdnConfigs, removeAllCdnLocalStorageItems, initCdnConfigFromEnv } from '../../utils/cdnTransformation';
|
|
10
|
-
import { COPY_OF
|
|
11
|
-
import { fetchSmsTemplatesFromQuery } from './utils/smsTemplatesListApi';
|
|
10
|
+
import { COPY_OF } from '../../constants/unified';
|
|
12
11
|
import { ZALO_TEMPLATE_INFO_REQUEST } from '../Zalo/constants';
|
|
13
12
|
import { getTemplateInfoById } from '../Zalo/saga';
|
|
14
13
|
|
|
15
|
-
|
|
14
|
+
// Individual exports for testing
|
|
15
|
+
export function* getAllTemplates(channel, queryParams) {
|
|
16
16
|
try {
|
|
17
|
-
const
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
);
|
|
22
|
-
if (typeof action.onSuccess === 'function') {
|
|
23
|
-
yield call(action.onSuccess, fetched);
|
|
24
|
-
}
|
|
25
|
-
} catch (error) {
|
|
26
|
-
if (typeof action.onFailure === 'function') {
|
|
27
|
-
yield call(action.onFailure, error);
|
|
28
|
-
}
|
|
29
|
-
}
|
|
30
|
-
}
|
|
31
|
-
|
|
32
|
-
export function* getAllTemplates(action) {
|
|
33
|
-
try {
|
|
34
|
-
if (action.channel && String(action.channel).toLowerCase() === SMS_CHANNEL) {
|
|
35
|
-
const fetched = yield call(
|
|
36
|
-
fetchSmsTemplatesFromQuery,
|
|
37
|
-
action.queryParams,
|
|
38
|
-
action.intlCopyOf,
|
|
39
|
-
);
|
|
40
|
-
yield put({
|
|
41
|
-
type: types.GET_ALL_TEMPLATES_SUCCESS,
|
|
42
|
-
data: fetched.channelTemplates,
|
|
43
|
-
weCRMTemplate: fetched.weCRMTemplate,
|
|
44
|
-
isReset: get(action, 'queryParams.page') === 1,
|
|
45
|
-
});
|
|
46
|
-
return;
|
|
47
|
-
}
|
|
48
|
-
|
|
49
|
-
const result = yield call(Api.getAllTemplates, action);
|
|
50
|
-
const channelTemplates = (action.channel === 'wechat')
|
|
51
|
-
? { templates: [...result.response.mapped, ...result.response.richmedia] }
|
|
52
|
-
: result.response;
|
|
53
|
-
if (action.channel === 'wechat' && action.queryParams && action.queryParams.sortBy && action.queryParams.sortBy.toLocaleLowerCase() === ("Most Recent").toLocaleLowerCase()) {
|
|
17
|
+
const result = yield call(Api.getAllTemplates, channel, queryParams);
|
|
18
|
+
const channelTemplates = (channel.channel === 'wechat') ? { templates: [...result.response.mapped, ...result.response.richmedia] } : result.response;
|
|
19
|
+
// const sidebar = result.response.sidebar;
|
|
20
|
+
if (channel.channel === 'wechat' && channel.queryParams && channel.queryParams.sortBy && channel.queryParams.sortBy.toLocaleLowerCase() === ("Most Recent").toLocaleLowerCase()) {
|
|
54
21
|
channelTemplates.templates.sort((a, b) => {
|
|
55
22
|
const dateA = new Date(a.updatedAt);
|
|
56
23
|
const dateB = new Date(b.updatedAt);
|
|
57
24
|
return dateB - dateA;
|
|
58
25
|
});
|
|
59
|
-
} else if (
|
|
26
|
+
} else if (channel.channel === 'wechat' && channel.queryParams && channel.queryParams.sortBy && channel.queryParams.sortBy.toLocaleLowerCase() === ("Alphabetically").toLocaleLowerCase()) {
|
|
60
27
|
channelTemplates.templates.sort((a, b) => b.name - a.name);
|
|
61
28
|
}
|
|
62
|
-
|
|
29
|
+
// Update the "name" property in each template
|
|
30
|
+
if (channel.intlCopyOf && channelTemplates?.templates) {
|
|
63
31
|
channelTemplates.templates = channelTemplates.templates.map((template) => ({
|
|
64
32
|
...template,
|
|
65
|
-
name: template.name.replace(new RegExp(COPY_OF, 'g'),
|
|
33
|
+
name: template.name.replace(new RegExp(COPY_OF, 'g'), channel.intlCopyOf),
|
|
66
34
|
}));
|
|
67
35
|
}
|
|
68
|
-
yield put({
|
|
69
|
-
type: types.GET_ALL_TEMPLATES_SUCCESS,
|
|
70
|
-
data: channelTemplates,
|
|
71
|
-
weCRMTemplate: result.response.unMapped,
|
|
72
|
-
isReset: get(action, 'queryParams.page') === 1,
|
|
73
|
-
});
|
|
36
|
+
yield put({ type: types.GET_ALL_TEMPLATES_SUCCESS, data: channelTemplates, weCRMTemplate: result.response.unMapped, isReset: channel.queryParams.page === 1 });
|
|
74
37
|
} catch (error) {
|
|
75
38
|
yield put({ type: types.GET_ALL_TEMPLATES_FAILURE, error });
|
|
76
39
|
}
|
|
@@ -307,11 +270,6 @@ export function* watchGetAllTemplates() {
|
|
|
307
270
|
yield takeLatest(types.GET_ALL_TEMPLATES_REQUEST, getAllTemplates);
|
|
308
271
|
}
|
|
309
272
|
|
|
310
|
-
|
|
311
|
-
export function* watchGetLocalSmsTemplates() {
|
|
312
|
-
yield takeEvery(types.GET_LOCAL_SMS_TEMPLATES_REQUEST, getLocalSmsTemplates);
|
|
313
|
-
}
|
|
314
|
-
|
|
315
273
|
export function* watchDeleteTemplate() {
|
|
316
274
|
yield takeLatest(types.DELETE_TEMPLATE_REQUEST, deleteTemplate);
|
|
317
275
|
}
|
|
@@ -365,7 +323,6 @@ export function* watchForGetTemplateInfoById() {
|
|
|
365
323
|
// All sagas to be loaded
|
|
366
324
|
export default [
|
|
367
325
|
watchGetAllTemplates,
|
|
368
|
-
watchGetLocalSmsTemplates,
|
|
369
326
|
watchDeleteTemplate,
|
|
370
327
|
watchDeleteRcsTemplate,
|
|
371
328
|
watchGetUserList,
|
|
@@ -382,7 +339,6 @@ export default [
|
|
|
382
339
|
export function* v2TemplateSaga() {
|
|
383
340
|
yield all([
|
|
384
341
|
watchGetAllTemplates(),
|
|
385
|
-
watchGetLocalSmsTemplates(),
|
|
386
342
|
watchDeleteTemplate(),
|
|
387
343
|
watchDeleteRcsTemplate(),
|
|
388
344
|
watchGetUserList(),
|