@capillarytech/creatives-library 8.0.94 → 8.0.95

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.
Files changed (33) hide show
  1. package/containers/Templates/constants.js +0 -7
  2. package/containers/Templates/index.js +24 -43
  3. package/package.json +1 -1
  4. package/services/api.js +7 -1
  5. package/services/tests/api.test.js +5 -1
  6. package/v2Components/CapImageUpload/index.js +13 -10
  7. package/v2Components/CapVideoUpload/index.js +12 -9
  8. package/v2Components/CapWhatsappCTA/messages.js +4 -0
  9. package/v2Components/CapWhatsappCarouselButton/constant.js +56 -0
  10. package/v2Components/CapWhatsappCarouselButton/index.js +446 -0
  11. package/v2Components/CapWhatsappCarouselButton/index.scss +39 -0
  12. package/v2Components/CapWhatsappCarouselButton/tests/index.test.js +237 -0
  13. package/v2Components/TemplatePreview/_templatePreview.scss +20 -0
  14. package/v2Components/TemplatePreview/assets/images/empty_image_preview.svg +4 -0
  15. package/v2Components/TemplatePreview/assets/images/empty_video_preview.svg +4 -0
  16. package/v2Components/TemplatePreview/index.js +160 -105
  17. package/v2Components/TemplatePreview/tests/__snapshots__/index.test.js.snap +6 -6
  18. package/v2Containers/CreativesContainer/index.js +92 -5
  19. package/v2Containers/CreativesContainer/tests/__snapshots__/SlideBoxContent.test.js.snap +1 -0
  20. package/v2Containers/Templates/_templates.scss +47 -0
  21. package/v2Containers/Templates/index.js +55 -5
  22. package/v2Containers/Templates/tests/__snapshots__/index.test.js.snap +177 -156
  23. package/v2Containers/Whatsapp/constants.js +87 -1
  24. package/v2Containers/Whatsapp/index.js +706 -188
  25. package/v2Containers/Whatsapp/index.scss +52 -1
  26. package/v2Containers/Whatsapp/messages.js +38 -2
  27. package/v2Containers/Whatsapp/styles.scss +5 -0
  28. package/v2Containers/Whatsapp/tests/__snapshots__/index.test.js.snap +27722 -90751
  29. package/v2Containers/Whatsapp/tests/__snapshots__/utils.test.js.snap +6 -0
  30. package/v2Containers/Whatsapp/tests/mockData.js +3 -7
  31. package/v2Containers/Whatsapp/tests/utils.test.js +80 -1
  32. package/v2Containers/Whatsapp/utils.js +33 -0
  33. package/v2Containers/mockdata.js +2 -0
@@ -2,6 +2,7 @@
2
2
 
3
3
  exports[`Test utils test getWhatsappContent 1`] = `
4
4
  Object {
5
+ "carouselData": Array [],
5
6
  "charCount": 151,
6
7
  "ctaData": Array [
7
8
  Object {
@@ -31,6 +32,7 @@ Click {{unsubscribe}} to unsubscribe
31
32
 
32
33
  exports[`Test utils test getWhatsappContent 2`] = `
