@capillarytech/creatives-library 7.17.81 → 7.17.82-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 +2 -1
- package/v2Components/CapWhatsappQuickReply/index.js +230 -0
- package/v2Components/CapWhatsappQuickReply/index.scss +40 -0
- package/v2Components/CapWhatsappQuickReply/messages.js +20 -0
- package/v2Components/TemplatePreview/index.js +30 -0
- package/v2Containers/CreativesContainer/tests/__snapshots__/SlideBoxContent.test.js.snap +4 -2
- package/v2Containers/Templates/index.js +5 -2
- package/v2Containers/Templates/tests/__snapshots__/index.test.js.snap +6 -0
- package/v2Containers/Whatsapp/constants.js +15 -0
- package/v2Containers/Whatsapp/index.js +545 -127
- package/v2Containers/Whatsapp/index.scss +44 -1
- package/v2Containers/Whatsapp/messages.js +28 -0
- package/v2Containers/Whatsapp/styles.scss +26 -0
- package/v2Containers/Whatsapp/tests/__snapshots__/index.test.js.snap +73374 -17531
- package/v2Containers/Whatsapp/tests/__snapshots__/utils.test.js.snap +20 -8
- package/v2Containers/Whatsapp/tests/utils.test.js +11 -0
- package/v2Containers/Whatsapp/utils.js +44 -2
- package/v2Containers/mockdata.js +115 -4
- package/v2Containers/InApp/constants.js +0 -0
- package/v2Containers/InApp/index.js +0 -499
- package/v2Containers/InApp/index.scss +0 -0
- package/v2Containers/InApp/messages.js +0 -0
|
@@ -2,8 +2,7 @@
|
|
|
2
2
|
|
|
3
3
|
exports[`Test utils test getWhatsappContent 1`] = `
|
|
4
4
|
Object {
|
|
5
|
-
"
|
|
6
|
-
"ctaData": Array [
|
|
5
|
+
"buttonsData": Array [
|
|
7
6
|
Object {
|
|
8
7
|
"index": 0,
|
|
9
8
|
"phone_number": "+919738752617",
|
|
@@ -17,6 +16,9 @@ Object {
|
|
|
17
16
|
"url": "https://docs.google.com/{{1}}",
|
|
18
17
|
},
|
|
19
18
|
],
|
|
19
|
+
"charCount": 151,
|
|
20
|
+
"footerMsg": "",
|
|
21
|
+
"headerMsg": "",
|
|
20
22
|
"templateMsg": <CapLabel
|
|
21
23
|
type="label9"
|
|
22
24
|
>
|
|
@@ -30,6 +32,8 @@ Click {{unsubscribe}} to unsubscribe
|
|
|
30
32
|
exports[`Test utils test getWhatsappContent 2`] = `
|
|
31
33
|
Object {
|
|
32
34
|
"charCount": 36,
|
|
35
|
+
"footerMsg": "",
|
|
36
|
+
"headerMsg": "",
|
|
33
37
|
"templateMsg": <CapLabel
|
|
34
38
|
type="label9"
|
|
35
39
|
>
|
|
@@ -40,8 +44,7 @@ Object {
|
|
|
40
44
|
|
|
41
45
|
exports[`Test utils test getWhatsappContent 3`] = `
|
|
42
46
|
Object {
|
|
43
|
-
"
|
|
44
|
-
"ctaData": Array [
|
|
47
|
+
"buttonsData": Array [
|
|
45
48
|
Object {
|
|
46
49
|
"index": 0,
|
|
47
50
|
"phone_number": "+919738752617",
|
|
@@ -55,6 +58,9 @@ Object {
|
|
|
55
58
|
"url": "https://docs.google.com/{{1}}",
|
|
56
59
|
},
|
|
57
60
|
],
|
|
61
|
+
"charCount": 151,
|
|
62
|
+
"footerMsg": "",
|
|
63
|
+
"headerMsg": "",
|
|
58
64
|
"templateMsg": <CapLabel
|
|
59
65
|
type="label9"
|
|
60
66
|
>
|
|
@@ -67,8 +73,7 @@ Click {{unsubscribe}} to unsubscribe
|
|
|
67
73
|
|
|
68
74
|
exports[`Test utils test getWhatsappContent 4`] = `
|
|
69
75
|
Object {
|
|
70
|
-
"
|
|
71
|
-
"ctaData": Array [
|
|
76
|
+
"buttonsData": Array [
|
|
72
77
|
Object {
|
|
73
78
|
"index": 0,
|
|
74
79
|
"phone_number": "+919738752617",
|
|
@@ -82,6 +87,7 @@ Object {
|
|
|
82
87
|
"url": "https://docs.google.com/{{1}}",
|
|
83
88
|
},
|
|
84
89
|
],
|
|
90
|
+
"charCount": 151,
|
|
85
91
|
"docPreview": <React.Fragment>
|
|
86
92
|
<div
|
|
87
93
|
className="pdf-img-box"
|
|
@@ -132,6 +138,8 @@ Object {
|
|
|
132
138
|
</div>
|
|
133
139
|
</div>
|
|
134
140
|
</React.Fragment>,
|
|
141
|
+
"footerMsg": "",
|
|
142
|
+
"headerMsg": "",
|
|
135
143
|
"templateMsg": <CapLabel
|
|
136
144
|
type="label9"
|
|
137
145
|
>
|
|
@@ -144,6 +152,8 @@ Click {{unsubscribe}} to unsubscribe
|
|
|
144
152
|
exports[`Test utils test getWhatsappContent 5`] = `
|
|
145
153
|
Object {
|
|
146
154
|
"charCount": -1,
|
|
155
|
+
"footerMsg": "",
|
|
156
|
+
"headerMsg": "",
|
|
147
157
|
"templateMsg": <CapLabel
|
|
148
158
|
type="label9"
|
|
149
159
|
>
|
|
@@ -154,8 +164,7 @@ Object {
|
|
|
154
164
|
|
|
155
165
|
exports[`Test utils test getWhatsappContent for preview 1`] = `
|
|
156
166
|
Object {
|
|
157
|
-
"
|
|
158
|
-
"ctaData": Array [
|
|
167
|
+
"buttonsData": Array [
|
|
159
168
|
Object {
|
|
160
169
|
"index": 0,
|
|
161
170
|
"phone_number": "+919738752617",
|
|
@@ -169,6 +178,9 @@ Object {
|
|
|
169
178
|
"url": "https://docs.google.com/{{1}}",
|
|
170
179
|
},
|
|
171
180
|
],
|
|
181
|
+
"charCount": 151,
|
|
182
|
+
"footerMsg": "",
|
|
183
|
+
"headerMsg": "",
|
|
172
184
|
"templateMsg": <CapLabel
|
|
173
185
|
type="label5"
|
|
174
186
|
>
|
|
@@ -5,6 +5,7 @@ import {
|
|
|
5
5
|
getWhatsappCta,
|
|
6
6
|
bytesConversion,
|
|
7
7
|
getWhatsappDocPreview,
|
|
8
|
+
getWhatsappQuickReply
|
|
8
9
|
} from '../utils';
|
|
9
10
|
import mockdata from '../../mockdata';
|
|
10
11
|
|
|
@@ -18,6 +19,9 @@ const {
|
|
|
18
19
|
getWhatsappCategoryOutput2,
|
|
19
20
|
getWhatsappDocPreviewOutput,
|
|
20
21
|
getWhatsappDocPreviewOutput1,
|
|
22
|
+
whatsappPreviewTemplateData3,
|
|
23
|
+
whatsappPreviewTemplateData3Result,
|
|
24
|
+
whatsappPreviewTemplateData3QuickReplyResult
|
|
21
25
|
} = mockdata;
|
|
22
26
|
|
|
23
27
|
describe('Test utils', () => {
|
|
@@ -27,10 +31,17 @@ describe('Test utils', () => {
|
|
|
27
31
|
expect(getWhatsappContent(whatsappPreviewTemplateDataVid)).toMatchSnapshot();
|
|
28
32
|
expect(getWhatsappContent(whatsappPreviewTemplateDataDoc)).toMatchSnapshot();
|
|
29
33
|
expect(getWhatsappContent({})).toMatchSnapshot();
|
|
34
|
+
expect(getWhatsappContent(whatsappPreviewTemplateData3)).toEqual(whatsappPreviewTemplateData3Result);
|
|
30
35
|
expect(bytesConversion(1024)).toEqual('1.0 KB');
|
|
31
36
|
expect(bytesConversion('abcd')).toEqual('0 bytes');
|
|
32
37
|
});
|
|
33
38
|
|
|
39
|
+
it("test getWhatsappQuickReply", () => {
|
|
40
|
+
expect(getWhatsappQuickReply(whatsappPreviewTemplateData3)).toEqual(
|
|
41
|
+
whatsappPreviewTemplateData3QuickReplyResult
|
|
42
|
+
);
|
|
43
|
+
});
|
|
44
|
+
|
|
34
45
|
it('test getWhatsappContent for preview', () => {
|
|
35
46
|
expect(
|
|
36
47
|
getWhatsappContent(whatsappPreviewTemplateData, true),
|
|
@@ -3,6 +3,7 @@ import { FormattedMessage } from 'react-intl';
|
|
|
3
3
|
import CapLabel from '@capillarytech/cap-ui-library/CapLabel';
|
|
4
4
|
import CapIcon from '@capillarytech/cap-ui-library/CapIcon';
|
|
5
5
|
import CapImage from '@capillarytech/cap-ui-library/CapImage';
|
|
6
|
+
import CapDivider from '@capillarytech/cap-ui-library/CapDivider';
|
|
6
7
|
import { get } from 'lodash';
|
|
7
8
|
import { WHATSAPP } from '../CreativesContainer/constants';
|
|
8
9
|
import {
|
|
@@ -17,6 +18,7 @@ import {
|
|
|
17
18
|
WHATSAPP_MEDIA_TYPES,
|
|
18
19
|
HOST_TWILIO,
|
|
19
20
|
SIZE_UNITS,
|
|
21
|
+
QUICK_REPLY
|
|
20
22
|
} from '../Whatsapp/constants';
|
|
21
23
|
import './styles.scss';
|
|
22
24
|
import pdfIcon from "../../assets/pdfIcon.svg";
|
|
@@ -65,11 +67,15 @@ export const getWhatsappContent = (template, isPreview) => {
|
|
|
65
67
|
[WHATSAPP.toLowerCase()]: {
|
|
66
68
|
languages = [{}],
|
|
67
69
|
buttonType = NONE,
|
|
68
|
-
buttons:
|
|
70
|
+
buttons: buttonsData = [],
|
|
69
71
|
mediaType = WHATSAPP_MEDIA_TYPES.TEXT,
|
|
70
72
|
imageUrl = '',
|
|
71
73
|
videoPreviewImg = '',
|
|
72
74
|
whatsappDocParams = {},
|
|
75
|
+
whatsappMedia: {
|
|
76
|
+
header = '',
|
|
77
|
+
footer = '',
|
|
78
|
+
} = {},
|
|
73
79
|
} = {},
|
|
74
80
|
} = {},
|
|
75
81
|
} = {},
|
|
@@ -104,10 +110,15 @@ export const getWhatsappContent = (template, isPreview) => {
|
|
|
104
110
|
}
|
|
105
111
|
|
|
106
112
|
return {
|
|
113
|
+
headerMsg: header ? <CapLabel className="whatsapp-template-header-preview">{header}</CapLabel> : '',
|
|
114
|
+
footerMsg: header ? <CapLabel className="whatsapp-template-footer-preview">{footer}</CapLabel> : '',
|
|
107
115
|
templateMsg: <CapLabel type={isPreview ? 'label5' : 'label9'}>{text}</CapLabel>,
|
|
108
116
|
charCount: text?.length - 1,
|
|
109
117
|
...(buttonType === CTA && {
|
|
110
|
-
|
|
118
|
+
buttonsData,
|
|
119
|
+
}),
|
|
120
|
+
...(buttonType === QUICK_REPLY && {
|
|
121
|
+
buttonsData,
|
|
111
122
|
}),
|
|
112
123
|
...mediaParams,
|
|
113
124
|
};
|
|
@@ -143,6 +154,37 @@ export const getWhatsappCta = (template) => {
|
|
|
143
154
|
return renderArray;
|
|
144
155
|
};
|
|
145
156
|
|
|
157
|
+
export const getWhatsappQuickReply= (template) => {
|
|
158
|
+
const { buttonType = NONE, buttons = [] } = get(
|
|
159
|
+
template,
|
|
160
|
+
`versions.base.content.whatsapp`,
|
|
161
|
+
{},
|
|
162
|
+
);
|
|
163
|
+
const renderArray = [];
|
|
164
|
+
if (buttonType === QUICK_REPLY && buttons?.length) {
|
|
165
|
+
renderArray.push(<CapDivider className="whatsapp-list-view-divider" />);
|
|
166
|
+
buttons.forEach((quickReply, index) => {
|
|
167
|
+
const { text } = quickReply || {};
|
|
168
|
+
if (text) {
|
|
169
|
+
renderArray.push(
|
|
170
|
+
<CapLabel type="label21" className="whatsapp-list-cta-preview">
|
|
171
|
+
<CapIcon
|
|
172
|
+
type='small-link'
|
|
173
|
+
size="xs"
|
|
174
|
+
svgProps={{ style: { marginRight: '4px' } }}
|
|
175
|
+
/>
|
|
176
|
+
{text}
|
|
177
|
+
</CapLabel>
|
|
178
|
+
)
|
|
179
|
+
}
|
|
180
|
+
if (index < buttons.length -1) {
|
|
181
|
+
renderArray.push(<CapDivider className="whatsapp-list-view-divider" />);
|
|
182
|
+
}
|
|
183
|
+
})
|
|
184
|
+
}
|
|
185
|
+
return renderArray;
|
|
186
|
+
}
|
|
187
|
+
|
|
146
188
|
export const getWhatsappCategory = (category, hostName) => (
|
|
147
189
|
hostName === HOST_TWILIO ? TWILIO_CATEGORY_OPTIONS : [...KARIX_GUPSHUP_CATEGORY_OPTIONS, ...KARIX_GUPSHUP_OLDER_CATEGORY_OPTIONS]
|
|
148
190
|
).find((obj) => obj.value === category);
|
package/v2Containers/mockdata.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import React from "react";
|
|
2
2
|
import { FormattedMessage } from "react-intl";
|
|
3
|
-
import { CapImage, CapLabel } from "@capillarytech/cap-ui-library";
|
|
3
|
+
import { CapImage, CapLabel, CapDivider, CapIcon } from "@capillarytech/cap-ui-library";
|
|
4
4
|
import pdfIcon from "../assets/pdfIcon.svg";
|
|
5
5
|
import messages from "./Whatsapp/messages";
|
|
6
6
|
|
|
@@ -1417,6 +1417,117 @@ export default {
|
|
|
1417
1417
|
updatedAt: "2022-07-17T11:08:56.326Z",
|
|
1418
1418
|
totalCount: 7,
|
|
1419
1419
|
},
|
|
1420
|
+
whatsappPreviewTemplateData3: {
|
|
1421
|
+
mode: "preview",
|
|
1422
|
+
_id: "62d3edc8b497b63ff5bbf8ea",
|
|
1423
|
+
name: "test_twilio_159425",
|
|
1424
|
+
type: "WHATSAPP",
|
|
1425
|
+
versions: {
|
|
1426
|
+
$init: true,
|
|
1427
|
+
history: [],
|
|
1428
|
+
base: {
|
|
1429
|
+
content: {
|
|
1430
|
+
whatsapp: {
|
|
1431
|
+
status: "approved",
|
|
1432
|
+
templateId: "HTee0274fb8dfdd45427bb678f875b0d54",
|
|
1433
|
+
hostName: "twiliowhatsapptrans",
|
|
1434
|
+
accessToken: "4676323eb5d1f975b0987070c03a8efc",
|
|
1435
|
+
accountId: "AC41030cebba9e2f1ce37c78235da0ee18",
|
|
1436
|
+
templateEditor: false,
|
|
1437
|
+
mediaType: "TEXT",
|
|
1438
|
+
languages: [
|
|
1439
|
+
{
|
|
1440
|
+
content: "Hi, your payment is successful.",
|
|
1441
|
+
language: "en",
|
|
1442
|
+
},
|
|
1443
|
+
],
|
|
1444
|
+
category: "ALERT_UPDATE",
|
|
1445
|
+
rejection_reason: null,
|
|
1446
|
+
whatsappMedia: {
|
|
1447
|
+
header: "Hello welcome",
|
|
1448
|
+
footer: "Thanks",
|
|
1449
|
+
},
|
|
1450
|
+
buttonType: "QUICK_REPLY",
|
|
1451
|
+
buttons: [
|
|
1452
|
+
{
|
|
1453
|
+
index: 0,
|
|
1454
|
+
type: "QUICK_REPLY",
|
|
1455
|
+
text: "Interested",
|
|
1456
|
+
},
|
|
1457
|
+
{
|
|
1458
|
+
index: 0,
|
|
1459
|
+
type: "QUICK_REPLY",
|
|
1460
|
+
text: "Not Interested",
|
|
1461
|
+
},
|
|
1462
|
+
],
|
|
1463
|
+
},
|
|
1464
|
+
},
|
|
1465
|
+
},
|
|
1466
|
+
},
|
|
1467
|
+
isActive: true,
|
|
1468
|
+
orgId: 50371,
|
|
1469
|
+
createdBy: "15000449",
|
|
1470
|
+
updatedBy: "15000449",
|
|
1471
|
+
createdAt: "2022-07-17T11:08:56.326Z",
|
|
1472
|
+
updatedAt: "2022-07-17T11:08:56.326Z",
|
|
1473
|
+
totalCount: 7,
|
|
1474
|
+
},
|
|
1475
|
+
whatsappPreviewTemplateData3Result: {
|
|
1476
|
+
buttonsData: [
|
|
1477
|
+
{
|
|
1478
|
+
index: 0,
|
|
1479
|
+
type: "QUICK_REPLY",
|
|
1480
|
+
text: "Interested",
|
|
1481
|
+
},
|
|
1482
|
+
{
|
|
1483
|
+
index: 0,
|
|
1484
|
+
type: "QUICK_REPLY",
|
|
1485
|
+
text: "Not Interested",
|
|
1486
|
+
},
|
|
1487
|
+
],
|
|
1488
|
+
charCount: 30,
|
|
1489
|
+
footerMsg: (
|
|
1490
|
+
<CapLabel className="whatsapp-template-footer-preview" type="label1">
|
|
1491
|
+
Thanks
|
|
1492
|
+
</CapLabel>
|
|
1493
|
+
),
|
|
1494
|
+
headerMsg: (
|
|
1495
|
+
<CapLabel className="whatsapp-template-header-preview" type="label1">
|
|
1496
|
+
Hello welcome
|
|
1497
|
+
</CapLabel>
|
|
1498
|
+
),
|
|
1499
|
+
templateMsg: (
|
|
1500
|
+
<CapLabel type="label9">Hi, your payment is successful.</CapLabel>
|
|
1501
|
+
),
|
|
1502
|
+
},
|
|
1503
|
+
whatsappPreviewTemplateData3QuickReplyResult: [
|
|
1504
|
+
<CapDivider className="whatsapp-list-view-divider" />,
|
|
1505
|
+
<CapLabel className="whatsapp-list-cta-preview" type="label21">
|
|
1506
|
+
<CapIcon
|
|
1507
|
+
size="xs"
|
|
1508
|
+
svgProps={{
|
|
1509
|
+
style: {
|
|
1510
|
+
marginRight: "4px",
|
|
1511
|
+
},
|
|
1512
|
+
}}
|
|
1513
|
+
type="small-link"
|
|
1514
|
+
/>
|
|
1515
|
+
Interested
|
|
1516
|
+
</CapLabel>,
|
|
1517
|
+
<CapDivider className="whatsapp-list-view-divider" />,
|
|
1518
|
+
<CapLabel className="whatsapp-list-cta-preview" type="label21">
|
|
1519
|
+
<CapIcon
|
|
1520
|
+
size="xs"
|
|
1521
|
+
svgProps={{
|
|
1522
|
+
style: {
|
|
1523
|
+
marginRight: "4px",
|
|
1524
|
+
},
|
|
1525
|
+
}}
|
|
1526
|
+
type="small-link"
|
|
1527
|
+
/>
|
|
1528
|
+
Not Interested
|
|
1529
|
+
</CapLabel>,
|
|
1530
|
+
],
|
|
1420
1531
|
rcsPreviewTemplateData: {
|
|
1421
1532
|
mode: "preview",
|
|
1422
1533
|
_id: "620e213d39bd394c58aeaaca",
|
|
@@ -1758,7 +1869,7 @@ export default {
|
|
|
1758
1869
|
},
|
|
1759
1870
|
zaloEditTemplateData: {
|
|
1760
1871
|
_id: 42342,
|
|
1761
|
-
name:
|
|
1762
|
-
type:
|
|
1763
|
-
}
|
|
1872
|
+
name: "Test sample",
|
|
1873
|
+
type: "ZALO",
|
|
1874
|
+
},
|
|
1764
1875
|
};
|
|
File without changes
|