@capillarytech/creatives-library 7.12.50 → 7.12.53

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 (57) hide show
  1. package/config/app.js +0 -1
  2. package/package.json +1 -1
  3. package/services/api.js +15 -2
  4. package/v2Components/CapImageUpload/index.js +33 -17
  5. package/v2Components/CapImageUpload/messages.js +11 -3
  6. package/v2Components/CapWhatsappCTA/constants.js +12 -1
  7. package/v2Components/CapWhatsappCTA/index.js +88 -29
  8. package/v2Components/CapWhatsappCTA/index.scss +4 -6
  9. package/v2Components/CapWhatsappCTA/messages.js +24 -0
  10. package/v2Components/TemplatePreview/_templatePreview.scss +9 -8
  11. package/v2Components/TemplatePreview/index.js +8 -6
  12. package/v2Components/TemplatePreview/tests/__snapshots__/index.test.js.snap +3 -19
  13. package/v2Components/TemplatePreview/tests/index.test.js +0 -2
  14. package/v2Components/WhatsappStatusContainer/index.js +42 -52
  15. package/v2Containers/Cap/tests/index.test.js +2 -2
  16. package/v2Containers/CreativesContainer/SlideBoxContent.js +8 -8
  17. package/v2Containers/CreativesContainer/tests/SlideBoxContent.test.js +28 -36
  18. package/v2Containers/CreativesContainer/tests/__snapshots__/SlideBoxContent.test.js.snap +165 -344
  19. package/v2Containers/CreativesContainer/tests/index.test.js +0 -3
  20. package/v2Containers/Line/Container/ImageCarousel/Content.js +15 -29
  21. package/v2Containers/Line/Container/ImageCarousel/constants.js +3 -0
  22. package/v2Containers/Line/Container/ImageCarousel/index.js +28 -40
  23. package/v2Containers/Line/Container/ImageCarousel/messages.js +2 -2
  24. package/v2Containers/Line/Container/ImageCarousel/tests/__snapshots__/content.test.js.snap +9851 -0
  25. package/v2Containers/Line/Container/ImageCarousel/tests/__snapshots__/index.test.js.snap +21113 -0
  26. package/v2Containers/Line/Container/ImageCarousel/tests/content.test.js +71 -0
  27. package/v2Containers/Line/Container/ImageCarousel/tests/index.test.js +58 -0
  28. package/v2Containers/Line/Container/ImageCarousel/tests/mockData.js +1322 -0
  29. package/v2Containers/Line/Container/ImageCarousel/tests/utils.test.js +13 -0
  30. package/v2Containers/Line/Container/ImageCarousel/utils.js +12 -0
  31. package/v2Containers/Line/Container/Wrapper/tests/__snapshots__/index.test.js.snap +84451 -0
  32. package/v2Containers/Line/Container/Wrapper/tests/index.test.js +58 -0
  33. package/v2Containers/Line/Container/Wrapper/tests/mockData.js +171 -0
  34. package/v2Containers/Line/Container/index.js +5 -1
  35. package/v2Containers/Line/Container/tests/__snapshots__/index.test.js.snap +63597 -0
  36. package/v2Containers/Line/Container/tests/index.test.js +105 -0
  37. package/v2Containers/Line/Container/tests/mockData.js +1334 -0
  38. package/v2Containers/Templates/_templates.scss +5 -0
  39. package/v2Containers/Templates/actions.js +7 -0
  40. package/v2Containers/Templates/constants.js +9 -1
  41. package/v2Containers/Templates/index.js +45 -30
  42. package/v2Containers/Templates/messages.js +1 -1
  43. package/v2Containers/Templates/reducer.js +15 -0
  44. package/v2Containers/Templates/sagas.js +32 -0
  45. package/v2Containers/Templates/tests/__snapshots__/index.test.js.snap +1774 -1881
  46. package/v2Containers/Templates/tests/index.test.js +14 -3
  47. package/v2Containers/Whatsapp/actions.js +22 -0
  48. package/v2Containers/Whatsapp/constants.js +56 -23
  49. package/v2Containers/Whatsapp/index.js +204 -66
  50. package/v2Containers/Whatsapp/index.scss +18 -2
  51. package/v2Containers/Whatsapp/messages.js +35 -7
  52. package/v2Containers/Whatsapp/reducer.js +35 -1
  53. package/v2Containers/Whatsapp/sagas.js +30 -1
  54. package/v2Containers/Whatsapp/tests/__snapshots__/index.test.js.snap +44349 -32926
  55. package/v2Containers/Whatsapp/tests/__snapshots__/utils.test.js.snap +15 -21
  56. package/v2Containers/Whatsapp/utils.js +16 -9
  57. package/v2Containers/mockdata.js +210 -555