33
34
  Object {
35
+ "carouselData": Array [],
34
36
  "charCount": 36,
35
37
  "templateFooterPreview": "",
36
38
  "templateHeaderPreview": "",
@@ -44,6 +46,7 @@ Object {
44
46
 
45
47
  exports[`Test utils test getWhatsappContent 3`] = `
46
48
  Object {
49
+ "carouselData": Array [],
47
50
  "charCount": 151,
48
51
  "ctaData": Array [
49
52
  Object {
@@ -73,6 +76,7 @@ Click {{unsubscribe}} to unsubscribe
73
76
 
74
77
  exports[`Test utils test getWhatsappContent 4`] = `
75
78
  Object {
79
+ "carouselData": Array [],
76
80
  "charCount": 151,
77
81
  "ctaData": Array [
78
82
  Object {
@@ -151,6 +155,7 @@ Click {{unsubscribe}} to unsubscribe
151
155
 
152
156
  exports[`Test utils test getWhatsappContent 5`] = `
153
157
  Object {
158
+ "carouselData": Array [],
154
159
  "charCount": -1,
155
160
  "templateFooterPreview": "",
156
161
  "templateHeaderPreview": "",
@@ -164,6 +169,7 @@ Object {
164
169
 
165
170
  exports[`Test utils test getWhatsappContent for preview 1`] = `
166
171
  Object {
172
+ "carouselData": Array [],
167
173
  "charCount": 151,
168
174
  "ctaData": Array [
169
175
  Object {
@@ -3,7 +3,7 @@ export const mockData = {
3
3
  selectedWhatsappAccount: {
4
4
  name: 'WhatsppTest',
5
5
  sourceAccountIdentifier: 'AC41030cebba9e2f1ce37c78235da0ee18',
6
- configs: { accessToken: '4676323eb5d1f975b0987070c03a8efc' },
6
+ configs: { },
7
7
  hostName: 'twiliowhatsapptrans',
8
8
  },
9
9
  },
@@ -11,7 +11,7 @@ export const mockData = {
11
11
  selectedWhatsappAccount: {
12
12
  name: 'WhatsappAccount',
13
13
  sourceAccountIdentifier: '107499611940863',
14
- configs: { accessToken: 'Bearer gDwEuRIm9icV6phixociSw==' },
14
+ configs: { },
15
15
  hostName: 'karixwhatsappbulk',
16
16
  },
17
17
  },
@@ -24,7 +24,7 @@ export const mockData = {
24
24
  selectedWhatsappAccount: {
25
25
  name: 'gupshup_test',
26
26
  sourceAccountIdentifier: '2000222347',
27
- configs: { accessToken: 'DTpZEh4VK' },
27
+ configs: { },
28
28
  hostName: 'gupshupwhatsappbulk',
29
29
  },
30
30
  },
@@ -41,7 +41,6 @@ export const mockData = {
41
41
  status: 'approved',
42
42
  templateId: 'HT9bb4d61eea1699d2dbcaecd1cb558345',
43
43
  accountName: 'WhatsppTest',
44
- accessToken: '4676323eb5d1f975b0987070c03a8efc',
45
44
  accountId: 'AC41030cebba9e2f1ce37c78235da0ee18',
46
45
  mediaType: 'text',
47
46
  languages: [
@@ -97,7 +96,6 @@ export const mockData = {
97
96
  status: 'rejected',
98
97
  templateId: 'HT9bb4d61eea1699d2dbcaecd1cb558345',
99
98
  accountName: 'WhatsppTest',
100
- accessToken: '4676323eb5d1f975b0987070c03a8efc',
101
99
  accountId: 'AC41030cebba9e2f1ce37c78235da0ee18',
102
100
  mediaType: 'text',
103
101
  languages: [
@@ -136,7 +134,6 @@ export const mockData = {
136
134
  status: 'rejected',
137
135
  templateId: 'HT9bb4d61eea1699d2dbcaecd1cb558345',
138
136
  accountName: 'WhatsppTest',
139
- accessToken: '4676323eb5d1f975b0987070c03a8efc',
140
137
  accountId: 'AC41030cebba9e2f1ce37c78235da0ee18',
141
138
  mediaType: 'text',
142
139
  languages: [
@@ -277,7 +274,6 @@ export const mockData = {
277
274
  varMapped: {},
278
275
  templateEditor: false,
279
276
  accountId: '123456789',
280
- accessToken: '12345',
281
277
  hostName: 'karixwhatsappbulk',
282
278
  whatsappMedia: {
283
279
  header: '',
@@ -7,9 +7,10 @@ import {
7
7
  getWhatsappDocPreview,
8
8
  getWhatsappQuickReply,
9
9
  getWhatsappAutoFill,
10
+ getWhatsappCarouselButtonView,
10
11
  } from '../utils';
11
12
  import mockdata from '../../mockdata';
12
- import { HOST_ICS } from '../constants';
13
+ import { HOST_ICS, PHONE_NUMBER, QUICK_REPLY } from '../constants';
13
14
 
14
15
  const {
15
16
  whatsappPreviewTemplateData,
@@ -100,4 +101,82 @@ describe('Test utils', () => {
100
101
  JSON.stringify(getWhatsappDocPreviewOutput1),
101
102
  );
102
103
  });
104
+
105
+ describe('test getWhatsappCarouselButtonView', () => {
106
+ it('should return empty array for null/undefined/empty input', () => {
107
+ expect(getWhatsappCarouselButtonView(null)).toEqual([]);
108
+ expect(getWhatsappCarouselButtonView(undefined)).toEqual([]);
109
+ expect(getWhatsappCarouselButtonView([])).toEqual([]);
110
+ });
111
+
112
+ it('should render single button correctly', () => {
113
+ const singleButton = [{
114
+ text: 'Click Me',
115
+ buttonType: 'URL'
116
+ }];
117
+
118
+ const result = getWhatsappCarouselButtonView(singleButton);
119
+ expect(result).toHaveLength(2); // 1 divider + 1 button
120
+ expect(result[0].props.className).toBe('whatsapp-list-view-divider'); // Divider
121
+ expect(result[1].props.children[1]).toBe('Click Me'); // Button text
122
+ });
123
+
124
+ it('should render multiple buttons with dividers', () => {
125
+ const multipleButtons = [
126
+ { text: 'Call Us', type: PHONE_NUMBER },
127
+ { text: 'Reply', type: QUICK_REPLY },
128
+ { text: 'Visit Website', buttonType: 'URL' }
129
+ ];
130
+
131
+ const result = getWhatsappCarouselButtonView(multipleButtons);
132
+ expect(result).toHaveLength(6); // Initial divider + 3 buttons + 2 intermediate dividers
133
+ });
134
+
135
+ it('should handle template preview mode correctly', () => {
136
+ const buttons = [{
137
+ text: 'Click Me',
138
+ buttonType: 'URL'
139
+ }];
140
+
141
+ const result = getWhatsappCarouselButtonView(buttons, true);
142
+ expect(result[0].props.className).toBe('whatsapp-divider'); // Check preview mode divider class
143
+ });
144
+
145
+ it('should handle buttons without text properly', () => {
146
+ const buttons = [
147
+ { buttonType: 'URL' },
148
+ { text: 'Valid Button', buttonType: 'URL' }
149
+ ];
150
+
151
+ const result = getWhatsappCarouselButtonView(buttons);
152
+ expect(result).toHaveLength(3); // Initial divider + 1 valid button + 1 divider
153
+ });
154
+
155
+ it('should use correct icons based on button type', () => {
156
+ const buttons = [
157
+ { text: 'Call Now', type: PHONE_NUMBER },
158
+ { text: 'Quick Reply', type: QUICK_REPLY },
159
+ { text: 'Visit Site', buttonType: 'URL' }
160
+ ];
161
+
162
+ const result = getWhatsappCarouselButtonView(buttons);
163
+
164
+ // Check icon types
165
+ expect(result[1].props.children[0].props.type).toBe('call'); // Phone number icon
166
+ expect(result[3].props.children[0].props.type).toBe('small-link'); // Quick reply icon
167
+ expect(result[5].props.children[0].props.type).toBe('launch'); // URL icon
168
+ });
169
+
170
+ it('should handle both type and buttonType properties', () => {
171
+ const buttons = [
172
+ { text: 'Button 1', type: PHONE_NUMBER },
173
+ { text: 'Button 2', buttonType: PHONE_NUMBER }
174
+ ];
175
+
176
+ const result = getWhatsappCarouselButtonView(buttons);
177
+ // Both buttons should have call icons
178
+ expect(result[1].props.children[0].props.type).toBe('call');
179
+ expect(result[3].props.children[0].props.type).toBe('call');
180
+ });
181
+ });
103
182
  });
@@ -80,6 +80,7 @@ export const getWhatsappContent = (template, isPreview) => {
80
80
  header = '',
81
81
  footer = '',
82
82
  } = {},
83
+ carouselData = [],
83
84
  } = {},
84
85
  } = {},
85
86
  } = {},
@@ -125,6 +126,7 @@ export const getWhatsappContent = (template, isPreview) => {
125
126
  quickReplyData: buttonsData
126
127
  }),
127
128
  ...mediaParams,
129
+ carouselData,
128
130
  };
129
131
  };
130
132
 
@@ -188,6 +190,37 @@ export const getWhatsappQuickReply= (template, templatePreview) => {
188
190
  }
189
191
  return renderArray;
190
192
  }
193
+
194
+ export const getWhatsappCarouselButtonView = (buttons, templatePreview) => {
195
+ const renderArray = [];
196
+ if (buttons?.length) {
197
+ renderArray.push(<CapDivider className={templatePreview ? "whatsapp-divider" : "whatsapp-list-view-divider"} />);
198
+ buttons.forEach((button, index) => {
199
+ const { text, buttonType, type } = button || {};
200
+ const currentButtonType = type || buttonType;
201
+ if (text) {
202
+ renderArray.push(
203
+ <CapLabel
204
+ type="label21"
205
+ className="whatsapp-list-view-text-align"
206
+ >
207
+ <CapIcon
208
+ type={currentButtonType === PHONE_NUMBER ? 'call' : currentButtonType === QUICK_REPLY ? "small-link" : 'launch'}
209
+ size="xs"
210
+ svgProps={{ style: { marginRight: '4px' } }}
211
+ />
212
+ {text}
213
+ </CapLabel>,
214
+ );
215
+ }
216
+ if (index < buttons?.length - 1) {
217
+ renderArray.push(<CapDivider className={templatePreview ? "whatsapp-divider" : "whatsapp-list-view-divider"} />);
218
+ }
219
+ });
220
+ }
221
+ return renderArray;
222
+ };
223
+
191
224
  export const getWhatsappAutoFill = (template) => {
192
225
  const {category}= get(
193
226
  template,
@@ -1592,6 +1592,7 @@ export default {
1592
1592
  totalCount: 7,
1593
1593
  },
1594
1594
  whatsappPreviewTemplateData3Result: {
1595
+ carouselData: [],
1595
1596
  quickReplyData: [
1596
1597
  {
1597
1598
  index: 0,
@@ -2595,3 +2596,4 @@ export default {
2595
2596
  />
2596
2597
  </CapLabel>,
2597
2598
  };
2599
+