@capillarytech/creatives-library 7.17.144 → 7.17.146

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
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@capillarytech/creatives-library",
3
3
  "author": "meharaj",
4
- "version": "7.17.144",
4
+ "version": "7.17.146",
5
5
  "description": "Capillary creatives ui",
6
6
  "main": "./index.js",
7
7
  "module": "./index.es.js",
@@ -592,8 +592,6 @@ export function SlideBoxContent(props) {
592
592
  cap={cap}
593
593
  onResetStep={onResetStep}
594
594
  showTemplateName={showTemplateName}
595
- onEnterTemplateName={onEnterTemplateName}
596
- onRemoveTemplateName={onRemoveTemplateName}
597
595
  onValidationFail={onValidationFail}
598
596
  forwardedTags={forwardedTags}
599
597
  selectedOfferDetails={selectedOfferDetails}
@@ -14,15 +14,14 @@ function SlideBoxFooter(props) {
14
14
  return (
15
15
  <div>
16
16
  <div>
17
-
18
17
  {props.shouldShowDoneFooter() && (
19
18
  <div>
20
- { isFullMode && isTemplateNameEmpty &&
19
+ { isFullMode && isTemplateNameEmpty &&
21
20
  <CapError type="error">
22
21
  <FormattedMessage {...messages.templateNameEmpty} />
23
- </CapError>
22
+ </CapError>
24
23
  }
25
- <CapButton onClick={onSave} disabled={isTemplateNameEmpty || fetchingCmsData || false}>
24
+ <CapButton onClick={onSave} disabled={isTemplateNameEmpty ||fetchingCmsData || false}>
26
25
  {isFullMode ?
27
26
  getFullModeSaveBtn(slidBoxContent)
28
27
  :
@@ -32,7 +31,7 @@ function SlideBoxFooter(props) {
32
31
  {/* {isFullMode && <CapButton type="secondary" onClick={onDiscard}><FormattedMessage {...messages.creativesTemplatesDiscard}/></CapButton>} */}
33
32
  </div>)}
34
33
  {props.shouldShowContinueFooter() &&
35
- <CapButton onClick={onCreateNextStep} >
34
+ <CapButton onClick={onCreateNextStep}>
36
35
  <FormattedMessage {...messages.continue} />
37
36
  </CapButton>
38
37
  }
@@ -53,6 +52,5 @@ SlideBoxFooter.propTypes = {
53
52
  shouldShowContinueFooter: PropTypes.func,
54
53
  shouldShowDoneFooter: PropTypes.func,
55
54
  isFullMode: PropTypes.bool,
56
- isTemplateNameEmpty: PropTypes.bool,
57
55
  };
58
56
  export default SlideBoxFooter;
@@ -84,7 +84,7 @@ export class Creatives extends React.Component {
84
84
 
85
85
  componentDidMount() {
86
86
  GA.timeTracker.startTimer(CREATIVES_CONTAINER);
87
- if (!this.props?.isFullMode) {
87
+ if(!this.props?.isFullMode){
88
88
  this.props?.templateActions.getCdnTransformationConfig();
89
89
  }
90
90
  }
@@ -598,7 +598,7 @@ export class Creatives extends React.Component {
598
598
  const type = (get(this.props, "messageDetails.type") || '').toLowerCase();
599
599
  const sourceType = get(channelTemplate, 'definition.sourceType');
600
600
  if (type === LOYALTY) {
601
- if (sourceType === 'MAPP_SDK') {
601
+ if(sourceType === 'MAPP_SDK') {
602
602
  templateData.templateId = get(channelTemplate, '_id');
603
603
  templateData.licenseCode = get(channelTemplate, 'definition.licenseCode');
604
604
  templateData.gatewayId = get(channelTemplate, 'definition.gatewayId');
@@ -741,10 +741,10 @@ export class Creatives extends React.Component {
741
741
  header,
742
742
  footer,
743
743
  headerVarMapped,
744
- headerTemplate,
744
+ headerTemplate
745
745
  };
746
746
  const {
747
- whatsappDocName = '', whatsappDocSize, whatsappDocPages, whatsappDocImg = '',
747
+ whatsappDocName = '', whatsappDocSize, whatsappDocPages, whatsappDocImg = ''
748
748
  } = whatsappDocParams;
749
749
  switch (mediaType) {
750
750
  case (WHATSAPP_MEDIA_TYPES.IMAGE):
@@ -970,10 +970,10 @@ export class Creatives extends React.Component {
970
970
  const templateData = this.state.templateData ? this.state.templateData : template; //select existing or create new content
971
971
  const channel = templateData.type;
972
972
  const creativesData = this.getCreativesData(channel, template, templateData );// convers data to consumer understandable format
973
- creativesData.then((data) => {
973
+ creativesData.then(data=>{
974
974
  this.logGTMEvent(channel, data);
975
975
  this.props.getCreativesData(data);// send data to consumer
976
- });
976
+ })
977
977
  },
978
978
  );
979
979
  }
@@ -1031,7 +1031,7 @@ export class Creatives extends React.Component {
1031
1031
  }
1032
1032
  } else if (channel === constants.EMAIL && isFullMode) {
1033
1033
  const isEmailCreate = slidBoxContent === 'createTemplate' && channel === constants.EMAIL && currentStep !== 'createTemplateContent';
1034
- showFooter = isEmailCreate && emailCreateMode && templateNameExists;
1034
+ showFooter = isEmailCreate && emailCreateMode;
1035
1035
  }
1036
1036
  if (channel === constants.EMAIL && emailCreateMode === "upload") {
1037
1037
  showFooter = showFooter && !this.props.isUploading;
@@ -1105,7 +1105,7 @@ export class Creatives extends React.Component {
1105
1105
  onChange={(ev) => {
1106
1106
  const value = ev.currentTarget.value;
1107
1107
  const isEmptyTemplateName = value.trim() ? false : true;
1108
- this.setState({isTemplateNameEmpty: isEmptyTemplateName});
1108
+ this.setState({isTemplateNameEmpty : isEmptyTemplateName});
1109
1109
  const newFormData = {...formData, 'template-name': value};
1110
1110
  onFormDataChange(newFormData);
1111
1111
  }}
@@ -1116,7 +1116,7 @@ export class Creatives extends React.Component {
1116
1116
  if ([constants.EMAIL, constants.MOBILE_PUSH, constants.INAPP].includes(channel) && (slidBoxContent === 'editTemplate' || slidBoxContent === 'createTemplate')) {
1117
1117
  const name = get(formData, 'template-name');
1118
1118
  if (channel === constants.EMAIL && !name && slidBoxContent === 'createTemplate') {
1119
- this.setState({isTemplateNameEmpty: true});
1119
+ this.setState({isTemplateNameEmpty:true});
1120
1120
  }
1121
1121
  this.templateContainerDetails = {formData, onFormDataChange};
1122
1122
  if (name && !isEditName) {
@@ -546,27 +546,18 @@ export class Email extends React.Component { // eslint-disable-line react/prefer
546
546
  window.removeEventListener("message", this.handleFrameTasks);
547
547
  this.props.actions.clearStoreValues();
548
548
  this.props.actions.clearCRUDResponse();
549
- delete window?.[CREATIVES_S3_ASSET_FILESIZES];
549
+ delete window?.[CREATIVES_S3_ASSET_FILESIZES]
550
550
  }
551
551
 
552
552
  onFormDataChange = (updatedFormData, tabCount, currentTab) => {
553
553
  // this.transformFormData(formData);
554
554
  const formData = {...updatedFormData};
555
- const {defaultData = {}, isFullMode, showTemplateName, syncTemplateName} = this.props;
556
- const templateName = formData['template-name'];
557
- const defaultTemplateName = _.get(defaultData, 'template-name', "");
558
-
559
- //sync back template name from from editing in create flow to wrapper when edited
560
- if (syncTemplateName) {
561
- syncTemplateName(_.isEmpty(templateName) && defaultTemplateName ? defaultTemplateName : templateName);
562
- }
563
-
564
- if (defaultData && _.isEmpty(templateName) && defaultTemplateName?.length >1 && isFullMode) {
565
- formData['template-name'] = defaultTemplateName;
555
+ if (this.props.defaultData && _.isEmpty(formData['template-name']) && this.props.isFullMode) {
556
+ formData['template-name'] = _.get(this.props, "defaultData['template-name']");
566
557
  }
567
558
  this.setState({formData, tabCount, isSchemaChanged: false}, () => {
568
- if (isFullMode) {
569
- showTemplateName({formData, onFormDataChange: this.onFormDataChange});
559
+ if (this.props.isFullMode) {
560
+ this.props.showTemplateName({formData, onFormDataChange: this.onFormDataChange});
570
561
  }
571
562
  });
572
563
  if (currentTab) {
@@ -656,7 +647,7 @@ export class Email extends React.Component { // eslint-disable-line react/prefer
656
647
  this.state.editorInstanse.insertHtml(`${anchor}`);
657
648
  } else if (data === CUSTOMER_BARCODE_TAG && this.state.editorInstanse) {
658
649
  this.state.editorInstanse.insertHtml(`<img src="https://crm-nightly-new-fileservice.s3.amazonaws.com/intouch_creative_assets/8ebc8301-e262-45a6-bdab-ff0de91a.png?code={{${data}}}" />`);
659
- } else if (this.state.editorInstanse) {
650
+ } else if (this.state.editorInstanse){
660
651
  this.state.editorInstanse.insertHtml(`{{${data}}}`);
661
652
  }
662
653
  //this.resetCkEditorInstance(currentTab, formData, true, data);
@@ -2418,7 +2409,7 @@ export class Email extends React.Component { // eslint-disable-line react/prefer
2418
2409
 
2419
2410
  // if (saveCount === 0) {
2420
2411
 
2421
- this.props.actions.transformEmailTemplate(obj, (newEmail) => {
2412
+ this.props.actions.transformEmailTemplate(obj, (newEmail)=>{
2422
2413
  this.props.actions.createTemplate(newEmail, this.onUpdateTemplateComplete);
2423
2414
  });
2424
2415
  // } else {
@@ -2781,7 +2772,6 @@ Email.propTypes = {
2781
2772
  setIsLoadingContent: PropTypes.func,
2782
2773
  injectedTags: PropTypes.object,
2783
2774
  defaultData: PropTypes.object,
2784
- syncTemplateName: PropTypes.func,
2785
2775
  showTemplateName: PropTypes.func,
2786
2776
  onValidationFail: PropTypes.func,
2787
2777
  selectedOfferDetails: PropTypes.array,
@@ -101,15 +101,10 @@ export class EmailWrapper extends React.Component { // eslint-disable-line react
101
101
  this.props.onResetStep();
102
102
  this.props.templatesActions.resetTemplateData();
103
103
  }
104
- onTemplateNameChange = ({target: {value}}) => {
105
- const {onEnterTemplateName, onRemoveTemplateName} = this.props;
106
- const isEmptyTemplateName = !value?.trim();
107
- this.setState({templateName: value, isTemplateNameEmpty: isEmptyTemplateName});
108
- if (value && onEnterTemplateName) {
109
- onEnterTemplateName();
110
- } else if (onRemoveTemplateName) {
111
- onRemoveTemplateName();
112
- }
104
+ onTemplateNameChange = ({target:{value}}) => {
105
+ this.setState({ templateName: value });
106
+ const isEmptyTemplateName = value.trim() ? false : true;
107
+ this.setState({isTemplateNameEmpty : isEmptyTemplateName});
113
108
  }
114
109
  onChange = (e) => {
115
110
  this.props.onEmailModeChange(e.target.value);
@@ -136,8 +131,8 @@ export class EmailWrapper extends React.Component { // eslint-disable-line react
136
131
  gtmPush('creativeDetails', {
137
132
  channel: EMAIL,
138
133
  timeTaken,
139
- mode: 'uploadZip',
140
- });
134
+ mode: 'uploadZip'
135
+ });
141
136
  }
142
137
  handleFileUpload = (file = {}) => {
143
138
  const { templatesActions, intl, showNextStep, isUploading } = this.props;
@@ -190,9 +185,7 @@ export class EmailWrapper extends React.Component { // eslint-disable-line react
190
185
  useEditor = (id) => {
191
186
  this.setState({ modeContent: { id } }, this.props.showNextStep);
192
187
  }
193
- onSyncTemplateName=(tempName) => {
194
- this.setState({templateName: tempName});
195
- }
188
+
196
189
  isShowEmailCreate = () => !_.isEmpty(this.state.selectedCreateMode) && (!_.isEmpty(this.props.EmailLayout) || this.props.SelectedEdmDefaultTemplate)
197
190
  render() {
198
191
  const {
@@ -250,10 +243,10 @@ export class EmailWrapper extends React.Component { // eslint-disable-line react
250
243
  {emailCreateMode === "upload" &&
251
244
  <div style={{ marginLeft: '8px' }}>
252
245
  <CapUploader onChange={this.useFileUpload} accept=".zip, .html, .htm" showUploadList={false}>
253
- { (isFullMode && isTemplateNameEmpty) &&
246
+ { (isFullMode && isTemplateNameEmpty) &&
254
247
  <CapError type="error">
255
248
  < FormattedMessage {...messages.emptyTemplateName} />
256
- </CapError>
249
+ </CapError>
257
250
  }
258
251
  <CapButton disabled={isFullMode && isTemplateNameEmpty}>{this.props.intl.formatMessage(messages.upload)}</CapButton>
259
252
  </CapUploader>
@@ -278,7 +271,6 @@ export class EmailWrapper extends React.Component { // eslint-disable-line react
278
271
  getDefaultTags={type}
279
272
  isFullMode={isFullMode}
280
273
  defaultData={{ 'template-name': templateName }}
281
- syncTemplateName={this.onSyncTemplateName}
282
274
  cap={cap}
283
275
  showTemplateName={showTemplateName}
284
276
  onValidationFail={onValidationFail}
@@ -289,7 +281,6 @@ export class EmailWrapper extends React.Component { // eslint-disable-line react
289
281
  editor={editor}
290
282
  moduleType={moduleType}
291
283
  />}
292
-
293
284
  {!isShowEmailCreate && (
294
285
  <CmsTemplatesComponent
295
286
  cmsTemplates={CmsTemplates}
@@ -331,8 +322,6 @@ EmailWrapper.propTypes = {
331
322
  getCmsTemplatesInProgress: PropTypes.bool,
332
323
  currentOrgDetails: PropTypes.object,
333
324
  moduleType: PropTypes.string,
334
- onEnterTemplateName: PropTypes.func,
335
- onRemoveTemplateName: PropTypes.func,
336
325
  };
337
326
 
338
327
  const mapStateToProps = createStructuredSelector({
@@ -31,7 +31,7 @@ import { GA } from '@capillarytech/cap-ui-utils';
31
31
  import { CREATE, TRACK_CREATE_MPUSH } from '../../App/constants';
32
32
  import { MOBILE_PUSH } from '../../CreativesContainer/constants';
33
33
  import { getContent } from '../commonMethods';
34
- import { getCdnUrl } from '../../../utils/cdnTransformation';
34
+ import { getCdnUrl } from '../../../utils/cdnTransformation'
35
35
 
36
36
  const PrefixWrapper = styled.div`
37
37
  margin-right: 16px;
@@ -149,8 +149,6 @@ export class Create extends React.Component { // eslint-disable-line react/prefe
149
149
  onFormDataChange = (formData, tabCount, currentTab, inputField) => {
150
150
  const newFormData = cloneDeep(formData);
151
151
  const {templateCta} = this.state;
152
- const {syncTemplateName, defaultData = {}, isFullMode, showTemplateName} = this.props;
153
-
154
152
  if (!isEmpty(templateCta)) {
155
153
  newFormData[this.state.currentTab - 1][`secondary-cta-${this.state.currentTab - 1}-label`] = get(templateCta, 'name');
156
154
  newFormData[this.state.currentTab - 1][`secondary-cta-${this.state.currentTab - 1}-action`] = get(templateCta, 'ctaTemplateDetails[0].buttonText');
@@ -159,14 +157,6 @@ export class Create extends React.Component { // eslint-disable-line react/prefe
159
157
  newFormData[this.state.currentTab - 1][`secondary-cta-${this.state.currentTab - 1}-action2`] = get(templateCta, 'ctaTemplateDetails[1].buttonText');
160
158
  }
161
159
  }
162
- const templateName = formData['template-name'];
163
- const defaultTemplateName= get(defaultData, 'template-name') ?? ""
164
- //sync back template name from from editing in create flow to wrapper when edited
165
-
166
- if(syncTemplateName){
167
- syncTemplateName(isEmpty(templateName) && defaultTemplateName?defaultTemplateName:templateName)
168
- }
169
-
170
160
 
171
161
  // copy content code
172
162
  // if (newFormData[0]['copy-iphone-content'] === "") {
@@ -189,12 +179,8 @@ export class Create extends React.Component { // eslint-disable-line react/prefe
189
179
  // newFormData[1]['copy-android-content'] = "";
190
180
  // }
191
181
  // }
192
-
193
- //assign newFormData['template-name'] to default name only once in inital render, if edited use latest form data
194
- if (isFullMode && defaultData && isEmpty(templateName) && defaultTemplateName?.length>1) {
195
- newFormData['template-name'] = defaultTemplateName;
196
- } else {
197
- newFormData['template-name'] = templateName;
182
+ if (this.props.isFullMode && this.props.defaultData && isEmpty(formData['template-name'])) {
183
+ newFormData['template-name'] = get(this.props, "defaultData['template-name']");
198
184
  }
199
185
  if (inputField && inputField.id === "add-sec-cta") {
200
186
  if (!newFormData[0]["add-sec-cta"]) {
@@ -202,8 +188,8 @@ export class Create extends React.Component { // eslint-disable-line react/prefe
202
188
  }
203
189
  }
204
190
  this.setState({formData: newFormData, tabCount, isSchemaChanged: !this.state.isSchemaChanged}, () => {
205
- if (isFullMode) {
206
- showTemplateName({formData: this.state.formData, onFormDataChange: this.onFormDataChange});
191
+ if (this.props.isFullMode) {
192
+ this.props.showTemplateName({formData: this.state.formData, onFormDataChange: this.onFormDataChange});
207
193
  }
208
194
  });
209
195
  };
@@ -218,7 +204,7 @@ export class Create extends React.Component { // eslint-disable-line react/prefe
218
204
  this.setState({currentTab: data});
219
205
  };
220
206
  onTemplateNameChange = () => {
221
- //
207
+ //
222
208
  };
223
209
 
224
210
 
@@ -382,7 +368,7 @@ export class Create extends React.Component { // eslint-disable-line react/prefe
382
368
  };
383
369
  obj.type = 'MOBILEPUSH';
384
370
  obj.name = formData['template-name'];
385
- if (this.props?.Templates?.selectedWeChatAccount?.sourceTypeName === 'MAPP_SDK') {
371
+ if(this.props?.Templates?.selectedWeChatAccount?.sourceTypeName === 'MAPP_SDK') {
386
372
  obj.definition = {
387
373
  accountId: this.props.Templates.selectedWeChatAccount.id,
388
374
  licenseCode: this.props.Templates.selectedWeChatAccount.sourceAccountIdentifier,
@@ -1464,10 +1450,10 @@ export class Create extends React.Component { // eslint-disable-line react/prefe
1464
1450
  //this function gets called from form bulder only when the form data is valid
1465
1451
  const obj = this.getTransformedData(formData);
1466
1452
  const content = getContent(obj);
1467
- const {
1453
+ const {
1468
1454
  definition: {
1469
- mode: definitionMode,
1470
- },
1455
+ mode: definitionMode
1456
+ }
1471
1457
  } = obj || {};
1472
1458
  const label = this.props.location.pathname.indexOf('image') >= 0 ? 'image' : 'text';
1473
1459
  this.props.actions.createTemplate(obj, (response) => {
@@ -1483,9 +1469,9 @@ export class Create extends React.Component { // eslint-disable-line react/prefe
1483
1469
  timeTaken,
1484
1470
  content,
1485
1471
  mode: CREATE,
1486
- imageAdded: definitionMode === 'image',
1472
+ imageAdded: definitionMode === 'image'
1487
1473
  });
1488
-
1474
+
1489
1475
  this.discardValues();
1490
1476
  const message = this.props.intl.formatMessage(messages.messageCreateSuccess);
1491
1477
  CapNotification.success({message, key: 'createMpushSuccess'});
@@ -1879,7 +1865,6 @@ Create.propTypes = {
1879
1865
  iosCtasData: PropTypes.array,
1880
1866
  injectedTags: PropTypes.object,
1881
1867
  defaultData: PropTypes.object,
1882
- syncTemplateName: PropTypes.func,
1883
1868
  showTemplateName: PropTypes.func,
1884
1869
  isGetFormData: PropTypes.bool,
1885
1870
  onValidationFail: PropTypes.func,
@@ -1908,4 +1893,4 @@ export default withCreatives({
1908
1893
  mapStateToProps,
1909
1894
  mapDispatchToProps,
1910
1895
  userAuth: false,
1911
- });
1896
+ });
@@ -56,9 +56,6 @@ export class MobilepushWrapper extends React.Component { // eslint-disable-line
56
56
  templateName: "",
57
57
  };
58
58
  }
59
-
60
-
61
-
62
59
  onChange = (e) => {
63
60
  this.props.onMobilepushModeChange( e.target.value );
64
61
  };
@@ -71,10 +68,6 @@ export class MobilepushWrapper extends React.Component { // eslint-disable-line
71
68
  onRemoveTemplateName();
72
69
  }
73
70
  }
74
-
75
- onSyncTemplateName=(tempName)=>{
76
- this.setState({templateName: tempName});
77
- }
78
71
  render() {
79
72
  const {mobilePushCreateMode, step, getFormData, setIsLoadingContent, isGetFormData, query, isFullMode, showTemplateName, type, onValidationFail, onPreviewContentClicked, onTestContentClicked, templateData} = this.props;
80
73
  const {templateName} = this.state;
@@ -108,8 +101,6 @@ export class MobilepushWrapper extends React.Component { // eslint-disable-line
108
101
  getFormLibraryData={getFormData}
109
102
  setIsLoadingContent={setIsLoadingContent}
110
103
  defaultData={{"template-name": templateName}}
111
- syncTemplateName={this.onSyncTemplateName}
112
-
113
104
  location={{
114
105
  pathname: `/mobilepush/create/${mobilePushCreateMode}`,
115
106
  query,
@@ -1970,7 +1970,7 @@ const isAuthenticationTemplate = isEqual(templateCategory, WHATSAPP_CATEGORIES.a
1970
1970
  </CapHeading>
1971
1971
  }
1972
1972
  suffix={
1973
- templateStatus === WHATSAPP_STATUSES.approved && (
1973
+ templateStatus === WHATSAPP_STATUSES.approved && !isAuthenticationTemplate && (
1974
1974
  <TagList
1975
1975
  label={formatMessage(globalMessages.addLabels)}
1976
1976
  onTagSelect={onHeaderTagSelect}