@capillarytech/creatives-library 8.0.97 → 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.
|
@@ -43,3 +43,9 @@ export const RESET_TEMPLATE = "app/containers/Templates/RESET_TEMPLATE";
|
|
|
43
43
|
export const RESET_TEMPLATE_DATA = "app/containers/Templates/RESET_TEMPLATE_DATA";
|
|
44
44
|
export const RESET_UPLOAD_DATA = "app/containers/Templates/RESET_UPLOAD_DATA";
|
|
45
45
|
export const CLEAR_TEMPLATE_STORE_DATA = "app/containers/Templates/CLEAR_TEMPLATE_STORE_DATA";
|
|
46
|
+
|
|
47
|
+
|
|
48
|
+
export const TRUE = 'true';
|
|
49
|
+
export const FALSE = 'false';
|
|
50
|
+
export const EMAIL = 'email';
|
|
51
|
+
export const TYPE_EMBEDDED = 'embedded';
|
|
@@ -57,6 +57,8 @@ import lineCreateReducer from '../Line/Create/reducer';
|
|
|
57
57
|
import { ebillSaga } from '../Ebill/sagas';
|
|
58
58
|
import { lineCreateSaga } from '../Line/Create/sagas';
|
|
59
59
|
import { duplicateMPushSaga } from '../MobilePush/Create/sagas';
|
|
60
|
+
import { FALSE, TRUE, TYPE_EMBEDDED } from './constants';
|
|
61
|
+
import { DEFAULT } from '../../v2Containers/Cap/constants';
|
|
60
62
|
|
|
61
63
|
const MenuItem = Menu.Item;
|
|
62
64
|
const Option = Select.Option;
|
|
@@ -914,31 +916,49 @@ export class Templates extends React.Component { // eslint-disable-line react/pr
|
|
|
914
916
|
|
|
915
917
|
handleEdmDefaultTemplateSelection = (isSelected, id) => {
|
|
916
918
|
if (isSelected) {
|
|
917
|
-
|
|
918
|
-
|
|
919
|
-
|
|
920
|
-
const
|
|
921
|
-
|
|
919
|
+
const template = _.find(this.props?.Templates?.cmsTemplates, (template = []) => {
|
|
920
|
+
return template?.versions && template?.versions?.base && _.get(template, 'versions.base.drag_drop_id') === id;
|
|
921
|
+
});
|
|
922
|
+
const {type,module = DEFAULT} = this.props?.location?.query;
|
|
923
|
+
const isLanguageSupport = this.props?.location?.query?.isLanguageSupport === TRUE;
|
|
924
|
+
const isEdmSupport = this.props?.location?.query?.isEdmSupport !== FALSE;
|
|
922
925
|
let getQuery = '';
|
|
923
|
-
|
|
924
|
-
|
|
925
|
-
|
|
926
|
-
|
|
927
|
-
|
|
928
|
-
|
|
929
|
-
|
|
930
|
-
|
|
931
|
-
|
|
932
|
-
|
|
933
|
-
|
|
926
|
+
|
|
927
|
+
if (template) {
|
|
928
|
+
this.props.actions.setEdmTemplate({
|
|
929
|
+
...template,
|
|
930
|
+
isEdmSupport,
|
|
931
|
+
isLanguageSupport,
|
|
932
|
+
projectId: template?.versions?.base?.drag_drop_id,
|
|
933
|
+
});
|
|
934
|
+
|
|
935
|
+
if (this.state.channel && this.state.channel.toLowerCase() === EMAIL) {
|
|
936
|
+
getQuery = (type === TYPE_EMBEDDED) ? {
|
|
937
|
+
type: TYPE_EMBEDDED,
|
|
938
|
+
module,
|
|
939
|
+
isLanguageSupport: isLanguageSupport ? 1 : 0,
|
|
940
|
+
isEdmSupport: isEdmSupport ? 1 : 0,
|
|
941
|
+
projectId: template?.versions?.base?.drag_drop_id,
|
|
942
|
+
} : {
|
|
943
|
+
module,
|
|
944
|
+
isLanguageSupport: isLanguageSupport ? 1 : 0,
|
|
945
|
+
isEdmSupport: isEdmSupport ? 1 : 0,
|
|
946
|
+
projectId: template?.versions?.base?.drag_drop_id,
|
|
947
|
+
};
|
|
948
|
+
} else {
|
|
949
|
+
getQuery = (type === TYPE_EMBEDDED) ? {type: TYPE_EMBEDDED, module} : {module};
|
|
950
|
+
}
|
|
934
951
|
|
|
935
|
-
|
|
936
|
-
|
|
952
|
+
if (this.isEnabledInLibraryModule("callCreateFromProps")) {
|
|
953
|
+
this.props.createNew();
|
|
954
|
+
return;
|
|
955
|
+
}
|
|
937
956
|
|
|
938
|
-
|
|
939
|
-
|
|
940
|
-
|
|
941
|
-
|
|
957
|
+
this.props.router.push({
|
|
958
|
+
pathname: `/${this.state.channel.toLowerCase()}/create`,
|
|
959
|
+
search: commonUtil.createQueryString(getQuery),
|
|
960
|
+
});
|
|
961
|
+
}
|
|
942
962
|
}
|
|
943
963
|
};
|
|
944
964
|
|
|
@@ -1128,7 +1148,7 @@ export class Templates extends React.Component { // eslint-disable-line react/pr
|
|
|
1128
1148
|
const imgSrc = template && template.versions && template.versions.base ? template.versions.base.preview_http_url : '';
|
|
1129
1149
|
const ifPreviewGenerated = template && template.versions && template.versions.base ? template.versions.base.isPreviewGenerated : 0;
|
|
1130
1150
|
content = <img src={imgSrc || ''} alt={this.props.intl.formatMessage(messages.previewGenerateText)} width="100%" height="100%"/>;
|
|
1131
|
-
|
|
1151
|
+
|
|
1132
1152
|
temp.content = (
|
|
1133
1153
|
<div
|
|
1134
1154
|
className="sms-template-content">
|
|
@@ -1136,7 +1156,7 @@ export class Templates extends React.Component { // eslint-disable-line react/pr
|
|
|
1136
1156
|
{content}
|
|
1137
1157
|
</div>
|
|
1138
1158
|
{!layoutSelection && template._id === this.state.hoveredItem ? <CapButton onClick={(e) => this.handleEditClick(e, template._id)} className="edit-button" type="secondary">{type === 'embedded' ? this.props.intl.formatMessage(messages.selectButton) : this.props.intl.formatMessage(messages.editButton)}</CapButton> : ''}
|
|
1139
|
-
{layoutSelection && template._id === this.state.hoveredItem ? <CapButton onClick={(event) =>{this.handleEdmDefaultTemplateSelection(true, template
|
|
1159
|
+
{layoutSelection && template._id === this.state.hoveredItem ? <CapButton onClick={(event) =>{this.handleEdmDefaultTemplateSelection(true, template?.versions?.base?.drag_drop_id); event.stopPropagation();}} className="select-button" type="secondary">{type === 'embedded' ? this.props.intl.formatMessage(messages.selectDefaultButton) : this.props.intl.formatMessage(messages.selectDefaultButton)}</CapButton> : ''}
|
|
1140
1160
|
{!layoutSelection && template._id === this.state.hoveredItem ? <CapButton onClick={() => this.handlePreviewClick(template)} className="preview-button" type="cancel">{this.props.intl.formatMessage(messages.previewButton)}</CapButton> : ''}
|
|
1141
1161
|
</div>);
|
|
1142
1162
|
} else if (this.state.channel.toLowerCase() === 'mobilepush') {
|
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
|
|