@capillarytech/creatives-library 8.0.88-alpha.7 → 8.0.88

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.
Files changed (32) hide show
  1. package/package.json +1 -1
  2. package/services/api.js +1 -7
  3. package/services/tests/api.test.js +1 -5
  4. package/v2Components/CapImageUpload/index.js +10 -13
  5. package/v2Components/CapVideoUpload/index.js +9 -12
  6. package/v2Components/CapWhatsappCTA/messages.js +0 -4
  7. package/v2Components/TemplatePreview/_templatePreview.scss +0 -9
  8. package/v2Components/TemplatePreview/index.js +105 -171
  9. package/v2Components/TemplatePreview/tests/__snapshots__/index.test.js.snap +6 -6
  10. package/v2Containers/CreativesContainer/index.js +4 -91
  11. package/v2Containers/CreativesContainer/tests/__snapshots__/SlideBoxContent.test.js.snap +0 -1
  12. package/v2Containers/Templates/_templates.scss +0 -47
  13. package/v2Containers/Templates/index.js +5 -55
  14. package/v2Containers/Templates/tests/__snapshots__/index.test.js.snap +156 -177
  15. package/v2Containers/Whatsapp/constants.js +1 -87
  16. package/v2Containers/Whatsapp/index.js +189 -707
  17. package/v2Containers/Whatsapp/index.scss +1 -52
  18. package/v2Containers/Whatsapp/messages.js +2 -38
  19. package/v2Containers/Whatsapp/tests/__snapshots__/index.test.js.snap +91371 -30860
  20. package/v2Containers/Whatsapp/tests/__snapshots__/utils.test.js.snap +0 -6
  21. package/v2Containers/Whatsapp/tests/utils.test.js +1 -80
  22. package/v2Containers/Whatsapp/utils.js +0 -34
  23. package/v2Containers/Zalo/index.js +37 -14
  24. package/v2Containers/Zalo/index.scss +4 -0
  25. package/v2Containers/Zalo/messages.js +4 -0
  26. package/v2Containers/mockdata.js +0 -2
  27. package/v2Components/CapWhatsappCarouselButton/constant.js +0 -56
  28. package/v2Components/CapWhatsappCarouselButton/index.js +0 -446
  29. package/v2Components/CapWhatsappCarouselButton/index.scss +0 -39
  30. package/v2Components/CapWhatsappCarouselButton/tests/index.test.js +0 -237
  31. package/v2Components/TemplatePreview/assets/images/empty_image_preview.svg +0 -4
  32. package/v2Components/TemplatePreview/assets/images/empty_video_preview.svg +0 -4
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@capillarytech/creatives-library",
3
3
  "author": "meharaj",
4
- "version": "8.0.88-alpha.7",
4
+ "version": "8.0.88",
5
5
  "description": "Capillary creatives ui",
6
6
  "main": "./index.js",
7
7
  "module": "./index.es.js",
