@capillarytech/creatives-library 8.0.92 → 8.0.94
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/containers/Templates/constants.js +7 -0
- package/containers/Templates/index.js +43 -24
- package/package.json +1 -1
- package/services/api.js +1 -7
- package/services/tests/api.test.js +1 -5
- package/v2Components/CapImageUpload/index.js +10 -13
- package/v2Components/CapVideoUpload/index.js +9 -12
- package/v2Components/CapWhatsappCTA/messages.js +0 -4
- package/v2Components/TemplatePreview/_templatePreview.scss +0 -20
- package/v2Components/TemplatePreview/index.js +105 -160
- package/v2Components/TemplatePreview/tests/__snapshots__/index.test.js.snap +6 -6
- package/v2Containers/CreativesContainer/index.js +5 -92
- package/v2Containers/CreativesContainer/tests/__snapshots__/SlideBoxContent.test.js.snap +0 -1
- package/v2Containers/Templates/_templates.scss +0 -47
- package/v2Containers/Templates/index.js +5 -55
- package/v2Containers/Templates/tests/__snapshots__/index.test.js.snap +156 -177
- package/v2Containers/Whatsapp/constants.js +1 -87
- package/v2Containers/Whatsapp/index.js +189 -707
- package/v2Containers/Whatsapp/index.scss +1 -52
- package/v2Containers/Whatsapp/messages.js +2 -38
- package/v2Containers/Whatsapp/tests/__snapshots__/index.test.js.snap +91371 -30860
- package/v2Containers/Whatsapp/tests/__snapshots__/utils.test.js.snap +0 -6
- package/v2Containers/Whatsapp/tests/utils.test.js +1 -80
- package/v2Containers/Whatsapp/utils.js +0 -34
- package/v2Containers/mockdata.js +0 -2
- package/v2Components/CapWhatsappCarouselButton/constant.js +0 -56
- package/v2Components/CapWhatsappCarouselButton/index.js +0 -446
- package/v2Components/CapWhatsappCarouselButton/index.scss +0 -39
- package/v2Components/CapWhatsappCarouselButton/tests/index.test.js +0 -237
- package/v2Components/TemplatePreview/assets/images/empty_image_preview.svg +0 -4
- package/v2Components/TemplatePreview/assets/images/empty_video_preview.svg +0 -4
|
@@ -2,7 +2,6 @@
|
|
|
2
2
|
|
|
3
3
|
exports[`Test utils test getWhatsappContent 1`] = `
|
|
4
4
|
Object {
|
|
5
|
-
"carouselData": Array [],
|
|
6
5
|
"charCount": 151,
|
|
7
6
|
"ctaData": Array [
|
|
8
7
|
Object {
|
|
@@ -32,7 +31,6 @@ Click {{unsubscribe}} to unsubscribe
|
|
|
32
31
|
|
|
33
32
|
exports[`Test utils test getWhatsappContent 2`] = `
|
|
34
33
|
Object {
|
|
35
|
-
"carouselData": Array [],
|
|
36
34
|
"charCount": 36,
|
|
37
35
|
"templateFooterPreview": "",
|
|
38
36
|
"templateHeaderPreview": "",
|
|
@@ -46,7 +44,6 @@ Object {
|
|
|
46
44
|
|
|
47
45
|
exports[`Test utils test getWhatsappContent 3`] = `
|
|
48
46
|
Object {
|
|
49
|
-
"carouselData": Array [],
|
|
50
47
|
"charCount": 151,
|
|
51
48
|
"ctaData": Array [
|
|
52
49
|
Object {
|
|
@@ -76,7 +73,6 @@ Click {{unsubscribe}} to unsubscribe
|
|
|
76
73
|
|
|
77
74
|
exports[`Test utils test getWhatsappContent 4`] = `
|
|
78
75
|
Object {
|
|
79
|
-
"carouselData": Array [],
|
|
80
76
|
"charCount": 151,
|
|
81
77
|
"ctaData": Array [
|
|
82
78
|
Object {
|
|
@@ -155,7 +151,6 @@ Click {{unsubscribe}} to unsubscribe
|
|
|
155
151
|
|
|
156
152
|
exports[`Test utils test getWhatsappContent 5`] = `
|
|
157
153
|
Object {
|
|
158
|
-
"carouselData": Array [],
|
|
159
154
|
"charCount": -1,
|
|
160
155
|
"templateFooterPreview": "",
|
|
161
156
|
"templateHeaderPreview": "",
|
|
@@ -169,7 +164,6 @@ Object {
|
|
|
169
164
|
|
|
170
165
|
exports[`Test utils test getWhatsappContent for preview 1`] = `
|
|
171
166
|
Object {
|
|
172
|
-
"carouselData": Array [],
|
|
173
167
|
"charCount": 151,
|
|
174
168
|
"ctaData": Array [
|
|
175
169
|
Object {
|
|
@@ -7,10 +7,9 @@ import {
|
|
|
7
7
|
getWhatsappDocPreview,
|
|
8
8
|
getWhatsappQuickReply,
|
|
9
9
|
getWhatsappAutoFill,
|
|
10
|
-
getWhatsappCarouselButtonView,
|
|
11
10
|
} from '../utils';
|
|
12
11
|
import mockdata from '../../mockdata';
|
|
13
|
-
import { HOST_ICS
|
|
12
|
+
import { HOST_ICS } from '../constants';
|
|
14
13
|
|
|
15
14
|
const {
|
|
16
15
|
whatsappPreviewTemplateData,
|
|
@@ -101,82 +100,4 @@ describe('Test utils', () => {
|
|
|
101
100
|
JSON.stringify(getWhatsappDocPreviewOutput1),
|
|
102
101
|
);
|
|
103
102
|
});
|
|
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
|
-
});
|
|
182
103
|
});
|
|
@@ -80,7 +80,6 @@ export const getWhatsappContent = (template, isPreview) => {
|
|
|
80
80
|
header = '',
|
|
81
81
|
footer = '',
|
|
82
82
|
} = {},
|
|
83
|
-
carouselData = [],
|
|
84
83
|
} = {},
|
|
85
84
|
} = {},
|
|
86
85
|
} = {},
|
|
@@ -126,7 +125,6 @@ export const getWhatsappContent = (template, isPreview) => {
|
|
|
126
125
|
quickReplyData: buttonsData
|
|
127
126
|
}),
|
|
128
127
|
...mediaParams,
|
|
129
|
-
carouselData,
|
|
130
128
|
};
|
|
131
129
|
};
|
|
132
130
|
|
|
@@ -190,38 +188,6 @@ export const getWhatsappQuickReply= (template, templatePreview) => {
|
|
|
190
188
|
}
|
|
191
189
|
return renderArray;
|
|
192
190
|
}
|
|
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
|
-
|
|
225
191
|
export const getWhatsappAutoFill = (template) => {
|
|
226
192
|
const {category}= get(
|
|
227
193
|
template,
|
package/v2Containers/mockdata.js
CHANGED
|
@@ -1592,7 +1592,6 @@ export default {
|
|
|
1592
1592
|
totalCount: 7,
|
|
1593
1593
|
},
|
|
1594
1594
|
whatsappPreviewTemplateData3Result: {
|
|
1595
|
-
carouselData: [],
|
|
1596
1595
|
quickReplyData: [
|
|
1597
1596
|
{
|
|
1598
1597
|
index: 0,
|
|
@@ -2596,4 +2595,3 @@ export default {
|
|
|
2596
2595
|
/>
|
|
2597
2596
|
</CapLabel>,
|
|
2598
2597
|
};
|
|
2599
|
-
|
|
@@ -1,56 +0,0 @@
|
|
|
1
|
-
import React from 'react';
|
|
2
|
-
import { FormattedMessage } from 'react-intl';
|
|
3
|
-
import capWhatsappCTAMsg from '../CapWhatsappCTA/messages';
|
|
4
|
-
import capWhatsappMsg from '../../v2Containers/Whatsapp/messages';
|
|
5
|
-
|
|
6
|
-
export const PHONE_NUMBER = 'PHONE_NUMBER';
|
|
7
|
-
export const URL = 'URL';
|
|
8
|
-
export const QUICK_REPLY = 'QUICK_REPLY';
|
|
9
|
-
export const STATIC_URL = 'STATIC_URL';
|
|
10
|
-
export const BTN_MAX_LENGTH = 20;
|
|
11
|
-
export const PHONE_NUMBER_MAX_LENGTH = 15;
|
|
12
|
-
export const URL_MAX_LENGTH = 2000;
|
|
13
|
-
export const carouselButtonOptions = (carouselIndex) => {
|
|
14
|
-
return [
|
|
15
|
-
{
|
|
16
|
-
value: PHONE_NUMBER,
|
|
17
|
-
label: <FormattedMessage {...capWhatsappCTAMsg.ctaPhoneNo} />,
|
|
18
|
-
disabled: carouselIndex > 0,
|
|
19
|
-
},
|
|
20
|
-
{
|
|
21
|
-
value: URL,
|
|
22
|
-
label: <FormattedMessage {...capWhatsappCTAMsg.url} />,
|
|
23
|
-
disabled: carouselIndex > 0,
|
|
24
|
-
},
|
|
25
|
-
{
|
|
26
|
-
value: QUICK_REPLY,
|
|
27
|
-
label: <FormattedMessage {...capWhatsappMsg.btnTypeQuickReply} />,
|
|
28
|
-
disabled: carouselIndex > 0,
|
|
29
|
-
},
|
|
30
|
-
];
|
|
31
|
-
};
|
|
32
|
-
|
|
33
|
-
export const INITIAL_CAROUSEL_PHONE_NUMBER_DATA = {
|
|
34
|
-
buttonType: PHONE_NUMBER,
|
|
35
|
-
text: '',
|
|
36
|
-
phone_number: '',
|
|
37
|
-
isSaved: false,
|
|
38
|
-
textError: "",
|
|
39
|
-
};
|
|
40
|
-
|
|
41
|
-
export const INITIAL_CAROUSEL_URL_DATA = {
|
|
42
|
-
buttonType: URL,
|
|
43
|
-
text: '',
|
|
44
|
-
urlType: STATIC_URL,
|
|
45
|
-
url: '',
|
|
46
|
-
isSaved: false,
|
|
47
|
-
textError: "",
|
|
48
|
-
urlError: "",
|
|
49
|
-
};
|
|
50
|
-
|
|
51
|
-
export const INITIAL_CAROUSEL_QUICK_REPLY_DATA = {
|
|
52
|
-
text: "",
|
|
53
|
-
buttonType: QUICK_REPLY,
|
|
54
|
-
isSaved: false,
|
|
55
|
-
textError: "",
|
|
56
|
-
};
|