@@ -11,8 +11,6 @@ const {
11
11
  whatsappGetTemplateData,
12
12
  rcsEditTemplateData,
13
13
  whatsappGetCreativeData2,
14
- lineCreateTemplateData,
15
- lineEditTemplateData,
16
14
  } = mockdata;
17
15
 
18
16
  jest.mock('../../../v2Components/FormBuilder', () => ({
@@ -102,5 +100,4 @@ describe('Test SlideBoxContent container', () => {
102
100
  expect(getCreativesData).toHaveBeenCalledTimes(1);
103
101
  expect(getCreativesData).toHaveBeenCalledWith({ channel: 'RCS' });
104
102
  });
105
-
106
103
  });
@@ -18,7 +18,7 @@ import { CAP_SPACE_12, CAP_SPACE_08, FONT_COLOR_05, CAP_WHITE, FONT_COLOR_01, CA
18
18
  import Gallery from '../../../Assets/Gallery';
19
19
  import style from './style';
20
20
  import withStyles from '../../../../hoc/withStyles';
21
-
21
+ import { calculateAspectRatio } from './utils';
22
22
  import messages from './messages';
23
23
  import {
24
24
  LINE_IMG_HEIGHT,
@@ -28,6 +28,7 @@ import {
28
28
  URL_ACTION_TYPE,
29
29
  TEXT_ACTION_TYPE,
30
30
  MAX_ACTION_LABEL_LENGTH,
31
+ CAROUSEL,
31
32
  } from './constants';
32
33
 
33
34
  export const LineImageCarouselContent = ({
@@ -64,7 +65,7 @@ export const LineImageCarouselContent = ({
64
65
  actionLabel = '',
65
66
  actionContent = '',
66
67
  } = content;
67
- if (type === 'carousel') {
68
+ if (type === CAROUSEL) {
68
69
  updateImageStatus(!!originalContentUrl);
69
70
  updateImageSrc(originalContentUrl);
70
71
  updateActionType(selectedActionType);
@@ -86,7 +87,7 @@ export const LineImageCarouselContent = ({
86
87
  actionContentErrorMessage,
87
88
  actionLabelErrorMessage,
88
89
  index,
89
- type: 'carousel',
90
+ type: CAROUSEL,
90
91
  messageType: 'originalContentUrl',
91
92
  });
92
93
  }
@@ -128,7 +129,7 @@ export const LineImageCarouselContent = ({
128
129
  actionContentErrorMessage,
129
130
  actionLabelErrorMessage,
130
131
  index,
131
- type: 'carousel',
132
+ type: CAROUSEL,
132
133
  messageType: 'originalContentUrl',
133
134
  });
134
135
  }
@@ -149,8 +150,7 @@ export const LineImageCarouselContent = ({
149
150
  updateImageErrorMessage(formatMessage(messages.lineImageIncorrectSize));
150
151
  } else {
151
152
  updateImageErrorMessage('');
152
- const aspectRatio1 = calculateAspectRatio(width, height);
153
- updateAspectRatio(aspectRatio1);
153
+ updateAspectRatio(calculateAspectRatio(width, height));
154
154
  actions.uploadAsset(
155
155
  data.file,
156
156
  data.type,
@@ -158,20 +158,7 @@ export const LineImageCarouselContent = ({
158
158
  `ImageCarousel${index}`,
159
159
  );
160
160
  }
161
- }
162
-
163
- const calculateGCD = (width, height) => {
164
- while (height !== 0 ) {
165
- let reminder = width % height;
166
- width = height;
167
- height = reminder;
168
- }
169
- return Math.abs(width);
170
161
  };
171
- const calculateAspectRatio = (width, height) => {
172
- const absValue = calculateGCD(width, height);
173
- return `${width / absValue}:${height / absValue}`;
174
- }
175
162
 
176
163
  const uploadImages = (e, { files }) => {
177
164
  if (e) {
@@ -262,7 +249,7 @@ export const LineImageCarouselContent = ({
262
249
  actionContentErrorMessage,
263
250
  actionLabelErrorMessage,
264
251
  index,
265
- type: 'carousel',
252
+ type: CAROUSEL,
266
253
  messageType: 'originalContentUrl',
267
254
  });
268
255
  }
@@ -294,7 +281,7 @@ export const LineImageCarouselContent = ({
294
281
  </CapButton>
295
282
  </CapUploader.CapDragger>
296
283
  <CapHeading type="h6" style={{ marginTop: CAP_SPACE_12 }}>
297
- <FormattedMessage {...messages.imageDimenstionDescription1} />
284
+ <FormattedMessage {...messages.imageDimenstionDesc} />
298
285
  </CapHeading>
299
286
  </>);
300
287
  }
@@ -322,11 +309,10 @@ export const LineImageCarouselContent = ({
322
309
  const imageHeight = get(imageTemplate, 'metaInfo.height');
323
310
  const imageWidth = get(imageTemplate, 'metaInfo.width');
324
311
  const imageSize = get(imageTemplate, 'metaInfo.file_size');
325
- const aspectRatio1 = calculateAspectRatio(imageWidth, imageHeight);
312
+ const calculatedAspectRatio = calculateAspectRatio(imageWidth, imageHeight);
326
313
  updateDrawerRequirement(false);
327
314
  if (
328
315
  !ALLOWED_EXTENSIONS_REGEX.test(image)
329
- // || imageHeight / imageWidth !== 1
330
316
  || imageHeight > LINE_IMG_HEIGHT
331
317
  || imageWidth > LINE_IMG_WIDTH
332
318
  || imageSize > LINE_IMG_SIZE
@@ -336,19 +322,19 @@ export const LineImageCarouselContent = ({
336
322
  updateImageErrorMessage('');
337
323
  updateImageStatus(true);
338
324
  updateImageSrc(image);
339
- updateAspectRatio(aspectRatio1);
325
+ updateAspectRatio(calculatedAspectRatio);
340
326
  updateCarouselMessageState({
341
327
  activeIndex,
342
328
  isError: !image || isImageError,
343
329
  originalContentUrl: image,
344
- aspectRatio: aspectRatio1,
330
+ aspectRatio: calculatedAspectRatio,
345
331
  selectedActionType,
346
332
  actionContent,
347
333
  actionLabel,
348
334
  actionContentErrorMessage,
349
335
  actionLabelErrorMessage,
350
336
  index,
351
- type: 'carousel',
337
+ type: CAROUSEL,
352
338
  messageType: 'originalContentUrl',
353
339
  });
354
340
  }
@@ -409,7 +395,7 @@ export const LineImageCarouselContent = ({
409
395
  actionContentErrorMessage,
410
396
  actionLabelErrorMessage,
411
397
  index,
412
- type: 'carousel',
398
+ type: CAROUSEL,
413
399
  messageType: 'originalContentUrl',
414
400
  });
415
401
  }
@@ -427,7 +413,7 @@ export const LineImageCarouselContent = ({
427
413
  actionContentErrorMessage,
428
414
  actionLabelErrorMessage,
429
415
  index,
430
- type: 'carousel',
416
+ type: CAROUSEL,
431
417
  messageType: 'originalContentUrl',
432
418
  });
433
419
  }
@@ -458,7 +444,7 @@ export const LineImageCarouselContent = ({
458
444
  actionContentErrorMessage,
459
445
  actionLabelErrorMessage,
460
446
  index,
461
- type: 'carousel',
447
+ type: CAROUSEL,
462
448
  messageType: 'originalContentUrl',
463
449
  });
464
450
  }
@@ -8,3 +8,6 @@ export const MESSAGE_ACTION_TYPE = 'message';
8
8
  export const URL_ACTION_TYPE = 'uri';
9
9
  export const MAX_ACTION_LABEL_LENGTH = 12;
10
10
  export const MAX_ALLOWED_TITLE_LENGTH = 100;
11
+ export const CAROUSEL = 'carousel';
12
+ export const FLEX = 'flex';
13
+ export const TEMPLATE = 'template';
@@ -25,6 +25,9 @@ import {
25
25
  MESSAGE_ACTION_TYPE,
26
26
  URL_ACTION_TYPE,
27
27
  MAX_ALLOWED_TITLE_LENGTH,
28
+ FLEX,
29
+ CAROUSEL,
30
+ TEMPLATE,
28
31
  } from './constants';
29
32
 
30
33
  export const LineImageCarousel = (props) => {
@@ -44,7 +47,7 @@ export const LineImageCarousel = (props) => {
44
47
  getAllTemplates,
45
48
  } = props;
46
49
 
47
- if (activeKey !== 'flex') {
50
+ if (activeKey !== FLEX) {
48
51
  return null;
49
52
  }
50
53
 
@@ -55,7 +58,7 @@ export const LineImageCarousel = (props) => {
55
58
  originalContentUrl: '',
56
59
  aspectRatio: '',
57
60
  previewImageUrl: '',
58
- type: 'carousel',
61
+ type: CAROUSEL,
59
62
  };
60
63
 
61
64
  const [carouselImages, updateCarouselImage] = useState([defaultCarouselContent]);
@@ -69,22 +72,20 @@ export const LineImageCarousel = (props) => {
69
72
  const [errorTitle, updateErrorTitle] = useState(false);
70
73
 
71
74
  useEffect(() => {
72
- const { messageTitle = '', type, template, altText } = content;
73
- if (type === 'template' || type === 'flex') {
74
- updateCreateNew(!isFullMode ? !!template : true);
75
+ const { messageTitle = '', type, template, altText, contents } = content;
76
+ if ([TEMPLATE, FLEX].includes(type)) {
77
+ updateCreateNew(!isFullMode ? !!(template || contents) : true);
75
78
  if (messageTitle) {
76
79
  updateTextMessageTitle(messageTitle);
77
80
  }
78
81
  if (altText) {
79
82
  updateTitle(altText);
80
83
  }
81
- if (template) {
84
+ if (template || contents) {
82
85
  const validCarouselImages = [];
83
- if (template.type != undefined && template.type === "carousel") {
84
- const { contents = [] } = template;
85
- if(contents && contents.length) {
86
- contents.forEach((content = {}, index1) => {
87
- const {
86
+ if (template?.type === CAROUSEL || contents?.type === CAROUSEL ) {
87
+ const { contents: innerContents = [] } = contents || template || [];
88
+ innerContents.forEach((content = {}, index) => { const {
88
89
  footer: {
89
90
  contents: [{
90
91
  action: {
@@ -101,19 +102,17 @@ export const LineImageCarousel = (props) => {
101
102
  } = {},
102
103
  } = content || {};
103
104
  validCarouselImages.push({
104
- activeIndex: index1,
105
+ activeIndex: index,
105
106
  originalContentUrl: url,
106
107
  aspectRatio,
107
108
  selectedActionType: buttonType ? (buttonType === MESSAGE_ACTION_TYPE ? TEXT_ACTION_TYPE : URL_ACTION_TYPE) : '',
108
109
  actionContent: text || uri,
109
110
  actionLabel: label,
110
- type: 'carousel',
111
+ type: CAROUSEL,
111
112
  });
112
113
  })
113
- }
114
114
  } else {
115
- const { columns } = template;
116
- if (columns && columns.length) {
115
+ const { columns = [] } = template;
117
116
  columns.forEach((column = {}, index) => {
118
117
  const {
119
118
  action: {
@@ -133,10 +132,9 @@ export const LineImageCarousel = (props) => {
133
132
  actionContent: text || uri,
134
133
  actionLabel: label,
135
134
  aspectRatio,
136
- type: 'carousel',
135
+ type: CAROUSEL,
137
136
  });
138
137
  })
139
- }
140
138
  }
141
139
  updateCarouselImage(validCarouselImages);
142
140
  }
@@ -176,7 +174,7 @@ export const LineImageCarousel = (props) => {
176
174
  isError: isErrorIndex !== undefined && isErrorIndex !== false,
177
175
  messageTitle: existingMessageTitle,
178
176
  altText: existingTitle,
179
- type: 'flex',
177
+ type: FLEX,
180
178
  index,
181
179
  }
182
180
 
@@ -392,17 +390,9 @@ export const LineImageCarousel = (props) => {
392
390
  if(!imageCarouselTemplate && imageCarouselContents) {
393
391
  isNewLineFormat = true;
394
392
  }
395
- if(isNewLineFormat) {
396
- templateData.url = (imageCarouselContents ? get(imageCarouselContents, 'contents.0.hero.url', '') : '');
397
- templateData.title = template.name;
398
- templateData.key = template.name;
399
-
400
- } else {
401
- templateData.url = (imageCarouselTemplate ? get(imageCarouselTemplate, 'columns.0.imageUrl', '') : '');
402
- templateData.title = template.name;
403
- templateData.key = template.name;
404
- }
405
-
393
+ templateData.url = get(imageCarouselContents, 'contents.0.hero.url', '') || get(imageCarouselTemplate, 'columns.0.imageUrl', '');
394
+ templateData.title = template.name;
395
+ templateData.key = template.name;
406
396
  templateData.hoverOption = (
407
397
  <CapButton onClick={() => onTemplateSelection(template)}>
408
398
  <FormattedMessage {...messages.select} />
@@ -435,19 +425,18 @@ export const LineImageCarousel = (props) => {
435
425
 
436
426
  const onTemplateSelection = (templateData) => {
437
427
  const template = get(templateData, 'versions.base.content.messages[0].template', {});
438
- const contents1 = get(templateData, 'versions.base.content.messages[0].contents', {});
428
+ const contents = get(templateData, 'versions.base.content.messages[0].contents', {});
439
429
  const altText = get(templateData, 'versions.base.content.messages[0].altText', '');
440
430
  let isNewLineFormat = false;
441
431
  const validCarouselImages = [];
442
432
 
443
- if (!isEmpty(contents1) && isEmpty(template)) {
433
+ if (!isEmpty(contents) && isEmpty(template)) {
444
434
  isNewLineFormat = true;
445
435
  }
446
436
  if (isNewLineFormat) {
447
- const { contents = [] } = contents1;
448
-
449
- if(contents && contents.length) {
450
- contents.forEach((content = {}, index1) => {
437
+ const { contents : flexContents = [] } = contents;
438
+
439
+ flexContents.forEach((content = {}, index) => {
451
440
  const {
452
441
  footer: {
453
442
  contents: [{
@@ -465,16 +454,15 @@ export const LineImageCarousel = (props) => {
465
454
  } = {},
466
455
  } = content || {};
467
456
  validCarouselImages.push({
468
- activeIndex: index1,
457
+ activeIndex: index,
469
458
  originalContentUrl: url,
470
459
  aspectRatio,
471
460
  selectedActionType: buttonType ? (buttonType === MESSAGE_ACTION_TYPE ? TEXT_ACTION_TYPE : URL_ACTION_TYPE) : '',
472
461
  actionContent: text || uri,
473
462
  actionLabel: label,
474
- type: 'carousel',
463
+ type: CAROUSEL,
475
464
  });
476
465
  })
477
- }
478
466
 
479
467
  } else {
480
468
  const { columns } = template;
@@ -496,7 +484,7 @@ export const LineImageCarousel = (props) => {
496
484
  selectedActionType: type ? (type === MESSAGE_ACTION_TYPE ? TEXT_ACTION_TYPE : URL_ACTION_TYPE) : '',
497
485
  actionContent: text || uri,
498
486
  actionLabel: label,
499
- type: 'carousel',
487
+ type: CAROUSEL,
500
488
  });
501
489
  })
502
490
 
@@ -39,8 +39,8 @@ export default defineMessages({
39
39
  id: `${scope}.imageDimenstionDescription`,
40
40
  defaultMessage: 'Format: JPEG, PNG Aspect ratio: 1:1 Dimensions: 1024px x 1024px Size: 1 MB',
41
41
  },
42
- "imageDimenstionDescription1": {
43
- id: `${scope}.imageDimenstionDescription1`,
42
+ "imageDimenstionDesc": {
43
+ id: `${scope}.imageDimenstionDesc`,
44
44
  defaultMessage: 'Format: JPEG, PNG Dimensions: 1024px x 1024px Size: 1 MB',
45
45
  },
46
46
  "imageReUpload": {