package/services/api.js CHANGED
@@ -524,13 +524,7 @@ export const checkBulkDuplicates = (data) => {
524
524
  export const createWhatsappTemplate = ({payload, gupshupMediaFile }) => {
525
525
  const data = new FormData();
526
526
  data.append('payload', JSON.stringify(payload));
527
- if (Array.isArray(gupshupMediaFile) && gupshupMediaFile?.length) {
528
- gupshupMediaFile.forEach((file, index) => {
529
- data.append(`gupshupMediaFile_${index}`, file);
530
- });
531
- } else {
532
- data.append('gupshupMediaFile', gupshupMediaFile);
533
- }
527
+ data.append('gupshupMediaFile', gupshupMediaFile);
534
528
  const url = `${API_ENDPOINT}/templates/WHATSAPP`;
535
529
  return request(url, getAPICallObject('POST', data, true));
536
530
  };
@@ -86,11 +86,7 @@ describe('uploadFile -- whatsapp image upload', () => {
86
86
  describe('createWhatsappTemplate -- Test with valid responses', () => {
87
87
  it('Should return correct response', () =>
88
88
  expect(
89
- createWhatsappTemplate({gupshupMediaFile: [sampleFile], payload: mockData.createWhatsappPayload}),
90
- ).toEqual(Promise.resolve()));
91
- it('Should return correct response when single file is present', () =>
92
- expect(
93
- createWhatsappTemplate({gupshupMediaFile: sampleFile, payload: mockData.createWhatsappPayload}),
89
+ createWhatsappTemplate(sampleFile, mockData.createWhatsappPayload),
94
90
  ).toEqual(Promise.resolve()));
95
91
  });
96
92
 
@@ -44,7 +44,6 @@ function CapImageUpload(props) {
44
44
  imageData,
45
45
  channel,
46
46
  channelSpecificStyle,
47
- showReUploadButton = true,
48
47
  } = props;
49
48
  const {
50
49
  formatMessage,
@@ -225,18 +224,16 @@ function CapImageUpload(props) {
225
224
  </>
226
225
  );
227
226
  }
228
- if (showReUploadButton) {
229
- return (
230
- <CapButton
231
- className="dragger-button re-upload"
232
- type="flat"
233
- onClick={onReUpload}
234
- style={channelSpecificStyle ? { marginTop: '-16px'} : {}}
235
- >
236
- <FormattedMessage {...messages.imageReUpload} />
237
- </CapButton>
238
- );
239
- }
227
+ return (
228
+ <CapButton
229
+ className="dragger-button re-upload"
230
+ type="flat"
231
+ onClick={onReUpload}
232
+ style={channelSpecificStyle ? { marginTop: '-16px'} : {}}
233
+ >
234
+ <FormattedMessage {...messages.imageReUpload} />
235
+ </CapButton>
236
+ );
240
237
  }, [isImageError, imageSrc]);
241
238
 
242
239
  return (
@@ -39,7 +39,6 @@ function CapVideoUpload(props) {
39
39
  errorMessage,
40
40
  showVideoNameAndDuration = true,
41
41
  formClassName = 'video-form',
42
- showReUploadButton = true,
43
42
  } = props;
44
43
  const [isVideoError, updateVideoErrorMessage] = useState(false);
45
44
  const [isVideo, updateVideoStatus] = useState(false);
@@ -247,17 +246,15 @@ function CapVideoUpload(props) {
247
246
  const videoDurationValue = moment('1900-01-01 00:00:00').add(videoDuration, 'seconds').format("HH.mm.ss"); // to get the duration of video
248
247
  return (
249
248
  <Fragment key={videoSrc}>
250
- {showReUploadButton && (
251
- <div style={{ overflow: 'hidden' }}>
252
- <CapButton
253
- className="dragger-button video-reupload"
254
- type="flat"
255
- onClick={onReUpload}
256
- >
257
- <FormattedMessage {...messages.imageReUpload} />
258
- </CapButton>
259
- </div>
260
- )}
249
+ <div style={{ overflow: 'hidden' }}>
250
+ <CapButton
251
+ className="dragger-button video-reupload"
252
+ type="flat"
253
+ onClick={onReUpload}
254
+ >
255
+ <FormattedMessage {...messages.imageReUpload} />
256
+ </CapButton>
257
+ </div>
261
258
  <div className={showVideoNameAndDuration ? 'video-panel' : 'video-panel-wp'}>
262
259
  <video
263
260
  width="230"
@@ -104,8 +104,4 @@ export default defineMessages({
104
104
  id: `${prefix}.whatsappCtaTagListRevert`,
105
105
  defaultMessage: 'Reset website URL label to default value',
106
106
  },
107
- url: {
108
- id: `${prefix}.url`,
109
- defaultMessage: 'URL',
110
- },
111
107
  });
@@ -567,10 +567,6 @@
567
567
  font-size: 10px;
568
568
  font-family: 'open-sans';
569
569
  }
570
- &.message-pop-carousel {
571
- position: relative;
572
- margin-right: $CAP_SPACE_04;
573
- }
574
570
  }
575
571
  }
576
572
  .android-push-message-Container, .iphone-push-message-Container{
@@ -751,11 +747,6 @@
751
747
  width: 153px;
752
748
  }
753
749
  }
754
-
755
- .msg-container-carousel {
756
- display: flex;
757
- flex-direction: column;
758
- }
759
750
  }
760
751
 
