@capillarytech/creatives-library 9.0.33 → 9.0.34-alpha.2
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/package.json +1 -1
- package/v2Components/CommonTestAndPreview/UnifiedPreview/ViberCarouselPreviewCards.js +132 -0
- package/v2Components/CommonTestAndPreview/UnifiedPreview/ViberPreviewContent.js +108 -15
- package/v2Components/CommonTestAndPreview/UnifiedPreview/_unifiedPreview.scss +139 -1
- package/v2Components/CommonTestAndPreview/UnifiedPreview/_viberCarouselPreviewCards.scss +131 -0
- package/v2Components/CommonTestAndPreview/index.js +240 -26
- package/v2Components/CommonTestAndPreview/tests/UnifiedPreview/ViberPreviewContent.test.js +364 -0
- package/v2Containers/Templates/_templates.scss +114 -0
- package/v2Containers/Templates/index.js +90 -10
- package/v2Containers/Templates/tests/__snapshots__/index.test.js.snap +5 -0
- package/v2Containers/TemplatesV2/TemplatesV2.style.js +0 -1
- package/v2Containers/TemplatesV2/index.js +1 -9
- package/v2Containers/Viber/constants.js +21 -0
- package/v2Containers/Viber/index.js +719 -49
- package/v2Containers/Viber/index.scss +175 -0
- package/v2Containers/Viber/messages.js +121 -0
- package/v2Containers/Viber/tests/index.test.js +80 -0
|
@@ -200,6 +200,370 @@ describe('ViberPreviewContent', () => {
|
|
|
200
200
|
|
|
201
201
|
expect(screen.getByText('Click Here')).toBeTruthy();
|
|
202
202
|
});
|
|
203
|
+
|
|
204
|
+
it('should not render button when buttonText has only whitespace', () => {
|
|
205
|
+
const props = {
|
|
206
|
+
...defaultProps,
|
|
207
|
+
content: {
|
|
208
|
+
viberPreviewContent: {
|
|
209
|
+
messageContent: 'Message',
|
|
210
|
+
buttonText: ' ',
|
|
211
|
+
},
|
|
212
|
+
},
|
|
213
|
+
};
|
|
214
|
+
|
|
215
|
+
const { container } = render(
|
|
216
|
+
<TestWrapper>
|
|
217
|
+
<ComponentToRender {...props} />
|
|
218
|
+
</TestWrapper>
|
|
219
|
+
);
|
|
220
|
+
|
|
221
|
+
expect(container.querySelector('.viber-button-base')).toBeFalsy();
|
|
222
|
+
});
|
|
223
|
+
});
|
|
224
|
+
|
|
225
|
+
describe('Carousel Content', () => {
|
|
226
|
+
it('should render no content when carousel is selected but cards are empty', () => {
|
|
227
|
+
const props = {
|
|
228
|
+
...defaultProps,
|
|
229
|
+
content: {
|
|
230
|
+
viberPreviewContent: {
|
|
231
|
+
type: 'CAROUSEL',
|
|
232
|
+
cards: [
|
|
233
|
+
{
|
|
234
|
+
text: '',
|
|
235
|
+
mediaUrl: '',
|
|
236
|
+
buttons: [
|
|
237
|
+
{ title: '', action: '' },
|
|
238
|
+
],
|
|
239
|
+
},
|
|
240
|
+
{
|
|
241
|
+
text: ' ',
|
|
242
|
+
mediaUrl: ' ',
|
|
243
|
+
buttons: [
|
|
244
|
+
{ title: ' ', action: 'https://example.com/2' },
|
|
245
|
+
],
|
|
246
|
+
},
|
|
247
|
+
],
|
|
248
|
+
},
|
|
249
|
+
},
|
|
250
|
+
};
|
|
251
|
+
|
|
252
|
+
render(
|
|
253
|
+
<TestWrapper>
|
|
254
|
+
<ComponentToRender {...props} />
|
|
255
|
+
</TestWrapper>
|
|
256
|
+
);
|
|
257
|
+
|
|
258
|
+
expect(screen.getByText('No content available')).toBeTruthy();
|
|
259
|
+
});
|
|
260
|
+
|
|
261
|
+
it('should render carousel cards when type is CAROUSEL', () => {
|
|
262
|
+
const props = {
|
|
263
|
+
...defaultProps,
|
|
264
|
+
content: {
|
|
265
|
+
viberPreviewContent: {
|
|
266
|
+
type: 'CAROUSEL',
|
|
267
|
+
cards: [
|
|
268
|
+
{
|
|
269
|
+
text: 'Card 1 text',
|
|
270
|
+
mediaUrl: 'https://image.url/card1.jpg',
|
|
271
|
+
buttons: [
|
|
272
|
+
{ title: 'Button 1', action: 'https://example.com/1' },
|
|
273
|
+
],
|
|
274
|
+
},
|
|
275
|
+
{
|
|
276
|
+
text: 'Card 2 text',
|
|
277
|
+
mediaUrl: 'https://image.url/card2.jpg',
|
|
278
|
+
buttons: [
|
|
279
|
+
{ title: 'Button 2', action: 'https://example.com/2' },
|
|
280
|
+
],
|
|
281
|
+
},
|
|
282
|
+
],
|
|
283
|
+
},
|
|
284
|
+
},
|
|
285
|
+
};
|
|
286
|
+
|
|
287
|
+
render(
|
|
288
|
+
<TestWrapper>
|
|
289
|
+
<ComponentToRender {...props} />
|
|
290
|
+
</TestWrapper>
|
|
291
|
+
);
|
|
292
|
+
|
|
293
|
+
expect(screen.getByText('Card 1 text')).toBeTruthy();
|
|
294
|
+
expect(screen.getByText('Card 2 text')).toBeTruthy();
|
|
295
|
+
expect(screen.getByText('Button 1')).toBeTruthy();
|
|
296
|
+
expect(screen.getByText('Button 2')).toBeTruthy();
|
|
297
|
+
});
|
|
298
|
+
|
|
299
|
+
it('should not render empty carousel button placeholder', () => {
|
|
300
|
+
const props = {
|
|
301
|
+
...defaultProps,
|
|
302
|
+
content: {
|
|
303
|
+
viberPreviewContent: {
|
|
304
|
+
type: 'CAROUSEL',
|
|
305
|
+
cards: [
|
|
306
|
+
{
|
|
307
|
+
text: 'Card 1 text',
|
|
308
|
+
mediaUrl: 'https://image.url/card1.jpg',
|
|
309
|
+
buttons: [
|
|
310
|
+
{ title: '', action: 'https://example.com/1' },
|
|
311
|
+
{ title: ' ', action: 'https://example.com/2' },
|
|
312
|
+
],
|
|
313
|
+
},
|
|
314
|
+
],
|
|
315
|
+
},
|
|
316
|
+
},
|
|
317
|
+
};
|
|
318
|
+
|
|
319
|
+
const { container } = render(
|
|
320
|
+
<TestWrapper>
|
|
321
|
+
<ComponentToRender {...props} />
|
|
322
|
+
</TestWrapper>
|
|
323
|
+
);
|
|
324
|
+
|
|
325
|
+
expect(container.querySelector('.viber-carousel-preview-button')).toBeNull();
|
|
326
|
+
});
|
|
327
|
+
|
|
328
|
+
it('should show carousel shell when showCarouselEditorPreview is true even if cards are empty', () => {
|
|
329
|
+
const props = {
|
|
330
|
+
...defaultProps,
|
|
331
|
+
content: {
|
|
332
|
+
viberPreviewContent: {
|
|
333
|
+
type: 'CAROUSEL',
|
|
334
|
+
showCarouselEditorPreview: true,
|
|
335
|
+
cards: [
|
|
336
|
+
{ text: '', mediaUrl: '', buttons: [{ title: '', action: '' }] },
|
|
337
|
+
{ text: '', mediaUrl: '', buttons: [{ title: '', action: '' }] },
|
|
338
|
+
],
|
|
339
|
+
},
|
|
340
|
+
},
|
|
341
|
+
};
|
|
342
|
+
|
|
343
|
+
const { container } = render(
|
|
344
|
+
<TestWrapper>
|
|
345
|
+
<ComponentToRender {...props} />
|
|
346
|
+
</TestWrapper>
|
|
347
|
+
);
|
|
348
|
+
|
|
349
|
+
expect(screen.queryByText('No content available')).toBeNull();
|
|
350
|
+
expect(container.querySelector('.viber-carousel-preview-scroll')).toBeTruthy();
|
|
351
|
+
expect(container.querySelector('.viber-carousel-message-box-placeholder')).toBeTruthy();
|
|
352
|
+
});
|
|
353
|
+
|
|
354
|
+
it('should render carousel message text in message box when type is CAROUSEL', () => {
|
|
355
|
+
const props = {
|
|
356
|
+
...defaultProps,
|
|
357
|
+
content: {
|
|
358
|
+
viberPreviewContent: {
|
|
359
|
+
type: 'CAROUSEL',
|
|
360
|
+
messageContent: 'Carousel intro copy',
|
|
361
|
+
cards: [
|
|
362
|
+
{
|
|
363
|
+
text: 'Card text',
|
|
364
|
+
mediaUrl: 'https://image.url/c.jpg',
|
|
365
|
+
buttons: [{ title: 'Go', action: 'https://example.com' }],
|
|
366
|
+
},
|
|
367
|
+
],
|
|
368
|
+
},
|
|
369
|
+
},
|
|
370
|
+
};
|
|
371
|
+
|
|
372
|
+
const { container } = render(
|
|
373
|
+
<TestWrapper>
|
|
374
|
+
<ComponentToRender {...props} />
|
|
375
|
+
</TestWrapper>
|
|
376
|
+
);
|
|
377
|
+
|
|
378
|
+
expect(container.querySelector('.viber-carousel-message-box-text')).toHaveTextContent('Carousel intro copy');
|
|
379
|
+
expect(screen.queryByText('Carousel intro copy')).toBeTruthy();
|
|
380
|
+
});
|
|
381
|
+
|
|
382
|
+
it('should hide account icon when carousel is shown', () => {
|
|
383
|
+
const props = {
|
|
384
|
+
...defaultProps,
|
|
385
|
+
content: {
|
|
386
|
+
viberPreviewContent: {
|
|
387
|
+
type: 'CAROUSEL',
|
|
388
|
+
cards: [
|
|
389
|
+
{
|
|
390
|
+
text: 'Carousel card line',
|
|
391
|
+
mediaUrl: '',
|
|
392
|
+
buttons: [{ title: 'Open link', action: 'https://x.com' }],
|
|
393
|
+
},
|
|
394
|
+
],
|
|
395
|
+
},
|
|
396
|
+
},
|
|
397
|
+
};
|
|
398
|
+
|
|
399
|
+
const { container } = render(
|
|
400
|
+
<TestWrapper>
|
|
401
|
+
<ComponentToRender {...props} />
|
|
402
|
+
</TestWrapper>
|
|
403
|
+
);
|
|
404
|
+
|
|
405
|
+
expect(container.querySelector('.viber-account-icon')).toBeNull();
|
|
406
|
+
});
|
|
407
|
+
|
|
408
|
+
it('should use image placeholder when carousel card mediaUrl is whitespace only', () => {
|
|
409
|
+
const props = {
|
|
410
|
+
...defaultProps,
|
|
411
|
+
content: {
|
|
412
|
+
viberPreviewContent: {
|
|
413
|
+
type: 'CAROUSEL',
|
|
414
|
+
cards: [
|
|
415
|
+
{
|
|
416
|
+
text: 'Only text',
|
|
417
|
+
mediaUrl: ' ',
|
|
418
|
+
buttons: [{ title: 'Btn', action: 'https://example.com' }],
|
|
419
|
+
},
|
|
420
|
+
],
|
|
421
|
+
},
|
|
422
|
+
},
|
|
423
|
+
};
|
|
424
|
+
|
|
425
|
+
const { container } = render(
|
|
426
|
+
<TestWrapper>
|
|
427
|
+
<ComponentToRender {...props} />
|
|
428
|
+
</TestWrapper>
|
|
429
|
+
);
|
|
430
|
+
|
|
431
|
+
expect(container.querySelector('.viber-carousel-preview-image-placeholder')).toBeTruthy();
|
|
432
|
+
expect(container.querySelector('.viber-carousel-preview-image')).toBeNull();
|
|
433
|
+
});
|
|
434
|
+
|
|
435
|
+
it('should render at most two carousel buttons per card', () => {
|
|
436
|
+
const props = {
|
|
437
|
+
...defaultProps,
|
|
438
|
+
content: {
|
|
439
|
+
viberPreviewContent: {
|
|
440
|
+
type: 'CAROUSEL',
|
|
441
|
+
cards: [
|
|
442
|
+
{
|
|
443
|
+
text: 'Card',
|
|
444
|
+
mediaUrl: 'https://image.url/c.jpg',
|
|
445
|
+
buttons: [
|
|
446
|
+
{ title: 'One', action: 'https://a.com' },
|
|
447
|
+
{ title: 'Two', action: 'https://b.com' },
|
|
448
|
+
{ title: 'Three', action: 'https://c.com' },
|
|
449
|
+
],
|
|
450
|
+
},
|
|
451
|
+
],
|
|
452
|
+
},
|
|
453
|
+
},
|
|
454
|
+
};
|
|
455
|
+
|
|
456
|
+
const { container } = render(
|
|
457
|
+
<TestWrapper>
|
|
458
|
+
<ComponentToRender {...props} />
|
|
459
|
+
</TestWrapper>
|
|
460
|
+
);
|
|
461
|
+
|
|
462
|
+
expect(container.querySelectorAll('.viber-carousel-preview-button')).toHaveLength(2);
|
|
463
|
+
expect(screen.getByText('One')).toBeTruthy();
|
|
464
|
+
expect(screen.getByText('Two')).toBeTruthy();
|
|
465
|
+
expect(screen.queryByText('Three')).toBeNull();
|
|
466
|
+
});
|
|
467
|
+
|
|
468
|
+
it('should apply secondary class to second carousel button', () => {
|
|
469
|
+
const props = {
|
|
470
|
+
...defaultProps,
|
|
471
|
+
content: {
|
|
472
|
+
viberPreviewContent: {
|
|
473
|
+
type: 'CAROUSEL',
|
|
474
|
+
cards: [
|
|
475
|
+
{
|
|
476
|
+
text: 'Card',
|
|
477
|
+
mediaUrl: 'https://image.url/c.jpg',
|
|
478
|
+
buttons: [
|
|
479
|
+
{ title: 'Primary', action: 'https://a.com' },
|
|
480
|
+
{ title: 'Secondary', action: 'https://b.com' },
|
|
481
|
+
],
|
|
482
|
+
},
|
|
483
|
+
],
|
|
484
|
+
},
|
|
485
|
+
},
|
|
486
|
+
};
|
|
487
|
+
|
|
488
|
+
const { container } = render(
|
|
489
|
+
<TestWrapper>
|
|
490
|
+
<ComponentToRender {...props} />
|
|
491
|
+
</TestWrapper>
|
|
492
|
+
);
|
|
493
|
+
|
|
494
|
+
const buttons = container.querySelectorAll('.viber-carousel-preview-button');
|
|
495
|
+
expect(buttons[0].className).toContain('viber-carousel-preview-button');
|
|
496
|
+
expect(buttons[0].className).not.toContain('viber-carousel-preview-button-secondary');
|
|
497
|
+
expect(buttons[1].className).toContain('viber-carousel-preview-button-secondary');
|
|
498
|
+
});
|
|
499
|
+
|
|
500
|
+
it('should show carousel when only a button title is present on a card', () => {
|
|
501
|
+
const props = {
|
|
502
|
+
...defaultProps,
|
|
503
|
+
content: {
|
|
504
|
+
viberPreviewContent: {
|
|
505
|
+
type: 'CAROUSEL',
|
|
506
|
+
cards: [
|
|
507
|
+
{
|
|
508
|
+
text: '',
|
|
509
|
+
mediaUrl: '',
|
|
510
|
+
buttons: [{ title: 'Tap me', action: 'https://example.com' }],
|
|
511
|
+
},
|
|
512
|
+
],
|
|
513
|
+
},
|
|
514
|
+
},
|
|
515
|
+
};
|
|
516
|
+
|
|
517
|
+
render(
|
|
518
|
+
<TestWrapper>
|
|
519
|
+
<ComponentToRender {...props} />
|
|
520
|
+
</TestWrapper>
|
|
521
|
+
);
|
|
522
|
+
|
|
523
|
+
expect(screen.getByText('Tap me')).toBeTruthy();
|
|
524
|
+
expect(screen.queryByText('No content available')).toBeNull();
|
|
525
|
+
});
|
|
526
|
+
|
|
527
|
+
it('should show one placeholder card when editor preview and cards array is empty', () => {
|
|
528
|
+
const props = {
|
|
529
|
+
...defaultProps,
|
|
530
|
+
content: {
|
|
531
|
+
viberPreviewContent: {
|
|
532
|
+
type: 'CAROUSEL',
|
|
533
|
+
showCarouselEditorPreview: true,
|
|
534
|
+
cards: [],
|
|
535
|
+
},
|
|
536
|
+
},
|
|
537
|
+
};
|
|
538
|
+
|
|
539
|
+
const { container } = render(
|
|
540
|
+
<TestWrapper>
|
|
541
|
+
<ComponentToRender {...props} />
|
|
542
|
+
</TestWrapper>
|
|
543
|
+
);
|
|
544
|
+
|
|
545
|
+
expect(container.querySelectorAll('.viber-carousel-preview-card')).toHaveLength(1);
|
|
546
|
+
});
|
|
547
|
+
|
|
548
|
+
it('should show no content when CAROUSEL has empty cards and no editor preview flag', () => {
|
|
549
|
+
const props = {
|
|
550
|
+
...defaultProps,
|
|
551
|
+
content: {
|
|
552
|
+
viberPreviewContent: {
|
|
553
|
+
type: 'CAROUSEL',
|
|
554
|
+
cards: [],
|
|
555
|
+
},
|
|
556
|
+
},
|
|
557
|
+
};
|
|
558
|
+
|
|
559
|
+
render(
|
|
560
|
+
<TestWrapper>
|
|
561
|
+
<ComponentToRender {...props} />
|
|
562
|
+
</TestWrapper>
|
|
563
|
+
);
|
|
564
|
+
|
|
565
|
+
expect(screen.getByText('No content available')).toBeTruthy();
|
|
566
|
+
});
|
|
203
567
|
});
|
|
204
568
|
|
|
205
569
|
describe('Account and Brand Name', () => {
|
|
@@ -160,6 +160,96 @@
|
|
|
160
160
|
line-clamp: 3;
|
|
161
161
|
}
|
|
162
162
|
}
|
|
163
|
+
.viber-carousel-static-content {
|
|
164
|
+
width: 100%;
|
|
165
|
+
overflow: hidden;
|
|
166
|
+
.viber-carousel-static-message-box {
|
|
167
|
+
width: 100%;
|
|
168
|
+
height: auto;
|
|
169
|
+
border-radius: $CAP_SPACE_04;
|
|
170
|
+
background: $CAP_WHITE;
|
|
171
|
+
margin-bottom: $CAP_SPACE_08;
|
|
172
|
+
display: flex;
|
|
173
|
+
align-items: flex-start;
|
|
174
|
+
}
|
|
175
|
+
.viber-carousel-static-message {
|
|
176
|
+
display: -webkit-box;
|
|
177
|
+
width: 100%;
|
|
178
|
+
color: $CAP_G01;
|
|
179
|
+
line-height: 1.3;
|
|
180
|
+
overflow: hidden;
|
|
181
|
+
text-overflow: ellipsis;
|
|
182
|
+
-webkit-line-clamp: 2;
|
|
183
|
+
line-clamp: 2;
|
|
184
|
+
-webkit-box-orient: vertical;
|
|
185
|
+
white-space: normal;
|
|
186
|
+
word-break: break-word;
|
|
187
|
+
}
|
|
188
|
+
.viber-carousel-static-cards {
|
|
189
|
+
display: flex;
|
|
190
|
+
gap: $CAP_SPACE_08;
|
|
191
|
+
overflow: hidden;
|
|
192
|
+
}
|
|
193
|
+
.viber-carousel-static-card {
|
|
194
|
+
flex: 1;
|
|
195
|
+
min-width: 0;
|
|
196
|
+
background: $CAP_WHITE;
|
|
197
|
+
border-radius: $CAP_SPACE_04;
|
|
198
|
+
overflow: hidden;
|
|
199
|
+
display: flex;
|
|
200
|
+
flex-direction: column;
|
|
201
|
+
}
|
|
202
|
+
.viber-carousel-static-image {
|
|
203
|
+
width: 100%;
|
|
204
|
+
max-height: 11rem;
|
|
205
|
+
margin-bottom: $CAP_SPACE_04;
|
|
206
|
+
border-radius: $CAP_SPACE_04;
|
|
207
|
+
display: block;
|
|
208
|
+
}
|
|
209
|
+
.viber-carousel-static-image-placeholder {
|
|
210
|
+
width: 100%;
|
|
211
|
+
height: 7.143rem;
|
|
212
|
+
border-radius: $CAP_SPACE_04;
|
|
213
|
+
}
|
|
214
|
+
.viber-carousel-static-image-placeholder {
|
|
215
|
+
background: $CAP_G07;
|
|
216
|
+
}
|
|
217
|
+
.viber-carousel-static-text {
|
|
218
|
+
display: block;
|
|
219
|
+
color: $CAP_G01;
|
|
220
|
+
margin: $CAP_SPACE_04 0;
|
|
221
|
+
line-height: 1.3;
|
|
222
|
+
overflow: hidden;
|
|
223
|
+
text-overflow: ellipsis;
|
|
224
|
+
white-space: normal;
|
|
225
|
+
-webkit-line-clamp: 2;
|
|
226
|
+
line-clamp: 2;
|
|
227
|
+
-webkit-box-orient: vertical;
|
|
228
|
+
display: -webkit-box;
|
|
229
|
+
}
|
|
230
|
+
.viber-carousel-static-buttons {
|
|
231
|
+
display: flex;
|
|
232
|
+
flex-direction: column;
|
|
233
|
+
gap: $CAP_SPACE_04;
|
|
234
|
+
margin-top: auto;
|
|
235
|
+
}
|
|
236
|
+
.viber-carousel-static-button {
|
|
237
|
+
display: block;
|
|
238
|
+
min-height: 1.5rem;
|
|
239
|
+
border-radius: $CAP_SPACE_12;
|
|
240
|
+
background: $CAP_PURPLE01;
|
|
241
|
+
color: $CAP_WHITE;
|
|
242
|
+
text-align: center;
|
|
243
|
+
padding: 0.179rem $CAP_SPACE_08;
|
|
244
|
+
white-space: normal;
|
|
245
|
+
}
|
|
246
|
+
.viber-carousel-static-button-secondary {
|
|
247
|
+
color: $CAP_PURPLE01;
|
|
248
|
+
background: transparent;
|
|
249
|
+
border: none;
|
|
250
|
+
box-shadow: none;
|
|
251
|
+
}
|
|
252
|
+
}
|
|
163
253
|
|
|
164
254
|
}
|
|
165
255
|
|
|
@@ -168,6 +258,30 @@
|
|
|
168
258
|
word-wrap: break-word;
|
|
169
259
|
}
|
|
170
260
|
}
|
|
261
|
+
|
|
262
|
+
&.viber-carousel-static {
|
|
263
|
+
height: auto;
|
|
264
|
+
min-height: 21.125rem;
|
|
265
|
+
|
|
266
|
+
.ant-card-body {
|
|
267
|
+
padding-bottom: $CAP_SPACE_12;
|
|
268
|
+
}
|
|
269
|
+
|
|
270
|
+
.truncate-text-viber {
|
|
271
|
+
.ant-card-meta-description {
|
|
272
|
+
display: block;
|
|
273
|
+
overflow: visible;
|
|
274
|
+
-webkit-line-clamp: unset;
|
|
275
|
+
line-clamp: unset;
|
|
276
|
+
}
|
|
277
|
+
}
|
|
278
|
+
|
|
279
|
+
.viber-carousel-static-content,
|
|
280
|
+
.viber-carousel-static-cards,
|
|
281
|
+
.viber-carousel-static-card {
|
|
282
|
+
overflow: visible;
|
|
283
|
+
}
|
|
284
|
+
}
|
|
171
285
|
|
|
172
286
|
|
|
173
287
|
&.carousel-img-section {
|
|
@@ -73,6 +73,7 @@ import * as ebillActions from '../Ebill/actions';
|
|
|
73
73
|
import * as emailActions from '../Email/actions';
|
|
74
74
|
import * as lineActions from '../Line/Container/actions';
|
|
75
75
|
import * as viberActions from '../Viber/actions';
|
|
76
|
+
import { VIBER_MEDIA_TYPES } from '../Viber/constants';
|
|
76
77
|
import * as facebookActions from '../Facebook/actions';
|
|
77
78
|
import * as whatsappActions from '../Whatsapp/actions';
|
|
78
79
|
import * as rcsActions from '../Rcs/actions';
|
|
@@ -1396,6 +1397,11 @@ export class Templates extends React.Component { // eslint-disable-line react/pr
|
|
|
1396
1397
|
const image = viberContent.image || {};
|
|
1397
1398
|
const video = viberContent.video || {};
|
|
1398
1399
|
const button = viberContent.button || {};
|
|
1400
|
+
const messageType = viberContent.type || '';
|
|
1401
|
+
const cardsRaw = viberContent.cards;
|
|
1402
|
+
const cards = Array.isArray(cardsRaw) ? cardsRaw : [];
|
|
1403
|
+
const isCarousel =
|
|
1404
|
+
messageType === VIBER_MEDIA_TYPES.CAROUSEL || cards.length > 0;
|
|
1399
1405
|
|
|
1400
1406
|
const viberPreview = {
|
|
1401
1407
|
messageContent: text,
|
|
@@ -1413,14 +1419,39 @@ export class Templates extends React.Component { // eslint-disable-line react/pr
|
|
|
1413
1419
|
};
|
|
1414
1420
|
}
|
|
1415
1421
|
|
|
1422
|
+
if (isCarousel) {
|
|
1423
|
+
viberPreview.type = VIBER_MEDIA_TYPES.CAROUSEL;
|
|
1424
|
+
viberPreview.cards = cards.map((card) => ({
|
|
1425
|
+
text: card?.text || '',
|
|
1426
|
+
mediaUrl: card?.mediaUrl || '',
|
|
1427
|
+
buttons: (card?.buttons || []).map((btn) => ({
|
|
1428
|
+
title: btn?.title || '',
|
|
1429
|
+
action: btn?.action || '',
|
|
1430
|
+
})),
|
|
1431
|
+
}));
|
|
1432
|
+
viberPreview.showCarouselEditorPreview = true;
|
|
1433
|
+
}
|
|
1434
|
+
|
|
1416
1435
|
// Extract account name
|
|
1417
1436
|
const accountName = get(template, 'definition.accountName', '');
|
|
1418
1437
|
|
|
1419
1438
|
// Return Viber content object (same as Viber/index.js getTemplateContent)
|
|
1420
1439
|
return {
|
|
1421
1440
|
viberPreviewContent: viberPreview,
|
|
1422
|
-
accountName: accountName
|
|
1423
|
-
brandName: accountName
|
|
1441
|
+
accountName: accountName || '',
|
|
1442
|
+
brandName: accountName || '',
|
|
1443
|
+
messageContent: text,
|
|
1444
|
+
...(isCarousel && {
|
|
1445
|
+
type: VIBER_MEDIA_TYPES.CAROUSEL,
|
|
1446
|
+
cards: viberPreview.cards,
|
|
1447
|
+
}),
|
|
1448
|
+
...(!isCarousel && !isEmpty(button) && button.text && (button.url || viberContent.buttonURL) && {
|
|
1449
|
+
button: {
|
|
1450
|
+
text: button.text,
|
|
1451
|
+
url: button.url || viberContent.buttonURL || '',
|
|
1452
|
+
},
|
|
1453
|
+
}),
|
|
1454
|
+
buttonURL: button.url || viberContent.buttonURL || '',
|
|
1424
1455
|
};
|
|
1425
1456
|
}
|
|
1426
1457
|
|
|
@@ -2441,10 +2472,52 @@ export class Templates extends React.Component { // eslint-disable-line react/pr
|
|
|
2441
2472
|
image = {},
|
|
2442
2473
|
button = {},
|
|
2443
2474
|
video = {},
|
|
2475
|
+
type = '',
|
|
2476
|
+
cards = [],
|
|
2444
2477
|
} = {},
|
|
2445
2478
|
} = {},
|
|
2446
2479
|
} = template.versions.base;
|
|
2480
|
+
const isViberCarousel = type === VIBER_MEDIA_TYPES.CAROUSEL;
|
|
2447
2481
|
templateData.content = text;
|
|
2482
|
+
if (isViberCarousel) {
|
|
2483
|
+
const previewCards = Array.isArray(cards) ? cards.slice(0, 1) : [];
|
|
2484
|
+
templateData.className = 'viber-carousel-static';
|
|
2485
|
+
templateData.content = (
|
|
2486
|
+
<CapRow className="viber-carousel-static-content">
|
|
2487
|
+
<CapRow className="viber-carousel-static-message-box">
|
|
2488
|
+
<CapLabel type="label1" className="viber-carousel-static-message">
|
|
2489
|
+
{text}
|
|
2490
|
+
</CapLabel>
|
|
2491
|
+
</CapRow>
|
|
2492
|
+
<CapRow className="viber-carousel-static-cards">
|
|
2493
|
+
{previewCards.map((card, cardIdx) => (
|
|
2494
|
+
<CapRow className="viber-carousel-static-card" key={`viber-static-card-${cardIdx}`}>
|
|
2495
|
+
{card?.mediaUrl ? (
|
|
2496
|
+
<CapImage src={card.mediaUrl} className="viber-carousel-static-image" />
|
|
2497
|
+
) : (
|
|
2498
|
+
<CapRow className="viber-carousel-static-image-placeholder" />
|
|
2499
|
+
)}
|
|
2500
|
+
<CapLabel type="label1" className="viber-carousel-static-text">
|
|
2501
|
+
{card?.text}
|
|
2502
|
+
</CapLabel>
|
|
2503
|
+
<CapRow className="viber-carousel-static-buttons">
|
|
2504
|
+
{(Array.isArray(card?.buttons) && card.buttons.length ? card.buttons : [{}, {}]).slice(0, 2).map((carouselButton, btnIdx) => (
|
|
2505
|
+
<CapLabel
|
|
2506
|
+
key={`viber-static-btn-${cardIdx}-${btnIdx}`}
|
|
2507
|
+
type="label1"
|
|
2508
|
+
className={`viber-carousel-static-button ${btnIdx === 1 ? 'viber-carousel-static-button-secondary' : ''}`}
|
|
2509
|
+
>
|
|
2510
|
+
{(carouselButton?.title || '').trim()}
|
|
2511
|
+
</CapLabel>
|
|
2512
|
+
))}
|
|
2513
|
+
</CapRow>
|
|
2514
|
+
</CapRow>
|
|
2515
|
+
))}
|
|
2516
|
+
</CapRow>
|
|
2517
|
+
</CapRow>
|
|
2518
|
+
);
|
|
2519
|
+
break;
|
|
2520
|
+
}
|
|
2448
2521
|
if (!isEmpty(image)) {
|
|
2449
2522
|
const { url = '' } = image;
|
|
2450
2523
|
templateData.url = url;
|
|
@@ -5065,15 +5138,22 @@ export class Templates extends React.Component { // eslint-disable-line react/pr
|
|
|
5065
5138
|
? this.props.Templates.selectedWhatsappAccount.name
|
|
5066
5139
|
: null
|
|
5067
5140
|
}
|
|
5068
|
-
// Pass formData for
|
|
5141
|
+
// Pass formData for tag extraction (EMAIL/SMS use nested formData; VIBER uses content object)
|
|
5069
5142
|
formData={
|
|
5070
|
-
|
|
5071
|
-
|
|
5072
|
-
|
|
5073
|
-
|
|
5074
|
-
|
|
5075
|
-
|
|
5076
|
-
|
|
5143
|
+
(() => {
|
|
5144
|
+
const previewContent = this.state.testAndPreviewContent;
|
|
5145
|
+
const channelUpper = this.state.channel?.toUpperCase();
|
|
5146
|
+
if (!previewContent || typeof previewContent !== 'object') {
|
|
5147
|
+
return null;
|
|
5148
|
+
}
|
|
5149
|
+
if ([EMAIL, SMS].includes(channelUpper)) {
|
|
5150
|
+
return previewContent.formData || null;
|
|
5151
|
+
}
|
|
5152
|
+
if (channelUpper === VIBER) {
|
|
5153
|
+
return previewContent;
|
|
5154
|
+
}
|
|
5155
|
+
return null;
|
|
5156
|
+
})()
|
|
5077
5157
|
}
|
|
5078
5158
|
/>
|
|
5079
5159
|
)}
|
|
@@ -239,6 +239,7 @@ exports[`Test Templates container Should render sms illustration when no templat
|
|
|
239
239
|
<CapButton
|
|
240
240
|
className="create-new-sms margin-l-8 margin-b-12"
|
|
241
241
|
disabled={false}
|
|
242
|
+
isAddBtn={true}
|
|
242
243
|
onClick={[Function]}
|
|
243
244
|
type="primary"
|
|
244
245
|
>
|
|
@@ -813,6 +814,7 @@ exports[`Test Templates container Should render temlates when whatsapp templates
|
|
|
813
814
|
<CapButton
|
|
814
815
|
className="create-new-whatsapp margin-l-8 margin-b-12"
|
|
815
816
|
disabled={false}
|
|
817
|
+
isAddBtn={true}
|
|
816
818
|
onClick={[Function]}
|
|
817
819
|
type="primary"
|
|
818
820
|
>
|
|
@@ -1223,6 +1225,7 @@ exports[`Test Templates container Test max templates exceeded 1`] = `
|
|
|
1223
1225
|
<CapButton
|
|
1224
1226
|
className="create-new-whatsapp margin-l-8 margin-b-12"
|
|
1225
1227
|
disabled={false}
|
|
1228
|
+
isAddBtn={true}
|
|
1226
1229
|
onClick={[Function]}
|
|
1227
1230
|
type="primary"
|
|
1228
1231
|
>
|
|
@@ -1696,6 +1699,7 @@ exports[`Test Templates container Test max templates not exceeded 1`] = `
|
|
|
1696
1699
|
<CapButton
|
|
1697
1700
|
className="create-new-whatsapp margin-l-8 margin-b-12"
|
|
1698
1701
|
disabled={false}
|
|
1702
|
+
isAddBtn={true}
|
|
1699
1703
|
onClick={[Function]}
|
|
1700
1704
|
type="primary"
|
|
1701
1705
|
>
|
|
@@ -2169,6 +2173,7 @@ exports[`Test Templates container Test max templates warning 1`] = `
|
|
|
2169
2173
|
<CapButton
|
|
2170
2174
|
className="create-new-whatsapp margin-l-8 margin-b-12"
|
|
2171
2175
|
disabled={false}
|
|
2176
|
+
isAddBtn={true}
|
|
2172
2177
|
onClick={[Function]}
|
|
2173
2178
|
type="primary"
|
|
2174
2179
|
>
|