@capillarytech/creatives-library 8.0.96 → 8.0.98

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
- 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;
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
- 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
- }
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
- const queryParams = commonUtil.createQueryString(getQuery);
936
- // this.props.router.push(`${pathName}${queryParams}`);
952
+ if (this.isEnabledInLibraryModule("callCreateFromProps")) {
953
+ this.props.createNew();
954
+ return;
955
+ }
937
956
 
938
- this.props.router.push({
939
- pathname: `/${this.state.channel.toLowerCase()}/create`,
940
- search: getQuery,
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._id); event.stopPropagation();}} className="select-button" type="secondary">{type === 'embedded' ? this.props.intl.formatMessage(messages.selectDefaultButton) : this.props.intl.formatMessage(messages.selectDefaultButton)}</CapButton> : ''}
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
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@capillarytech/creatives-library",
3
3
  "author": "meharaj",
4
- "version": "8.0.96",
4
+ "version": "8.0.98",
5
5
  "description": "Capillary creatives ui",
6
6
  "main": "./index.js",
7
7
  "module": "./index.es.js",
@@ -2784,8 +2784,8 @@ const isAuthenticationTemplate = isEqual(templateCategory, WHATSAPP_CATEGORIES.a
2784
2784
  data.carouselTagValidationErr ||
2785
2785
  Object.values(data.varMap).some((inputValue) => inputValue === "") ||
2786
2786
  computeTextLength(CAROUSEL_TEXT, data) > TEMPLATE_MESSAGE_MAX_LENGTH ||
2787
- (carouselMediaType === "image" && !data.imageSrc) ||
2788
- (carouselMediaType === "video" && !data.videoSrc) ||
2787
+ (carouselMediaType === IMAGE.toLowerCase() && !data.imageSrc) ||
2788
+ (carouselMediaType === VIDEO.toLowerCase() && !data.videoSrc) ||
2789
2789
  data?.buttons.some((btn) => btn?.url?.includes("{{1}}"))
2790
2790
  );
2791
2791
  });