@capillarytech/creatives-library 8.0.98 → 8.0.99
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
CHANGED
|
@@ -405,10 +405,16 @@ export const Whatsapp = (props) => {
|
|
|
405
405
|
videoSrc: carousel?.videoUrl,
|
|
406
406
|
videoPreviewImg: carousel?.videoPreviewImg,
|
|
407
407
|
}),
|
|
408
|
+
karixFileHandle: carousel?.karixFileHandle || '',
|
|
408
409
|
buttons: carousel?.buttons?.map((button) => ({
|
|
409
410
|
...button,
|
|
410
411
|
buttonType: button?.type,
|
|
411
412
|
})),
|
|
413
|
+
assetList: {
|
|
414
|
+
previewUrl: carousel?.videoPreviewImg,
|
|
415
|
+
videoSrc: carousel?.videoUrl,
|
|
416
|
+
fileHandle: carousel?.karixFileHandle,
|
|
417
|
+
}
|
|
412
418
|
};
|
|
413
419
|
})
|
|
414
420
|
);
|
|
@@ -1130,7 +1136,7 @@ const isAuthenticationTemplate = isEqual(templateCategory, WHATSAPP_CATEGORIES.a
|
|
|
1130
1136
|
videoSize={WHATSAPP_VIDEO_SIZE}
|
|
1131
1137
|
isFullMode={isFullMode}
|
|
1132
1138
|
uploadAsset={uploadWhatsappAsset}
|
|
1133
|
-
uploadedAssetList={carouselData?.[activeIndex]?.assetList
|
|
1139
|
+
uploadedAssetList={isMediaTypeCarousel ? carouselData?.[activeIndex]?.assetList : assetList}
|
|
1134
1140
|
onVideoUploadUpdateAssestList={setUpdateWhatsappVideoSrc}
|
|
1135
1141
|
videoData={editData}
|
|
1136
1142
|
className="cap-custom-video-upload"
|
|
@@ -11,6 +11,7 @@ import {
|
|
|
11
11
|
} from '../utils';
|
|
12
12
|
import mockdata from '../../mockdata';
|
|
13
13
|
import { HOST_ICS, PHONE_NUMBER, QUICK_REPLY } from '../constants';
|
|
14
|
+
import { WHATSAPP_MEDIA_TYPES } from '../../Whatsapp/constants';
|
|
14
15
|
|
|
15
16
|
const {
|
|
16
17
|
whatsappPreviewTemplateData,
|
|
@@ -179,4 +180,101 @@ describe('Test utils', () => {
|
|
|
179
180
|
expect(result[3].props.children[0].props.type).toBe('call');
|
|
180
181
|
});
|
|
181
182
|
});
|
|
183
|
+
|
|
184
|
+
describe('carousel functionality', () => {
|
|
185
|
+
const mockTemplate = {
|
|
186
|
+
versions: {
|
|
187
|
+
base: {
|
|
188
|
+
content: {
|
|
189
|
+
whatsapp: {
|
|
190
|
+
languages: [{ content: 'Test message' }],
|
|
191
|
+
carouselData: [
|
|
192
|
+
{
|
|
193
|
+
mediaType: 'image',
|
|
194
|
+
imageUrl: 'https://example.com/image.jpg',
|
|
195
|
+
},
|
|
196
|
+
{
|
|
197
|
+
mediaType: 'video',
|
|
198
|
+
videoUrl: 'https://example.com/video.mp4',
|
|
199
|
+
videoPreviewImg: 'https://example.com/preview.jpg',
|
|
200
|
+
},
|
|
201
|
+
],
|
|
202
|
+
},
|
|
203
|
+
},
|
|
204
|
+
},
|
|
205
|
+
},
|
|
206
|
+
};
|
|
207
|
+
|
|
208
|
+
it('should return original carousel data when isPreview is false', () => {
|
|
209
|
+
const result = getWhatsappContent(mockTemplate, false);
|
|
210
|
+
expect(result.carouselData).toEqual([
|
|
211
|
+
{
|
|
212
|
+
mediaType: 'image',
|
|
213
|
+
imageUrl: 'https://example.com/image.jpg',
|
|
214
|
+
},
|
|
215
|
+
{
|
|
216
|
+
mediaType: 'video',
|
|
217
|
+
videoUrl: 'https://example.com/video.mp4',
|
|
218
|
+
videoPreviewImg: 'https://example.com/preview.jpg',
|
|
219
|
+
},
|
|
220
|
+
]);
|
|
221
|
+
expect(result.carouselMediaType).toBeUndefined();
|
|
222
|
+
});
|
|
223
|
+
|
|
224
|
+
it('should transform carousel data correctly when isPreview is true', () => {
|
|
225
|
+
const result = getWhatsappContent(mockTemplate, true);
|
|
226
|
+
|
|
227
|
+
expect(result.carouselData).toEqual([
|
|
228
|
+
{
|
|
229
|
+
mediaType: 'image',
|
|
230
|
+
imageUrl: 'https://example.com/image.jpg',
|
|
231
|
+
imageSrc: 'https://example.com/image.jpg',
|
|
232
|
+
},
|
|
233
|
+
{
|
|
234
|
+
mediaType: 'video',
|
|
235
|
+
videoUrl: 'https://example.com/video.mp4',
|
|
236
|
+
videoPreviewImg: 'https://example.com/preview.jpg',
|
|
237
|
+
videoSrc: 'https://example.com/video.mp4',
|
|
238
|
+
},
|
|
239
|
+
]);
|
|
240
|
+
expect(result.carouselMediaType).toBe('image');
|
|
241
|
+
});
|
|
242
|
+
|
|
243
|
+
it('should handle empty carousel data', () => {
|
|
244
|
+
const emptyTemplate = {
|
|
245
|
+
versions: {
|
|
246
|
+
base: {
|
|
247
|
+
content: {
|
|
248
|
+
whatsapp: {
|
|
249
|
+
languages: [{ content: 'Test message' }],
|
|
250
|
+
carouselData: [],
|
|
251
|
+
},
|
|
252
|
+
},
|
|
253
|
+
},
|
|
254
|
+
},
|
|
255
|
+
};
|
|
256
|
+
|
|
257
|
+
const result = getWhatsappContent(emptyTemplate, true);
|
|
258
|
+
expect(result.carouselData).toEqual([]);
|
|
259
|
+
expect(result.carouselMediaType).toBeUndefined();
|
|
260
|
+
});
|
|
261
|
+
|
|
262
|
+
it('should handle undefined carousel data', () => {
|
|
263
|
+
const undefinedTemplate = {
|
|
264
|
+
versions: {
|
|
265
|
+
base: {
|
|
266
|
+
content: {
|
|
267
|
+
whatsapp: {
|
|
268
|
+
languages: [{ content: 'Test message' }],
|
|
269
|
+
},
|
|
270
|
+
},
|
|
271
|
+
},
|
|
272
|
+
},
|
|
273
|
+
};
|
|
274
|
+
|
|
275
|
+
const result = getWhatsappContent(undefinedTemplate, true);
|
|
276
|
+
expect(result.carouselData).toEqual([]);
|
|
277
|
+
expect(result.carouselMediaType).toBeUndefined();
|
|
278
|
+
});
|
|
279
|
+
});
|
|
182
280
|
});
|
|
@@ -114,6 +114,22 @@ export const getWhatsappContent = (template, isPreview) => {
|
|
|
114
114
|
break;
|
|
115
115
|
}
|
|
116
116
|
|
|
117
|
+
const getCarouselData = () => {
|
|
118
|
+
if (isPreview && carouselData?.length) {
|
|
119
|
+
return carouselData.map((carousel) => {
|
|
120
|
+
if (carousel?.mediaType === WHATSAPP_MEDIA_TYPES.IMAGE.toLowerCase()) {
|
|
121
|
+
carousel.imageSrc = carousel?.imageUrl;
|
|
122
|
+
}
|
|
123
|
+
if (carousel?.mediaType === WHATSAPP_MEDIA_TYPES.VIDEO.toLowerCase()) {
|
|
124
|
+
carousel.videoSrc = carousel?.videoUrl;
|
|
125
|
+
carousel.videoPreviewImg = carousel?.videoPreviewImg;
|
|
126
|
+
}
|
|
127
|
+
return carousel;
|
|
128
|
+
});
|
|
129
|
+
}
|
|
130
|
+
return carouselData;
|
|
131
|
+
};
|
|
132
|
+
|
|
117
133
|
return {
|
|
118
134
|
templateHeaderPreview: header ? <CapLabel className="whatsapp-template-list-header-preview">{header}</CapLabel> : '',
|
|
119
135
|
templateFooterPreview: footer ? <CapLabel className="whatsapp-template-list-footer-preview">{footer}</CapLabel> : '',
|
|
@@ -126,7 +142,10 @@ export const getWhatsappContent = (template, isPreview) => {
|
|
|
126
142
|
quickReplyData: buttonsData
|
|
127
143
|
}),
|
|
128
144
|
...mediaParams,
|
|
129
|
-
carouselData,
|
|
145
|
+
carouselData: getCarouselData(),
|
|
146
|
+
...(isPreview && carouselData?.length && {
|
|
147
|
+
carouselMediaType: carouselData[0]?.mediaType,
|
|
148
|
+
}),
|
|
130
149
|
};
|
|
131
150
|
};
|
|
132
151
|
|