@capillarytech/creatives-library 7.10.50 → 7.10.52
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/containers/Assets/Gallery/tests/__snapshots__/reducer.test.js.snap +2 -0
- package/containers/Email/index.js +3 -2
- package/package.json +1 -1
- package/utils/v2common.js +0 -13
- package/v2Components/TemplatePreview/_templatePreview.scss +17 -9
- package/v2Components/TemplatePreview/assets/images/whatsapp_mobile_android.svg +1 -2041
- package/v2Components/TemplatePreview/index.js +66 -41
- package/v2Components/TemplatePreview/messages.js +4 -0
- package/v2Components/WhatsappStatusContainer/_whatsappStatusContainer.scss +13 -0
- package/v2Components/WhatsappStatusContainer/index.js +58 -0
- package/v2Containers/Assets/Gallery/tests/__snapshots__/reducer.test.js.snap +2 -0
- package/v2Containers/Cap/messages.js +8 -0
- package/v2Containers/CreativesContainer/SlideBoxContent.js +9 -9
- package/v2Containers/CreativesContainer/SlideBoxHeader.js +2 -1
- package/v2Containers/CreativesContainer/index.js +24 -46
- package/v2Containers/Email/index.js +3 -1
- package/v2Containers/Templates/_templates.scss +19 -45
- package/v2Containers/Templates/actions.js +10 -16
- package/v2Containers/Templates/index.js +79 -89
- package/v2Containers/Templates/messages.js +8 -4
- package/v2Containers/TemplatesV2/index.js +4 -11
- package/v2Containers/Whatsapp/index.js +20 -87
- package/v2Containers/Whatsapp/index.scss +53 -54
- package/v2Containers/Whatsapp/messages.js +0 -17
- package/v2Containers/Whatsapp/tests/__snapshots__/index.test.js.snap +34190 -6356
- package/v2Containers/Whatsapp/tests/index.test.js +51 -13
- package/v2Containers/Whatsapp/tests/mockData.js +120 -1
- package/v2Containers/Whatsapp/utils.js +0 -47
|
@@ -22,7 +22,31 @@ import find from 'lodash/find';
|
|
|
22
22
|
import map from 'lodash/map';
|
|
23
23
|
import { bindActionCreators } from 'redux';
|
|
24
24
|
import { Modal, Form} from 'antd';
|
|
25
|
-
import {
|
|
25
|
+
import {
|
|
26
|
+
CapMenu,
|
|
27
|
+
CapDropdown,
|
|
28
|
+
CapButton,
|
|
29
|
+
CapInput,
|
|
30
|
+
CapIcon,
|
|
31
|
+
CapRadioCard,
|
|
32
|
+
CapPopover,
|
|
33
|
+
CapSpin,
|
|
34
|
+
CapCustomCard,
|
|
35
|
+
CapRow,
|
|
36
|
+
CapSlideBox,
|
|
37
|
+
CapLink,
|
|
38
|
+
CapHeading,
|
|
39
|
+
CapNotification,
|
|
40
|
+
CapIllustration,
|
|
41
|
+
CapHeader,
|
|
42
|
+
CapLabel,
|
|
43
|
+
CapRadio,
|
|
44
|
+
CapSelectFilter,
|
|
45
|
+
CapTag,
|
|
46
|
+
CapTooltip,
|
|
47
|
+
CapAlert,
|
|
48
|
+
CapModal,
|
|
49
|
+
} from '@capillarytech/cap-ui-library';
|
|
26
50
|
import { makeSelectTemplates, makeSelectTemplatesResponse } from './selectors';
|
|
27
51
|
import { makeSelectCreate as makeSelectCreateSms} from '../Sms/Create/selectors';
|
|
28
52
|
import { makeSelectCreate as makeSelectCreateMobilePush } from '../MobilePush/Create/selectors';
|
|
@@ -32,7 +56,6 @@ import { makeSelectEdit } from '../Sms/Edit/selectors';
|
|
|
32
56
|
import { makeSelectLine } from '../Line/Container/selectors';
|
|
33
57
|
import { makeSelectViber } from '../Viber/selectors';
|
|
34
58
|
import { UserIsAuthenticated } from '../../utils/authWrapper';
|
|
35
|
-
import { getObjFromQueryParams } from '../../utils/v2common';
|
|
36
59
|
import messages from './messages';
|
|
37
60
|
import {checkUnicode} from '../../utils/smsCharCountV2';
|
|
38
61
|
import * as actions from './actions';
|
|
@@ -54,6 +77,7 @@ import * as commonUtil from '../../utils/common';
|
|
|
54
77
|
import Pagination from '../../v2Components/Pagination';
|
|
55
78
|
import EmailPreview from '../../v2Components/EmailPreview';
|
|
56
79
|
import CreativesContainer from '../CreativesContainer';
|
|
80
|
+
import WhatsappStatusContainer from '../../v2Components/WhatsappStatusContainer';
|
|
57
81
|
import WechatRichmediaTemplatePreview from '../../v2Components/TemplatePreview/WechatRichmediaTemplatePreview';
|
|
58
82
|
import {
|
|
59
83
|
CHANNEL_CREATE_TRACK_MAPPING,
|
|
@@ -69,7 +93,7 @@ import {
|
|
|
69
93
|
STATUS as WHATSAPP_STATUS,
|
|
70
94
|
WHATSAPP_STATUSES,
|
|
71
95
|
} from '../Whatsapp/constants';
|
|
72
|
-
import { getWhatsappContent,
|
|
96
|
+
import { getWhatsappContent, getWhatsappStatus, getWhatsappCategory } from '../Whatsapp/utils';
|
|
73
97
|
import { MOBILE_PUSH, WECHAT, SMS, EMAIL, EBILL, LINE, VIBER, FACEBOOK, WHATSAPP } from '../CreativesContainer/constants';
|
|
74
98
|
|
|
75
99
|
import {CREATIVE} from '../Facebook/constants';
|
|
@@ -78,7 +102,7 @@ import emailIllustration from '../Assets/images/emailIllustration.svg';
|
|
|
78
102
|
import smsIllustration from '../Assets/images/smsIllustration.svg';
|
|
79
103
|
import pushIllustration from '../Assets/images/pushIllustration.svg';
|
|
80
104
|
import whatsappIllustration from '../Assets/images/whatsappIllustration.png';
|
|
81
|
-
import { CAP_SPACE_16 } from '@capillarytech/cap-ui-library/styled/variables';
|
|
105
|
+
import { CAP_SPACE_16, CAP_SPACE_44 } from '@capillarytech/cap-ui-library/styled/variables';
|
|
82
106
|
import { GA } from '@capillarytech/cap-ui-utils';
|
|
83
107
|
const { timeTracker } = GA;
|
|
84
108
|
const {CapCustomCardList} = CapCustomCard;
|
|
@@ -241,13 +265,6 @@ export class Templates extends React.Component { // eslint-disable-line react/pr
|
|
|
241
265
|
if (this.props.location.query.type === 'embedded' && this.isEnabledInLibraryModule("setLocale")) {
|
|
242
266
|
this.setLocale();
|
|
243
267
|
}
|
|
244
|
-
|
|
245
|
-
const queryItems = getObjFromQueryParams(location.search);
|
|
246
|
-
|
|
247
|
-
if(queryItems.channel === WHATSAPP_LOWERCASE && queryItems.mode === 'create') {
|
|
248
|
-
this.createTemplate();
|
|
249
|
-
}
|
|
250
|
-
|
|
251
268
|
if (this.props.location.query.type === 'embedded') {
|
|
252
269
|
this.props.actions.resetAccount();
|
|
253
270
|
}
|
|
@@ -576,9 +593,8 @@ export class Templates extends React.Component { // eslint-disable-line react/pr
|
|
|
576
593
|
this.getAllTemplates({getNextPage: true});
|
|
577
594
|
}
|
|
578
595
|
onCreateComplete = (isReloadTemplates) => {
|
|
579
|
-
const isWhatsappEdit = this.state.routeParams?.pathname?.includes(`${WHATSAPP_LOWERCASE}/edit`);
|
|
580
596
|
this.setState({routeParams: null, previewOpen: false}, () => {
|
|
581
|
-
if (this.isFullMode() &&
|
|
597
|
+
if (this.isFullMode() && isReloadTemplates) {
|
|
582
598
|
this.getAllTemplates({params: {}}, true);
|
|
583
599
|
}
|
|
584
600
|
});
|
|
@@ -714,16 +730,10 @@ export class Templates extends React.Component { // eslint-disable-line react/pr
|
|
|
714
730
|
}
|
|
715
731
|
|
|
716
732
|
isStatusMatching = (status, selectedWhatsappStatus) => {
|
|
717
|
-
if(
|
|
718
|
-
|
|
719
|
-
return selectedWhatsappStatus === WHATSAPP_STATUSES.awaitingApproval;
|
|
720
|
-
}
|
|
721
|
-
return selectedWhatsappStatus === status;
|
|
722
|
-
}
|
|
723
|
-
else if (!this.props.isFullMode){
|
|
724
|
-
return status === WHATSAPP_STATUSES.approved;
|
|
733
|
+
if ( [WHATSAPP_STATUSES.unsubmitted, WHATSAPP_STATUSES.pending].includes(status) ) {
|
|
734
|
+
return selectedWhatsappStatus === WHATSAPP_STATUSES.awaitingApproval;
|
|
725
735
|
}
|
|
726
|
-
|
|
736
|
+
return selectedWhatsappStatus === status;
|
|
727
737
|
}
|
|
728
738
|
|
|
729
739
|
filterWhatsappTemplates = (templates) => {
|
|
@@ -733,7 +743,9 @@ export class Templates extends React.Component { // eslint-disable-line react/pr
|
|
|
733
743
|
|
|
734
744
|
// if status or category filter is applied, filter templates which match these filters
|
|
735
745
|
return (
|
|
736
|
-
|
|
746
|
+
selectedWhatsappStatus
|
|
747
|
+
? this.isStatusMatching(status, selectedWhatsappStatus)
|
|
748
|
+
: true
|
|
737
749
|
) && (
|
|
738
750
|
selectedWhatsappCategory
|
|
739
751
|
? category === selectedWhatsappCategory
|
|
@@ -763,7 +775,6 @@ export class Templates extends React.Component { // eslint-disable-line react/pr
|
|
|
763
775
|
const channelLowerCase = stateChannel.toLowerCase();
|
|
764
776
|
let filteredTemplates = templates;
|
|
765
777
|
let isTraiDltFeature = false;
|
|
766
|
-
console.log("getTemplateDataForGrid", currentChannel);
|
|
767
778
|
switch (currentChannel) {
|
|
768
779
|
case WECHAT:
|
|
769
780
|
filteredTemplates = this.filterWechatTemplates(templates);
|
|
@@ -947,10 +958,10 @@ export class Templates extends React.Component { // eslint-disable-line react/pr
|
|
|
947
958
|
}
|
|
948
959
|
case WHATSAPP:
|
|
949
960
|
templateData.title = (
|
|
950
|
-
<
|
|
951
|
-
<
|
|
952
|
-
{
|
|
953
|
-
</
|
|
961
|
+
<CapRow className="whatsapp-card-title">
|
|
962
|
+
<CapLabel>{template.name}</CapLabel>
|
|
963
|
+
<WhatsappStatusContainer template={template} />
|
|
964
|
+
</CapRow>
|
|
954
965
|
);
|
|
955
966
|
|
|
956
967
|
templateData.content = getWhatsappContent(template);
|
|
@@ -1014,11 +1025,22 @@ export class Templates extends React.Component { // eslint-disable-line react/pr
|
|
|
1014
1025
|
</CapHeading>
|
|
1015
1026
|
</div> : (
|
|
1016
1027
|
[WHATSAPP_LOWERCASE].includes(this.state.channel.toLowerCase()) &&
|
|
1017
|
-
isEmpty(filteredTemplates) &&
|
|
1018
1028
|
isEmpty(this.state.searchText) &&
|
|
1019
1029
|
!isLoading &&
|
|
1020
|
-
<div style={this.isFullMode() ? { height: "calc(100vh - 325px)", overflow: 'auto'} : {}}>
|
|
1021
|
-
<CapIllustration buttonClassName={`create-new-${channelLowerCase}`} {...this.getChannelTypeIllustrationInfo(currentChannel)} />
|
|
1030
|
+
<div style={this.isFullMode() ? { height: "calc(100vh - 325px)", overflow: 'auto' } : {}}>
|
|
1031
|
+
{isEmpty(templates) && <CapIllustration buttonClassName={`create-new-${channelLowerCase}`} {...this.getChannelTypeIllustrationInfo(currentChannel)} />}
|
|
1032
|
+
{!isEmpty(templates) && isEmpty(filteredTemplates) && <CapHeader
|
|
1033
|
+
title={
|
|
1034
|
+
<CapHeading type="h3" style={{ textAlign: "center", marginTop: CAP_SPACE_44 }}>
|
|
1035
|
+
{this.props.intl.formatMessage(messages.noFilteredWhatsappTemplatesTitle)}
|
|
1036
|
+
</CapHeading>
|
|
1037
|
+
}
|
|
1038
|
+
description={
|
|
1039
|
+
<CapLabel style={{ textAlign: "center" }}>
|
|
1040
|
+
{this.props.intl.formatMessage(messages.noFilteredWhatsappTemplatesDesc)}
|
|
1041
|
+
</CapLabel>
|
|
1042
|
+
}
|
|
1043
|
+
/>}
|
|
1022
1044
|
</div>
|
|
1023
1045
|
)
|
|
1024
1046
|
}
|
|
@@ -1328,7 +1350,7 @@ export class Templates extends React.Component { // eslint-disable-line react/pr
|
|
|
1328
1350
|
} else {
|
|
1329
1351
|
this.props.createNew();
|
|
1330
1352
|
}
|
|
1331
|
-
} else if (ev
|
|
1353
|
+
} else if (ev.key && (ev.key.toLowerCase() === "text" || ev.key.toLowerCase() === "image")) {
|
|
1332
1354
|
routeParams = {
|
|
1333
1355
|
pathname: `/${channel === 'line' ? 'line' : 'mobilepush'}/create/${ev.key.toLowerCase()}`,
|
|
1334
1356
|
query: type === 'embedded' ? {type: 'embedded', module} : {module},
|
|
@@ -2149,16 +2171,13 @@ export class Templates extends React.Component { // eslint-disable-line react/pr
|
|
|
2149
2171
|
formatMessage,
|
|
2150
2172
|
},
|
|
2151
2173
|
} = this.props;
|
|
2152
|
-
|
|
2153
|
-
|
|
2154
|
-
|
|
2155
|
-
|
|
2156
|
-
|
|
2157
|
-
case WHATSAPP:
|
|
2158
|
-
return formatMessage(messages.whatsappAccount);
|
|
2159
|
-
default:
|
|
2160
|
-
return '';
|
|
2174
|
+
|
|
2175
|
+
const channelObj = {
|
|
2176
|
+
[MOBILE_PUSH]: 'mobilepushAccount',
|
|
2177
|
+
[WECHAT]: 'wechatAccount',
|
|
2178
|
+
[WHATSAPP]: 'whatsappAccount',
|
|
2161
2179
|
}
|
|
2180
|
+
return formatMessage(messages[channelObj[channel?.toUpperCase()]]);
|
|
2162
2181
|
}
|
|
2163
2182
|
|
|
2164
2183
|
showAccountName = () => {
|
|
@@ -2230,9 +2249,6 @@ export class Templates extends React.Component { // eslint-disable-line react/pr
|
|
|
2230
2249
|
setLineFilter = (e) => this.setState({lineFilter: e.target.value});
|
|
2231
2250
|
setSMSFilter = (e) => this.setState({smsFilter: e.target.value});
|
|
2232
2251
|
|
|
2233
|
-
openCreativesFullMode = () => {
|
|
2234
|
-
window.open("/creatives/ui/v2?channel=WHATSAPP&&mode=create", "_blank");
|
|
2235
|
-
}
|
|
2236
2252
|
|
|
2237
2253
|
render() {
|
|
2238
2254
|
const isFullMode = this.isFullMode();
|
|
@@ -2306,27 +2322,14 @@ export class Templates extends React.Component { // eslint-disable-line react/pr
|
|
|
2306
2322
|
const channelLowerCase = (channel || '').toLowerCase();
|
|
2307
2323
|
const isTraiDltFeature = this.checkDLTfeatureEnable();
|
|
2308
2324
|
|
|
2309
|
-
const createButton =
|
|
2310
|
-
|
|
2311
|
-
|
|
2312
|
-
|
|
2313
|
-
|
|
2314
|
-
|
|
2315
|
-
|
|
2316
|
-
|
|
2317
|
-
/>
|
|
2318
|
-
)
|
|
2319
|
-
: (
|
|
2320
|
-
<CapButton
|
|
2321
|
-
className={`create-new-${channelLowerCase}`}
|
|
2322
|
-
type={"primary"}
|
|
2323
|
-
disabled={this.isCreateDisabled()}
|
|
2324
|
-
style={{marginLeft: '8px', marginBottom: '12px'}}
|
|
2325
|
-
onClick={this.createTemplate}
|
|
2326
|
-
>
|
|
2327
|
-
{ this.props.intl.formatMessage((isTraiDltFeature && channel.toUpperCase() === SMS ) ? messages.uploadTemplate : messages.createNewActionButton) }
|
|
2328
|
-
</CapButton>
|
|
2329
|
-
);
|
|
2325
|
+
const createButton = (<CapButton
|
|
2326
|
+
className={`create-new-${channelLowerCase}`}
|
|
2327
|
+
type={"primary"}
|
|
2328
|
+
disabled={this.isCreateDisabled()}
|
|
2329
|
+
style={{marginLeft: '8px', marginBottom: '12px'}}
|
|
2330
|
+
onClick={this.createTemplate} >
|
|
2331
|
+
{ this.props.intl.formatMessage((isTraiDltFeature && channel.toUpperCase() === SMS ) ? messages.uploadTemplate : messages.createNewActionButton) }
|
|
2332
|
+
</CapButton>);
|
|
2330
2333
|
|
|
2331
2334
|
const isWhatsappCountExeeded = templatesCount >= MAX_WHATSAPP_TEMPLATES;
|
|
2332
2335
|
const whatsappCountExceedText = <FormattedMessage {...messages.whatsappMaxTemplates} values={{ maxCount: MAX_WHATSAPP_TEMPLATES }}/>;
|
|
@@ -2358,19 +2361,16 @@ export class Templates extends React.Component { // eslint-disable-line react/pr
|
|
|
2358
2361
|
{
|
|
2359
2362
|
channel.toUpperCase() === WHATSAPP && (
|
|
2360
2363
|
<div className="whatsapp-filters">
|
|
2361
|
-
|
|
2362
|
-
|
|
2363
|
-
|
|
2364
|
-
|
|
2365
|
-
|
|
2366
|
-
|
|
2367
|
-
|
|
2368
|
-
|
|
2369
|
-
|
|
2370
|
-
|
|
2371
|
-
/>
|
|
2372
|
-
) : null
|
|
2373
|
-
}
|
|
2364
|
+
<CapSelectFilter
|
|
2365
|
+
placement="bottomLeft"
|
|
2366
|
+
data={STATUS_OPTIONS}
|
|
2367
|
+
onSelect={this.setWhatsappStatus}
|
|
2368
|
+
selectedValue={this.state.selectedWhatsappStatus}
|
|
2369
|
+
placeholder="Status"
|
|
2370
|
+
showBadge={true}
|
|
2371
|
+
width="90px"
|
|
2372
|
+
overlayStyle={{ overflowY: "hidden" }}
|
|
2373
|
+
/>
|
|
2374
2374
|
<CapSelectFilter
|
|
2375
2375
|
placement="bottomLeft"
|
|
2376
2376
|
data={CATEGORY_OPTIONS}
|
|
@@ -2379,6 +2379,7 @@ export class Templates extends React.Component { // eslint-disable-line react/pr
|
|
|
2379
2379
|
placeholder="Category"
|
|
2380
2380
|
showBadge={true}
|
|
2381
2381
|
width="105px"
|
|
2382
|
+
overlayStyle={{ overflowY: "hidden" }}
|
|
2382
2383
|
/>
|
|
2383
2384
|
</div>
|
|
2384
2385
|
|
|
@@ -2502,21 +2503,10 @@ export class Templates extends React.Component { // eslint-disable-line react/pr
|
|
|
2502
2503
|
|
|
2503
2504
|
<CapRow>
|
|
2504
2505
|
<Pagination onPageChange={templates.length ? this.onPaginationChange : () => {}} paginationSelector="pagination-container">
|
|
2505
|
-
|
|
2506
|
-
{
|
|
2507
|
-
channel.toLowerCase() === WHATSAPP_LOWERCASE ? (
|
|
2508
|
-
<CapAlert message={whatsappCountExceedText} type="info" />
|
|
2509
|
-
) : null
|
|
2510
|
-
}
|
|
2511
2506
|
{this.getTemplateDataForGrid({isLoading, loadingTip, channel: this.state.channel, templates: this.props.TemplatesList, filterContent, handlers: {handlePreviewClick: this.handlePreviewClick, handleEditClick: this.handleEditClick}})}
|
|
2512
2507
|
</Pagination>
|
|
2513
2508
|
{(((this.state.selectedAccount !== '' && !isEmpty(this.props.Templates.selectedWeChatAccount) && this.state.channel.toLowerCase() === 'wechat') || this.state.channel.toLowerCase() !== 'wechat') && isEmpty(this.props.TemplatesList)) && !this.props.Templates.getAllTemplatesInProgress && !isEmpty(this.state.searchText) &&
|
|
2514
2509
|
<div style={{ height: '65vh', textAlign: 'center', lineHeight: '65vh'}}>
|
|
2515
|
-
{
|
|
2516
|
-
channel.toLowerCase() === WHATSAPP_LOWERCASE ? (
|
|
2517
|
-
<CapAlert message={whatsappCountExceedText} type="info" />
|
|
2518
|
-
) : null
|
|
2519
|
-
}
|
|
2520
2510
|
<CapHeading type="h6">{this.props.intl.formatMessage(messages.noTemplatesFound)}</CapHeading>
|
|
2521
2511
|
</div>}
|
|
2522
2512
|
</CapRow>
|
|
@@ -274,10 +274,6 @@ export default defineMessages({
|
|
|
274
274
|
id: `${scope}.createNewActionButton`,
|
|
275
275
|
defaultMessage: `Create new`,
|
|
276
276
|
},
|
|
277
|
-
"createNewTemplateLink": {
|
|
278
|
-
id: `${scope}.createNewTemplateLink`,
|
|
279
|
-
defaultMessage: `Create new template`,
|
|
280
|
-
},
|
|
281
277
|
"creativeTemplates": {
|
|
282
278
|
id: `${scope}.creativeTemplates`,
|
|
283
279
|
defaultMessage: `Creative templates`,
|
|
@@ -346,6 +342,14 @@ export default defineMessages({
|
|
|
346
342
|
id: `${scope}.whatsappDescIllustration`,
|
|
347
343
|
defaultMessage: 'These templates can be reused when creating a\nnew message content.',
|
|
348
344
|
},
|
|
345
|
+
"noFilteredWhatsappTemplatesTitle": {
|
|
346
|
+
id: `${scope}.noFilteredWhatsappTemplatesTitle`,
|
|
347
|
+
defaultMessage: 'Sorry, we couldn’t find any matches',
|
|
348
|
+
},
|
|
349
|
+
"noFilteredWhatsappTemplatesDesc": {
|
|
350
|
+
id: `${scope}.noFilteredWhatsappTemplatesDesc`,
|
|
351
|
+
defaultMessage: 'Please try searching with another term or apply different filter',
|
|
352
|
+
},
|
|
349
353
|
"smsTitleIllustartion": {
|
|
350
354
|
id: `${scope}.smsTitleIllustartion`,
|
|
351
355
|
defaultMessage: 'Create an SMS {template}',
|
|
@@ -31,7 +31,6 @@ import withStyles from '../../hoc/withStyles';
|
|
|
31
31
|
import styles, { CapTabStyle } from './TemplatesV2.style';
|
|
32
32
|
import { CREATIVES_UI_VIEW, LOYALTY} from '../App/constants';
|
|
33
33
|
import AccessForbidden from '../../v2Components/AccessForbidden';
|
|
34
|
-
import { getObjFromQueryParams } from '../../utils/v2common';
|
|
35
34
|
|
|
36
35
|
const {CapCustomCardList} = CapCustomCard;
|
|
37
36
|
|
|
@@ -51,6 +50,7 @@ export class TemplatesV2 extends React.Component { // eslint-disable-line react/
|
|
|
51
50
|
isFullMode,
|
|
52
51
|
onChannelChange,
|
|
53
52
|
showDisabledFBInfo,
|
|
53
|
+
enableNewChannels,
|
|
54
54
|
} = props;
|
|
55
55
|
|
|
56
56
|
const defaultPanes = {
|
|
@@ -80,6 +80,9 @@ export class TemplatesV2 extends React.Component { // eslint-disable-line react/
|
|
|
80
80
|
filteredPanes.push({content: <></>, tab: intl.formatMessage(messages.FTP), key: 'ftp'});
|
|
81
81
|
defaultChannel = 'FTP';
|
|
82
82
|
}
|
|
83
|
+
if (!enableNewChannels.includes('WHATSAPP')) {
|
|
84
|
+
filteredPanes.splice(7, 1);
|
|
85
|
+
}
|
|
83
86
|
}
|
|
84
87
|
|
|
85
88
|
|
|
@@ -121,16 +124,6 @@ export class TemplatesV2 extends React.Component { // eslint-disable-line react/
|
|
|
121
124
|
onChannelChange(defaultChannel);
|
|
122
125
|
}
|
|
123
126
|
}
|
|
124
|
-
|
|
125
|
-
componentDidMount() {
|
|
126
|
-
const queryItems = getObjFromQueryParams(location.search);
|
|
127
|
-
|
|
128
|
-
if(queryItems.channel === 'whatsapp') {
|
|
129
|
-
console.log("reached whatsapp content");
|
|
130
|
-
this.channelChange('whatsapp');
|
|
131
|
-
}
|
|
132
|
-
}
|
|
133
|
-
|
|
134
127
|
componentWillReceiveProps(nextProps) {
|
|
135
128
|
if (this.props.channel !== nextProps.channel) {
|
|
136
129
|
const panes = this.setChannelContent(nextProps.channel, this.state.panes);
|
|
@@ -47,15 +47,14 @@ import {
|
|
|
47
47
|
} from './constants';
|
|
48
48
|
import { DATE_DISPLAY_FORMAT, TIME_DISPLAY_FORMAT } from '../App/constants';
|
|
49
49
|
import messages from './messages';
|
|
50
|
+
import globalMessages from '../Cap/messages'
|
|
50
51
|
import withCreatives from '../../hoc/withCreatives';
|
|
51
52
|
import TemplatePreview from '../../v2Components/TemplatePreview';
|
|
52
53
|
import TagList from '../TagList';
|
|
53
54
|
import { makeSelectMetaEntities, setInjectedTags } from '../Cap/selectors';
|
|
54
|
-
import { validateTags } from '../../utils/tagValidations';
|
|
55
55
|
|
|
56
56
|
let varMap = {};
|
|
57
57
|
let editContent = {};
|
|
58
|
-
let tagValidationResponse = {};
|
|
59
58
|
|
|
60
59
|
export const Whatsapp = (props) => {
|
|
61
60
|
const {
|
|
@@ -75,7 +74,6 @@ export const Whatsapp = (props) => {
|
|
|
75
74
|
metaEntities,
|
|
76
75
|
injectedTags,
|
|
77
76
|
loadingTags,
|
|
78
|
-
getFormData
|
|
79
77
|
} = props || {};
|
|
80
78
|
const { formatMessage } = intl;
|
|
81
79
|
const { TextArea } = CapInput;
|
|
@@ -94,16 +92,13 @@ export const Whatsapp = (props) => {
|
|
|
94
92
|
//for edit only
|
|
95
93
|
const [isEditFlow, setEditFlow] = useState(false);
|
|
96
94
|
const [templateDate, setTemplateDate] = useState('');
|
|
97
|
-
const [templateStatus, setTemplateStatus] = useState(
|
|
98
|
-
WHATSAPP_STATUSES.unsubmitted,
|
|
99
|
-
);
|
|
95
|
+
const [templateStatus, setTemplateStatus] = useState();
|
|
100
96
|
const [templateRejectionReason, setTemplateRejectionReason] = useState(null);
|
|
101
97
|
const [tempMsgArray, updateTempMsgArray] = useState([]);
|
|
102
98
|
const [updatedSmsEditor, setUpdatedSmsEditor] = useState([]);
|
|
103
99
|
//for tag only
|
|
104
100
|
const [tags, updateTags] = useState([]);
|
|
105
101
|
const [textAreaId, updateTextAreaId] = useState();
|
|
106
|
-
const [isTagValidationError, updateIsTagValidationError] = useState(false);
|
|
107
102
|
|
|
108
103
|
const validVarRegex = /{{([1-9]|1[0-9])}}/g;
|
|
109
104
|
|
|
@@ -114,8 +109,7 @@ export const Whatsapp = (props) => {
|
|
|
114
109
|
width: 100%;
|
|
115
110
|
margin-left: -32px;
|
|
116
111
|
padding: ${CAP_SPACE_32} ${CAP_SPACE_24};
|
|
117
|
-
|
|
118
|
-
|
|
112
|
+
|
|
119
113
|
.ant-btn {
|
|
120
114
|
margin-right: ${CAP_SPACE_16};
|
|
121
115
|
}
|
|
@@ -147,6 +141,7 @@ export const Whatsapp = (props) => {
|
|
|
147
141
|
setSpin(true);
|
|
148
142
|
actions.getTemplateDetails(id);
|
|
149
143
|
}
|
|
144
|
+
setEditFlow(true);
|
|
150
145
|
}
|
|
151
146
|
//cleanup code
|
|
152
147
|
return () => {
|
|
@@ -160,10 +155,9 @@ export const Whatsapp = (props) => {
|
|
|
160
155
|
name = '',
|
|
161
156
|
versions = {},
|
|
162
157
|
createdAt = '',
|
|
163
|
-
} =
|
|
158
|
+
} = editData.templateDetails || templateData || {};
|
|
164
159
|
editContent = get(versions, `base.content.whatsapp`, {});
|
|
165
160
|
if (editContent && !isEmpty(editContent)) {
|
|
166
|
-
setEditFlow(true);
|
|
167
161
|
setTemplateName(name);
|
|
168
162
|
setTemplateDate(createdAt);
|
|
169
163
|
const {
|
|
@@ -267,27 +261,6 @@ export const Whatsapp = (props) => {
|
|
|
267
261
|
}
|
|
268
262
|
}, [metaEntities, isEditFlow]);
|
|
269
263
|
|
|
270
|
-
//performs tag validation
|
|
271
|
-
useEffect(() => {
|
|
272
|
-
if (
|
|
273
|
-
!isFullMode &&
|
|
274
|
-
updatedSmsEditor?.length > 0 &&
|
|
275
|
-
!updatedSmsEditor.join('').match(validVarRegex)
|
|
276
|
-
) {
|
|
277
|
-
tagValidationResponse =
|
|
278
|
-
validateTags({
|
|
279
|
-
content: updatedSmsEditor.join(''),
|
|
280
|
-
tagsParam: tags,
|
|
281
|
-
injectedTagsParams: injectedTags,
|
|
282
|
-
location,
|
|
283
|
-
tagModule: getDefaultTags,
|
|
284
|
-
}) || {};
|
|
285
|
-
updateIsTagValidationError(
|
|
286
|
-
tagValidationResponse.unsupportedTags.length > 0,
|
|
287
|
-
);
|
|
288
|
-
}
|
|
289
|
-
}, [updatedSmsEditor, tags]);
|
|
290
|
-
|
|
291
264
|
const handleOnTagsContextChange = (data) => {
|
|
292
265
|
const { type } = location.query || {};
|
|
293
266
|
const isEmbedded = type === EMBEDDED;
|
|
@@ -495,16 +468,13 @@ export const Whatsapp = (props) => {
|
|
|
495
468
|
languages: [
|
|
496
469
|
{
|
|
497
470
|
language: 'en',
|
|
498
|
-
content:
|
|
499
|
-
|
|
500
|
-
|
|
501
|
-
: `$'${templateMessage}\nClick {{${
|
|
502
|
-
addedVarCount + 1 }}} to unsubscribe'`,
|
|
471
|
+
content: `$'${templateMessage}\nClick {{${
|
|
472
|
+
addedVarCount + 1
|
|
473
|
+
}}} to unsubscribe'`,
|
|
503
474
|
},
|
|
504
475
|
],
|
|
505
|
-
mediaType: '
|
|
506
|
-
varMapped:
|
|
507
|
-
templateEditor: templateMessage,
|
|
476
|
+
mediaType: 'text',
|
|
477
|
+
varMapped: {},
|
|
508
478
|
accountId,
|
|
509
479
|
accessToken,
|
|
510
480
|
accountName,
|
|
@@ -549,15 +519,6 @@ export const Whatsapp = (props) => {
|
|
|
549
519
|
}
|
|
550
520
|
};
|
|
551
521
|
|
|
552
|
-
const saveToMessage = () => {
|
|
553
|
-
getFormData({
|
|
554
|
-
value: createPayload(),
|
|
555
|
-
_id: params?.paramObj?.id,
|
|
556
|
-
validity: true,
|
|
557
|
-
type: 'WHATSAPP',
|
|
558
|
-
});
|
|
559
|
-
}
|
|
560
|
-
|
|
561
522
|
const isDisableDone = () => {
|
|
562
523
|
//if template name is not entered
|
|
563
524
|
if (templateName.trim() === '' || templateNameError) {
|
|
@@ -580,7 +541,7 @@ export const Whatsapp = (props) => {
|
|
|
580
541
|
<CapHeader
|
|
581
542
|
title={
|
|
582
543
|
<CapHeading type="h4">
|
|
583
|
-
{formatMessage(
|
|
544
|
+
{formatMessage(globalMessages.templateNameLabel)}
|
|
584
545
|
<CapTooltipWithInfo
|
|
585
546
|
infoIconProps={{
|
|
586
547
|
style: { marginLeft: CAP_SPACE_04 },
|
|
@@ -600,7 +561,7 @@ export const Whatsapp = (props) => {
|
|
|
600
561
|
id={`whatsapp_template_name_input`}
|
|
601
562
|
onChange={onTemplateNameChange}
|
|
602
563
|
errorMessage={templateNameError}
|
|
603
|
-
placeholder={formatMessage(
|
|
564
|
+
placeholder={formatMessage(globalMessages.templateNamePlaceholder)}
|
|
604
565
|
defaultValue={templateName || ''}
|
|
605
566
|
value={templateName || ''}
|
|
606
567
|
size="default"
|
|
@@ -813,23 +774,14 @@ export const Whatsapp = (props) => {
|
|
|
813
774
|
}
|
|
814
775
|
};
|
|
815
776
|
|
|
816
|
-
const tagValidationErrorMessage = () => {
|
|
817
|
-
const { unsupportedTags = [] } = tagValidationResponse;
|
|
818
|
-
let tagError = '';
|
|
819
|
-
if (unsupportedTags.length > 0) {
|
|
820
|
-
tagError = formatMessage(messages.unsupportedTagsValidationError, {
|
|
821
|
-
unsupportedTags,
|
|
822
|
-
});
|
|
823
|
-
}
|
|
824
|
-
return <CapError>{tagError}</CapError>;
|
|
825
|
-
};
|
|
826
|
-
|
|
827
777
|
const editModeContent = (
|
|
828
778
|
<>
|
|
829
|
-
|
|
830
|
-
|
|
831
|
-
|
|
832
|
-
|
|
779
|
+
{templateStatus && (
|
|
780
|
+
<CapAlert
|
|
781
|
+
message={getTemplateStatusMessage()}
|
|
782
|
+
type={getTemplateStatusType()}
|
|
783
|
+
/>
|
|
784
|
+
)}
|
|
833
785
|
<CapRow className="whatsapp-render-heading">
|
|
834
786
|
<CapHeader
|
|
835
787
|
title={
|
|
@@ -863,7 +815,6 @@ export const Whatsapp = (props) => {
|
|
|
863
815
|
</CapTooltip>
|
|
864
816
|
|
|
865
817
|
{renderMessageLength()}
|
|
866
|
-
{isTagValidationError && tagValidationErrorMessage()}
|
|
867
818
|
</>
|
|
868
819
|
);
|
|
869
820
|
//edit methods end
|
|
@@ -884,22 +835,15 @@ export const Whatsapp = (props) => {
|
|
|
884
835
|
<TemplatePreview
|
|
885
836
|
channel={WHATSAPP}
|
|
886
837
|
content={{ templateMsg }}
|
|
838
|
+
whatsappContentLen={isEditFlow ? updatedSmsEditor.join('').length : templateMessage.length}
|
|
887
839
|
whatsappAccountName={accountName}
|
|
888
840
|
/>
|
|
889
841
|
);
|
|
890
842
|
};
|
|
891
843
|
|
|
892
|
-
const isEditDoneDisabled = () => {
|
|
893
|
-
return isTagValidationError || Object.values(varMap).some( (inputValue) => {
|
|
894
|
-
if (inputValue === '') {
|
|
895
|
-
return true;
|
|
896
|
-
}
|
|
897
|
-
});
|
|
898
|
-
}
|
|
899
|
-
|
|
900
844
|
return (
|
|
901
845
|
<CapSpin spinning={spin}>
|
|
902
|
-
<CapRow>
|
|
846
|
+
<CapRow className='cap-whatsapp-creatives'>
|
|
903
847
|
<CapColumn span={14}>
|
|
904
848
|
{isEditFlow ? editModeContent : createModeContent}
|
|
905
849
|
<div className="whatsapp-scroll-div" />
|
|
@@ -931,17 +875,6 @@ export const Whatsapp = (props) => {
|
|
|
931
875
|
</CapButton>
|
|
932
876
|
</>
|
|
933
877
|
)}
|
|
934
|
-
{!isFullMode && isEditFlow && (
|
|
935
|
-
<>
|
|
936
|
-
<CapButton
|
|
937
|
-
onClick={saveToMessage}
|
|
938
|
-
disabled={isEditDoneDisabled()}
|
|
939
|
-
className="whatsapp-create-btn"
|
|
940
|
-
>
|
|
941
|
-
<FormattedMessage {...messages.done} />
|
|
942
|
-
</CapButton>
|
|
943
|
-
</>
|
|
944
|
-
)}
|
|
945
878
|
</WhatsappFooter>
|
|
946
879
|
</CapSpin>
|
|
947
880
|
);
|