@capillarytech/creatives-library 7.12.48 → 7.12.50

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