@capillarytech/creatives-library 8.0.359 → 8.0.360-alpha.0
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 +97 -14
- package/v2Components/CommonTestAndPreview/UnifiedPreview/WhatsAppPreviewContent.js +3 -3
- package/v2Components/CommonTestAndPreview/UnifiedPreview/_unifiedPreview.scss +79 -0
- package/v2Components/CommonTestAndPreview/UnifiedPreview/_viberCarouselPreviewCards.scss +127 -0
- package/v2Components/CommonTestAndPreview/index.js +244 -26
- package/v2Components/CommonTestAndPreview/tests/UnifiedPreview/ViberPreviewContent.test.js +364 -0
- package/v2Components/CommonTestAndPreview/tests/UnifiedPreview/WhatsAppPreviewContent.test.js +2 -9
- package/v2Containers/Templates/_templates.scss +77 -0
- package/v2Containers/Templates/index.js +90 -10
- package/v2Containers/Viber/constants.js +19 -0
- package/v2Containers/Viber/index.js +720 -47
- package/v2Containers/Viber/index.scss +175 -0
- package/v2Containers/Viber/messages.js +116 -0
- package/v2Containers/Viber/tests/index.test.js +80 -0
- package/v2Containers/Whatsapp/index.js +2 -5
|
@@ -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', () => {
|
package/v2Components/CommonTestAndPreview/tests/UnifiedPreview/WhatsAppPreviewContent.test.js
CHANGED
|
@@ -27,7 +27,6 @@ jest.mock('../../../../v2Containers/Whatsapp/constants', () => ({
|
|
|
27
27
|
authentication: 'authentication',
|
|
28
28
|
},
|
|
29
29
|
TEMPLATE_VARIABLE_REGEX: /\{\{.*?\}\}/,
|
|
30
|
-
SIZE_UNITS: ['bytes', 'KB', 'MB', 'GB', 'TB', 'PB', 'EB', 'ZB', 'YB'],
|
|
31
30
|
}));
|
|
32
31
|
|
|
33
32
|
// Convert messages object to format expected by IntlProvider
|
|
@@ -311,13 +310,7 @@ describe('WhatsAppPreviewContent', () => {
|
|
|
311
310
|
...defaultProps,
|
|
312
311
|
content: {
|
|
313
312
|
templateMsg: 'Message',
|
|
314
|
-
|
|
315
|
-
whatsappDocParams: {
|
|
316
|
-
whatsappDocImg: 'https://example.com/doc-preview.png',
|
|
317
|
-
whatsappDocName: 'test.pdf',
|
|
318
|
-
whatsappDocPages: 2,
|
|
319
|
-
whatsappDocSize: 12345,
|
|
320
|
-
},
|
|
313
|
+
docPreview: <div data-testid="doc-preview">Document</div>,
|
|
321
314
|
},
|
|
322
315
|
};
|
|
323
316
|
|
|
@@ -327,7 +320,7 @@ describe('WhatsAppPreviewContent', () => {
|
|
|
327
320
|
</TestWrapper>
|
|
328
321
|
);
|
|
329
322
|
|
|
330
|
-
expect(screen.
|
|
323
|
+
expect(screen.getByTestId('doc-preview')).toBeTruthy();
|
|
331
324
|
});
|
|
332
325
|
});
|
|
333
326
|
|
|
@@ -153,6 +153,83 @@
|
|
|
153
153
|
line-clamp: 3;
|
|
154
154
|
}
|
|
155
155
|
}
|
|
156
|
+
.viber-carousel-static-content {
|
|
157
|
+
width: 100%;
|
|
158
|
+
overflow: hidden;
|
|
159
|
+
.viber-carousel-static-message-box {
|
|
160
|
+
width: 100%;
|
|
161
|
+
height: 2.25rem;
|
|
162
|
+
border-radius: $CAP_SPACE_04;
|
|
163
|
+
background: $CAP_WHITE;
|
|
164
|
+
margin-bottom: $CAP_SPACE_08;
|
|
165
|
+
padding: 0 $CAP_SPACE_08;
|
|
166
|
+
display: flex;
|
|
167
|
+
align-items: center;
|
|
168
|
+
}
|
|
169
|
+
.viber-carousel-static-message {
|
|
170
|
+
display: block;
|
|
171
|
+
width: 100%;
|
|
172
|
+
color: $CAP_G01;
|
|
173
|
+
overflow: hidden;
|
|
174
|
+
text-overflow: ellipsis;
|
|
175
|
+
white-space: nowrap;
|
|
176
|
+
}
|
|
177
|
+
.viber-carousel-static-cards {
|
|
178
|
+
display: flex;
|
|
179
|
+
gap: $CAP_SPACE_08;
|
|
180
|
+
overflow: hidden;
|
|
181
|
+
}
|
|
182
|
+
.viber-carousel-static-card {
|
|
183
|
+
flex: 1;
|
|
184
|
+
min-width: 0;
|
|
185
|
+
background: $CAP_WHITE;
|
|
186
|
+
border-radius: $CAP_SPACE_04;
|
|
187
|
+
padding: $CAP_SPACE_06;
|
|
188
|
+
overflow: hidden;
|
|
189
|
+
}
|
|
190
|
+
.viber-carousel-static-image,
|
|
191
|
+
.viber-carousel-static-image-placeholder {
|
|
192
|
+
width: 100%;
|
|
193
|
+
height: 5.357rem;
|
|
194
|
+
border-radius: $CAP_SPACE_04;
|
|
195
|
+
}
|
|
196
|
+
.viber-carousel-static-image {
|
|
197
|
+
object-fit: cover;
|
|
198
|
+
}
|
|
199
|
+
.viber-carousel-static-image-placeholder {
|
|
200
|
+
background: $CAP_G07;
|
|
201
|
+
}
|
|
202
|
+
.viber-carousel-static-text {
|
|
203
|
+
display: block;
|
|
204
|
+
color: $CAP_G01;
|
|
205
|
+
margin: $CAP_SPACE_04 0;
|
|
206
|
+
line-height: 1.3;
|
|
207
|
+
overflow: hidden;
|
|
208
|
+
text-overflow: ellipsis;
|
|
209
|
+
white-space: normal;
|
|
210
|
+
}
|
|
211
|
+
.viber-carousel-static-buttons {
|
|
212
|
+
display: flex;
|
|
213
|
+
flex-direction: column;
|
|
214
|
+
gap: $CAP_SPACE_04;
|
|
215
|
+
}
|
|
216
|
+
.viber-carousel-static-button {
|
|
217
|
+
display: block;
|
|
218
|
+
min-height: 1.5rem;
|
|
219
|
+
border-radius: $CAP_SPACE_12;
|
|
220
|
+
background: $CAP_PURPLE01;
|
|
221
|
+
color: $CAP_WHITE;
|
|
222
|
+
text-align: center;
|
|
223
|
+
padding: 0.179rem $CAP_SPACE_08;
|
|
224
|
+
white-space: normal;
|
|
225
|
+
}
|
|
226
|
+
.viber-carousel-static-button-secondary {
|
|
227
|
+
color: $CAP_PURPLE01;
|
|
228
|
+
background: transparent;
|
|
229
|
+
border: none;
|
|
230
|
+
box-shadow: none;
|
|
231
|
+
}
|
|
232
|
+
}
|
|
156
233
|
|
|
157
234
|
}
|
|
158
235
|
|
|
@@ -72,6 +72,7 @@ import * as ebillActions from '../Ebill/actions';
|
|
|
72
72
|
import * as emailActions from '../Email/actions';
|
|
73
73
|
import * as lineActions from '../Line/Container/actions';
|
|
74
74
|
import * as viberActions from '../Viber/actions';
|
|
75
|
+
import { VIBER_MEDIA_TYPES } from '../Viber/constants';
|
|
75
76
|
import * as facebookActions from '../Facebook/actions';
|
|
76
77
|
import * as whatsappActions from '../Whatsapp/actions';
|
|
77
78
|
import * as rcsActions from '../Rcs/actions';
|
|
@@ -1374,6 +1375,11 @@ export class Templates extends React.Component { // eslint-disable-line react/pr
|
|
|
1374
1375
|
const image = viberContent.image || {};
|
|
1375
1376
|
const video = viberContent.video || {};
|
|
1376
1377
|
const button = viberContent.button || {};
|
|
1378
|
+
const messageType = viberContent.type || '';
|
|
1379
|
+
const cardsRaw = viberContent.cards;
|
|
1380
|
+
const cards = Array.isArray(cardsRaw) ? cardsRaw : [];
|
|
1381
|
+
const isCarousel =
|
|
1382
|
+
messageType === VIBER_MEDIA_TYPES.CAROUSEL || cards.length > 0;
|
|
1377
1383
|
|
|
1378
1384
|
const viberPreview = {
|
|
1379
1385
|
messageContent: text,
|
|
@@ -1391,14 +1397,39 @@ export class Templates extends React.Component { // eslint-disable-line react/pr
|
|
|
1391
1397
|
};
|
|
1392
1398
|
}
|
|
1393
1399
|
|
|
1400
|
+
if (isCarousel) {
|
|
1401
|
+
viberPreview.type = VIBER_MEDIA_TYPES.CAROUSEL;
|
|
1402
|
+
viberPreview.cards = cards.map((card) => ({
|
|
1403
|
+
text: card?.text || '',
|
|
1404
|
+
mediaUrl: card?.mediaUrl || '',
|
|
1405
|
+
buttons: (card?.buttons || []).map((btn) => ({
|
|
1406
|
+
title: btn?.title || '',
|
|
1407
|
+
action: btn?.action || '',
|
|
1408
|
+
})),
|
|
1409
|
+
}));
|
|
1410
|
+
viberPreview.showCarouselEditorPreview = true;
|
|
1411
|
+
}
|
|
1412
|
+
|
|
1394
1413
|
// Extract account name
|
|
1395
1414
|
const accountName = get(template, 'definition.accountName', '');
|
|
1396
1415
|
|
|
1397
1416
|
// Return Viber content object (same as Viber/index.js getTemplateContent)
|
|
1398
1417
|
return {
|
|
1399
1418
|
viberPreviewContent: viberPreview,
|
|
1400
|
-
accountName: accountName
|
|
1401
|
-
brandName: accountName
|
|
1419
|
+
accountName: accountName || '',
|
|
1420
|
+
brandName: accountName || '',
|
|
1421
|
+
messageContent: text,
|
|
1422
|
+
...(isCarousel && {
|
|
1423
|
+
type: VIBER_MEDIA_TYPES.CAROUSEL,
|
|
1424
|
+
cards: viberPreview.cards,
|
|
1425
|
+
}),
|
|
1426
|
+
...(!isCarousel && !isEmpty(button) && button.text && (button.url || viberContent.buttonURL) && {
|
|
1427
|
+
button: {
|
|
1428
|
+
text: button.text,
|
|
1429
|
+
url: button.url || viberContent.buttonURL || '',
|
|
1430
|
+
},
|
|
1431
|
+
}),
|
|
1432
|
+
buttonURL: button.url || viberContent.buttonURL || '',
|
|
1402
1433
|
};
|
|
1403
1434
|
}
|
|
1404
1435
|
|
|
@@ -2411,10 +2442,52 @@ export class Templates extends React.Component { // eslint-disable-line react/pr
|
|
|
2411
2442
|
image = {},
|
|
2412
2443
|
button = {},
|
|
2413
2444
|
video = {},
|
|
2445
|
+
type = '',
|
|
2446
|
+
cards = [],
|
|
2414
2447
|
} = {},
|
|
2415
2448
|
} = {},
|
|
2416
2449
|
} = template.versions.base;
|
|
2450
|
+
const isViberCarousel = type === VIBER_MEDIA_TYPES.CAROUSEL;
|
|
2417
2451
|
templateData.content = text;
|
|
2452
|
+
if (isViberCarousel) {
|
|
2453
|
+
const previewCards = Array.isArray(cards) ? cards.slice(0, 1) : [];
|
|
2454
|
+
templateData.className = 'viber-carousel-static';
|
|
2455
|
+
templateData.content = (
|
|
2456
|
+
<CapRow className="viber-carousel-static-content">
|
|
2457
|
+
<CapRow className="viber-carousel-static-message-box">
|
|
2458
|
+
<CapLabel type="label1" className="viber-carousel-static-message">
|
|
2459
|
+
{text}
|
|
2460
|
+
</CapLabel>
|
|
2461
|
+
</CapRow>
|
|
2462
|
+
<CapRow className="viber-carousel-static-cards">
|
|
2463
|
+
{previewCards.map((card, cardIdx) => (
|
|
2464
|
+
<CapRow className="viber-carousel-static-card" key={`viber-static-card-${cardIdx}`}>
|
|
2465
|
+
{card?.mediaUrl ? (
|
|
2466
|
+
<CapImage src={card.mediaUrl} className="viber-carousel-static-image" />
|
|
2467
|
+
) : (
|
|
2468
|
+
<CapRow className="viber-carousel-static-image-placeholder" />
|
|
2469
|
+
)}
|
|
2470
|
+
<CapLabel type="label1" className="viber-carousel-static-text">
|
|
2471
|
+
{card?.text}
|
|
2472
|
+
</CapLabel>
|
|
2473
|
+
<CapRow className="viber-carousel-static-buttons">
|
|
2474
|
+
{(Array.isArray(card?.buttons) && card.buttons.length ? card.buttons : [{}, {}]).slice(0, 2).map((carouselButton, btnIdx) => (
|
|
2475
|
+
<CapLabel
|
|
2476
|
+
key={`viber-static-btn-${cardIdx}-${btnIdx}`}
|
|
2477
|
+
type="label1"
|
|
2478
|
+
className={`viber-carousel-static-button ${btnIdx === 1 ? 'viber-carousel-static-button-secondary' : ''}`}
|
|
2479
|
+
>
|
|
2480
|
+
{(carouselButton?.title || '').trim()}
|
|
2481
|
+
</CapLabel>
|
|
2482
|
+
))}
|
|
2483
|
+
</CapRow>
|
|
2484
|
+
</CapRow>
|
|
2485
|
+
))}
|
|
2486
|
+
</CapRow>
|
|
2487
|
+
</CapRow>
|
|
2488
|
+
);
|
|
2489
|
+
break;
|
|
2490
|
+
}
|
|
2418
2491
|
if (!isEmpty(image)) {
|
|
2419
2492
|
const { url = '' } = image;
|
|
2420
2493
|
templateData.url = url;
|
|
@@ -4976,15 +5049,22 @@ export class Templates extends React.Component { // eslint-disable-line react/pr
|
|
|
4976
5049
|
? this.props.Templates.selectedWhatsappAccount.name
|
|
4977
5050
|
: null
|
|
4978
5051
|
}
|
|
4979
|
-
// Pass formData for
|
|
5052
|
+
// Pass formData for tag extraction (EMAIL/SMS use nested formData; VIBER uses content object)
|
|
4980
5053
|
formData={
|
|
4981
|
-
|
|
4982
|
-
|
|
4983
|
-
|
|
4984
|
-
|
|
4985
|
-
|
|
4986
|
-
|
|
4987
|
-
|
|
5054
|
+
(() => {
|
|
5055
|
+
const previewContent = this.state.testAndPreviewContent;
|
|
5056
|
+
const channelUpper = this.state.channel?.toUpperCase();
|
|
5057
|
+
if (!previewContent || typeof previewContent !== 'object') {
|
|
5058
|
+
return null;
|
|
5059
|
+
}
|
|
5060
|
+
if (channelUpper === EMAIL || channelUpper === SMS) {
|
|
5061
|
+
return previewContent.formData || null;
|
|
5062
|
+
}
|
|
5063
|
+
if (channelUpper === VIBER) {
|
|
5064
|
+
return previewContent;
|
|
5065
|
+
}
|
|
5066
|
+
return null;
|
|
5067
|
+
})()
|
|
4988
5068
|
}
|
|
4989
5069
|
/>
|
|
4990
5070
|
)}
|
|
@@ -47,7 +47,22 @@ export const VIBER_MEDIA_TYPES = {
|
|
|
47
47
|
TEXT: 'TEXT',
|
|
48
48
|
IMAGE: 'IMAGE',
|
|
49
49
|
VIDEO: 'VIDEO',
|
|
50
|
+
CAROUSEL: 'CAROUSEL',
|
|
50
51
|
};
|
|
52
|
+
export const VIBER_CAROUSEL_MIN_CARDS = 2;
|
|
53
|
+
export const VIBER_CAROUSEL_MAX_CARDS = 5;
|
|
54
|
+
export const VIBER_CAROUSEL_MAX_BUTTONS = 2;
|
|
55
|
+
export const VIBER_CAROUSEL_CARD_TITLE_MIN_LENGTH = 2;
|
|
56
|
+
export const VIBER_CAROUSEL_CARD_TITLE_MAX_LENGTH = 38;
|
|
57
|
+
export const VIBER_CAROUSEL_FIRST_BUTTON_TITLE_MAX_LENGTH = 10;
|
|
58
|
+
export const VIBER_CAROUSEL_SECOND_BUTTON_TITLE_MAX_LENGTH = 12;
|
|
59
|
+
export const VIBER_CAROUSEL_BUTTON_URL_MAX_LENGTH = 1000;
|
|
60
|
+
/** Recommended / validated carousel image height in pixels (passed to image upload). */
|
|
61
|
+
export const VIBER_CAROUSEL_IMG_HEIGHT = 600;
|
|
62
|
+
/** Recommended / validated carousel image width in pixels (passed to image upload). */
|
|
63
|
+
export const VIBER_CAROUSEL_IMG_WIDTH = 696;
|
|
64
|
+
/** Maximum carousel image file size (bytes). 10_000_000 ≈ 10 MB (decimal). */
|
|
65
|
+
export const VIBER_CAROUSEL_IMG_SIZE = 10000000;
|
|
51
66
|
export const ALLOWED_IMAGE_EXTENSIONS_REGEX_VIBER = /\.(jpe?g|png)$/i;
|
|
52
67
|
export const ALLOWED_EXTENSIONS_VIDEO_REGEX_VIBER = /\.(mp4|3gp|m4v|mov)$/i;
|
|
53
68
|
export const NONE = 'NONE';
|
|
@@ -69,6 +84,10 @@ export const mediaRadioOptions = [
|
|
|
69
84
|
value: VIBER_MEDIA_TYPES.VIDEO,
|
|
70
85
|
label: <FormattedMessage {...messages.mediaVideo} />,
|
|
71
86
|
},
|
|
87
|
+
{
|
|
88
|
+
value: VIBER_MEDIA_TYPES.CAROUSEL,
|
|
89
|
+
label: <FormattedMessage {...messages.mediaCarousel} />,
|
|
90
|
+
},
|
|
72
91
|
];
|
|
73
92
|
|
|
74
93
|
export const buttonRadioOptions = [
|