@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.
Files changed (33) hide show
  1. package/containers/Templates/constants.js +0 -7
  2. package/containers/Templates/index.js +24 -43
  3. package/package.json +1 -1
  4. package/services/api.js +7 -1
  5. package/services/tests/api.test.js +5 -1
  6. package/v2Components/CapImageUpload/index.js +13 -10
  7. package/v2Components/CapVideoUpload/index.js +12 -9
  8. package/v2Components/CapWhatsappCTA/messages.js +4 -0
  9. package/v2Components/CapWhatsappCarouselButton/constant.js +56 -0
  10. package/v2Components/CapWhatsappCarouselButton/index.js +446 -0
  11. package/v2Components/CapWhatsappCarouselButton/index.scss +39 -0
  12. package/v2Components/CapWhatsappCarouselButton/tests/index.test.js +237 -0
  13. package/v2Components/TemplatePreview/_templatePreview.scss +20 -0
  14. package/v2Components/TemplatePreview/assets/images/empty_image_preview.svg +4 -0
  15. package/v2Components/TemplatePreview/assets/images/empty_video_preview.svg +4 -0
  16. package/v2Components/TemplatePreview/index.js +160 -105
  17. package/v2Components/TemplatePreview/tests/__snapshots__/index.test.js.snap +6 -6
  18. package/v2Containers/CreativesContainer/index.js +92 -5
  19. package/v2Containers/CreativesContainer/tests/__snapshots__/SlideBoxContent.test.js.snap +1 -0
  20. package/v2Containers/Templates/_templates.scss +47 -0
  21. package/v2Containers/Templates/index.js +55 -5
  22. package/v2Containers/Templates/tests/__snapshots__/index.test.js.snap +177 -156
  23. package/v2Containers/Whatsapp/constants.js +87 -1
  24. package/v2Containers/Whatsapp/index.js +706 -188
  25. package/v2Containers/Whatsapp/index.scss +52 -1
  26. package/v2Containers/Whatsapp/messages.js +38 -2
  27. package/v2Containers/Whatsapp/styles.scss +5 -0
  28. package/v2Containers/Whatsapp/tests/__snapshots__/index.test.js.snap +27722 -90751
  29. package/v2Containers/Whatsapp/tests/__snapshots__/utils.test.js.snap +6 -0
  30. package/v2Containers/Whatsapp/tests/mockData.js +3 -7
  31. package/v2Containers/Whatsapp/tests/utils.test.js +80 -1
  32. package/v2Containers/Whatsapp/utils.js +33 -0
  33. 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
- const template = _.find(this.props.Templates.cmsTemplates, (template) => {
919
- return template?.versions && template?.versions?.base && template?.versions?.base?.drag_drop_id === id;
920
- });
921
- const {type,module = DEFAULT} = this.props?.location?.query;
922
- const isLanguageSupport = this.props?.location?.query?.isLanguageSupport === TRUE;
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
- if (template) {
927
- this.props.actions.setEdmTemplate({
928
- ...template,
929
- isEdmSupport,
930
- isLanguageSupport,
931
- projectId: template?.versions?.base?.drag_drop_id,
932
- });
933
-
934
- if (this.state.channel && this.state.channel.toLowerCase() === EMAIL) {
935
- getQuery = (type === TYPE_EMBEDDED) ? {
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
- if (this.isEnabledInLibraryModule("callCreateFromProps")) {
952
- this.props.createNew();
953
- return;
954
- }
935
+ const queryParams = commonUtil.createQueryString(getQuery);
936
+ // this.props.router.push(`${pathName}${queryParams}`);
955
937
 
956
- this.props.router.push({
957
- pathname: `/${this.state.channel.toLowerCase()}/create`,
958
- search: commonUtil.createQueryString(getQuery),
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.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> : ''}
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
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@capillarytech/creatives-library",
3
3
  "author": "meharaj",
4
- "version": "8.0.94",
4
+ "version": "8.0.96",
5
5
  "description": "Capillary creatives ui",
6
6
  "main": "./index.js",
7
7
  "module": "./index.es.js",
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
- data.append('gupshupMediaFile', gupshupMediaFile);
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
- return (
228
- <CapButton
229
- className="dragger-button re-upload"
230
- type="flat"
231
- onClick={onReUpload}
232
- style={channelSpecificStyle ? { marginTop: '-16px'} : {}}
233
- >
234
- <FormattedMessage {...messages.imageReUpload} />
235
- </CapButton>
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
- <div style={{ overflow: 'hidden' }}>
250
- <CapButton
251
- className="dragger-button video-reupload"
252
- type="flat"
253
- onClick={onReUpload}
254
- >
255
- <FormattedMessage {...messages.imageReUpload} />
256
- </CapButton>
257
- </div>
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"
@@ -104,4 +104,8 @@ export default defineMessages({
104
104
  id: `${prefix}.whatsappCtaTagListRevert`,
105
105
  defaultMessage: 'Reset website URL label to default value',
106
106
  },
107
+ url: {
108
+ id: `${prefix}.url`,
109
+ defaultMessage: 'URL',
110
+ },
107
111
  });
@@ -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
+ };