@capillarytech/creatives-library 8.0.94 → 8.0.96
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 +0 -7
- package/containers/Templates/index.js +24 -43
- 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 +20 -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 +160 -105
- package/v2Components/TemplatePreview/tests/__snapshots__/index.test.js.snap +6 -6
- package/v2Containers/CreativesContainer/index.js +92 -5
- 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 +706 -188
- package/v2Containers/Whatsapp/index.scss +52 -1
- package/v2Containers/Whatsapp/messages.js +38 -2
- package/v2Containers/Whatsapp/styles.scss +5 -0
- package/v2Containers/Whatsapp/tests/__snapshots__/index.test.js.snap +27722 -90751
- package/v2Containers/Whatsapp/tests/__snapshots__/utils.test.js.snap +6 -0
- package/v2Containers/Whatsapp/tests/mockData.js +3 -7
- package/v2Containers/Whatsapp/tests/utils.test.js +80 -1
- package/v2Containers/Whatsapp/utils.js +33 -0
- package/v2Containers/mockdata.js +2 -0
|
@@ -43,10 +43,3 @@ 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';
|
|
52
|
-
export const DEFAULT = 'default';
|
|
@@ -57,7 +57,6 @@ 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 { DEFAULT, FALSE, TRUE, TYPE_EMBEDDED } from './constants';
|
|
61
60
|
|
|
62
61
|
const MenuItem = Menu.Item;
|
|
63
62
|
const Option = Select.Option;
|
|
@@ -915,49 +914,31 @@ export class Templates extends React.Component { // eslint-disable-line react/pr
|
|
|
915
914
|
|
|
916
915
|
handleEdmDefaultTemplateSelection = (isSelected, id) => {
|
|
917
916
|
if (isSelected) {
|
|
918
|
-
|
|
919
|
-
|
|
920
|
-
|
|
921
|
-
const
|
|
922
|
-
|
|
923
|
-
const isEdmSupport = this.props?.location?.query?.isEdmSupport !== FALSE;
|
|
917
|
+
const data = _.find(this.props.Templates.cmsTemplates, {_id: id});
|
|
918
|
+
const type = this.props.location.query.type
|
|
919
|
+
const module = this.props.location.query.module ? this.props.location.query.module : 'default';
|
|
920
|
+
const isLanguageSupport = this.props.location.query.isLanguageSupport ? this.props.location.query.isLanguageSupport : true;
|
|
921
|
+
const isEdmSupport = (this.props.location.query.isEdmSupport !== "false") || false;
|
|
924
922
|
let getQuery = '';
|
|
925
|
-
|
|
926
|
-
|
|
927
|
-
|
|
928
|
-
|
|
929
|
-
|
|
930
|
-
|
|
931
|
-
|
|
932
|
-
|
|
933
|
-
|
|
934
|
-
|
|
935
|
-
|
|
936
|
-
type: TYPE_EMBEDDED,
|
|
937
|
-
module,
|
|
938
|
-
isLanguageSupport: isLanguageSupport ? 1 : 0,
|
|
939
|
-
isEdmSupport: isEdmSupport ? 1 : 0,
|
|
940
|
-
projectId: template?.versions?.base?.drag_drop_id,
|
|
941
|
-
} : {
|
|
942
|
-
module,
|
|
943
|
-
isLanguageSupport: isLanguageSupport ? 1 : 0,
|
|
944
|
-
isEdmSupport: isEdmSupport ? 1 : 0,
|
|
945
|
-
projectId: template?.versions?.base?.drag_drop_id,
|
|
946
|
-
};
|
|
947
|
-
} else {
|
|
948
|
-
getQuery = (type === TYPE_EMBEDDED) ? {type: TYPE_EMBEDDED, module} : {module};
|
|
949
|
-
}
|
|
923
|
+
|
|
924
|
+
this.props.actions.setEdmTemplate(data);
|
|
925
|
+
if (this.state.channel && this.state.channel.toLowerCase() === 'email') {
|
|
926
|
+
getQuery = (type === 'embedded') ? {type: 'embedded', module, isLanguageSupport, isEdmSupport} : {module, isLanguageSupport, isEdmSupport};
|
|
927
|
+
} else {
|
|
928
|
+
getQuery = (type === 'embedded') ? {type: 'embedded', module} : {module};
|
|
929
|
+
}
|
|
930
|
+
if (this.isEnabledInLibraryModule("callCreateFromProps")) {
|
|
931
|
+
this.props.createNew();
|
|
932
|
+
return;
|
|
933
|
+
}
|
|
950
934
|
|
|
951
|
-
|
|
952
|
-
this.props.
|
|
953
|
-
return;
|
|
954
|
-
}
|
|
935
|
+
const queryParams = commonUtil.createQueryString(getQuery);
|
|
936
|
+
// this.props.router.push(`${pathName}${queryParams}`);
|
|
955
937
|
|
|
956
|
-
|
|
957
|
-
|
|
958
|
-
|
|
959
|
-
|
|
960
|
-
}
|
|
938
|
+
this.props.router.push({
|
|
939
|
+
pathname: `/${this.state.channel.toLowerCase()}/create`,
|
|
940
|
+
search: getQuery,
|
|
941
|
+
});
|
|
961
942
|
}
|
|
962
943
|
};
|
|
963
944
|
|
|
@@ -1147,7 +1128,7 @@ export class Templates extends React.Component { // eslint-disable-line react/pr
|
|
|
1147
1128
|
const imgSrc = template && template.versions && template.versions.base ? template.versions.base.preview_http_url : '';
|
|
1148
1129
|
const ifPreviewGenerated = template && template.versions && template.versions.base ? template.versions.base.isPreviewGenerated : 0;
|
|
1149
1130
|
content = <img src={imgSrc || ''} alt={this.props.intl.formatMessage(messages.previewGenerateText)} width="100%" height="100%"/>;
|
|
1150
|
-
|
|
1131
|
+
|
|
1151
1132
|
temp.content = (
|
|
1152
1133
|
<div
|
|
1153
1134
|
className="sms-template-content">
|
|
@@ -1155,7 +1136,7 @@ export class Templates extends React.Component { // eslint-disable-line react/pr
|
|
|
1155
1136
|
{content}
|
|
1156
1137
|
</div>
|
|
1157
1138
|
{!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> : ''}
|
|
1158
|
-
{layoutSelection && template._id === this.state.hoveredItem ? <CapButton onClick={(event) =>{this.handleEdmDefaultTemplateSelection(true, template.
|
|
1139
|
+
{layoutSelection && template._id === this.state.hoveredItem ? <CapButton onClick={(event) =>{this.handleEdmDefaultTemplateSelection(true, template._id); event.stopPropagation();}} className="select-button" type="secondary">{type === 'embedded' ? this.props.intl.formatMessage(messages.selectDefaultButton) : this.props.intl.formatMessage(messages.selectDefaultButton)}</CapButton> : ''}
|
|
1159
1140
|
{!layoutSelection && template._id === this.state.hoveredItem ? <CapButton onClick={() => this.handlePreviewClick(template)} className="preview-button" type="cancel">{this.props.intl.formatMessage(messages.previewButton)}</CapButton> : ''}
|
|
1160
1141
|
</div>);
|
|
1161
1142
|
} else if (this.state.channel.toLowerCase() === 'mobilepush') {
|
package/package.json
CHANGED
package/services/api.js
CHANGED
|
@@ -524,7 +524,13 @@ export const checkBulkDuplicates = (data) => {
|
|
|
524
524
|
export const createWhatsappTemplate = ({payload, gupshupMediaFile }) => {
|
|
525
525
|
const data = new FormData();
|
|
526
526
|
data.append('payload', JSON.stringify(payload));
|
|
527
|
-
|
|
527
|
+
if (Array.isArray(gupshupMediaFile) && gupshupMediaFile?.length) {
|
|
528
|
+
gupshupMediaFile.forEach((file, index) => {
|
|
529
|
+
data.append(`gupshupMediaFile_${index}`, file);
|
|
530
|
+
});
|
|
531
|
+
} else {
|
|
532
|
+
data.append('gupshupMediaFile', gupshupMediaFile);
|
|
533
|
+
}
|
|
528
534
|
const url = `${API_ENDPOINT}/templates/WHATSAPP`;
|
|
529
535
|
return request(url, getAPICallObject('POST', data, true));
|
|
530
536
|
};
|
|
@@ -86,7 +86,11 @@ describe('uploadFile -- whatsapp image upload', () => {
|
|
|
86
86
|
describe('createWhatsappTemplate -- Test with valid responses', () => {
|
|
87
87
|
it('Should return correct response', () =>
|
|
88
88
|
expect(
|
|
89
|
-
createWhatsappTemplate(sampleFile, mockData.createWhatsappPayload),
|
|
89
|
+
createWhatsappTemplate({gupshupMediaFile: [sampleFile], payload: mockData.createWhatsappPayload}),
|
|
90
|
+
).toEqual(Promise.resolve()));
|
|
91
|
+
it('Should return correct response when single file is present', () =>
|
|
92
|
+
expect(
|
|
93
|
+
createWhatsappTemplate({gupshupMediaFile: sampleFile, payload: mockData.createWhatsappPayload}),
|
|
90
94
|
).toEqual(Promise.resolve()));
|
|
91
95
|
});
|
|
92
96
|
|
|
@@ -44,6 +44,7 @@ function CapImageUpload(props) {
|
|
|
44
44
|
imageData,
|
|
45
45
|
channel,
|
|
46
46
|
channelSpecificStyle,
|
|
47
|
+
showReUploadButton = true,
|
|
47
48
|
} = props;
|
|
48
49
|
const {
|
|
49
50
|
formatMessage,
|
|
@@ -224,16 +225,18 @@ function CapImageUpload(props) {
|
|
|
224
225
|
</>
|
|
225
226
|
);
|
|
226
227
|
}
|
|
227
|
-
|
|
228
|
-
|
|
229
|
-
|
|
230
|
-
|
|
231
|
-
|
|
232
|
-
|
|
233
|
-
|
|
234
|
-
|
|
235
|
-
|
|
236
|
-
|
|
228
|
+
if (showReUploadButton) {
|
|
229
|
+
return (
|
|
230
|
+
<CapButton
|
|
231
|
+
className="dragger-button re-upload"
|
|
232
|
+
type="flat"
|
|
233
|
+
onClick={onReUpload}
|
|
234
|
+
style={channelSpecificStyle ? { marginTop: '-16px'} : {}}
|
|
235
|
+
>
|
|
236
|
+
<FormattedMessage {...messages.imageReUpload} />
|
|
237
|
+
</CapButton>
|
|
238
|
+
);
|
|
239
|
+
}
|
|
237
240
|
}, [isImageError, imageSrc]);
|
|
238
241
|
|
|
239
242
|
return (
|
|
@@ -39,6 +39,7 @@ function CapVideoUpload(props) {
|
|
|
39
39
|
errorMessage,
|
|
40
40
|
showVideoNameAndDuration = true,
|
|
41
41
|
formClassName = 'video-form',
|
|
42
|
+
showReUploadButton = true,
|
|
42
43
|
} = props;
|
|
43
44
|
const [isVideoError, updateVideoErrorMessage] = useState(false);
|
|
44
45
|
const [isVideo, updateVideoStatus] = useState(false);
|
|
@@ -246,15 +247,17 @@ function CapVideoUpload(props) {
|
|
|
246
247
|
const videoDurationValue = moment('1900-01-01 00:00:00').add(videoDuration, 'seconds').format("HH.mm.ss"); // to get the duration of video
|
|
247
248
|
return (
|
|
248
249
|
<Fragment key={videoSrc}>
|
|
249
|
-
|
|
250
|
-
<
|
|
251
|
-
|
|
252
|
-
|
|
253
|
-
|
|
254
|
-
|
|
255
|
-
|
|
256
|
-
|
|
257
|
-
|
|
250
|
+
{showReUploadButton && (
|
|
251
|
+
<div style={{ overflow: 'hidden' }}>
|
|
252
|
+
<CapButton
|
|
253
|
+
className="dragger-button video-reupload"
|
|
254
|
+
type="flat"
|
|
255
|
+
onClick={onReUpload}
|
|
256
|
+
>
|
|
257
|
+
<FormattedMessage {...messages.imageReUpload} />
|
|
258
|
+
</CapButton>
|
|
259
|
+
</div>
|
|
260
|
+
)}
|
|
258
261
|
<div className={showVideoNameAndDuration ? 'video-panel' : 'video-panel-wp'}>
|
|
259
262
|
<video
|
|
260
263
|
width="230"
|
|
@@ -0,0 +1,56 @@
|
|
|
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
|
+
};
|