@capillarytech/creatives-library 7.10.47 → 7.10.48
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/package.json +1 -1
- package/v2Components/TemplatePreview/assets/images/whatsapp_mobile_android.svg +2041 -1
- package/v2Containers/CreativesContainer/SlideBoxContent.js +1 -0
- package/v2Containers/CreativesContainer/index.js +44 -3
- package/v2Containers/Templates/index.js +44 -34
- package/v2Containers/Templates/messages.js +0 -8
- package/v2Containers/Whatsapp/index.js +40 -15
- package/v2Containers/Whatsapp/messages.js +4 -0
- package/v2Containers/Whatsapp/tests/__snapshots__/index.test.js.snap +5932 -33286
- package/v2Containers/Whatsapp/tests/index.test.js +9 -49
- package/v2Containers/Whatsapp/tests/mockData.js +1 -120
|
@@ -364,6 +364,28 @@ class Creatives extends React.Component {
|
|
|
364
364
|
};
|
|
365
365
|
break;
|
|
366
366
|
}
|
|
367
|
+
case constants.WHATSAPP: {
|
|
368
|
+
const { messageBody } = templateData;
|
|
369
|
+
const body = JSON.parse(messageBody || '{}');
|
|
370
|
+
console.log("getTemplateData body", body);
|
|
371
|
+
creativesTemplateData = {
|
|
372
|
+
type: constants.WHATSAPP,
|
|
373
|
+
edit: true,
|
|
374
|
+
name: "",
|
|
375
|
+
versions: {
|
|
376
|
+
base: {
|
|
377
|
+
content: {
|
|
378
|
+
...body,
|
|
379
|
+
whatsapp: {
|
|
380
|
+
...body.whatsapp,
|
|
381
|
+
status: 'approved'
|
|
382
|
+
}
|
|
383
|
+
},
|
|
384
|
+
},
|
|
385
|
+
},
|
|
386
|
+
};
|
|
387
|
+
break;
|
|
388
|
+
}
|
|
367
389
|
default:
|
|
368
390
|
break;
|
|
369
391
|
}
|
|
@@ -495,6 +517,27 @@ class Creatives extends React.Component {
|
|
|
495
517
|
};
|
|
496
518
|
}
|
|
497
519
|
break;
|
|
520
|
+
case constants.WHATSAPP:
|
|
521
|
+
if (template.value) {
|
|
522
|
+
const { Templates, templateData: templateDataProps } = this.props;
|
|
523
|
+
const { accountDetails: selectedAccountDetails, accountId: selectedAccountId } = templateDataProps || {};
|
|
524
|
+
const selectedWhatsappAccount = Templates?.selectedWhatsappAccount;
|
|
525
|
+
const accountDetails = (selectedWhatsappAccount ? selectedWhatsappAccount : selectedAccountDetails);
|
|
526
|
+
const accountId = selectedAccountId || (selectedWhatsappAccount?.id || '');
|
|
527
|
+
const { versions } = template.value;
|
|
528
|
+
const whatsappContent = cloneDeep(versions.base.content.whatsapp);
|
|
529
|
+
console.log("accountDetailsaccountDetails", accountDetails, accountDetails.name)
|
|
530
|
+
templateData = {
|
|
531
|
+
channel,
|
|
532
|
+
accountId,
|
|
533
|
+
accountName: accountDetails.name,
|
|
534
|
+
messageBody: JSON.stringify(whatsappContent.languages[0].content),
|
|
535
|
+
category: whatsappContent.category,
|
|
536
|
+
language: whatsappContent.languages[0].language,
|
|
537
|
+
mediaType: whatsappContent.mediaType,
|
|
538
|
+
};
|
|
539
|
+
}
|
|
540
|
+
break;
|
|
498
541
|
case constants.FACEBOOK: {
|
|
499
542
|
if (template.value) {
|
|
500
543
|
const FacebookAd = template?.value?.versions?.base?.content?.FacebookAd;
|
|
@@ -660,13 +703,11 @@ class Creatives extends React.Component {
|
|
|
660
703
|
});
|
|
661
704
|
}
|
|
662
705
|
handleCloseSlideBox = () => {
|
|
663
|
-
const { currentChannel = '', slidBoxContent = '' } = this.state;
|
|
664
|
-
const reloadTemplates = currentChannel === constants.WHATSAPP && slidBoxContent === 'editTemplate';
|
|
665
706
|
this.setState((prevState) => ({
|
|
666
707
|
...prevState,
|
|
667
708
|
templateData: undefined,
|
|
668
709
|
showSlideBox: false,
|
|
669
|
-
}),
|
|
710
|
+
}), this.props.handleCloseCreatives);
|
|
670
711
|
};
|
|
671
712
|
saveMessage = () => {
|
|
672
713
|
this.setState({ isGetFormData: true });
|
|
@@ -77,7 +77,7 @@ import emailIllustration from '../Assets/images/emailIllustration.svg';
|
|
|
77
77
|
import smsIllustration from '../Assets/images/smsIllustration.svg';
|
|
78
78
|
import pushIllustration from '../Assets/images/pushIllustration.svg';
|
|
79
79
|
import whatsappIllustration from '../Assets/images/whatsappIllustration.png';
|
|
80
|
-
import { CAP_SPACE_16
|
|
80
|
+
import { CAP_SPACE_16 } from '@capillarytech/cap-ui-library/styled/variables';
|
|
81
81
|
import { GA } from '@capillarytech/cap-ui-utils';
|
|
82
82
|
const { timeTracker } = GA;
|
|
83
83
|
const {CapCustomCardList} = CapCustomCard;
|
|
@@ -568,8 +568,9 @@ export class Templates extends React.Component { // eslint-disable-line react/pr
|
|
|
568
568
|
this.getAllTemplates({getNextPage: true});
|
|
569
569
|
}
|
|
570
570
|
onCreateComplete = (isReloadTemplates) => {
|
|
571
|
+
const isWhatsappEdit = this.state.routeParams?.pathname?.includes(`${WHATSAPP_LOWERCASE}/edit`);
|
|
571
572
|
this.setState({routeParams: null, previewOpen: false}, () => {
|
|
572
|
-
if (this.isFullMode() && isReloadTemplates) {
|
|
573
|
+
if (this.isFullMode() && (isReloadTemplates || isWhatsappEdit)) {
|
|
573
574
|
this.getAllTemplates({params: {}}, true);
|
|
574
575
|
}
|
|
575
576
|
});
|
|
@@ -705,10 +706,16 @@ export class Templates extends React.Component { // eslint-disable-line react/pr
|
|
|
705
706
|
}
|
|
706
707
|
|
|
707
708
|
isStatusMatching = (status, selectedWhatsappStatus) => {
|
|
708
|
-
if
|
|
709
|
-
|
|
709
|
+
if(this.props.isFullMode && selectedWhatsappStatus) {
|
|
710
|
+
if ( [WHATSAPP_STATUSES.unsubmitted, WHATSAPP_STATUSES.pending].includes(status) ) {
|
|
711
|
+
return selectedWhatsappStatus === WHATSAPP_STATUSES.awaitingApproval;
|
|
712
|
+
}
|
|
713
|
+
return selectedWhatsappStatus === status;
|
|
714
|
+
}
|
|
715
|
+
else if (!this.props.isFullMode){
|
|
716
|
+
return status === WHATSAPP_STATUSES.approved;
|
|
710
717
|
}
|
|
711
|
-
|
|
718
|
+
return true;
|
|
712
719
|
}
|
|
713
720
|
|
|
714
721
|
filterWhatsappTemplates = (templates) => {
|
|
@@ -718,9 +725,7 @@ export class Templates extends React.Component { // eslint-disable-line react/pr
|
|
|
718
725
|
|
|
719
726
|
// if status or category filter is applied, filter templates which match these filters
|
|
720
727
|
return (
|
|
721
|
-
selectedWhatsappStatus
|
|
722
|
-
? this.isStatusMatching(status, selectedWhatsappStatus)
|
|
723
|
-
: true
|
|
728
|
+
this.isStatusMatching(status, selectedWhatsappStatus)
|
|
724
729
|
) && (
|
|
725
730
|
selectedWhatsappCategory
|
|
726
731
|
? category === selectedWhatsappCategory
|
|
@@ -750,6 +755,7 @@ export class Templates extends React.Component { // eslint-disable-line react/pr
|
|
|
750
755
|
const channelLowerCase = stateChannel.toLowerCase();
|
|
751
756
|
let filteredTemplates = templates;
|
|
752
757
|
let isTraiDltFeature = false;
|
|
758
|
+
console.log("getTemplateDataForGrid", currentChannel);
|
|
753
759
|
switch (currentChannel) {
|
|
754
760
|
case WECHAT:
|
|
755
761
|
filteredTemplates = this.filterWechatTemplates(templates);
|
|
@@ -1000,22 +1006,11 @@ export class Templates extends React.Component { // eslint-disable-line react/pr
|
|
|
1000
1006
|
</CapHeading>
|
|
1001
1007
|
</div> : (
|
|
1002
1008
|
[WHATSAPP_LOWERCASE].includes(this.state.channel.toLowerCase()) &&
|
|
1009
|
+
isEmpty(filteredTemplates) &&
|
|
1003
1010
|
isEmpty(this.state.searchText) &&
|
|
1004
1011
|
!isLoading &&
|
|
1005
|
-
<div style={this.isFullMode() ? { height: "calc(100vh - 325px)", overflow: 'auto'
|
|
1006
|
-
|
|
1007
|
-
{!isEmpty(templates) && isEmpty(filteredTemplates) && <CapHeader
|
|
1008
|
-
title={
|
|
1009
|
-
<CapHeading type="h3" style={{ textAlign: "center", marginTop: CAP_SPACE_44 }}>
|
|
1010
|
-
{this.props.intl.formatMessage(messages.noFilteredWhatsappTemplatesTitle)}
|
|
1011
|
-
</CapHeading>
|
|
1012
|
-
}
|
|
1013
|
-
description={
|
|
1014
|
-
<CapLabel style={{ textAlign: "center" }}>
|
|
1015
|
-
{this.props.intl.formatMessage(messages.noFilteredWhatsappTemplatesDesc)}
|
|
1016
|
-
</CapLabel>
|
|
1017
|
-
}
|
|
1018
|
-
/>}
|
|
1012
|
+
<div style={this.isFullMode() ? { height: "calc(100vh - 325px)", overflow: 'auto'} : {}}>
|
|
1013
|
+
<CapIllustration buttonClassName={`create-new-${channelLowerCase}`} {...this.getChannelTypeIllustrationInfo(currentChannel)} />
|
|
1019
1014
|
</div>
|
|
1020
1015
|
)
|
|
1021
1016
|
}
|
|
@@ -2305,7 +2300,9 @@ export class Templates extends React.Component { // eslint-disable-line react/pr
|
|
|
2305
2300
|
type={"primary"}
|
|
2306
2301
|
disabled={this.isCreateDisabled()}
|
|
2307
2302
|
style={{marginLeft: '8px', marginBottom: '12px'}}
|
|
2308
|
-
onClick={this.createTemplate}
|
|
2303
|
+
onClick={this.createTemplate}
|
|
2304
|
+
target={channelLowerCase === WHATSAPP_LOWERCASE && !this.props.isFullMode ? "_blank" : null}
|
|
2305
|
+
>
|
|
2309
2306
|
{ this.props.intl.formatMessage((isTraiDltFeature && channel.toUpperCase() === SMS ) ? messages.uploadTemplate : messages.createNewActionButton) }
|
|
2310
2307
|
</CapButton>);
|
|
2311
2308
|
|
|
@@ -2339,16 +2336,19 @@ export class Templates extends React.Component { // eslint-disable-line react/pr
|
|
|
2339
2336
|
{
|
|
2340
2337
|
channel.toUpperCase() === WHATSAPP && (
|
|
2341
2338
|
<div className="whatsapp-filters">
|
|
2342
|
-
|
|
2343
|
-
|
|
2344
|
-
|
|
2345
|
-
|
|
2346
|
-
|
|
2347
|
-
|
|
2348
|
-
|
|
2349
|
-
|
|
2350
|
-
|
|
2351
|
-
|
|
2339
|
+
{
|
|
2340
|
+
this.props.isFullMode ? (
|
|
2341
|
+
<CapSelectFilter
|
|
2342
|
+
placement="bottomLeft"
|
|
2343
|
+
data={STATUS_OPTIONS}
|
|
2344
|
+
onSelect={this.setWhatsappStatus}
|
|
2345
|
+
selectedValue={this.state.selectedWhatsappStatus}
|
|
2346
|
+
placeholder="Status"
|
|
2347
|
+
showBadge={true}
|
|
2348
|
+
width="90px"
|
|
2349
|
+
/>
|
|
2350
|
+
) : null
|
|
2351
|
+
}
|
|
2352
2352
|
<CapSelectFilter
|
|
2353
2353
|
placement="bottomLeft"
|
|
2354
2354
|
data={CATEGORY_OPTIONS}
|
|
@@ -2357,7 +2357,6 @@ export class Templates extends React.Component { // eslint-disable-line react/pr
|
|
|
2357
2357
|
placeholder="Category"
|
|
2358
2358
|
showBadge={true}
|
|
2359
2359
|
width="105px"
|
|
2360
|
-
overlayStyle={{ overflowY: "hidden" }}
|
|
2361
2360
|
/>
|
|
2362
2361
|
</div>
|
|
2363
2362
|
|
|
@@ -2481,10 +2480,21 @@ export class Templates extends React.Component { // eslint-disable-line react/pr
|
|
|
2481
2480
|
|
|
2482
2481
|
<CapRow>
|
|
2483
2482
|
<Pagination onPageChange={templates.length ? this.onPaginationChange : () => {}} paginationSelector="pagination-container">
|
|
2483
|
+
|
|
2484
|
+
{
|
|
2485
|
+
channel.toLowerCase() === WHATSAPP_LOWERCASE ? (
|
|
2486
|
+
<CapAlert message={whatsappCountExceedText} type="info" />
|
|
2487
|
+
) : null
|
|
2488
|
+
}
|
|
2484
2489
|
{this.getTemplateDataForGrid({isLoading, loadingTip, channel: this.state.channel, templates: this.props.TemplatesList, filterContent, handlers: {handlePreviewClick: this.handlePreviewClick, handleEditClick: this.handleEditClick}})}
|
|
2485
2490
|
</Pagination>
|
|
2486
2491
|
{(((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) &&
|
|
2487
2492
|
<div style={{ height: '65vh', textAlign: 'center', lineHeight: '65vh'}}>
|
|
2493
|
+
{
|
|
2494
|
+
channel.toLowerCase() === WHATSAPP_LOWERCASE ? (
|
|
2495
|
+
<CapAlert message={whatsappCountExceedText} type="info" />
|
|
2496
|
+
) : null
|
|
2497
|
+
}
|
|
2488
2498
|
<CapHeading type="h6">{this.props.intl.formatMessage(messages.noTemplatesFound)}</CapHeading>
|
|
2489
2499
|
</div>}
|
|
2490
2500
|
</CapRow>
|
|
@@ -342,14 +342,6 @@ export default defineMessages({
|
|
|
342
342
|
id: `${scope}.whatsappDescIllustration`,
|
|
343
343
|
defaultMessage: 'These templates can be reused when creating a\nnew message content.',
|
|
344
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
|
-
},
|
|
353
345
|
"smsTitleIllustartion": {
|
|
354
346
|
id: `${scope}.smsTitleIllustartion`,
|
|
355
347
|
defaultMessage: 'Create an SMS {template}',
|
|
@@ -73,6 +73,7 @@ export const Whatsapp = (props) => {
|
|
|
73
73
|
metaEntities,
|
|
74
74
|
injectedTags,
|
|
75
75
|
loadingTags,
|
|
76
|
+
getFormData
|
|
76
77
|
} = props || {};
|
|
77
78
|
const { formatMessage } = intl;
|
|
78
79
|
const { TextArea } = CapInput;
|
|
@@ -91,7 +92,9 @@ export const Whatsapp = (props) => {
|
|
|
91
92
|
//for edit only
|
|
92
93
|
const [isEditFlow, setEditFlow] = useState(false);
|
|
93
94
|
const [templateDate, setTemplateDate] = useState('');
|
|
94
|
-
const [templateStatus, setTemplateStatus] = useState(
|
|
95
|
+
const [templateStatus, setTemplateStatus] = useState(
|
|
96
|
+
WHATSAPP_STATUSES.unsubmitted,
|
|
97
|
+
);
|
|
95
98
|
const [templateRejectionReason, setTemplateRejectionReason] = useState(null);
|
|
96
99
|
const [tempMsgArray, updateTempMsgArray] = useState([]);
|
|
97
100
|
const [updatedSmsEditor, setUpdatedSmsEditor] = useState([]);
|
|
@@ -108,7 +111,8 @@ export const Whatsapp = (props) => {
|
|
|
108
111
|
width: 100%;
|
|
109
112
|
margin-left: -32px;
|
|
110
113
|
padding: ${CAP_SPACE_32} ${CAP_SPACE_24};
|
|
111
|
-
|
|
114
|
+
z-index: 1;
|
|
115
|
+
|
|
112
116
|
.ant-btn {
|
|
113
117
|
margin-right: ${CAP_SPACE_16};
|
|
114
118
|
}
|
|
@@ -140,7 +144,6 @@ export const Whatsapp = (props) => {
|
|
|
140
144
|
setSpin(true);
|
|
141
145
|
actions.getTemplateDetails(id);
|
|
142
146
|
}
|
|
143
|
-
setEditFlow(true);
|
|
144
147
|
}
|
|
145
148
|
//cleanup code
|
|
146
149
|
return () => {
|
|
@@ -154,9 +157,10 @@ export const Whatsapp = (props) => {
|
|
|
154
157
|
name = '',
|
|
155
158
|
versions = {},
|
|
156
159
|
createdAt = '',
|
|
157
|
-
} = editData.templateDetails
|
|
160
|
+
} = isFullMode ? editData.templateDetails : templateData;
|
|
158
161
|
editContent = get(versions, `base.content.whatsapp`, {});
|
|
159
162
|
if (editContent && !isEmpty(editContent)) {
|
|
163
|
+
setEditFlow(true);
|
|
160
164
|
setTemplateName(name);
|
|
161
165
|
setTemplateDate(createdAt);
|
|
162
166
|
const {
|
|
@@ -467,13 +471,16 @@ export const Whatsapp = (props) => {
|
|
|
467
471
|
languages: [
|
|
468
472
|
{
|
|
469
473
|
language: 'en',
|
|
470
|
-
content:
|
|
471
|
-
|
|
472
|
-
|
|
474
|
+
content:
|
|
475
|
+
isEditFlow
|
|
476
|
+
? `${updatedSmsEditor.join('')} ${formatMessage(messages.templateMessageUnsubscribeText)}`
|
|
477
|
+
: `$'${templateMessage}\nClick {{${
|
|
478
|
+
addedVarCount + 1 }}} to unsubscribe'`,
|
|
473
479
|
},
|
|
474
480
|
],
|
|
475
|
-
mediaType: '
|
|
476
|
-
varMapped:
|
|
481
|
+
mediaType: 'TEXT',
|
|
482
|
+
varMapped: varMap,
|
|
483
|
+
templateEditor: templateMessage,
|
|
477
484
|
accountId,
|
|
478
485
|
accessToken,
|
|
479
486
|
accountName,
|
|
@@ -518,6 +525,15 @@ export const Whatsapp = (props) => {
|
|
|
518
525
|
}
|
|
519
526
|
};
|
|
520
527
|
|
|
528
|
+
const saveToMessage = () => {
|
|
529
|
+
getFormData({
|
|
530
|
+
value: createPayload(),
|
|
531
|
+
_id: params?.paramObj?.id,
|
|
532
|
+
validity: true,
|
|
533
|
+
type: 'WHATSAPP',
|
|
534
|
+
});
|
|
535
|
+
}
|
|
536
|
+
|
|
521
537
|
const isDisableDone = () => {
|
|
522
538
|
//if template name is not entered
|
|
523
539
|
if (templateName.trim() === '' || templateNameError) {
|
|
@@ -775,12 +791,10 @@ export const Whatsapp = (props) => {
|
|
|
775
791
|
|
|
776
792
|
const editModeContent = (
|
|
777
793
|
<>
|
|
778
|
-
|
|
779
|
-
|
|
780
|
-
|
|
781
|
-
|
|
782
|
-
/>
|
|
783
|
-
)}
|
|
794
|
+
<CapAlert
|
|
795
|
+
message={getTemplateStatusMessage()}
|
|
796
|
+
type={getTemplateStatusType()}
|
|
797
|
+
/>
|
|
784
798
|
<CapRow className="whatsapp-render-heading">
|
|
785
799
|
<CapHeader
|
|
786
800
|
title={
|
|
@@ -873,6 +887,17 @@ export const Whatsapp = (props) => {
|
|
|
873
887
|
</CapButton>
|
|
874
888
|
</>
|
|
875
889
|
)}
|
|
890
|
+
{!isFullMode && isEditFlow && (
|
|
891
|
+
<>
|
|
892
|
+
<CapButton
|
|
893
|
+
onClick={saveToMessage}
|
|
894
|
+
//disabled={isDisableDone()}
|
|
895
|
+
className="whatsapp-create-btn"
|
|
896
|
+
>
|
|
897
|
+
<FormattedMessage {...messages.done} />
|
|
898
|
+
</CapButton>
|
|
899
|
+
</>
|
|
900
|
+
)}
|
|
876
901
|
</WhatsappFooter>
|
|
877
902
|
</CapSpin>
|
|
878
903
|
);
|