@capillarytech/creatives-library 7.14.10 → 7.14.11

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.
@@ -39,6 +39,99 @@ Object {
39
39
  `;
40
40
 
41
41
  exports[`Test utils test getWhatsappContent 3`] = `
42
+ Object {
43
+ "charCount": 151,
44
+ "ctaData": Array [
45
+ Object {
46
+ "index": 0,
47
+ "phone_number": "+919738752617",
48
+ "text": "Call",
49
+ "type": "PHONE_NUMBER",
50
+ },
51
+ Object {
52
+ "index": 1,
53
+ "text": "Visit",
54
+ "type": "DYNAMIC_URL",
55
+ "url": "https://docs.google.com/{{1}}",
56
+ },
57
+ ],
58
+ "templateMsg": <CapLabel
59
+ type="label9"
60
+ >
61
+ Hey {{1}}, Easier implementation, tracking, reporting and planning of promotions is now live! Check it out at {{2}}
62
+ Click {{unsubscribe}} to unsubscribe
63
+ </CapLabel>,
64
+ "whatsappVideoSrc": "https://crm-nightly-new-fileservice.s3.amazonaws.com/intouch_creative_assets/c9edc114-923b-4ac7-82d0-d6682213/1040",
65
+ }
66
+ `;
67
+
68
+ exports[`Test utils test getWhatsappContent 4`] = `
69
+ Object {
70
+ "charCount": 151,
71
+ "ctaData": Array [
72
+ Object {
73
+ "index": 0,
74
+ "phone_number": "+919738752617",
75
+ "text": "Call",
76
+ "type": "PHONE_NUMBER",
77
+ },
78
+ Object {
79
+ "index": 1,
80
+ "text": "Visit",
81
+ "type": "DYNAMIC_URL",
82
+ "url": "https://docs.google.com/{{1}}",
83
+ },
84
+ ],
85
+ "docPreview": <React.Fragment>
86
+ <div
87
+ className="pdf-img-box"
88
+ >
89
+ <CapImage
90
+ alt="upload-document-src"
91
+ className="pdf-preview-img"
92
+ />
93
+ </div>
94
+ <div
95
+ className="pdf-label"
96
+ >
97
+ <CapImage
98
+ src="test-file-stub"
99
+ />
100
+ <div
101
+ className="pdf-info"
102
+ >
103
+ <div
104
+ className="pdf-name-div"
105
+ >
106
+ <CapLabel
107
+ className="pdf-name"
108
+ type="label9"
109
+ />
110
+ <CapLabel
111
+ type="label9"
112
+ >
113
+ .pdf
114
+ </CapLabel>
115
+ </div>
116
+ <CapLabel
117
+ className="pdf-info-sec"
118
+ type="label1"
119
+ >
120
+ undefined page · 0 bytes · PDF
121
+ </CapLabel>
122
+ </div>
123
+ </div>
124
+ </React.Fragment>,
125
+ "templateMsg": <CapLabel
126
+ type="label9"
127
+ >
128
+ Hey {{1}}, Easier implementation, tracking, reporting and planning of promotions is now live! Check it out at {{2}}
129
+ Click {{unsubscribe}} to unsubscribe
130
+ </CapLabel>,
131
+ }
132
+ `;
133
+
134
+ exports[`Test utils test getWhatsappContent 5`] = `
42
135
  Object {
43
136
  "charCount": -1,
44
137
  "templateMsg": <CapLabel
@@ -11,6 +11,8 @@ import mockdata from '../../mockdata';
11
11
  const {
12
12
  whatsappPreviewTemplateData,
13
13
  whatsappPreviewTemplateData2,
14
+ whatsappPreviewTemplateDataVid,
15
+ whatsappPreviewTemplateDataDoc,
14
16
  getWhatsappStatusOutput1,
15
17
  getWhatsappCategoryOutput1,
16
18
  getWhatsappCategoryOutput2,
@@ -22,6 +24,8 @@ describe('Test utils', () => {
22
24
  it('test getWhatsappContent', () => {
23
25
  expect(getWhatsappContent(whatsappPreviewTemplateData)).toMatchSnapshot();
24
26
  expect(getWhatsappContent(whatsappPreviewTemplateData2)).toMatchSnapshot();
27
+ expect(getWhatsappContent(whatsappPreviewTemplateDataVid)).toMatchSnapshot();
28
+ expect(getWhatsappContent(whatsappPreviewTemplateDataDoc)).toMatchSnapshot();
25
29
  expect(getWhatsappContent({})).toMatchSnapshot();
26
30
  expect(bytesConversion(1024)).toEqual('1.0 KB');
27
31
  expect(bytesConversion('abcd')).toEqual('0 bytes');
@@ -15,11 +15,17 @@ import {
15
15
  WHATSAPP_MEDIA_TYPES,
16
16
  HOST_KARIX,
17
17
  SIZE_UNITS,
18
+ PAGES,
19
+ PAGE,
20
+ PDF,
18
21
  } from '../Whatsapp/constants';
19
22
  import './styles.scss';
20
23
  import pdfIcon from "../../assets/pdfIcon.svg";
21
24
 
22
25
  export function bytesConversion(x) {
26
+ // the function accepts bytes and convert in appropriate size following the,
27
+ // l variable, this variable holds the size_unit index and displays the
28
+ // respective size, eg : 5120 bytes gives 5 KB and 5242880 gives 5 MB
23
29
  let l;
24
30
  l = 0;
25
31
  let n;
@@ -45,8 +51,8 @@ export const getWhatsappDocPreview = (whatsappDocParams) =>
45
51
  </div>
46
52
  <CapLabel className="pdf-info-sec">
47
53
  {
48
- `${whatsappDocParams?.whatsappDocPages} ${whatsappDocParams?.whatsappDocPages > 1 ? "pages" : "page"} · ${bytesConversion(whatsappDocParams?.whatsappDocSize)} · PDF`
49
- }
54
+ `${whatsappDocParams?.whatsappDocPages} ${whatsappDocParams?.whatsappDocPages > 1 ? PAGES : PAGE} · ${bytesConversion(whatsappDocParams?.whatsappDocSize)} · ${PDF}`
55
+ }
50
56
  </CapLabel>
51
57
  </div>
52
58
  </div>
@@ -84,21 +90,28 @@ export const getWhatsappContent = (template, isPreview) => {
84
90
  '{{unsubscribe}}',
85
91
  );
86
92
  }
93
+ let mediaParams = {};
94
+ switch (mediaType) {
95
+ case WHATSAPP_MEDIA_TYPES.IMAGE:
96
+ mediaParams = {whatsappImageSrc: imageUrl};
97
+ break;
98
+ case WHATSAPP_MEDIA_TYPES.VIDEO:
99
+ mediaParams = {whatsappVideoSrc: videoPreviewImg};
100
+ break;
101
+ case WHATSAPP_MEDIA_TYPES.DOCUMENT:
102
+ mediaParams = {docPreview: getWhatsappDocPreview(whatsappDocParams)};
103
+ break;
104
+ default:
105
+ break;
106
+ }
107
+
87
108
  return {
88
109
  templateMsg: <CapLabel type={isPreview ? 'label5' : 'label9'}>{text}</CapLabel>,
89
110
  charCount: text?.length - 1,
90
111
  ...(buttonType === CTA && {
91
112
  ctaData,
92
113
  }),
93
- ...(mediaType === WHATSAPP_MEDIA_TYPES.IMAGE && {
94
- whatsappImageSrc: imageUrl,
95
- }),
96
- ...(mediaType === WHATSAPP_MEDIA_TYPES.VIDEO && {
97
- whatsappImageSrc: videoPreviewImg,
98
- }),
99
- ...(mediaType === WHATSAPP_MEDIA_TYPES.DOCUMENT && {
100
- docPreview: getWhatsappDocPreview(whatsappDocParams),
101
- }),
114
+ ...mediaParams,
102
115
  };
103
116
  };
104
117
 
@@ -1121,6 +1121,124 @@ export default {
1121
1121
  updatedAt: '2022-07-17T11:58:45.592Z',
1122
1122
  totalCount: 8,
1123
1123
  },
1124
+ whatsappPreviewTemplateDataVid: {
1125
+ mode: 'preview',
1126
+ _id: '62d3f971b497b671d3bbf8f7',
1127
+ name: 'creatives_whatsapp6',
1128
+ type: 'WHATSAPP',
1129
+ versions: {
1130
+ $init: true,
1131
+ history: [],
1132
+ base: {
1133
+ content: {
1134
+ whatsapp: {
1135
+ status: 'approved',
1136
+ templateId: '720951875646523',
1137
+ hostName: 'karixwhatsappbulk',
1138
+ accessToken: 'Bearer gDwEuRIm9icV6phixociSw==',
1139
+ accountId: '107499611940863',
1140
+ templateEditor: false,
1141
+ karixFileHandle:
1142
+ '4::aW1hZ2UvanBlZw==:ARZpmm0pMfsBvKepIjR-HG2HIw_78ynisr-riY1s4xpi2noK9QsvtvVfnZb5hUxks5HM5JHG0gCn_ZtPuJzya1SH3eq4Upn3M0eqsDLr4CzdPw:e:1658404714:259409122277300:100066839164237:ARbbCRjU-2ksqoUOp4Y',
1143
+ videoUrl:
1144
+ 'https://crm-nightly-new-fileservice.s3.amazonaws.com/intouch_creative_assets/c9edc114-923b-4ac7-82d0-d6682213.MP4',
1145
+ videoPreviewImg: 'https://crm-nightly-new-fileservice.s3.amazonaws.com/intouch_creative_assets/c9edc114-923b-4ac7-82d0-d6682213/1040',
1146
+ mediaType: 'VIDEO',
1147
+ buttons: [
1148
+ {
1149
+ phone_number: '+919738752617',
1150
+ text: 'Call',
1151
+ type: 'PHONE_NUMBER',
1152
+ index: 0,
1153
+ },
1154
+ {
1155
+ url: 'https://docs.google.com/{{1}}',
1156
+ text: 'Visit',
1157
+ type: 'DYNAMIC_URL',
1158
+ index: 1,
1159
+ },
1160
+ ],
1161
+ buttonType: 'CTA',
1162
+ languages: [
1163
+ {
1164
+ content:
1165
+ 'Hey {{1}}, Easier implementation, tracking, reporting and planning of promotions is now live! Check it out at {{2}}\nClick {{3}} to unsubscribe',
1166
+ language: 'en',
1167
+ },
1168
+ ],
1169
+ category: 'MARKETING',
1170
+ rejection_reason: '',
1171
+ },
1172
+ },
1173
+ },
1174
+ },
1175
+ isActive: true,
1176
+ orgId: 50074,
1177
+ createdBy: '15000449',
1178
+ updatedBy: '15000449',
1179
+ createdAt: '2022-07-17T11:58:45.592Z',
1180
+ updatedAt: '2022-07-17T11:58:45.592Z',
1181
+ totalCount: 8,
1182
+ },
1183
+ whatsappPreviewTemplateDataDoc: {
1184
+ mode: 'preview',
1185
+ _id: '62d3f971b497b671d3bbf8f7',
1186
+ name: 'creatives_whatsapp6',
1187
+ type: 'WHATSAPP',
1188
+ versions: {
1189
+ $init: true,
1190
+ history: [],
1191
+ base: {
1192
+ content: {
1193
+ whatsapp: {
1194
+ status: 'approved',
1195
+ templateId: '720951875646523',
1196
+ hostName: 'karixwhatsappbulk',
1197
+ accessToken: 'Bearer gDwEuRIm9icV6phixociSw==',
1198
+ accountId: '107499611940863',
1199
+ templateEditor: false,
1200
+ karixFileHandle:
1201
+ '4::aW1hZ2UvanBlZw==:ARZpmm0pMfsBvKepIjR-HG2HIw_78ynisr-riY1s4xpi2noK9QsvtvVfnZb5hUxks5HM5JHG0gCn_ZtPuJzya1SH3eq4Upn3M0eqsDLr4CzdPw:e:1658404714:259409122277300:100066839164237:ARbbCRjU-2ksqoUOp4Y',
1202
+ documentUrl:
1203
+ 'https://crm-nightly-new-fileservice.s3.amazonaws.com/intouch_creative_assets/c9edc114-923b-4ac7-82d0-d6682213.pdf',
1204
+ whatsappDocParams: {},
1205
+ mediaType: 'DOCUMENT',
1206
+ buttons: [
1207
+ {
1208
+ phone_number: '+919738752617',
1209
+ text: 'Call',
1210
+ type: 'PHONE_NUMBER',
1211
+ index: 0,
1212
+ },
1213
+ {
1214
+ url: 'https://docs.google.com/{{1}}',
1215
+ text: 'Visit',
1216
+ type: 'DYNAMIC_URL',
1217
+ index: 1,
1218
+ },
1219
+ ],
1220
+ buttonType: 'CTA',
1221
+ languages: [
1222
+ {
1223
+ content:
1224
+ 'Hey {{1}}, Easier implementation, tracking, reporting and planning of promotions is now live! Check it out at {{2}}\nClick {{3}} to unsubscribe',
1225
+ language: 'en',
1226
+ },
1227
+ ],
1228
+ category: 'MARKETING',
1229
+ rejection_reason: '',
1230
+ },
1231
+ },
1232
+ },
1233
+ },
1234
+ isActive: true,
1235
+ orgId: 50074,
1236
+ createdBy: '15000449',
1237
+ updatedBy: '15000449',
1238
+ createdAt: '2022-07-17T11:58:45.592Z',
1239
+ updatedAt: '2022-07-17T11:58:45.592Z',
1240
+ totalCount: 8,
1241
+ },
1124
1242
  whatsappPreviewTemplateData2: {
1125
1243
  mode: 'preview',
1126
1244
  _id: '62d3edc8b497b63ff5bbf8ea',