@capillarytech/creatives-library 7.10.26 → 7.10.27

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.10.26",
4
+ "version": "7.10.27",
5
5
  "description": "Capillary creatives ui",
6
6
  "main": "./index.js",
7
7
  "module": "./index.es.js",
@@ -2430,7 +2430,7 @@ class FormBuilder extends React.Component { // eslint-disable-line react/prefer-
2430
2430
  content={content}
2431
2431
  charCounterEnabled={val.charCounterEnabled}
2432
2432
  unicodeEnabled={unicodeEnabled}
2433
- showTestAndPreviewIcon={!this.props.disablePreviewAndTest}
2433
+ showTestAndPreviewIcon
2434
2434
  onPreviewContentClicked={this.props.onPreviewContentClicked}
2435
2435
  onTestContentClicked={this.props.onTestContentClicked}
2436
2436
  module={this.props.tagModule}
@@ -3028,7 +3028,7 @@ class FormBuilder extends React.Component { // eslint-disable-line react/prefer-
3028
3028
  content={content}
3029
3029
  charCounterEnabled={val.charCounterEnabled}
3030
3030
  unicodeEnabled={unicodeEnabled}
3031
- showTestAndPreviewIcon={!this.props.disablePreviewAndTest}
3031
+ showTestAndPreviewIcon
3032
3032
  onPreviewContentClicked={this.props.onPreviewContentClicked}
3033
3033
  onTestContentClicked={this.props.onTestContentClicked}
3034
3034
  module={this.props.tagModule}
@@ -3081,7 +3081,7 @@ class FormBuilder extends React.Component { // eslint-disable-line react/prefer-
3081
3081
  ],
3082
3082
  appName: val.content.appName,
3083
3083
  }}
3084
- showTestAndPreviewIcon={!this.props.disablePreviewAndTest}
3084
+ showTestAndPreviewIcon
3085
3085
  onPreviewContentClicked={this.props.onPreviewContentClicked}
3086
3086
  onTestContentClicked={this.props.onTestContentClicked}
3087
3087
  templateDataRaw={this.props.templateData}
@@ -143,7 +143,6 @@ function SlideBoxContent(props) {
143
143
  showDisabledFBInfo,
144
144
  orgUnitId,
145
145
  smsRegister,
146
- disablePreviewAndTest,
147
146
  } = props;
148
147
  const type = (messageDetails.type || '').toLowerCase(); // type is context in get tags values : outbound | dvs | referral | loyalty | coupons
149
148
  const query = { type: !isFullMode && 'embedded', module: isFullMode ? 'default' : 'library', isEditFromCampaigns: (templateData || {}).isEditFromCampaigns};
@@ -426,7 +425,6 @@ function SlideBoxContent(props) {
426
425
  handleClose={handleClose}
427
426
  onCreateComplete={onCreateComplete}
428
427
  smsRegister={smsRegister}
429
- disablePreviewAndTest={disablePreviewAndTest}
430
428
  />
431
429
  )}