761
752
  .align-center {
@@ -20,7 +20,6 @@ import {
20
20
  CAP_PURPLE01,
21
21
  CAP_G16,
22
22
  CAP_SPACE_08,
23
- CAP_SPACE_04,
24
23
  } from '@capillarytech/cap-ui-library/styled/variables';
25
24
  import isEmpty from 'lodash/isEmpty';
26
25
  import './_templatePreview.scss';
@@ -44,16 +43,14 @@ import inAppMobileIOSModal from './assets/images/inapp_mobile_ios_modal.svg';
44
43
  import inAppMobileIOSTop from './assets/images/inapp_mobile_ios_top.svg';
45
44
  import inAppMobileIOSBottom from './assets/images/inapp_mobile_ios_bottom.svg';
46
45
  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';
49
46
  import videoPlay from '../../assets/videoPlay.svg';
50
47
  import zaloMessage from '../../v2Containers/Zalo/messages';
51
48
  import { handlePreviewInNewTab } from '../../utils/common';
52
49
  import { TEMPLATE, IMAGE_CAROUSEL, IMAGE, STICKER, TEXT, IMAGE_MAP, VIDEO } from '../../v2Containers/Line/Container/constants';
53
50
  import CapFacebookPreview from '../../v2Containers/CapFacebookPreview';
54
51
  import WhatsappStatusContainer from '../WhatsappStatusContainer';
55
- import { getWhatsappQuickReply, getWhatsappCarouselButtonView } from '../../v2Containers/Whatsapp/utils';
56
- import { QUICK_REPLY, WHATSAPP_CATEGORIES, PHONE_NUMBER } from '../../v2Containers/Whatsapp/constants';
52
+ import { getWhatsappQuickReply } from '../../v2Containers/Whatsapp/utils';
53
+ import { QUICK_REPLY, WHATSAPP_CATEGORIES } from '../../v2Containers/Whatsapp/constants';
57
54
  import { ANDROID, INAPP_MESSAGE_LAYOUT_TYPES } from '../../v2Containers/InApp/constants';
58
55
 
59
56
  const wechatBodyNew = require('./assets/images/wechat_mobile_android.svg');
@@ -216,7 +213,7 @@ export class TemplatePreview extends React.Component { // eslint-disable-line re
216
213
  iosActions = _.map(content.actions, (action) => {
217
214
  if (action.label) {
218
215
  return (<div className="actions" key={`action-${action.label}`}>
219
- <span className="action">{action.label.toUpperCase()}</span>
216
+ <span className="action">{action.label.toUpperCase()}</span>
220
217
  </div>);
221
218
  }
222
219
  return undefined;
@@ -256,15 +253,6 @@ export class TemplatePreview extends React.Component { // eslint-disable-line re
256
253
  'width': '88%',
257
254
  'left': 0,
258
255
  };
259
- const carouselWhatsappSectionStyle = {
260
- 'padding': `${CAP_SPACE_04} 0 ${CAP_SPACE_08}`,
261
- 'border-radius': '0.428rem',
262
- 'background-color': CAP_WHITE,
263
- 'width': '11.857rem',
264
- 'cursor': 'pointer',
265
- 'flex-shrink': 0,
266
- 'left': 0,
267
- };
268
256
  const getVideoContent = ({
269
257
  video,
270
258
  actionUrl,
@@ -286,53 +274,53 @@ export class TemplatePreview extends React.Component { // eslint-disable-line re
286
274
  >
287
275
  {
288
276
  video
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
- }}
277
+ ? (
278
+ <>
279
+ <video style={{ opacity: 0.5, width: '100%' }}>
280
+ <source src={video} type="video/mp4" />
281
+ </video>
282
+ <div
283
+ style={{
284
+ position: 'absolute',
285
+ display: 'flex',
286
+ flexDirection: 'column',
287
+ }}
288
+ >
289
+ <CapButton
290
+ className="preview-video-btn"
291
+ type="flat"
300
292
  >
301
- <CapButton
302
- className="preview-video-btn"
303
- type="flat"
304
- >
305
293
  <CapIcon type="play"/>
306
- <FormattedMessage {...messages.playVideo} />
307
- </CapButton>
308
- {
309
- actionUrl
310
- ? (
311
- <CapButton
312
- className="preview-video-btn"
313
- type="flat"
314
- >
294
+ <FormattedMessage {...messages.playVideo} />
295
+ </CapButton>
296
+ {
297
+ actionUrl
298
+ ? (
299
+ <CapButton
300
+ className="preview-video-btn"
301
+ type="flat"
302
+ >
315
303
  <CapIcon type="reply" style={{ fontSize: 18 }}/>
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
- )
304
+ <FormattedMessage {...messages.showDetails} />
305
+ </CapButton>
306
+ )
307
+ : null
308
+ }
309
+ </div>
310
+ </>
311
+ )
312
+ : (
313
+ <CapImage
314
+ src={lineVideoPlaceholder}
315
+ alt="brand-name"
316
+ rest={{
317
+ style: {
318
+ width: 126,
319
+ marginBottom: 5,
320
+ },
321
+ }}
322
+ />
323
+ )
336
324
  }
337
325
  </div>
338
326
  );
@@ -348,10 +336,10 @@ export class TemplatePreview extends React.Component { // eslint-disable-line re
348
336
  renderArray.push(
349
337
  <CapLabel type="label21" className="whatsapp-cta-preview">
350
338
  {type !== WHATSAPP_CATEGORIES.authentication && <CapIcon
351
- type={
352
- (ctaType || type) === PHONE_NUMBER ? 'call' : 'launch'
353
- }
354
- size="xs"
339
+ type={
340
+ (ctaType || type) === 'PHONE_NUMBER' ? 'call' : 'launch'
341
+ }
342
+ size="xs"
355
343
  />}
356
344
  {text}
357
345
  </CapLabel>,
@@ -442,42 +430,42 @@ export class TemplatePreview extends React.Component { // eslint-disable-line re
442
430
  {this.props.showCount &&
443
431
  channel &&
444
432
  channel.toLowerCase() !== FACEBOOK && (
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">
433
+ <CapColumn span={16}>
434
+ {channel && channel.toLowerCase() === "sms" && (
435
+ <CapHeading type="h3">
472
436
  <FormattedMessage
473
- {...messages.whatsappMessageLength}
474
- values={{ length: whatsappUpdatedLen }}
437
+ {...messages.charactersTotal}
438
+ values={{
439
+ smsCount: smsDetails.parts,
440
+ charCount: smsDetails.chars_used,
441
+ }}
475
442
  />
443
+ {smsDetails.unicode && (
444
+ <FormattedMessage {...messages.smsFormatType} />
445
+ )}
476
446
  </CapHeading>
477
- </>
478
- ) : null}
479
- </CapColumn>
480
- )}
447
+ )}
448
+ {smsDetails.optoutUrlPresent && (
449
+ <CapHeading type="h6">
450
+ <FormattedMessage
451
+ {...messages.optoutCharactersTotal}
452
+ values={{ optoutUrlLength: smsDetails.optouturlLength }}
453
+ />
454
+ </CapHeading>
455
+ )}
456
+ {channel?.toLowerCase() === WHATSAPP.toLowerCase() ? (
457
+ <>
458
+ <WhatsappStatusContainer template={templateData} />
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
+ )}
481
469
  <CapColumn span={this.props.showCount ? 8 : 24}>
482
470
  {showTestAndPreview && (
483
471
  <div className="test-and-preview-container">
@@ -640,9 +628,9 @@ export class TemplatePreview extends React.Component { // eslint-disable-line re
640
628
  )}
641
629
  {content.actions.filter((action) => action.label)
642
630
  .length ? (
643
- <div className="actions">
644
- {_.map(
645
- content.actions,
631
+ <div className="actions">
632
+ {_.map(
633
+ content.actions,
646
634
  (action) =>
647
635
  !!action.label && (
648
636
  <span
@@ -652,11 +640,11 @@ export class TemplatePreview extends React.Component { // eslint-disable-line re
652
640
  {action.label && action.label.toUpperCase()}
653
641
  </span>
654
642
  )
655
- )}
656
- </div>
657
- ) : (
658
- ""
659
- )}
643
+ )}
644
+ </div>
645
+ ) : (
646
+ ""
647
+ )}
660
648
  </div>
661
649
  ) : (
662
650
  <div className="message-pop align-left">
@@ -992,14 +980,14 @@ export class TemplatePreview extends React.Component { // eslint-disable-line re
992
980
  <CapLabel className="whatsapp-brand-name">
993
981
  {whatsappUpdatedAccountName || ""}
994
982
  </CapLabel>
995
- <div className={`msg-container whatsapp-message-container ${content?.carouselData && 'msg-container-carousel'}`}>
983
+ <div className="msg-container whatsapp-message-container">
996
984
  <div
997
- className={`message-pop align-left ${content?.carouselData && 'message-pop-carousel'}`}
985
+ className="message-pop align-left"
998
986
  style={whatsappSectionStyle}
999
987
  >
1000
988
  <div className="whatsapp-content">
1001
- {content?.showUrlPreview
1002
- && renderUrlPreview(content?.metaTagsDetails)}
989
+ {content?.showUrlPreview &&
990
+ renderUrlPreview(content?.metaTagsDetails)}
1003
991
  {content?.whatsappImageSrc && (
1004
992
  <CapImage
1005
993
  src={content.whatsappImageSrc}
@@ -1038,60 +1026,6 @@ export class TemplatePreview extends React.Component { // eslint-disable-line re
1038
1026
  {renderQuickReplyPreview()}
1039
1027
  </div>
1040
1028
  </div>
1041
- {content?.carouselData && (
1042
- <div
1043
- style={{
1044
- overflowX: "auto",
1045
- display: "flex",
1046
- paddingTop: "5px",
1047
- paddingRight: "5px",
1048
- whiteSpace: "nowrap",
1049
- scrollbarWidth: "none", // Hide scrollbar in Firefox
1050
- msOverflowStyle: "none", // Hide scrollbar in IE/Edge
1051
- }}
1052
- className="scroll-container"
1053
- >
1054
- {content?.carouselData?.map((data, index) => (
1055
- <div
1056
- key={`carousel-${index}`}
1057
- className="message-pop align-left message-pop-carousel"
1058
- style={carouselWhatsappSectionStyle}>
1059
- <div className="whatsapp-content">
1060
- {content?.carouselMediaType === "image" && (
1061
- <CapImage
1062
- src={data?.imageSrc ? data?.imageSrc : whatsappImageEmptyPreview}
1063
- className="whatsapp-image"
1064
- alt={formatMessage(messages.previewGenerated)}
1065
- />
1066
- )}
1067
- {content?.carouselMediaType === "video" && (
1068
- <CapTooltip
1069
- title={formatMessage(messages.videoPreviewTooltip)}
1070
- >
1071
- <div className="video-preview">
1072
- <CapImage
1073
- src={data?.videoPreviewImg ? data?.videoPreviewImg : whatsappVideoEmptyPreview}
1074
- className="whatsapp-image"
1075
- alt={formatMessage(messages.previewGenerated)}
1076
- />
1077
- <div className="icon-position">
1078
- <CapImage
1079
- className="video-icon"
1080
- src={videoPlay}
1081
- />
1082
- </div>
1083
- </div>
1084
- </CapTooltip>
1085
- )}
1086
- <CapLabel type="label5">
1087
- {content?.isEditFlow ? data?.updatedBodyText?.join("") : data?.bodyText}
1088
- </CapLabel>
1089
- {getWhatsappCarouselButtonView(data?.buttons, true)}
1090
- </div>
1091
- </div>
1092
- ))}
1093
- </div>
1094
- )}
1095
1029
  </div>
1096
1030
  </div>
1097
1031
  <CapHeading
@@ -1271,21 +1205,21 @@ export class TemplatePreview extends React.Component { // eslint-disable-line re
1271
1205
  {ctaData &&
1272
1206
  !isEmpty(ctaData) &&
1273
1207
  ctaData[0]?.text !== "" && (
1274
- <CapButton
1275
- type="primary"
1276
- className={`inapp-button-${templateLayoutType}-${device} ${
1208
+ <CapButton
1209
+ type="primary"
1210
+ className={`inapp-button-${templateLayoutType}-${device} ${
1277
1211
  mediaPreview?.inAppImageSrcAndroid
1278
1212
  ? ""
1279
1213
  : `without-image-button-${templateLayoutType}-android`
1280
- } ${
1214
+ } ${
1281
1215
  mediaPreview?.inAppImageSrcIos
1282
1216
  ? ""
1283
1217
  : `without-image-button-${templateLayoutType}-ios`
1284
- }`}
1285
- >
1286
- {ctaData[0]?.text}
1287
- </CapButton>
1288
- )}
1218
+ }`}
1219
+ >
1220
+ {ctaData[0]?.text}
1221
+ </CapButton>
1222
+ )}
1289
1223
  </div>
1290
1224
  </div>
1291
1225
  </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 undefined"
69
+ className="msg-container whatsapp-message-container"
70
70
  >
71
71
  <div
72
- className="message-pop align-left undefined"
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 undefined"
166
+ className="msg-container whatsapp-message-container"
167
167
  >
168
168
  <div
169
- className="message-pop align-left undefined"
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 undefined"
238
+ className="msg-container whatsapp-message-container"
239
239
  >
240
240
  <div
241
- className="message-pop align-left undefined"
241
+ className="message-pop align-left"
242
242
  style={
243
243
  Object {
244
244
  "background-color": "#ffffff",