@capillarytech/creatives-library 8.0.87-alpha.21 → 8.0.87-alpha.22
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 +6 -0
- package/containers/Templates/index.js +44 -24
- package/package.json +1 -1
- package/services/api.js +20 -10
- package/services/tests/api.test.js +5 -1
- package/utils/commonUtils.js +64 -10
- package/utils/tests/commonUtil.test.js +108 -3
- package/utils/tests/transformerUtils.test.js +2127 -0
- package/v2Components/CapImageUpload/index.js +13 -10
- package/v2Components/CapVideoUpload/index.js +12 -9
- package/v2Components/CapWhatsappCTA/messages.js +4 -0
- package/v2Components/CapWhatsappCarouselButton/constant.js +56 -0
- package/v2Components/CapWhatsappCarouselButton/index.js +446 -0
- package/v2Components/CapWhatsappCarouselButton/index.scss +39 -0
- package/v2Components/CapWhatsappCarouselButton/tests/index.test.js +237 -0
- package/v2Components/FormBuilder/constants.js +8 -0
- package/v2Components/FormBuilder/index.js +2 -2
- package/v2Components/TemplatePreview/_templatePreview.scss +20 -0
- package/v2Components/TemplatePreview/assets/images/empty_image_preview.svg +4 -0
- package/v2Components/TemplatePreview/assets/images/empty_video_preview.svg +4 -0
- package/v2Components/TemplatePreview/index.js +160 -105
- package/v2Components/TemplatePreview/tests/__snapshots__/index.test.js.snap +6 -6
- package/v2Containers/CreativesContainer/SlideBoxContent.js +0 -6
- package/v2Containers/CreativesContainer/index.js +100 -7
- package/v2Containers/CreativesContainer/tests/__snapshots__/SlideBoxContent.test.js.snap +3 -0
- package/v2Containers/Email/index.js +0 -1
- package/v2Containers/EmailWrapper/components/EmailWrapperView.js +192 -0
- package/v2Containers/EmailWrapper/constants.js +11 -1
- package/v2Containers/EmailWrapper/hooks/useEmailWrapper.js +343 -0
- package/v2Containers/EmailWrapper/index.js +116 -300
- package/v2Containers/EmailWrapper/mockdata/mockdata.js +119 -0
- package/v2Containers/EmailWrapper/tests/EmailWrapperView.test.js +214 -0
- package/v2Containers/EmailWrapper/tests/index.test.js +101 -0
- package/v2Containers/EmailWrapper/tests/useEmailWrapper.test.js +601 -0
- package/v2Containers/MobilePush/Edit/index.js +0 -1
- package/v2Containers/MobilepushWrapper/index.js +1 -2
- package/v2Containers/Sms/Create/index.js +0 -1
- package/v2Containers/SmsWrapper/index.js +0 -2
- package/v2Containers/Templates/_templates.scss +47 -0
- package/v2Containers/Templates/index.js +55 -5
- package/v2Containers/Templates/tests/__snapshots__/index.test.js.snap +177 -156
- package/v2Containers/Whatsapp/constants.js +87 -1
- package/v2Containers/Whatsapp/index.js +715 -190
- package/v2Containers/Whatsapp/index.scss +52 -1
- package/v2Containers/Whatsapp/messages.js +38 -2
- package/v2Containers/Whatsapp/styles.scss +5 -0
- package/v2Containers/Whatsapp/tests/__snapshots__/index.test.js.snap +27722 -90751
- package/v2Containers/Whatsapp/tests/__snapshots__/utils.test.js.snap +6 -0
- package/v2Containers/Whatsapp/tests/mockData.js +3 -7
- package/v2Containers/Whatsapp/tests/utils.test.js +178 -1
- package/v2Containers/Whatsapp/utils.js +52 -0
- package/v2Containers/Zalo/index.js +47 -15
- package/v2Containers/Zalo/index.scss +8 -0
- package/v2Containers/Zalo/messages.js +4 -0
- package/v2Containers/mockdata.js +2 -0
|
@@ -20,6 +20,7 @@ import {
|
|
|
20
20
|
CAP_PURPLE01,
|
|
21
21
|
CAP_G16,
|
|
22
22
|
CAP_SPACE_08,
|
|
23
|
+
CAP_SPACE_04,
|
|
23
24
|
} from '@capillarytech/cap-ui-library/styled/variables';
|
|
24
25
|
import isEmpty from 'lodash/isEmpty';
|
|
25
26
|
import './_templatePreview.scss';
|
|
@@ -43,14 +44,16 @@ import inAppMobileIOSModal from './assets/images/inapp_mobile_ios_modal.svg';
|
|
|
43
44
|
import inAppMobileIOSTop from './assets/images/inapp_mobile_ios_top.svg';
|
|
44
45
|
import inAppMobileIOSBottom from './assets/images/inapp_mobile_ios_bottom.svg';
|
|
45
46
|
import inAppMobileIOSFull from './assets/images/inapp_mobile_ios_full.svg';
|
|
47
|
+
import whatsappImageEmptyPreview from './assets/images/empty_image_preview.svg';
|
|
48
|
+
import whatsappVideoEmptyPreview from './assets/images/empty_video_preview.svg';
|
|
46
49
|
import videoPlay from '../../assets/videoPlay.svg';
|
|
47
50
|
import zaloMessage from '../../v2Containers/Zalo/messages';
|
|
48
51
|
import { handlePreviewInNewTab } from '../../utils/common';
|
|
49
52
|
import { TEMPLATE, IMAGE_CAROUSEL, IMAGE, STICKER, TEXT, IMAGE_MAP, VIDEO } from '../../v2Containers/Line/Container/constants';
|
|
50
53
|
import CapFacebookPreview from '../../v2Containers/CapFacebookPreview';
|
|
51
54
|
import WhatsappStatusContainer from '../WhatsappStatusContainer';
|
|
52
|
-
import { getWhatsappQuickReply } from '../../v2Containers/Whatsapp/utils';
|
|
53
|
-
import { QUICK_REPLY, WHATSAPP_CATEGORIES } from '../../v2Containers/Whatsapp/constants';
|
|
55
|
+
import { getWhatsappQuickReply, getWhatsappCarouselButtonView } from '../../v2Containers/Whatsapp/utils';
|
|
56
|
+
import { QUICK_REPLY, WHATSAPP_CATEGORIES, PHONE_NUMBER } from '../../v2Containers/Whatsapp/constants';
|
|
54
57
|
import { ANDROID, INAPP_MESSAGE_LAYOUT_TYPES } from '../../v2Containers/InApp/constants';
|
|
55
58
|
|
|
56
59
|
const wechatBodyNew = require('./assets/images/wechat_mobile_android.svg');
|
|
@@ -213,7 +216,7 @@ export class TemplatePreview extends React.Component { // eslint-disable-line re
|
|
|
213
216
|
iosActions = _.map(content.actions, (action) => {
|
|
214
217
|
if (action.label) {
|
|
215
218
|
return (<div className="actions" key={`action-${action.label}`}>
|
|
216
|
-
|
|
219
|
+
<span className="action">{action.label.toUpperCase()}</span>
|
|
217
220
|
</div>);
|
|
218
221
|
}
|
|
219
222
|
return undefined;
|
|
@@ -253,6 +256,15 @@ export class TemplatePreview extends React.Component { // eslint-disable-line re
|
|
|
253
256
|
'width': '88%',
|
|
254
257
|
'left': 0,
|
|
255
258
|
};
|
|
259
|
+
const carouselWhatsappSectionStyle = {
|
|
260
|
+
'padding': `${CAP_SPACE_04} 0 ${CAP_SPACE_08}`,
|
|
261
|
+
'border-radius': '0.428rem',
|
|
262
|
+
'background-color': CAP_WHITE,
|
|
263
|
+
'width': '10.4rem',
|
|
264
|
+
'cursor': 'pointer',
|
|
265
|
+
'flex-shrink': 0,
|
|
266
|
+
'left': 0,
|
|
267
|
+
};
|
|
256
268
|
const getVideoContent = ({
|
|
257
269
|
video,
|
|
258
270
|
actionUrl,
|
|
@@ -274,53 +286,53 @@ export class TemplatePreview extends React.Component { // eslint-disable-line re
|
|
|
274
286
|
>
|
|
275
287
|
{
|
|
276
288
|
video
|
|
277
|
-
|
|
278
|
-
|
|
279
|
-
|
|
280
|
-
|
|
281
|
-
|
|
282
|
-
|
|
283
|
-
|
|
284
|
-
|
|
285
|
-
|
|
286
|
-
|
|
287
|
-
|
|
288
|
-
>
|
|
289
|
-
<CapButton
|
|
290
|
-
className="preview-video-btn"
|
|
291
|
-
type="flat"
|
|
289
|
+
? (
|
|
290
|
+
<>
|
|
291
|
+
<video style={{ opacity: 0.5, width: '100%' }}>
|
|
292
|
+
<source src={video} type="video/mp4" />
|
|
293
|
+
</video>
|
|
294
|
+
<div
|
|
295
|
+
style={{
|
|
296
|
+
position: 'absolute',
|
|
297
|
+
display: 'flex',
|
|
298
|
+
flexDirection: 'column',
|
|
299
|
+
}}
|
|
292
300
|
>
|
|
301
|
+
<CapButton
|
|
302
|
+
className="preview-video-btn"
|
|
303
|
+
type="flat"
|
|
304
|
+
>
|
|
293
305
|
<CapIcon type="play"/>
|
|
294
|
-
|
|
295
|
-
|
|
296
|
-
|
|
297
|
-
|
|
298
|
-
|
|
299
|
-
|
|
300
|
-
|
|
301
|
-
|
|
302
|
-
|
|
306
|
+
<FormattedMessage {...messages.playVideo} />
|
|
307
|
+
</CapButton>
|
|
308
|
+
{
|
|
309
|
+
actionUrl
|
|
310
|
+
? (
|
|
311
|
+
<CapButton
|
|
312
|
+
className="preview-video-btn"
|
|
313
|
+
type="flat"
|
|
314
|
+
>
|
|
303
315
|
<CapIcon type="reply" style={{ fontSize: 18 }}/>
|
|
304
|
-
|
|
305
|
-
|
|
306
|
-
|
|
307
|
-
|
|
308
|
-
|
|
309
|
-
|
|
310
|
-
|
|
311
|
-
|
|
312
|
-
|
|
313
|
-
|
|
314
|
-
|
|
315
|
-
|
|
316
|
-
|
|
317
|
-
|
|
318
|
-
|
|
319
|
-
|
|
320
|
-
|
|
321
|
-
|
|
322
|
-
|
|
323
|
-
|
|
316
|
+
<FormattedMessage {...messages.showDetails} />
|
|
317
|
+
</CapButton>
|
|
318
|
+
)
|
|
319
|
+
: null
|
|
320
|
+
}
|
|
321
|
+
</div>
|
|
322
|
+
</>
|
|
323
|
+
)
|
|
324
|
+
: (
|
|
325
|
+
<CapImage
|
|
326
|
+
src={lineVideoPlaceholder}
|
|
327
|
+
alt="brand-name"
|
|
328
|
+
rest={{
|
|
329
|
+
style: {
|
|
330
|
+
width: 126,
|
|
331
|
+
marginBottom: 5,
|
|
332
|
+
},
|
|
333
|
+
}}
|
|
334
|
+
/>
|
|
335
|
+
)
|
|
324
336
|
}
|
|
325
337
|
</div>
|
|
326
338
|
);
|
|
@@ -336,10 +348,10 @@ export class TemplatePreview extends React.Component { // eslint-disable-line re
|
|
|
336
348
|
renderArray.push(
|
|
337
349
|
<CapLabel type="label21" className="whatsapp-cta-preview">
|
|
338
350
|
{type !== WHATSAPP_CATEGORIES.authentication && <CapIcon
|
|
339
|
-
|
|
340
|
-
|
|
341
|
-
|
|
342
|
-
|
|
351
|
+
type={
|
|
352
|
+
(ctaType || type) === PHONE_NUMBER ? 'call' : 'launch'
|
|
353
|
+
}
|
|
354
|
+
size="xs"
|
|
343
355
|
/>}
|
|
344
356
|
{text}
|
|
345
357
|
</CapLabel>,
|
|
@@ -430,42 +442,42 @@ export class TemplatePreview extends React.Component { // eslint-disable-line re
|
|
|
430
442
|
{this.props.showCount &&
|
|
431
443
|
channel &&
|
|
432
444
|
channel.toLowerCase() !== FACEBOOK && (
|
|
433
|
-
|
|
434
|
-
|
|
435
|
-
|
|
436
|
-
|
|
437
|
-
|
|
438
|
-
|
|
439
|
-
|
|
440
|
-
|
|
441
|
-
|
|
442
|
-
|
|
443
|
-
|
|
444
|
-
|
|
445
|
-
|
|
446
|
-
|
|
447
|
-
|
|
448
|
-
|
|
449
|
-
|
|
445
|
+
<CapColumn span={16}>
|
|
446
|
+
{channel && channel.toLowerCase() === "sms" && (
|
|
447
|
+
<CapHeading type="h3">
|
|
448
|
+
<FormattedMessage
|
|
449
|
+
{...messages.charactersTotal}
|
|
450
|
+
values={{
|
|
451
|
+
smsCount: smsDetails.parts,
|
|
452
|
+
charCount: smsDetails.chars_used,
|
|
453
|
+
}}
|
|
454
|
+
/>
|
|
455
|
+
{smsDetails.unicode && (
|
|
456
|
+
<FormattedMessage {...messages.smsFormatType} />
|
|
457
|
+
)}
|
|
458
|
+
</CapHeading>
|
|
459
|
+
)}
|
|
460
|
+
{smsDetails.optoutUrlPresent && (
|
|
461
|
+
<CapHeading type="h6">
|
|
462
|
+
<FormattedMessage
|
|
463
|
+
{...messages.optoutCharactersTotal}
|
|
464
|
+
values={{ optoutUrlLength: smsDetails.optouturlLength }}
|
|
465
|
+
/>
|
|
466
|
+
</CapHeading>
|
|
467
|
+
)}
|
|
468
|
+
{channel?.toLowerCase() === WHATSAPP.toLowerCase() ? (
|
|
469
|
+
<>
|
|
470
|
+
<WhatsappStatusContainer template={templateData} />
|
|
471
|
+
<CapHeading type="h3" className="margin-t-12">
|
|
450
472
|
<FormattedMessage
|
|
451
|
-
{...messages.
|
|
452
|
-
values={{
|
|
473
|
+
{...messages.whatsappMessageLength}
|
|
474
|
+
values={{ length: whatsappUpdatedLen }}
|
|
453
475
|
/>
|
|
454
476
|
</CapHeading>
|
|
455
|
-
|
|
456
|
-
|
|
457
|
-
|
|
458
|
-
|
|
459
|
-
<CapHeading type="h3" className="margin-t-12">
|
|
460
|
-
<FormattedMessage
|
|
461
|
-
{...messages.whatsappMessageLength}
|
|
462
|
-
values={{ length: whatsappUpdatedLen }}
|
|
463
|
-
/>
|
|
464
|
-
</CapHeading>
|
|
465
|
-
</>
|
|
466
|
-
) : null}
|
|
467
|
-
</CapColumn>
|
|
468
|
-
)}
|
|
477
|
+
</>
|
|
478
|
+
) : null}
|
|
479
|
+
</CapColumn>
|
|
480
|
+
)}
|
|
469
481
|
<CapColumn span={this.props.showCount ? 8 : 24}>
|
|
470
482
|
{showTestAndPreview && (
|
|
471
483
|
<div className="test-and-preview-container">
|
|
@@ -628,9 +640,9 @@ export class TemplatePreview extends React.Component { // eslint-disable-line re
|
|
|
628
640
|
)}
|
|
629
641
|
{content.actions.filter((action) => action.label)
|
|
630
642
|
.length ? (
|
|
631
|
-
|
|
632
|
-
|
|
633
|
-
|
|
643
|
+
<div className="actions">
|
|
644
|
+
{_.map(
|
|
645
|
+
content.actions,
|
|
634
646
|
(action) =>
|
|
635
647
|
!!action.label && (
|
|
636
648
|
<span
|
|
@@ -640,11 +652,11 @@ export class TemplatePreview extends React.Component { // eslint-disable-line re
|
|
|
640
652
|
{action.label && action.label.toUpperCase()}
|
|
641
653
|
</span>
|
|
642
654
|
)
|
|
643
|
-
|
|
644
|
-
|
|
645
|
-
|
|
646
|
-
|
|
647
|
-
|
|
655
|
+
)}
|
|
656
|
+
</div>
|
|
657
|
+
) : (
|
|
658
|
+
""
|
|
659
|
+
)}
|
|
648
660
|
</div>
|
|
649
661
|
) : (
|
|
650
662
|
<div className="message-pop align-left">
|
|
@@ -980,14 +992,14 @@ export class TemplatePreview extends React.Component { // eslint-disable-line re
|
|
|
980
992
|
<CapLabel className="whatsapp-brand-name">
|
|
981
993
|
{whatsappUpdatedAccountName || ""}
|
|
982
994
|
</CapLabel>
|
|
983
|
-
<div className=
|
|
995
|
+
<div className={`msg-container whatsapp-message-container ${content?.carouselData && 'msg-container-carousel'}`}>
|
|
984
996
|
<div
|
|
985
|
-
className=
|
|
997
|
+
className={`message-pop align-left ${content?.carouselData && 'message-pop-carousel'}`}
|
|
986
998
|
style={whatsappSectionStyle}
|
|
987
999
|
>
|
|
988
1000
|
<div className="whatsapp-content">
|
|
989
|
-
{content?.showUrlPreview
|
|
990
|
-
renderUrlPreview(content?.metaTagsDetails)}
|
|
1001
|
+
{content?.showUrlPreview
|
|
1002
|
+
&& renderUrlPreview(content?.metaTagsDetails)}
|
|
991
1003
|
{content?.whatsappImageSrc && (
|
|
992
1004
|
<CapImage
|
|
993
1005
|
src={content.whatsappImageSrc}
|
|
@@ -1026,6 +1038,49 @@ export class TemplatePreview extends React.Component { // eslint-disable-line re
|
|
|
1026
1038
|
{renderQuickReplyPreview()}
|
|
1027
1039
|
</div>
|
|
1028
1040
|
</div>
|
|
1041
|
+
{content?.carouselData && (
|
|
1042
|
+
<div className="scroll-container">
|
|
1043
|
+
{content?.carouselData?.map((data, index) => (
|
|
1044
|
+
<div
|
|
1045
|
+
key={`carousel-${index}-${data?.bodyText}`}
|
|
1046
|
+
className="message-pop align-left message-pop-carousel"
|
|
1047
|
+
style={carouselWhatsappSectionStyle}>
|
|
1048
|
+
<div className="whatsapp-content">
|
|
1049
|
+
{content?.carouselMediaType === "image" && (
|
|
1050
|
+
<CapImage
|
|
1051
|
+
src={data?.imageSrc ? data?.imageSrc : whatsappImageEmptyPreview}
|
|
1052
|
+
className="whatsapp-image"
|
|
1053
|
+
alt={formatMessage(messages.previewGenerated)}
|
|
1054
|
+
/>
|
|
1055
|
+
)}
|
|
1056
|
+
{content?.carouselMediaType === "video" && (
|
|
1057
|
+
<CapTooltip
|
|
1058
|
+
title={formatMessage(messages.videoPreviewTooltip)}
|
|
1059
|
+
>
|
|
1060
|
+
<div className="video-preview">
|
|
1061
|
+
<CapImage
|
|
1062
|
+
src={data?.videoPreviewImg ? data?.videoPreviewImg : whatsappVideoEmptyPreview}
|
|
1063
|
+
className="whatsapp-image"
|
|
1064
|
+
alt={formatMessage(messages.previewGenerated)}
|
|
1065
|
+
/>
|
|
1066
|
+
<div className="icon-position">
|
|
1067
|
+
<CapImage
|
|
1068
|
+
className="video-icon"
|
|
1069
|
+
src={videoPlay}
|
|
1070
|
+
/>
|
|
1071
|
+
</div>
|
|
1072
|
+
</div>
|
|
1073
|
+
</CapTooltip>
|
|
1074
|
+
)}
|
|
1075
|
+
<CapLabel type="label5">
|
|
1076
|
+
{content?.isEditFlow ? data?.updatedBodyText?.join("") : data?.bodyText}
|
|
1077
|
+
</CapLabel>
|
|
1078
|
+
{getWhatsappCarouselButtonView(data?.buttons, true)}
|
|
1079
|
+
</div>
|
|
1080
|
+
</div>
|
|
1081
|
+
))}
|
|
1082
|
+
</div>
|
|
1083
|
+
)}
|
|
1029
1084
|
</div>
|
|
1030
1085
|
</div>
|
|
1031
1086
|
<CapHeading
|
|
@@ -1205,21 +1260,21 @@ export class TemplatePreview extends React.Component { // eslint-disable-line re
|
|
|
1205
1260
|
{ctaData &&
|
|
1206
1261
|
!isEmpty(ctaData) &&
|
|
1207
1262
|
ctaData[0]?.text !== "" && (
|
|
1208
|
-
|
|
1209
|
-
|
|
1210
|
-
|
|
1263
|
+
<CapButton
|
|
1264
|
+
type="primary"
|
|
1265
|
+
className={`inapp-button-${templateLayoutType}-${device} ${
|
|
1211
1266
|
mediaPreview?.inAppImageSrcAndroid
|
|
1212
1267
|
? ""
|
|
1213
1268
|
: `without-image-button-${templateLayoutType}-android`
|
|
1214
|
-
|
|
1269
|
+
} ${
|
|
1215
1270
|
mediaPreview?.inAppImageSrcIos
|
|
1216
1271
|
? ""
|
|
1217
1272
|
: `without-image-button-${templateLayoutType}-ios`
|
|
1218
|
-
|
|
1219
|
-
|
|
1220
|
-
|
|
1221
|
-
|
|
1222
|
-
|
|
1273
|
+
}`}
|
|
1274
|
+
>
|
|
1275
|
+
{ctaData[0]?.text}
|
|
1276
|
+
</CapButton>
|
|
1277
|
+
)}
|
|
1223
1278
|
</div>
|
|
1224
1279
|
</div>
|
|
1225
1280
|
</div>
|
|
@@ -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 undefined"
|
|
70
70
|
>
|
|
71
71
|
<div
|
|
72
|
-
className="message-pop align-left"
|
|
72
|
+
className="message-pop align-left undefined"
|
|
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 undefined"
|
|
167
167
|
>
|
|
168
168
|
<div
|
|
169
|
-
className="message-pop align-left"
|
|
169
|
+
className="message-pop align-left undefined"
|
|
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 undefined"
|
|
239
239
|
>
|
|
240
240
|
<div
|
|
241
|
-
className="message-pop align-left"
|
|
241
|
+
className="message-pop align-left undefined"
|
|
242
242
|
style={
|
|
243
243
|
Object {
|
|
244
244
|
"background-color": "#ffffff",
|
|
@@ -517,7 +517,6 @@ export function SlideBoxContent(props) {
|
|
|
517
517
|
onCreateComplete={onCreateComplete}
|
|
518
518
|
smsRegister={smsRegister}
|
|
519
519
|
eventContextTags={eventContextTags}
|
|
520
|
-
messageDetails={messageDetails}
|
|
521
520
|
/>
|
|
522
521
|
)}
|
|
523
522
|
{isEditFTP && (
|
|
@@ -586,7 +585,6 @@ export function SlideBoxContent(props) {
|
|
|
586
585
|
smsRegister={smsRegister}
|
|
587
586
|
onShowTemplates={onShowTemplates}
|
|
588
587
|
eventContextTags={eventContextTags}
|
|
589
|
-
messageDetails={messageDetails}
|
|
590
588
|
/>
|
|
591
589
|
)}
|
|
592
590
|
|
|
@@ -620,7 +618,6 @@ export function SlideBoxContent(props) {
|
|
|
620
618
|
showLiquidErrorInFooter={showLiquidErrorInFooter}
|
|
621
619
|
eventContextTags={eventContextTags}
|
|
622
620
|
isLoyaltyModule={isLoyaltyModule}
|
|
623
|
-
messageDetails={messageDetails}
|
|
624
621
|
/>
|
|
625
622
|
)}
|
|
626
623
|
{(isEditEmailWithId || isEmailEditWithContent) && (
|
|
@@ -651,7 +648,6 @@ export function SlideBoxContent(props) {
|
|
|
651
648
|
showLiquidErrorInFooter={showLiquidErrorInFooter}
|
|
652
649
|
eventContextTags={eventContextTags}
|
|
653
650
|
isLoyaltyModule={isLoyaltyModule}
|
|
654
|
-
messageDetails={messageDetails}
|
|
655
651
|
/>
|
|
656
652
|
)}
|
|
657
653
|
{isEditMPush &&
|
|
@@ -678,7 +674,6 @@ export function SlideBoxContent(props) {
|
|
|
678
674
|
hideTestAndPreviewBtn={hideTestAndPreviewBtn}
|
|
679
675
|
creativesMode={creativesMode}
|
|
680
676
|
eventContextTags={eventContextTags}
|
|
681
|
-
messageDetails={messageDetails}
|
|
682
677
|
/>
|
|
683
678
|
}
|
|
684
679
|
{isCreateMPush &&
|
|
@@ -708,7 +703,6 @@ export function SlideBoxContent(props) {
|
|
|
708
703
|
hideTestAndPreviewBtn={hideTestAndPreviewBtn}
|
|
709
704
|
onTestContentClicked={onTestContentClicked}
|
|
710
705
|
eventContextTags={eventContextTags}
|
|
711
|
-
messageDetails={messageDetails}
|
|
712
706
|
/>
|
|
713
707
|
}
|
|
714
708
|
{
|
|
@@ -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 } from '../Whatsapp/constants';
|
|
47
|
+
import { WHATSAPP_STATUSES, WHATSAPP_MEDIA_TYPES, PHONE_NUMBER, URL } from '../Whatsapp/constants';
|
|
48
48
|
|
|
49
49
|
import { updateImagesInHtml } from '../../utils/cdnTransformation';
|
|
50
50
|
import { IOS } from '../InApp/constants';
|
|
@@ -58,6 +58,7 @@ 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';
|
|
61
62
|
|
|
62
63
|
import {
|
|
63
64
|
transformChannelPayload,
|
|
@@ -234,6 +235,39 @@ export class Creatives extends React.Component {
|
|
|
234
235
|
this.setState({ isGetFormData: false });
|
|
235
236
|
};
|
|
236
237
|
|
|
238
|
+
mapCarouselDataToCreatives = (cards) => {
|
|
239
|
+
return cards.map((card) => {
|
|
240
|
+
const { cardVarMapped, bodyTemplate, media, buttons, mediaType } = card || {};
|
|
241
|
+
const buttonData = buttons?.map((button) => {
|
|
242
|
+
const { type, text, phoneNumber, url, dynamicUrlPayload } = button || {};
|
|
243
|
+
const buttonObj = { type, text };
|
|
244
|
+
if (type === PHONE_NUMBER) {
|
|
245
|
+
buttonObj.phone_number = phoneNumber;
|
|
246
|
+
}
|
|
247
|
+
if (type === URL) {
|
|
248
|
+
buttonObj.url = url;
|
|
249
|
+
if (dynamicUrlPayload) {
|
|
250
|
+
buttonObj.urlType = DYNAMIC_URL;
|
|
251
|
+
}
|
|
252
|
+
}
|
|
253
|
+
return buttonObj;
|
|
254
|
+
});
|
|
255
|
+
return {
|
|
256
|
+
bodyText: bodyTemplate,
|
|
257
|
+
varMap: cardVarMapped,
|
|
258
|
+
...(mediaType === IMAGE && {
|
|
259
|
+
imageUrl: media?.url,
|
|
260
|
+
}),
|
|
261
|
+
...(mediaType === VIDEO && {
|
|
262
|
+
videoUrl: media?.url,
|
|
263
|
+
videoPreviewImg: media?.previewUrl,
|
|
264
|
+
}),
|
|
265
|
+
buttons: buttonData,
|
|
266
|
+
mediaType: mediaType?.toLowerCase(),
|
|
267
|
+
};
|
|
268
|
+
});
|
|
269
|
+
}
|
|
270
|
+
|
|
237
271
|
getTemplateData = (templateData) => { //from consumers to creatives
|
|
238
272
|
const { isFullMode, messageDetails = {}, smsRegister } = this.props;
|
|
239
273
|
const { additionalProperties = {} } = messageDetails;
|
|
@@ -476,6 +510,7 @@ export class Creatives extends React.Component {
|
|
|
476
510
|
mediaType = 'TEXT',
|
|
477
511
|
whatsappMedia = {},
|
|
478
512
|
isPreviewUrl = false,
|
|
513
|
+
cards = [],
|
|
479
514
|
} = {},
|
|
480
515
|
} = templateData;
|
|
481
516
|
const mediaParams = {};
|
|
@@ -498,7 +533,7 @@ export class Creatives extends React.Component {
|
|
|
498
533
|
default:
|
|
499
534
|
break;
|
|
500
535
|
}
|
|
501
|
-
const modifiedButtons = cloneDeep(buttons)
|
|
536
|
+
const modifiedButtons = cloneDeep(buttons)?.map((btn) => {
|
|
502
537
|
if (btn.type === 'PHONE_NUMBER') {
|
|
503
538
|
btn.phone_number = btn.phoneNumber;
|
|
504
539
|
delete btn.phoneNumber;
|
|
@@ -542,6 +577,10 @@ export class Creatives extends React.Component {
|
|
|
542
577
|
},
|
|
543
578
|
],
|
|
544
579
|
isPreviewUrl,
|
|
580
|
+
carouselData: this.mapCarouselDataToCreatives(cards),
|
|
581
|
+
...(cards?.length && {
|
|
582
|
+
mediaType: WHATSAPP_MEDIA_TYPES.CAROUSEL,
|
|
583
|
+
}),
|
|
545
584
|
},
|
|
546
585
|
},
|
|
547
586
|
},
|
|
@@ -588,6 +627,47 @@ export class Creatives extends React.Component {
|
|
|
588
627
|
return templateData || null;
|
|
589
628
|
}
|
|
590
629
|
|
|
630
|
+
getCarouselMappedData = (carouselData = []) => {
|
|
631
|
+
return carouselData.map((carousel) => {
|
|
632
|
+
const { bodyText, imageUrl, videoUrl, videoPreviewImg, buttons, mediaType, cardVarMapped, bodyTemplate } = carousel || {};
|
|
633
|
+
const buttonData = buttons.map((button, index) => {
|
|
634
|
+
const { type, text, phone_number, urlType, url } = button || {};
|
|
635
|
+
const buttonObj = {
|
|
636
|
+
type,
|
|
637
|
+
text,
|
|
638
|
+
index,
|
|
639
|
+
};
|
|
640
|
+
if (type === PHONE_NUMBER) {
|
|
641
|
+
buttonObj.phoneNumber = phone_number;
|
|
642
|
+
}
|
|
643
|
+
if (type === URL) {
|
|
644
|
+
buttonObj.url = url;
|
|
645
|
+
if (urlType === DYNAMIC_URL) {
|
|
646
|
+
const dynamicUrlPayload = url?.match(/{{(.*?)}}/g);
|
|
647
|
+
buttonObj.dynamicUrlPayload = dynamicUrlPayload?.length === 1 ? dynamicUrlPayload[0] : '';
|
|
648
|
+
}
|
|
649
|
+
}
|
|
650
|
+
return buttonObj;
|
|
651
|
+
});
|
|
652
|
+
return {
|
|
653
|
+
body: bodyText,
|
|
654
|
+
cardVarMapped,
|
|
655
|
+
bodyTemplate,
|
|
656
|
+
media: {
|
|
657
|
+
...(mediaType?.toLowerCase() === IMAGE.toLowerCase() && {
|
|
658
|
+
url: imageUrl,
|
|
659
|
+
}),
|
|
660
|
+
...(mediaType?.toLowerCase() === VIDEO.toLowerCase() && {
|
|
661
|
+
url: videoUrl,
|
|
662
|
+
previewUrl: videoPreviewImg,
|
|
663
|
+
}),
|
|
664
|
+
},
|
|
665
|
+
buttons: buttonData,
|
|
666
|
+
mediaType: mediaType?.toUpperCase(),
|
|
667
|
+
};
|
|
668
|
+
});
|
|
669
|
+
};
|
|
670
|
+
|
|
591
671
|
getCreativesData = async (channel, template, templateRecords) => { //from creatives to consumers
|
|
592
672
|
let templateData = { channel };
|
|
593
673
|
switch (channel) {
|
|
@@ -666,7 +746,10 @@ export class Creatives extends React.Component {
|
|
|
666
746
|
forEach(androidContent.custom, (customKeyValue) => {
|
|
667
747
|
custom[customKeyValue.key] = customKeyValue.value;
|
|
668
748
|
});
|
|
669
|
-
|
|
749
|
+
//skipping it for MPUSH as custom key is already in the reqd format for hydra sdk
|
|
750
|
+
if (channel !== constants.MOBILE_PUSH) {
|
|
751
|
+
androidContent.custom = custom;
|
|
752
|
+
}
|
|
670
753
|
templateData.androidContent = androidContent;
|
|
671
754
|
templateData.androidContent.type = get(channelTemplate, 'definition.mode', '').toUpperCase();
|
|
672
755
|
templateData.androidContent.deviceType = 'ANDROID';
|
|
@@ -682,7 +765,10 @@ export class Creatives extends React.Component {
|
|
|
682
765
|
forEach(iosContent.custom, (customKeyValue) => {
|
|
683
766
|
custom[customKeyValue.key] = customKeyValue.value;
|
|
684
767
|
});
|
|
685
|
-
|
|
768
|
+
//skipping it for MPUSH as custom key is already in the reqd format for hydra sdk
|
|
769
|
+
if (channel !== constants.MOBILE_PUSH) {
|
|
770
|
+
iosContent.custom = custom;
|
|
771
|
+
}
|
|
686
772
|
templateData.iosContent = iosContent;
|
|
687
773
|
templateData.iosContent.type = get(channelTemplate, 'definition.mode').toUpperCase();
|
|
688
774
|
templateData.iosContent.deviceType = IOS.toUpperCase();
|
|
@@ -760,6 +846,7 @@ export class Creatives extends React.Component {
|
|
|
760
846
|
headerTemplate = '',
|
|
761
847
|
} = {},
|
|
762
848
|
isPreviewUrl = false,
|
|
849
|
+
carouselData = [],
|
|
763
850
|
} = cloneDeep(versions.base.content.whatsapp);
|
|
764
851
|
|
|
765
852
|
const modifiedButtons = cloneDeep(buttons).map((btn) => {
|
|
@@ -826,11 +913,17 @@ export class Creatives extends React.Component {
|
|
|
826
913
|
varMapped,
|
|
827
914
|
category,
|
|
828
915
|
language: languages[0].language,
|
|
829
|
-
|
|
830
|
-
|
|
916
|
+
...(mediaType !== WHATSAPP_MEDIA_TYPES.CAROUSEL && {
|
|
917
|
+
buttonType,
|
|
918
|
+
buttons: modifiedButtons,
|
|
919
|
+
whatsappMedia,
|
|
920
|
+
}),
|
|
831
921
|
mediaType,
|
|
832
|
-
whatsappMedia,
|
|
833
922
|
isPreviewUrl,
|
|
923
|
+
...(mediaType === WHATSAPP_MEDIA_TYPES.CAROUSEL && {
|
|
924
|
+
cards: this.getCarouselMappedData(carouselData),
|
|
925
|
+
mediaType: carouselData[0]?.mediaType?.toUpperCase(),
|
|
926
|
+
}),
|
|
834
927
|
},
|
|
835
928
|
};
|
|
836
929
|
}
|
|
@@ -651,6 +651,7 @@ exports[`Test SlideBoxContent container Should render correct component for rcs
|
|
|
651
651
|
"search": "",
|
|
652
652
|
}
|
|
653
653
|
}
|
|
654
|
+
loyaltyMetaData={Object {}}
|
|
654
655
|
messageDetails={Object {}}
|
|
655
656
|
onCreateComplete={[MockFunction]}
|
|
656
657
|
slidBoxContent="templates"
|
|
@@ -935,6 +936,7 @@ exports[`Test SlideBoxContent container Should render correct component for what
|
|
|
935
936
|
charCounterEnabled={false}
|
|
936
937
|
content={
|
|
937
938
|
Object {
|
|
939
|
+
"carouselData": Array [],
|
|
938
940
|
"charCount": 151,
|
|
939
941
|
"ctaData": Array [
|
|
940
942
|
Object {
|
|
@@ -1041,6 +1043,7 @@ exports[`Test SlideBoxContent container Should render correct component for what
|
|
|
1041
1043
|
"search": "",
|
|
1042
1044
|
}
|
|
1043
1045
|
}
|
|
1046
|
+
loyaltyMetaData={Object {}}
|
|
1044
1047
|
messageDetails={Object {}}
|
|
1045
1048
|
onCreateComplete={[MockFunction]}
|
|
1046
1049
|
slidBoxContent="templates"
|
|
@@ -2747,7 +2747,6 @@ export class Email extends React.Component { // eslint-disable-line react/prefer
|
|
|
2747
2747
|
eventContextTags={this.props?.eventContextTags}
|
|
2748
2748
|
forwardedTags={this.props?.forwardedTags}
|
|
2749
2749
|
isLoyaltyModule={this.props?.isLoyaltyModule}
|
|
2750
|
-
messageDetails={this.props?.messageDetails}
|
|
2751
2750
|
/> : ''}
|
|
2752
2751
|
</Col>
|
|
2753
2752
|
</Row>
|