@capillarytech/creatives-library 7.12.40 → 7.12.41
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/CapWhatsappCTA/constants.js +0 -5
- package/v2Components/CapWhatsappCTA/index.js +13 -12
- package/v2Components/CapWhatsappCTA/index.scss +15 -0
- package/v2Components/CapWhatsappCTA/messages.js +0 -4
- package/v2Components/CapWhatsappCTA/tests/index.test.js +152 -0
- package/v2Components/TemplatePreview/tests/__snapshots__/index.test.js.snap +191 -19
- package/v2Components/TemplatePreview/tests/index.test.js +52 -5
- package/v2Containers/CreativesContainer/index.js +7 -2
- package/v2Containers/CreativesContainer/tests/__snapshots__/SlideBoxContent.test.js.snap +29 -0
- package/v2Containers/CreativesContainer/tests/index.test.js +47 -14
- package/v2Containers/Whatsapp/constants.js +10 -7
- package/v2Containers/Whatsapp/index.js +52 -47
- package/v2Containers/Whatsapp/messages.js +6 -2
- package/v2Containers/Whatsapp/tests/__snapshots__/index.test.js.snap +84338 -18311
- package/v2Containers/Whatsapp/tests/__snapshots__/utils.test.js.snap +100 -0
- package/v2Containers/Whatsapp/tests/index.test.js +159 -18
- package/v2Containers/Whatsapp/tests/mockData.js +150 -89
- package/v2Containers/Whatsapp/tests/utils.test.js +8 -0
- package/v2Containers/Whatsapp/utils.js +16 -14
- package/v2Containers/mockdata.js +177 -5
|
@@ -7,6 +7,9 @@ import {
|
|
|
7
7
|
STATUS_OPTIONS,
|
|
8
8
|
CATEGORY_OPTIONS,
|
|
9
9
|
WHATSAPP_STATUSES,
|
|
10
|
+
PHONE_NUMBER,
|
|
11
|
+
NONE,
|
|
12
|
+
CTA,
|
|
10
13
|
} from '../Whatsapp/constants';
|
|
11
14
|
|
|
12
15
|
export const getWhatsappContent = (template, isPreview) => {
|
|
@@ -16,7 +19,7 @@ export const getWhatsappContent = (template, isPreview) => {
|
|
|
16
19
|
content: {
|
|
17
20
|
[WHATSAPP.toLowerCase()]: {
|
|
18
21
|
languages = [{}],
|
|
19
|
-
buttonType =
|
|
22
|
+
buttonType = NONE,
|
|
20
23
|
buttons: ctaData = [],
|
|
21
24
|
} = {},
|
|
22
25
|
} = {},
|
|
@@ -26,8 +29,8 @@ export const getWhatsappContent = (template, isPreview) => {
|
|
|
26
29
|
//removing $'' which was added for twilio enter handling
|
|
27
30
|
let text = languages[0]?.content || '';
|
|
28
31
|
const validVarRegex = /{{([1-9]|1[0-9])}}/g;
|
|
29
|
-
const
|
|
30
|
-
if (text.match(
|
|
32
|
+
const unsubscribeRegex = /Click {{([1-9]|1[0-9])}} to unsubscribe/g;
|
|
33
|
+
if (text.match(unsubscribeRegex)?.length > 0) {
|
|
31
34
|
const validVarArr = text.match(validVarRegex) || [];
|
|
32
35
|
//replacing Click {{5}} to unsubscribe with Click {{unsubscribe}} to unsubscribe,
|
|
33
36
|
//for listing preview and cards listing
|
|
@@ -43,14 +46,14 @@ export const getWhatsappContent = (template, isPreview) => {
|
|
|
43
46
|
</>
|
|
44
47
|
),
|
|
45
48
|
charCount: text?.length - 1,
|
|
46
|
-
...(buttonType ===
|
|
49
|
+
...(buttonType === CTA && {
|
|
47
50
|
ctaData,
|
|
48
51
|
}),
|
|
49
52
|
};
|
|
50
53
|
};
|
|
51
54
|
|
|
52
55
|
export const getWhatsappCta = (template) => {
|
|
53
|
-
const { buttonType =
|
|
56
|
+
const { buttonType = NONE, buttons = [] } = get(
|
|
54
57
|
template,
|
|
55
58
|
`versions.base.content.whatsapp`,
|
|
56
59
|
{},
|
|
@@ -58,7 +61,7 @@ export const getWhatsappCta = (template) => {
|
|
|
58
61
|
const renderArray = [];
|
|
59
62
|
if (buttonType === 'CTA' && buttons?.length) {
|
|
60
63
|
buttons.forEach((cta) => {
|
|
61
|
-
const { type, text } = cta
|
|
64
|
+
const { type, text } = cta;
|
|
62
65
|
if (text) {
|
|
63
66
|
renderArray.push(
|
|
64
67
|
<CapLabel
|
|
@@ -66,7 +69,7 @@ export const getWhatsappCta = (template) => {
|
|
|
66
69
|
style={{ textAlign: 'center', marginTop: '12px' }}
|
|
67
70
|
>
|
|
68
71
|
<CapIcon
|
|
69
|
-
type={type ===
|
|
72
|
+
type={type === PHONE_NUMBER ? 'call' : 'launch'}
|
|
70
73
|
size="xs"
|
|
71
74
|
svgProps={{ style: { marginRight: '4px' } }}
|
|
72
75
|
/>
|
|
@@ -79,14 +82,13 @@ export const getWhatsappCta = (template) => {
|
|
|
79
82
|
return renderArray;
|
|
80
83
|
};
|
|
81
84
|
|
|
82
|
-
export const getWhatsappCategory = (category) =>
|
|
83
|
-
CATEGORY_OPTIONS.find((obj) => obj.value === category);
|
|
85
|
+
export const getWhatsappCategory = (category) => {
|
|
86
|
+
return CATEGORY_OPTIONS.find((obj) => obj.value === category);
|
|
87
|
+
}
|
|
84
88
|
|
|
85
89
|
export const getWhatsappStatus = (status) => {
|
|
86
|
-
if (
|
|
87
|
-
|
|
88
|
-
) {
|
|
89
|
-
status = WHATSAPP_STATUSES.awaitingApproval;
|
|
90
|
+
if ([WHATSAPP_STATUSES.pending, WHATSAPP_STATUSES.unsubmitted].includes(status)) {
|
|
91
|
+
status = WHATSAPP_STATUSES.awaitingApproval;
|
|
90
92
|
}
|
|
91
93
|
return STATUS_OPTIONS.find((obj) => obj.value === status);
|
|
92
|
-
}
|
|
94
|
+
}
|
package/v2Containers/mockdata.js
CHANGED
|
@@ -1072,6 +1072,117 @@ export default {
|
|
|
1072
1072
|
channel: 'WHATSAPP',
|
|
1073
1073
|
validity: true,
|
|
1074
1074
|
},
|
|
1075
|
+
whatsappGetTemplateData: {
|
|
1076
|
+
channel: 'WHATSAPP',
|
|
1077
|
+
accountId: 12680,
|
|
1078
|
+
accountName: 'whatsappTest',
|
|
1079
|
+
messageBody:
|
|
1080
|
+
'Hi user, You have received new offer which is valid till tomorrow. Make use of it.\nClick {{unsubscribe}} to unsubscribe',
|
|
1081
|
+
templateConfigs: {
|
|
1082
|
+
id: '629713be7d11edf651825283',
|
|
1083
|
+
name: 'test_14',
|
|
1084
|
+
template:
|
|
1085
|
+
'Hi {{1}}, You have received {{2}} offer which is valid till {{3}}. Make use of it.',
|
|
1086
|
+
varMapped: {
|
|
1087
|
+
'{{1}}_1': 'user',
|
|
1088
|
+
'{{2}}_3': 'new',
|
|
1089
|
+
'{{3}}_5': 'tomorrow',
|
|
1090
|
+
},
|
|
1091
|
+
category: 'ALERT_UPDATE',
|
|
1092
|
+
language: 'en',
|
|
1093
|
+
mediaType: 'TEXT',
|
|
1094
|
+
buttonType: 'CTA',
|
|
1095
|
+
buttons: [
|
|
1096
|
+
{
|
|
1097
|
+
index: 0,
|
|
1098
|
+
type: 'PHONE_NUMBER',
|
|
1099
|
+
text: 'Call us',
|
|
1100
|
+
phoneNumber: '+919738752617',
|
|
1101
|
+
},
|
|
1102
|
+
{
|
|
1103
|
+
index: 1,
|
|
1104
|
+
type: 'STATIC_URL',
|
|
1105
|
+
text: 'Visit us',
|
|
1106
|
+
url: 'https://fast.com/',
|
|
1107
|
+
},
|
|
1108
|
+
],
|
|
1109
|
+
},
|
|
1110
|
+
},
|
|
1111
|
+
whatsappGetCreativeData: {
|
|
1112
|
+
type: 'WHATSAPP',
|
|
1113
|
+
channel: 'WHATSAPP',
|
|
1114
|
+
value: {
|
|
1115
|
+
name: 'test_206',
|
|
1116
|
+
versions: {
|
|
1117
|
+
base: {
|
|
1118
|
+
content: {
|
|
1119
|
+
whatsapp: {
|
|
1120
|
+
category: 'ALERT_UPDATE',
|
|
1121
|
+
languages: [
|
|
1122
|
+
{
|
|
1123
|
+
language: 'en',
|
|
1124
|
+
content:
|
|
1125
|
+
'You have received 50 points\nClick {{unsubscribe}} to unsubscribe',
|
|
1126
|
+
},
|
|
1127
|
+
],
|
|
1128
|
+
buttonType: 'CTA',
|
|
1129
|
+
buttons: [
|
|
1130
|
+
{
|
|
1131
|
+
index: 0,
|
|
1132
|
+
type: 'PHONE_NUMBER',
|
|
1133
|
+
text: 'Call',
|
|
1134
|
+
phone_number: '+919738752617',
|
|
1135
|
+
},
|
|
1136
|
+
{
|
|
1137
|
+
index: 1,
|
|
1138
|
+
type: 'STATIC_URL',
|
|
1139
|
+
text: 'More info',
|
|
1140
|
+
url: 'https://fast.com/',
|
|
1141
|
+
},
|
|
1142
|
+
],
|
|
1143
|
+
mediaType: 'TEXT',
|
|
1144
|
+
varMapped: {
|
|
1145
|
+
'{{1}}_1': '50',
|
|
1146
|
+
},
|
|
1147
|
+
templateEditor: 'You have received {{1}} points',
|
|
1148
|
+
accountId: 'AC41030cebba9e2f1ce37c78235da0ee18',
|
|
1149
|
+
accessToken: '4676323eb5d1f975b0987070c03a8efc',
|
|
1150
|
+
accountName: 'whatsappTest',
|
|
1151
|
+
},
|
|
1152
|
+
},
|
|
1153
|
+
},
|
|
1154
|
+
},
|
|
1155
|
+
type: 'WHATSAPP',
|
|
1156
|
+
},
|
|
1157
|
+
_id: '62988c2f7d11ed69168252a6',
|
|
1158
|
+
validity: true,
|
|
1159
|
+
type: 'WHATSAPP',
|
|
1160
|
+
},
|
|
1161
|
+
whatsappGetCreativeData2: {
|
|
1162
|
+
type: 'WHATSAPP',
|
|
1163
|
+
channel: 'WHATSAPP',
|
|
1164
|
+
value: {
|
|
1165
|
+
name: 'test_206',
|
|
1166
|
+
versions: {
|
|
1167
|
+
base: {
|
|
1168
|
+
content: {
|
|
1169
|
+
whatsapp: {
|
|
1170
|
+
category: 'ALERT_UPDATE',
|
|
1171
|
+
mediaType: 'TEXT',
|
|
1172
|
+
templateEditor: 'You have received {{1}} points',
|
|
1173
|
+
accountId: 'AC41030cebba9e2f1ce37c78235da0ee18',
|
|
1174
|
+
accessToken: '4676323eb5d1f975b0987070c03a8efc',
|
|
1175
|
+
accountName: 'whatsappTest',
|
|
1176
|
+
},
|
|
1177
|
+
},
|
|
1178
|
+
},
|
|
1179
|
+
},
|
|
1180
|
+
type: 'WHATSAPP',
|
|
1181
|
+
},
|
|
1182
|
+
_id: '62988c2f7d11ed69168252a6',
|
|
1183
|
+
validity: true,
|
|
1184
|
+
type: 'WHATSAPP',
|
|
1185
|
+
},
|
|
1075
1186
|
rcsEditTemplateData: {
|
|
1076
1187
|
mode: 'edit',
|
|
1077
1188
|
_id: '620e213d39bd394c58aeaaca',
|
|
@@ -1130,6 +1241,21 @@ export default {
|
|
|
1130
1241
|
accountId: 'AC41030cebba9e2f1ce37c78235da0ee18',
|
|
1131
1242
|
templateEditor: '',
|
|
1132
1243
|
mediaType: 'TEXT',
|
|
1244
|
+
buttonType: 'CTA',
|
|
1245
|
+
buttons: [
|
|
1246
|
+
{
|
|
1247
|
+
phone_number: '+919738752617',
|
|
1248
|
+
text: 'Call',
|
|
1249
|
+
type: 'PHONE_NUMBER',
|
|
1250
|
+
index: 0,
|
|
1251
|
+
},
|
|
1252
|
+
{
|
|
1253
|
+
url: 'https://fast.com/',
|
|
1254
|
+
text: 'More info',
|
|
1255
|
+
type: 'STATIC_URL',
|
|
1256
|
+
index: 1,
|
|
1257
|
+
},
|
|
1258
|
+
],
|
|
1133
1259
|
languages: [
|
|
1134
1260
|
{
|
|
1135
1261
|
content: '1234567890\nClick {{1}} to unsubscribe',
|
|
@@ -1151,6 +1277,54 @@ export default {
|
|
|
1151
1277
|
totalCount: 12,
|
|
1152
1278
|
updatedByName: 'Ashish Karan fd',
|
|
1153
1279
|
},
|
|
1280
|
+
whatsappPreviewTemplateData2: {
|
|
1281
|
+
mode: 'preview',
|
|
1282
|
+
_id: '620e213d39bd394c58aeaaca',
|
|
1283
|
+
name: 'amit123456',
|
|
1284
|
+
type: 'WHATSAPP',
|
|
1285
|
+
versions: {
|
|
1286
|
+
$init: true,
|
|
1287
|
+
history: [],
|
|
1288
|
+
base: {
|
|
1289
|
+
content: {
|
|
1290
|
+
whatsapp: {
|
|
1291
|
+
status: 'approved',
|
|
1292
|
+
templateId: 'HT5203cccf5b1e9e41f222fab6cd6c2754',
|
|
1293
|
+
accountName: 'whatsappTest',
|
|
1294
|
+
accessToken: '4676323eb5d1f975b0987070c03a8efc',
|
|
1295
|
+
accountId: 'AC41030cebba9e2f1ce37c78235da0ee18',
|
|
1296
|
+
templateEditor: '',
|
|
1297
|
+
mediaType: 'TEXT',
|
|
1298
|
+
buttonType: 'CTA',
|
|
1299
|
+
buttons: [
|
|
1300
|
+
{
|
|
1301
|
+
phone_number: '',
|
|
1302
|
+
text: '',
|
|
1303
|
+
type: 'PHONE_NUMBER',
|
|
1304
|
+
index: 0,
|
|
1305
|
+
},
|
|
1306
|
+
],
|
|
1307
|
+
languages: [
|
|
1308
|
+
{
|
|
1309
|
+
content: 'test',
|
|
1310
|
+
language: 'en',
|
|
1311
|
+
},
|
|
1312
|
+
],
|
|
1313
|
+
category: 'ALERT_UPDATE',
|
|
1314
|
+
rejection_reason: null,
|
|
1315
|
+
},
|
|
1316
|
+
},
|
|
1317
|
+
},
|
|
1318
|
+
},
|
|
1319
|
+
isActive: true,
|
|
1320
|
+
orgId: 50371,
|
|
1321
|
+
createdBy: '15000449',
|
|
1322
|
+
updatedBy: '15000449',
|
|
1323
|
+
createdAt: '2022-02-17T10:19:42.211Z',
|
|
1324
|
+
updatedAt: '2022-02-17T10:19:42.211Z',
|
|
1325
|
+
totalCount: 12,
|
|
1326
|
+
updatedByName: 'Ashish Karan fd',
|
|
1327
|
+
},
|
|
1154
1328
|
rcsPreviewTemplateData: {
|
|
1155
1329
|
mode: 'preview',
|
|
1156
1330
|
_id: '620e213d39bd394c58aeaaca',
|
|
@@ -1201,12 +1375,11 @@ export default {
|
|
|
1201
1375
|
modeType: undefined,
|
|
1202
1376
|
type: 'WHATSAPP',
|
|
1203
1377
|
whatsappTemplateCategory: '',
|
|
1204
|
-
whatsappTemplateLanguageCode:
|
|
1378
|
+
whatsappTemplateLanguageCode: '',
|
|
1205
1379
|
whatsappTemplateName: '',
|
|
1206
1380
|
},
|
|
1207
1381
|
location: {
|
|
1208
|
-
pathname:
|
|
1209
|
-
'/creatives/ui/v2',
|
|
1382
|
+
pathname: '/creatives/ui/v2',
|
|
1210
1383
|
search: '',
|
|
1211
1384
|
hash: '',
|
|
1212
1385
|
key: 'm54f43',
|
|
@@ -1215,8 +1388,7 @@ export default {
|
|
|
1215
1388
|
path: '/creatives/ui/v2',
|
|
1216
1389
|
url: '/creatives/ui/v2',
|
|
1217
1390
|
isExact: true,
|
|
1218
|
-
params: {
|
|
1219
|
-
},
|
|
1391
|
+
params: {},
|
|
1220
1392
|
},
|
|
1221
1393
|
capGlobal: {
|
|
1222
1394
|
fetching_userdata: false,
|