@capillarytech/creatives-library 8.0.90 → 8.0.91
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/services/api.js +7 -1
- package/services/tests/api.test.js +5 -1
- package/v2Components/CapImageUpload/index.js +13 -10
- package/v2Components/CapVideoUpload/index.js +12 -9
- package/v2Components/CapWhatsappCTA/messages.js +4 -0
- package/v2Components/CapWhatsappCarouselButton/constant.js +56 -0
- package/v2Components/CapWhatsappCarouselButton/index.js +446 -0
- package/v2Components/CapWhatsappCarouselButton/index.scss +39 -0
- package/v2Components/CapWhatsappCarouselButton/tests/index.test.js +237 -0
- package/v2Components/TemplatePreview/_templatePreview.scss +9 -0
- package/v2Components/TemplatePreview/assets/images/empty_image_preview.svg +4 -0
- package/v2Components/TemplatePreview/assets/images/empty_video_preview.svg +4 -0
- package/v2Components/TemplatePreview/index.js +171 -105
- package/v2Components/TemplatePreview/tests/__snapshots__/index.test.js.snap +6 -6
- package/v2Containers/CreativesContainer/index.js +91 -4
- package/v2Containers/CreativesContainer/tests/__snapshots__/SlideBoxContent.test.js.snap +1 -0
- package/v2Containers/Templates/_templates.scss +47 -0
- package/v2Containers/Templates/index.js +55 -5
- package/v2Containers/Templates/tests/__snapshots__/index.test.js.snap +177 -156
- package/v2Containers/Whatsapp/constants.js +87 -1
- package/v2Containers/Whatsapp/index.js +707 -189
- package/v2Containers/Whatsapp/index.scss +52 -1
- package/v2Containers/Whatsapp/messages.js +38 -2
- package/v2Containers/Whatsapp/tests/__snapshots__/index.test.js.snap +30183 -90694
- package/v2Containers/Whatsapp/tests/__snapshots__/utils.test.js.snap +6 -0
- package/v2Containers/Whatsapp/tests/utils.test.js +80 -1
- package/v2Containers/Whatsapp/utils.js +34 -0
- 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 {
|
|
@@ -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,38 @@ 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
|
+
style={{ textAlign: 'center', marginTop: '12px' }}
|
|
206
|
+
// className={templatePreview ? "whatsapp-cta-preview" : "whatsapp-list-quick-reply-preview"}
|
|
207
|
+
>
|
|
208
|
+
<CapIcon
|
|
209
|
+
type={currentButtonType === PHONE_NUMBER ? 'call' : currentButtonType === QUICK_REPLY ? "small-link" : 'launch'}
|
|
210
|
+
size="xs"
|
|
211
|
+
svgProps={{ style: { marginRight: '4px' } }}
|
|
212
|
+
/>
|
|
213
|
+
{text}
|
|
214
|
+
</CapLabel>,
|
|
215
|
+
);
|
|
216
|
+
}
|
|
217
|
+
if (index < buttons?.length - 1) {
|
|
218
|
+
renderArray.push(<CapDivider className={templatePreview ? "whatsapp-divider" : "whatsapp-list-view-divider"} />);
|
|
219
|
+
}
|
|
220
|
+
});
|
|
221
|
+
}
|
|
222
|
+
return renderArray;
|
|
223
|
+
};
|
|
224
|
+
|
|
191
225
|
export const getWhatsappAutoFill = (template) => {
|
|
192
226
|
const {category}= get(
|
|
193
227
|
template,
|
package/v2Containers/mockdata.js
CHANGED
|
@@ -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
|
+
|