@capillarytech/creatives-library 8.0.92 → 8.0.94
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/Templates/constants.js +7 -0
- package/containers/Templates/index.js +43 -24
- package/package.json +1 -1
- package/services/api.js +1 -7
- package/services/tests/api.test.js +1 -5
- package/v2Components/CapImageUpload/index.js +10 -13
- package/v2Components/CapVideoUpload/index.js +9 -12
- package/v2Components/CapWhatsappCTA/messages.js +0 -4
- package/v2Components/TemplatePreview/_templatePreview.scss +0 -20
- package/v2Components/TemplatePreview/index.js +105 -160
- package/v2Components/TemplatePreview/tests/__snapshots__/index.test.js.snap +6 -6
- package/v2Containers/CreativesContainer/index.js +5 -92
- package/v2Containers/CreativesContainer/tests/__snapshots__/SlideBoxContent.test.js.snap +0 -1
- package/v2Containers/Templates/_templates.scss +0 -47
- package/v2Containers/Templates/index.js +5 -55
- package/v2Containers/Templates/tests/__snapshots__/index.test.js.snap +156 -177
- package/v2Containers/Whatsapp/constants.js +1 -87
- package/v2Containers/Whatsapp/index.js +189 -707
- package/v2Containers/Whatsapp/index.scss +1 -52
- package/v2Containers/Whatsapp/messages.js +2 -38
- package/v2Containers/Whatsapp/tests/__snapshots__/index.test.js.snap +91371 -30860
- package/v2Containers/Whatsapp/tests/__snapshots__/utils.test.js.snap +0 -6
- package/v2Containers/Whatsapp/tests/utils.test.js +1 -80
- package/v2Containers/Whatsapp/utils.js +0 -34
- package/v2Containers/mockdata.js +0 -2
- package/v2Components/CapWhatsappCarouselButton/constant.js +0 -56
- package/v2Components/CapWhatsappCarouselButton/index.js +0 -446
- package/v2Components/CapWhatsappCarouselButton/index.scss +0 -39
- package/v2Components/CapWhatsappCarouselButton/tests/index.test.js +0 -237
- package/v2Components/TemplatePreview/assets/images/empty_image_preview.svg +0 -4
- package/v2Components/TemplatePreview/assets/images/empty_video_preview.svg +0 -4
|
@@ -66,10 +66,10 @@ exports[`Test Templates container Should render correct preview component for wh
|
|
|
66
66
|
test
|
|
67
67
|
</CapLabel>
|
|
68
68
|
<div
|
|
69
|
-
className="msg-container whatsapp-message-container
|
|
69
|
+
className="msg-container whatsapp-message-container"
|
|
70
70
|
>
|
|
71
71
|
<div
|
|
72
|
-
className="message-pop align-left
|
|
72
|
+
className="message-pop align-left"
|
|
73
73
|
style={
|
|
74
74
|
Object {
|
|
75
75
|
"background-color": "#ffffff",
|
|
@@ -163,10 +163,10 @@ exports[`Test Templates container Should render correct preview component for wh
|
|
|
163
163
|
test
|
|
164
164
|
</CapLabel>
|
|
165
165
|
<div
|
|
166
|
-
className="msg-container whatsapp-message-container
|
|
166
|
+
className="msg-container whatsapp-message-container"
|
|
167
167
|
>
|
|
168
168
|
<div
|
|
169
|
-
className="message-pop align-left
|
|
169
|
+
className="message-pop align-left"
|
|
170
170
|
style={
|
|
171
171
|
Object {
|
|
172
172
|
"background-color": "#ffffff",
|
|
@@ -235,10 +235,10 @@ exports[`Test Templates container Should render correct preview component for wh
|
|
|
235
235
|
test
|
|
236
236
|
</CapLabel>
|
|
237
237
|
<div
|
|
238
|
-
className="msg-container whatsapp-message-container
|
|
238
|
+
className="msg-container whatsapp-message-container"
|
|
239
239
|
>
|
|
240
240
|
<div
|
|
241
|
-
className="message-pop align-left
|
|
241
|
+
className="message-pop align-left"
|
|
242
242
|
style={
|
|
243
243
|
Object {
|
|
244
244
|
"background-color": "#ffffff",
|
|
@@ -44,7 +44,7 @@ import {
|
|
|
44
44
|
import { IMAGE, VIDEO } from '../Facebook/Advertisement/constant';
|
|
45
45
|
import { CREATIVE } from '../Facebook/constants';
|
|
46
46
|
import { LOYALTY } from '../App/constants';
|
|
47
|
-
import { WHATSAPP_STATUSES, WHATSAPP_MEDIA_TYPES
|
|
47
|
+
import { WHATSAPP_STATUSES, WHATSAPP_MEDIA_TYPES } from '../Whatsapp/constants';
|
|
48
48
|
|
|
49
49
|
import { updateImagesInHtml } from '../../utils/cdnTransformation';
|
|
50
50
|
import { IOS } from '../InApp/constants';
|
|
@@ -58,7 +58,6 @@ import {
|
|
|
58
58
|
CAP_SPACE_32, CAP_SPACE_56, CAP_SPACE_64,
|
|
59
59
|
} from '@capillarytech/cap-ui-library/styled/variables';
|
|
60
60
|
import { DAEMON } from '@capillarytech/vulcan-react-sdk/utils/sagaInjectorTypes';
|
|
61
|
-
import { DYNAMIC_URL } from '../../v2Components/CapWhatsappCTA/constants';
|
|
62
61
|
|
|
63
62
|
const classPrefix = 'add-creatives-section';
|
|
64
63
|
const CREATIVES_CONTAINER = 'creativesContainer';
|
|
@@ -230,39 +229,6 @@ export class Creatives extends React.Component {
|
|
|
230
229
|
this.setState({ isGetFormData: false });
|
|
231
230
|
};
|
|
232
231
|
|
|
233
|
-
mapCarouselDataToCreatives = (cards) => {
|
|
234
|
-
return cards.map((card) => {
|
|
235
|
-
const { cardVarMapped, bodyTemplate, media, buttons, mediaType } = card || {};
|
|
236
|
-
const buttonData = buttons?.map((button) => {
|
|
237
|
-
const { type, text, phoneNumber, url, dynamicUrlPayload } = button || {};
|
|
238
|
-
const buttonObj = { type, text };
|
|
239
|
-
if (type === PHONE_NUMBER) {
|
|
240
|
-
buttonObj.phone_number = phoneNumber;
|
|
241
|
-
}
|
|
242
|
-
if (type === URL) {
|
|
243
|
-
buttonObj.url = url;
|
|
244
|
-
if (dynamicUrlPayload) {
|
|
245
|
-
buttonObj.urlType = DYNAMIC_URL;
|
|
246
|
-
}
|
|
247
|
-
}
|
|
248
|
-
return buttonObj;
|
|
249
|
-
});
|
|
250
|
-
return {
|
|
251
|
-
bodyText: bodyTemplate,
|
|
252
|
-
varMap: cardVarMapped,
|
|
253
|
-
...(mediaType === IMAGE && {
|
|
254
|
-
imageUrl: media?.url,
|
|
255
|
-
}),
|
|
256
|
-
...(mediaType === VIDEO && {
|
|
257
|
-
videoUrl: media?.url,
|
|
258
|
-
videoPreviewImg: media?.previewUrl,
|
|
259
|
-
}),
|
|
260
|
-
buttons: buttonData,
|
|
261
|
-
mediaType: mediaType?.toLowerCase(),
|
|
262
|
-
};
|
|
263
|
-
});
|
|
264
|
-
}
|
|
265
|
-
|
|
266
232
|
getTemplateData = (templateData) => { //from consumers to creatives
|
|
267
233
|
const { isFullMode, messageDetails = {}, smsRegister } = this.props;
|
|
268
234
|
const { additionalProperties = {} } = messageDetails;
|
|
@@ -504,7 +470,6 @@ export class Creatives extends React.Component {
|
|
|
504
470
|
mediaType = 'TEXT',
|
|
505
471
|
whatsappMedia = {},
|
|
506
472
|
isPreviewUrl = false,
|
|
507
|
-
cards = [],
|
|
508
473
|
} = {},
|
|
509
474
|
} = templateData;
|
|
510
475
|
const mediaParams = {};
|
|
@@ -527,7 +492,7 @@ export class Creatives extends React.Component {
|
|
|
527
492
|
default:
|
|
528
493
|
break;
|
|
529
494
|
}
|
|
530
|
-
const modifiedButtons = cloneDeep(buttons)
|
|
495
|
+
const modifiedButtons = cloneDeep(buttons).map((btn) => {
|
|
531
496
|
if (btn.type === 'PHONE_NUMBER') {
|
|
532
497
|
btn.phone_number = btn.phoneNumber;
|
|
533
498
|
delete btn.phoneNumber;
|
|
@@ -571,10 +536,6 @@ export class Creatives extends React.Component {
|
|
|
571
536
|
},
|
|
572
537
|
],
|
|
573
538
|
isPreviewUrl,
|
|
574
|
-
carouselData: this.mapCarouselDataToCreatives(cards),
|
|
575
|
-
...(cards?.length && {
|
|
576
|
-
mediaType: WHATSAPP_MEDIA_TYPES.CAROUSEL,
|
|
577
|
-
}),
|
|
578
539
|
},
|
|
579
540
|
},
|
|
580
541
|
},
|
|
@@ -621,47 +582,6 @@ export class Creatives extends React.Component {
|
|
|
621
582
|
return templateData || null;
|
|
622
583
|
}
|
|
623
584
|
|
|
624
|
-
getCarouselMappedData = (carouselData = []) => {
|
|
625
|
-
return carouselData.map((carousel) => {
|
|
626
|
-
const { bodyText, imageUrl, videoUrl, videoPreviewImg, buttons, mediaType, cardVarMapped, bodyTemplate } = carousel || {};
|
|
627
|
-
const buttonData = buttons.map((button, index) => {
|
|
628
|
-
const { type, text, phone_number, urlType, url } = button || {};
|
|
629
|
-
const buttonObj = {
|
|
630
|
-
type,
|
|
631
|
-
text,
|
|
632
|
-
index,
|
|
633
|
-
};
|
|
634
|
-
if (type === PHONE_NUMBER) {
|
|
635
|
-
buttonObj.phoneNumber = phone_number;
|
|
636
|
-
}
|
|
637
|
-
if (type === URL) {
|
|
638
|
-
buttonObj.url = url;
|
|
639
|
-
if (urlType === DYNAMIC_URL) {
|
|
640
|
-
const dynamicUrlPayload = url?.match(/{{(.*?)}}/g);
|
|
641
|
-
buttonObj.dynamicUrlPayload = dynamicUrlPayload?.length === 1 ? dynamicUrlPayload[0] : '';
|
|
642
|
-
}
|
|
643
|
-
}
|
|
644
|
-
return buttonObj;
|
|
645
|
-
});
|
|
646
|
-
return {
|
|
647
|
-
body: bodyText,
|
|
648
|
-
cardVarMapped,
|
|
649
|
-
bodyTemplate,
|
|
650
|
-
media: {
|
|
651
|
-
...(mediaType?.toLowerCase() === IMAGE.toLowerCase() && {
|
|
652
|
-
url: imageUrl,
|
|
653
|
-
}),
|
|
654
|
-
...(mediaType?.toLowerCase() === VIDEO.toLowerCase() && {
|
|
655
|
-
url: videoUrl,
|
|
656
|
-
previewUrl: videoPreviewImg,
|
|
657
|
-
}),
|
|
658
|
-
},
|
|
659
|
-
buttons: buttonData,
|
|
660
|
-
mediaType: mediaType?.toUpperCase(),
|
|
661
|
-
};
|
|
662
|
-
});
|
|
663
|
-
};
|
|
664
|
-
|
|
665
585
|
getCreativesData = async (channel, template, templateRecords) => { //from creatives to consumers
|
|
666
586
|
let templateData = { channel };
|
|
667
587
|
switch (channel) {
|
|
@@ -834,7 +754,6 @@ export class Creatives extends React.Component {
|
|
|
834
754
|
headerTemplate = '',
|
|
835
755
|
} = {},
|
|
836
756
|
isPreviewUrl = false,
|
|
837
|
-
carouselData = [],
|
|
838
757
|
} = cloneDeep(versions.base.content.whatsapp);
|
|
839
758
|
|
|
840
759
|
const modifiedButtons = cloneDeep(buttons).map((btn) => {
|
|
@@ -901,17 +820,11 @@ export class Creatives extends React.Component {
|
|
|
901
820
|
varMapped,
|
|
902
821
|
category,
|
|
903
822
|
language: languages[0].language,
|
|
904
|
-
|
|
905
|
-
|
|
906
|
-
buttons: modifiedButtons,
|
|
907
|
-
whatsappMedia,
|
|
908
|
-
}),
|
|
823
|
+
buttonType,
|
|
824
|
+
buttons: modifiedButtons,
|
|
909
825
|
mediaType,
|
|
826
|
+
whatsappMedia,
|
|
910
827
|
isPreviewUrl,
|
|
911
|
-
...(mediaType === WHATSAPP_MEDIA_TYPES.CAROUSEL && {
|
|
912
|
-
cards: this.getCarouselMappedData(carouselData),
|
|
913
|
-
mediaType: carouselData[0]?.mediaType?.toUpperCase(),
|
|
914
|
-
}),
|
|
915
828
|
},
|
|
916
829
|
};
|
|
917
830
|
}
|
|
@@ -172,53 +172,6 @@
|
|
|
172
172
|
}
|
|
173
173
|
|
|
174
174
|
}
|
|
175
|
-
|
|
176
|
-
.WHATSAPP {
|
|
177
|
-
.cap-custom-card {
|
|
178
|
-
.ant-card-body {
|
|
179
|
-
.ant-card-meta {
|
|
180
|
-
background-color: $CAP_G09;
|
|
181
|
-
padding: 0;
|
|
182
|
-
.ant-card-meta-description {
|
|
183
|
-
.whatsapp-container {
|
|
184
|
-
background-color: $CAP_WHITE;
|
|
185
|
-
padding: $CAP_SPACE_12;
|
|
186
|
-
}
|
|
187
|
-
.scroll-container {
|
|
188
|
-
overflow-x: auto;
|
|
189
|
-
display: flex;
|
|
190
|
-
padding-top: $CAP_SPACE_06;
|
|
191
|
-
padding-right: $CAP_SPACE_06;
|
|
192
|
-
white-space: nowrap;
|
|
193
|
-
scrollbar-width: none; // Hide scrollbar in Firefox
|
|
194
|
-
&::-webkit-scrollbar {
|
|
195
|
-
display: none; // Hide scrollbar in Chrome/Safari/Opera
|
|
196
|
-
}
|
|
197
|
-
overflow: hidden;
|
|
198
|
-
.whatsapp-carousel-container {
|
|
199
|
-
padding: $CAP_SPACE_04 0px $CAP_SPACE_08;
|
|
200
|
-
border-radius: $CAP_SPACE_06;
|
|
201
|
-
background-color: $CAP_WHITE;
|
|
202
|
-
width: 80%;
|
|
203
|
-
flex-shrink: 0;
|
|
204
|
-
margin-right: $CAP_SPACE_04;
|
|
205
|
-
white-space: pre-wrap;
|
|
206
|
-
word-break: break-word;
|
|
207
|
-
overflow: auto;
|
|
208
|
-
text-align: left;
|
|
209
|
-
.whatsapp-carousel-card {
|
|
210
|
-
margin: $CAP_SPACE_02 $CAP_SPACE_06 $CAP_SPACE_01 $CAP_SPACE_08;
|
|
211
|
-
.whatsapp-carousel-body {
|
|
212
|
-
margin-bottom: $CAP_SPACE_08;
|
|
213
|
-
}
|
|
214
|
-
}
|
|
215
|
-
}
|
|
216
|
-
}
|
|
217
|
-
}
|
|
218
|
-
}
|
|
219
|
-
}
|
|
220
|
-
}
|
|
221
|
-
}
|
|
222
175
|
}
|
|
223
176
|
|
|
224
177
|
.create-new-link{
|
|
@@ -113,12 +113,10 @@ import {
|
|
|
113
113
|
KARIX_GUPSHUP_CATEGORY_OPTIONS,
|
|
114
114
|
ICS_CATEGORY_OPTIONS,
|
|
115
115
|
HOST_ICS,
|
|
116
|
-
IMAGE,
|
|
117
|
-
VIDEO,
|
|
118
116
|
} from '../Whatsapp/constants';
|
|
119
117
|
import { INAPP_LAYOUT_DETAILS } from '../InApp/constants';
|
|
120
118
|
import { ZALO_STATUS_OPTIONS, ZALO_STATUSES } from '../Zalo/constants';
|
|
121
|
-
import { getWhatsappContent, getWhatsappStatus, getWhatsappCategory, getWhatsappCta, getWhatsappQuickReply, getWhatsappAutoFill
|
|
119
|
+
import { getWhatsappContent, getWhatsappStatus, getWhatsappCategory, getWhatsappCta, getWhatsappQuickReply, getWhatsappAutoFill } from '../Whatsapp/utils';
|
|
122
120
|
import { getRCSContent } from '../Rcs/utils';
|
|
123
121
|
import zaloMessages from '../Zalo/messages';
|
|
124
122
|
import globalMessages from '../../v2Containers/Cap/messages';
|
|
@@ -136,8 +134,7 @@ import whatsappOrZaloAccountIllustration from '../Assets/images/whatsappOrZaloAc
|
|
|
136
134
|
import rcsIllustration from '../Assets/images/rcsIllustration.png';
|
|
137
135
|
import zaloillustration from '@capillarytech/cap-ui-library/assets/images/featureUiNotEnabledIllustration.svg';
|
|
138
136
|
import inAppIllustration from '@capillarytech/cap-ui-library/assets/images/featureUiNotEnabledIllustration.svg';
|
|
139
|
-
|
|
140
|
-
import whatsappVideoEmptyPreview from '../../v2Components/TemplatePreview/assets/images/empty_video_preview.svg';
|
|
137
|
+
|
|
141
138
|
import { CAP_SPACE_16 } from '@capillarytech/cap-ui-library/styled/variables';
|
|
142
139
|
import { GA } from '@capillarytech/cap-ui-utils';
|
|
143
140
|
import { MAPP_SDK } from '../InApp/constants';
|
|
@@ -1113,7 +1110,8 @@ export class Templates extends React.Component { // eslint-disable-line react/pr
|
|
|
1113
1110
|
? this.getCreativesEditText(channelLowerCase)
|
|
1114
1111
|
: messages.selectButton
|
|
1115
1112
|
);
|
|
1116
|
-
|
|
1113
|
+
|
|
1114
|
+
const cardDataList = filteredTemplates && filteredTemplates.length ? map(filteredTemplates, (template) => {
|
|
1117
1115
|
const androidBodyType = get(template, 'versions.base.content.ANDROID.bodyType');
|
|
1118
1116
|
const iosBodyType = get(template, 'versions.base.content.IOS.bodyType');
|
|
1119
1117
|
const inappBodyType = androidBodyType || iosBodyType;
|
|
@@ -1368,7 +1366,7 @@ export class Templates extends React.Component { // eslint-disable-line react/pr
|
|
|
1368
1366
|
break;
|
|
1369
1367
|
}
|
|
1370
1368
|
case WHATSAPP: {
|
|
1371
|
-
const { whatsappImageSrc = '', templateMsg, docPreview, whatsappVideoPreviewImg = '', templateHeaderPreview, templateFooterPreview
|
|
1369
|
+
const { whatsappImageSrc = '', templateMsg, docPreview, whatsappVideoPreviewImg = '', templateHeaderPreview, templateFooterPreview} = getWhatsappContent(template);
|
|
1372
1370
|
templateData.title = (
|
|
1373
1371
|
<CapRow>
|
|
1374
1372
|
<CapLabel className="whatsapp-rcs-template-name">{template?.name}</CapLabel>
|
|
@@ -1377,7 +1375,6 @@ export class Templates extends React.Component { // eslint-disable-line react/pr
|
|
|
1377
1375
|
);
|
|
1378
1376
|
templateData.content = (
|
|
1379
1377
|
<>
|
|
1380
|
-
<div className='whatsapp-container'>
|
|
1381
1378
|
{whatsappImageSrc && (
|
|
1382
1379
|
<CapImage src={whatsappImageSrc} className="whatsapp-image" />
|
|
1383
1380
|
)}
|
|
@@ -1407,53 +1404,6 @@ export class Templates extends React.Component { // eslint-disable-line react/pr
|
|
|
1407
1404
|
{getWhatsappCta(template)}
|
|
1408
1405
|
{getWhatsappQuickReply(template)}
|
|
1409
1406
|
{getWhatsappAutoFill(template)}
|
|
1410
|
-
</div>
|
|
1411
|
-
<div className="scroll-container">
|
|
1412
|
-
{carouselData.map((data, index) => {
|
|
1413
|
-
return (
|
|
1414
|
-
<div
|
|
1415
|
-
key={`carousel-${index + 1}`}
|
|
1416
|
-
className="whatsapp-carousel-container"
|
|
1417
|
-
role="group"
|
|
1418
|
-
>
|
|
1419
|
-
<div className="whatsapp-carousel-card">
|
|
1420
|
-
{data?.mediaType === IMAGE.toLowerCase() && (
|
|
1421
|
-
<CapImage
|
|
1422
|
-
src={data?.imageUrl ? data?.imageUrl : whatsappImageEmptyPreview}
|
|
1423
|
-
className="whatsapp-image"
|
|
1424
|
-
/>
|
|
1425
|
-
)}
|
|
1426
|
-
{data?.mediaType === VIDEO.toLowerCase() && (
|
|
1427
|
-
<div className="video-preview">
|
|
1428
|
-
<CapImage
|
|
1429
|
-
src={data?.videoPreviewImg ? data?.videoPreviewImg : whatsappVideoEmptyPreview}
|
|
1430
|
-
className="whatsapp-image"
|
|
1431
|
-
/>
|
|
1432
|
-
<div className="icon-position">
|
|
1433
|
-
<CapImage
|
|
1434
|
-
className="video-icon"
|
|
1435
|
-
src={videoPlay}
|
|
1436
|
-
/>
|
|
1437
|
-
</div>
|
|
1438
|
-
</div>
|
|
1439
|
-
)}
|
|
1440
|
-
<span
|
|
1441
|
-
className={`${
|
|
1442
|
-
(data?.imageUrl || data?.videoPreviewImg)
|
|
1443
|
-
? 'whatsapp-message-with-media'
|
|
1444
|
-
: 'whatsapp-message-without-media'
|
|
1445
|
-
}`}
|
|
1446
|
-
>
|
|
1447
|
-
<CapLabel type="label9" className='whatsapp-carousel-body'>
|
|
1448
|
-
{data?.bodyText}
|
|
1449
|
-
</CapLabel>
|
|
1450
|
-
</span>
|
|
1451
|
-
{getWhatsappCarouselButtonView(data?.buttons, false)}
|
|
1452
|
-
</div>
|
|
1453
|
-
</div>
|
|
1454
|
-
)
|
|
1455
|
-
})}
|
|
1456
|
-
</div>
|
|
1457
1407
|
</>
|
|
1458
1408
|
);
|
|
1459
1409
|
break;
|