432
430
  {isEditFTP && (
@@ -853,7 +853,6 @@ class Creatives extends React.Component {
853
853
  location={this.props.location}
854
854
  messageDetails={this.props.messageDetails}
855
855
  showDisabledFBInfo={this.props.showDisabledFBInfo}
856
- disablePreviewAndTest={this.props.disablePreviewAndTest}
857
856
  getFormData={this.getFormData}
858
857
  onCallTaskSubmit={this.onCallTaskSubmit}
859
858
  onCreateNew={this.onCreateNew}
@@ -989,7 +989,6 @@ export class Create extends React.Component { // eslint-disable-line react/prefe
989
989
  selectedOfferDetails={this.props.selectedOfferDetails}
990
990
  onTestContentClicked={this.props.onTestContentClicked}
991
991
  onPreviewContentClicked={this.props.onPreviewContentClicked}
992
- disablePreviewAndTest={this.props.disablePreviewAndTest}
993
992
  />
994
993
  </CapColumn>
995
994
  </CapRow>
@@ -1016,7 +1015,6 @@ Create.propTypes = {
1016
1015
  getFormSubscriptionData: PropTypes.func,
1017
1016
  isLoadingMetaEntities: PropTypes.bool,
1018
1017
  selectedOfferDetails: PropTypes.array,
1019
- disablePreviewAndTest: PropTypes.bool,
1020
1018
  };
1021
1019
 
1022
1020
  const mapStateToProps = createStructuredSelector({
@@ -987,7 +987,6 @@ export class Edit extends React.Component { // eslint-disable-line react/prefer-
987
987
  selectedOfferDetails={this.props.selectedOfferDetails}
988
988
  onPreviewContentClicked={this.props.onPreviewContentClicked}
989
989
  onTestContentClicked={this.props.onTestContentClicked}
990
- disablePreviewAndTest={this.props.disablePreviewAndTest}
991
990
  />
992
991
  </CapColumn>
993
992
  </CapRow>
@@ -1017,7 +1016,6 @@ Edit.propTypes = {
1017
1016
  // route: PropTypes.object,
1018
1017
  injectedTags: PropTypes.object,
1019
1018
  selectedOfferDetails: PropTypes.array,
1020
- disablePreviewAndTest: PropTypes.bool,
1021
1019
  };
1022
1020
 
1023
1021
  const mapStateToProps = createStructuredSelector({
@@ -39,6 +39,7 @@ import {
39
39
  APPROVED,
40
40
  ACTIVE,
41
41
  REGISTERED,
42
+ TEMPLATE_NAME,
42
43
  TEMPLATE_ID_ALIASES,
43
44
  TEMPLATE_MESSAGE_ALIASES,
44
45
  STATUS_ALIASES,
@@ -123,6 +124,34 @@ export const SmsTraiCreate = (props) => {
123
124
  return isError;
124
125
  };
125
126
 
127
+ const duplicateTemplateNameValidation = (
128
+ transformedResults,
129
+ templateNameObj,
130
+ ) => {
131
+ //filtering and extracting index of template names with more than 1 occurence
132
+ const duplicateTemplateNameRows =
133
+ Object.values(templateNameObj)
134
+ ?.filter((i) => i.count > 1)
135
+ ?.map((i) => i.csvRow)
136
+ ?.flat()
137
+ ?.sort((a, b) => a - b) || [];
138
+ let duplicateTemplateNameCounts = 0;
139
+
140
+ //only if there are atleast 2 duplicate template names
141
+ if (duplicateTemplateNameRows.length > 1) {
142
+ duplicateTemplateNameRows.forEach((row) => {
143
+ if (!transformedResults[row][transformedResults[row]?.length - 1]) {
144
+ duplicateTemplateNameCounts += 1;
145
+ }
146
+ transformedResults[row][
147
+ transformedResults[row]?.length - 1
148
+ ] += ` Duplicate template names are not allowed.`;
149
+ });
150
+ setTotalFailCount((prev) => prev + duplicateTemplateNameCounts);
151
+ }
152
+ return transformedResults;
153
+ };
154
+
126
155
  const checkCSVRowsValidation = (
127
156
  transformedResults,
128
157
  selectedHeaderAlias,
@@ -141,6 +170,11 @@ export const SmsTraiCreate = (props) => {
141
170
  transformedResults[0],
142
171
  selectedStatusAlias,
143
172
  );
173
+ const templateNameIndex = getIndexofColumn(
174
+ transformedResults[0],
175
+ TEMPLATE_NAME,
176
+ );
177
+ const templateNameObj = {};
144
178
 
145
179
  for (let row = 1; row < transformedResults.length; row += 1) {
146
180
  const errorArray = [];
@@ -159,7 +193,7 @@ export const SmsTraiCreate = (props) => {
159
193
  cell.toLowerCase() !== APPROVED
160
194
  ) {
161
195
  columnErrorArray.push(
162
- `Only Templates with active/registered/approved status will be created.`,
196
+ `Only templates with active/registered/approved status will be created.`,
163
197
  );
164
198
  } else if (index === templateIdIndex && templateIdValidation(cell)) {
165
199
  columnErrorArray.push(
@@ -170,6 +204,13 @@ export const SmsTraiCreate = (props) => {
170
204
  ![headerIndex, templateIdIndex, statusIndex].includes(index)
171
205
  ) {
172
206
  errorArray.push(`"${transformedResults[0][index]}"`);
207
+ } else if (index === templateNameIndex && cell) {
208
+ if (templateNameObj[cell]) {
209
+ templateNameObj[cell]['count'] += 1;
210
+ templateNameObj[cell]['csvRow']?.push(row);
211
+ } else {
212
+ templateNameObj[cell] = { count: 1, csvRow: [row] };
213
+ }
173
214
  }
174
215
  });
175
216
 
@@ -190,7 +231,7 @@ export const SmsTraiCreate = (props) => {
190
231
  }
191
232
  }
192
233
  uploadValidated = true;
193
- return transformedResults;
234
+ return duplicateTemplateNameValidation(transformedResults, templateNameObj);
194
235
  };
195
236
 
196
237
  const checkCSVValidation = (results, file) => {
@@ -3,13 +3,13 @@
3
3
  * SmsWrapper
4
4
  *
5
5
  */
6
- import PropTypes from "prop-types";
7
- import React from "react";
8
- import SmsCreate from "../Sms/Create";
9
- import { isTraiDLTEnable } from "../../utils/common";
10
- import SmsEdit from "../Sms/Edit";
11
- import SmsTraiCreate from "../SmsTrai/Create";
12
- import SmsTraiEdit from "../SmsTrai/Edit";
6
+ import PropTypes from 'prop-types';
7
+ import React from 'react';
8
+ import SmsCreate from '../Sms/Create';
9
+ import { isTraiDLTEnable } from '../../utils/common';
10
+ import SmsEdit from '../Sms/Edit';
11
+ import SmsTraiCreate from '../SmsTrai/Create';
12
+ import SmsTraiEdit from '../SmsTrai/Edit';
13
13
  const SmsWrapper = (props) => {
14
14
  const {
15
15
  isCreateSms,
@@ -29,14 +29,13 @@ const SmsWrapper = (props) => {
29
29
  handleClose,
30
30
  smsRegister,
31
31
  onShowTemplates,
32
- disablePreviewAndTest,
33
32
  } = props;
34
33
 
35
34
  const smsProps = {
36
35
  onCreateComplete,
37
36
  setIsLoadingContent,
38
37
  location,
39
- route: { name: "sms" },
38
+ route: { name: 'sms' },
40
39
  isGetFormData,
41
40
  getFormSubscriptionData,
42
41
  getDefaultTags,
@@ -45,38 +44,36 @@ const SmsWrapper = (props) => {
45
44
  selectedOfferDetails,
46
45
  onPreviewContentClicked,
47
46
  onTestContentClicked,
48
- disablePreviewAndTest,
49
47
  };
50
48
  const isTraiDlt = isTraiDLTEnable(isFullMode, smsRegister);
51
- return (
52
- <>
53
- {isCreateSms &&
54
- (isTraiDlt ? (
55
- <SmsTraiCreate
56
- isComponent
57
- {...smsProps}
58
- onShowTemplates={onShowTemplates}
59
- />
60
- ) : (
61
- <SmsCreate isComponent {...smsProps} />
62
- ))}
63
- {isEditSms &&
64
- (isTraiDlt ? (
65
- <SmsTraiEdit
66
- {...smsProps}
67
- params={{ id: templateData._id }}
68
- templateData={templateData}
69
- handleClose={handleClose}
49
+ return <>
50
+ {
51
+ isCreateSms && (isTraiDlt ?
52
+ <SmsTraiCreate
53
+ isComponent
54
+ {...smsProps}
55
+ onShowTemplates={onShowTemplates}
56
+ /> :
57
+ <SmsCreate
58
+ isComponent {
59
+ ...smsProps
60
+ }
70
61
  />
71
- ) : (
72
- <SmsEdit
62
+ )
63
+ }
64
+ {isEditSms && (isTraiDlt ?
65
+ <SmsTraiEdit
66
+ {...smsProps}
67
+ params={{id: templateData._id}}
68
+ templateData={templateData}
69
+ handleClose={handleClose}
70
+ /> : <SmsEdit
73
71
  {...smsProps}
74
- params={{ id: templateData._id }}
72
+ params={{id: templateData._id}}
75
73
  templateData={templateData}
76
74
  />
77
- ))}
78
- </>
79
- );
75
+ )}
76
+ </>;
80
77
  };
81
78
 
82
79
  export default SmsWrapper;