@capillarytech/creatives-library 7.10.10 → 7.10.11

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/config/app.js CHANGED
@@ -17,6 +17,7 @@ const config = {
17
17
  },
18
18
  development: {
19
19
  api_endpoint: 'https://crm-nightly-new.cc.capillarytech.com/arya/api/v1/creatives',
20
+ //api_endpoint: 'http://localhost:2022/arya/api/v1/creatives',
20
21
  campaigns_api_endpoint: 'https://crm-nightly-new.cc.capillarytech.com/iris/v2/campaigns',
21
22
  campaigns_api_org_endpoint: 'https://crm-nightly-new.cc.capillarytech.com/iris/v2/org/campaign',
22
23
  auth_endpoint: 'https://crm-nightly-new.cc.capillarytech.com/arya/api/v1/auth',
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@capillarytech/creatives-library",
3
3
  "author": "meharaj",
4
- "version": "7.10.10",
4
+ "version": "7.10.11",
5
5
  "description": "Capillary creatives ui",
6
6
  "main": "./index.js",
7
7
  "module": "./index.es.js",
@@ -12,10 +12,9 @@
12
12
  },
13
13
  "license": "LicenseRef-LICENSE",
14
14
  "dependencies": {
15
- "@babel/polyfill": "7.4.3",
16
15
  "@bugsnag/js": "^7.2.1",
17
16
  "@bugsnag/plugin-react": "^7.2.1",
18
- "@capillarytech/cap-ui-utils": "1.4.0",
17
+ "@capillarytech/cap-ui-utils": "1.4.2",
19
18
  "@mailupinc/bee-plugin": "^1.2.0",
20
19
  "babel-cli": "^6.26.0",
21
20
  "chalk": "1.1.3",
package/utils/common.js CHANGED
@@ -258,7 +258,7 @@ export const bytes2Size = (bytes, decimals = 2) => {
258
258
 
259
259
  export const isTraiDLTEnable = (isFullMode, smsRegister) => {
260
260
  const isTraiDltFeatureForOrg = hasTraiDltFeature();
261
- const isTariEnableforLib = (!isFullMode && smsRegister === "DLT" ) || isFullMode;
262
- const isTraiDltFeature = isTraiDltFeatureForOrg && isTariEnableforLib;
261
+ const isTraiEnableforLib = (!isFullMode && smsRegister === "DLT") || isFullMode;
262
+ const isTraiDltFeature = isTraiDltFeatureForOrg && isTraiEnableforLib;
263
263
  return isTraiDltFeature;
264
264
  };
@@ -1,17 +1,11 @@
1
- /*
2
- *
3
- * SmsTrai constants
4
- *
5
- */
6
-
7
1
  export const DEFAULT_ACTION = 'app/SmsTrai/DEFAULT_ACTION';
8
2
  export const APPROVAL_STATUS = 'approval status';
3
+ export const STATUS = 'status';
9
4
  export const TEMPLATE_NAME = 'template name';
10
5
  export const TYPE = 'type';
11
6
  export const HEADER = 'header';
12
7
  export const TEMPLATE_ID = 'template id';
13
8
  export const SMS = 'SMS';
14
-
15
9
  export const MAPPED_SAVED_COLUMN = {
16
10
  'TEMPLATE ID': 'template_id',
17
11
  'TEMPLATE REGISTRATION NUMBER': 'template_id',
@@ -28,7 +22,6 @@ export const MAPPED_SAVED_COLUMN = {
28
22
  'CONSENT TYPE': 'consent-type',
29
23
  'COMMUNICATION TYPE': 'consent-type',
30
24
  };
31
-
32
25
  export const HEADER_ALIASES = [
33
26
  HEADER,
34
27
  'sender id',
@@ -36,36 +29,36 @@ export const HEADER_ALIASES = [
36
29
  'header id',
37
30
  'headers',
38
31
  ];
39
-
40
32
  export const TEMPLATE_ID_ALIASES = [
41
33
  'template id',
42
34
  'template registration number',
43
35
  ];
44
-
45
36
  export const TEMPLATE_MESSAGE_ALIASES = [
46
37
  'template message',
47
38
  'template content',
48
39
  ];
49
-
40
+ export const STATUS_ALIASES = [
41
+ 'status',
42
+ 'template status',
43
+ ];
50
44
  export const MANDATORY_COLUMNS = [TEMPLATE_NAME, TYPE, APPROVAL_STATUS];
51
45
  export const SAVED_COLUMNS = [TEMPLATE_NAME, TYPE, 'category', 'consent type'];
52
-
53
46
  export const SAMPLE_CSV_DATA = [
54
47
  [
55
- 'TEMPLATE ID',
56
48
  'TEMPLATE NAME',
49
+ 'TEMPLATE ID',
57
50
  'TYPE',
58
- 'HEADER',
51
+ 'SENDER ID',
59
52
  'APPROVAL STATUS',
53
+ 'STATUS',
60
54
  'TEMPLATE MESSAGE',
61
55
  ],
62
56
  ];
63
-
64
57
  export const DOWNLOAD_ISSUES_CSV = 'Downloaded issues.csv';
65
58
  export const SAMPLE_CSV = 'Sample.csv';
66
59
  export const CAPILLARY_REJECTION_REASON = 'CAPILLARY REJECTION REASON';
67
60
  export const APPROVED = 'approved';
68
-
61
+ export const ACTIVE = 'active';
69
62
  export const CREATE_TRAI_SMS_TEMPLATE_REQUEST =
70
63
  'app/v2Containers/SmsTrai/Create/CREATE_TRAI_SMS_TEMPLATE_REQUEST';
71
64
  export const CREATE_TRAI_SMS_TEMPLATE_SUCCESS =
@@ -73,4 +66,4 @@ export const CREATE_TRAI_SMS_TEMPLATE_SUCCESS =
73
66
  export const CREATE_TRAI_SMS_TEMPLATE_FAILURE =
74
67
  'app/v2Containers/SmsTrai/Create/CREATE_TRAI_SMS_TEMPLATE_FAILURE';
75
68
  export const CLEAR_TRAI_SMS_TEMPLATE_CREATE_RESPONSE_REQUEST =
76
- 'app/v2Containers/SmsTrai/Create/CLEAR_TRAI_SMS_TEMPLATE_CREATE_RESPONSE_REQUEST';
69
+ 'app/v2Containers/SmsTrai/Create/CLEAR_TRAI_SMS_TEMPLATE_CREATE_RESPONSE_REQUEST';
@@ -37,8 +37,10 @@ import {
37
37
  CAPILLARY_REJECTION_REASON,
38
38
  APPROVAL_STATUS,
39
39
  APPROVED,
40
+ ACTIVE,
40
41
  TEMPLATE_ID_ALIASES,
41
42
  TEMPLATE_MESSAGE_ALIASES,
43
+ STATUS_ALIASES,
42
44
  SAVED_COLUMNS,
43
45
  MAPPED_SAVED_COLUMN,
44
46
  SMS,
@@ -109,7 +111,16 @@ export const SmsTraiCreate = (props) => {
109
111
  return isError;
110
112
  };
111
113
 
112
- const checkCSVRowsValidation = (transformedResults, selectedHeaderAlias) => {
114
+ const templateIdValidation = (templateId) => {
115
+ let isError = false;
116
+ const numbersOnly = /^\d+$/;
117
+ if (templateId.length !== 20 || !numbersOnly.test(templateId)) {
118
+ isError = true;
119
+ }
120
+ return isError;
121
+ };
122
+
123
+ const checkCSVRowsValidation = (transformedResults, selectedHeaderAlias, selectedTemplateIdAlias, selectedStatusAlias) => {
113
124
  const headerIndex = getIndexofColumn(
114
125
  transformedResults[0],
115
126
  selectedHeaderAlias,
@@ -118,21 +129,34 @@ export const SmsTraiCreate = (props) => {
118
129
  transformedResults[0],
119
130
  APPROVAL_STATUS,
120
131
  );
132
+ const templateIdIndex = getIndexofColumn(
133
+ transformedResults[0],
134
+ selectedTemplateIdAlias,
135
+ );
136
+ const statusIndex = getIndexofColumn(
137
+ transformedResults[0],
138
+ selectedStatusAlias,
139
+ );
121
140
 
122
141
  for (let row = 1; row < transformedResults.length; row += 1) {
123
142
  const errorArray = [];
124
- const headerErrorArray = [];
125
- const approvalErrorArray = [];
143
+ const columnErrorArray = [];
126
144
  let rejectionReasons = '';
127
145
  //adding rejection reasons
128
146
  transformedResults[row].forEach((cell, index) => {
129
147
  if (index === headerIndex && headerValidationHandler(cell)) {
130
- headerErrorArray.push(
131
- `${selectedHeaderAlias.toUpperCase()} is mandatory and each ${selectedHeaderAlias.toUpperCase()} must contain either 6 letters or 6 numbers. It cannot contain special characters`,
148
+ columnErrorArray.push(
149
+ `${selectedHeaderAlias.toUpperCase()} is mandatory and each ${selectedHeaderAlias.toUpperCase()} must contain either 6 letters or 6 digits. It cannot contain special characters. `,
132
150
  );
133
151
  } else if (index === approvalIndex && cell.toLowerCase() !== APPROVED) {
134
- approvalErrorArray.push(`Templates will be created for only approved/ registered templates.`);
135
- } else if (!cell && index !== headerIndex && index !== approvalIndex) {
152
+ columnErrorArray.push(`Templates will be created for only approved/ registered templates.`);
153
+ } else if (index === statusIndex && cell.toLowerCase() !== ACTIVE) {
154
+ columnErrorArray.push(`Only Templates with active status will be created.`);
155
+ } else if (index === templateIdIndex && templateIdValidation(cell)) {
156
+ columnErrorArray.push(
157
+ `${selectedTemplateIdAlias.toUpperCase()} is mandatory and ${selectedTemplateIdAlias.toUpperCase()} must contain only 20 digits.`,
158
+ );
159
+ } else if (!cell && ![headerIndex, approvalIndex, templateIdIndex, statusIndex].includes(index)) {
136
160
  errorArray.push(`"${transformedResults[0][index]}"`);
137
161
  }
138
162
  });
@@ -142,12 +166,12 @@ export const SmsTraiCreate = (props) => {
142
166
  ' ',
143
167
  )}.`;
144
168
  }
145
- if (headerErrorArray.length !== 0 || approvalErrorArray.length !== 0) {
146
- rejectionReasons = `${rejectionReasons} ${headerErrorArray.toString()} ${approvalErrorArray.toString()}`;
169
+ if (columnErrorArray.length !== 0) {
170
+ rejectionReasons = `${rejectionReasons} ${columnErrorArray.toString().replace(',', ' ')}`;
147
171
  }
148
172
  transformedResults[row].push(rejectionReasons);
149
173
  //if there are rejected reasons present in this row at column 6(where we store rejected reasons), consider it as failure
150
- if (transformedResults[row][6]) {
174
+ if (transformedResults[row][7]) {
151
175
  setTotalFailCount((prev) => prev + 1);
152
176
  }
153
177
  }
@@ -161,6 +185,7 @@ export const SmsTraiCreate = (props) => {
161
185
  const headerAliasPresent = [];
162
186
  const templateIdAliasPresent = [];
163
187
  const templateMessageAliasPresent = [];
188
+ const statusAliasPresent = [];
164
189
  const colCounts = {};
165
190
  //removing last empty row if each cell is empty
166
191
  if (results?.data[results.data.length - 1]?.every((cell) => !cell)) {
@@ -177,25 +202,23 @@ export const SmsTraiCreate = (props) => {
177
202
  setErrorText(formatMessage(messages.fileMaxlengthError));
178
203
  return;
179
204
  }
180
- // mandatory 3 header name should be available.
205
+
181
206
  const cols = getAllColumnNames(results.data[0]);
182
207
 
183
- for (let i = 0; i < MANDATORY_COLUMNS.length; i++) {
208
+ for (let i = 0; i < MANDATORY_COLUMNS.length; i += 1) {
184
209
  if (!cols.includes(MANDATORY_COLUMNS[i])) {
185
210
  mandatoryColNotPresent.push(MANDATORY_COLUMNS[i]);
186
211
  }
187
212
  }
188
213
  if (mandatoryColNotPresent.length > 0) {
189
214
  setErrorText(
190
- formatMessage(messages.invalidFileErrorDescription, {
191
- columns: mandatoryColNotPresent.join(','),
192
- }),
215
+ formatMessage(messages.mandatoryColsErrorDescription),
193
216
  );
194
217
  return;
195
218
  }
196
219
 
197
220
  //one of the mandatory header alias should be available.
198
- for (let i = 0; i < HEADER_ALIASES.length; i++) {
221
+ for (let i = 0; i < HEADER_ALIASES.length; i += 1) {
199
222
  if (cols.includes(HEADER_ALIASES[i])) {
200
223
  headerAliasPresent.push(HEADER_ALIASES[i]);
201
224
  }
@@ -236,6 +259,20 @@ export const SmsTraiCreate = (props) => {
236
259
  );
237
260
  return;
238
261
  }
262
+ //one of the mandatory status alias should be available.
263
+ for (let i = 0; i < STATUS_ALIASES.length; i += 1) {
264
+ if (cols.includes(STATUS_ALIASES[i])) {
265
+ statusAliasPresent.push(STATUS_ALIASES[i]);
266
+ }
267
+ }
268
+ if (statusAliasPresent.length === 0) {
269
+ setErrorText(
270
+ formatMessage(messages.statusAliasErrorDescription, {
271
+ statusAliases: STATUS_ALIASES.join(' / '),
272
+ }),
273
+ );
274
+ return;
275
+ }
239
276
  // count of each col to validate blank and repetitive cols
240
277
  for (const num of cols) {
241
278
  colCounts[num] = colCounts[num] ? colCounts[num] + 1 : 1;
@@ -252,27 +289,28 @@ export const SmsTraiCreate = (props) => {
252
289
  if (repetitiveColsArray.length !== 0) {
253
290
  setErrorText(
254
291
  formatMessage(messages.repetitiveColsErrorDescription, {
255
- repetitiveCols: repetitiveColsArray,
292
+ repetitiveCols: repetitiveColsArray.join(", "),
256
293
  }),
257
294
  );
258
295
  return;
259
296
  }
260
297
  //perform required data transformation
261
- return dataTransformHandler(cols, results, headerAliasPresent);
298
+ return dataTransformHandler(cols, results, headerAliasPresent, templateIdAliasPresent, statusAliasPresent);
262
299
  } else {
263
300
  setErrorText(formatMessage(messages.nonCsvErrorDescription));
264
301
  }
265
302
  };
266
303
 
267
- const dataTransformHandler = (cols, results, headerAliasPresent) => {
268
- //getting the index of the cols for 6 mandatory cols and also taking care of alias of headers of mandatory columns
304
+ const dataTransformHandler = (cols, results, headerAliasPresent, templateIdAliasPresent, statusAliasPresent) => {
305
+ //getting the index of the cols for 7 mandatory cols and also taking care of alias of headers of mandatory columns
269
306
  const indexArray = [];
270
- for (let i = 0; i < cols.length; i++) {
307
+ for (let i = 0; i < cols.length; i += 1) {
271
308
  if (
272
309
  MANDATORY_COLUMNS.includes(cols[i]) ||
273
310
  HEADER_ALIASES.includes(cols[i]) ||
274
311
  TEMPLATE_ID_ALIASES.includes(cols[i]) ||
275
- TEMPLATE_MESSAGE_ALIASES.includes(cols[i])
312
+ TEMPLATE_MESSAGE_ALIASES.includes(cols[i]) ||
313
+ STATUS_ALIASES.includes(cols[i])
276
314
  ) {
277
315
  indexArray.push(i);
278
316
  }
@@ -284,7 +322,7 @@ export const SmsTraiCreate = (props) => {
284
322
  }
285
323
  //add rejection header
286
324
  transformedResults[0].push(CAPILLARY_REJECTION_REASON);
287
- return checkCSVRowsValidation(transformedResults, headerAliasPresent[0]);
325
+ return checkCSVRowsValidation(transformedResults, headerAliasPresent[0], templateIdAliasPresent[0], statusAliasPresent[0]);
288
326
  };
289
327
 
290
328
  //returns the headers(first row) of the uploaded file in lowercase
@@ -312,7 +350,7 @@ export const SmsTraiCreate = (props) => {
312
350
  }
313
351
  //adding validated rejection reason column to original results
314
352
  for (let i = 0; i < validatedResults.length; i += 1) {
315
- results.data[i].push(validatedResults[i][6]);
353
+ results.data[i].push(validatedResults[i][7]);
316
354
  }
317
355
  updateSaveTemplate(true);
318
356
  }
@@ -437,7 +475,7 @@ export const SmsTraiCreate = (props) => {
437
475
  arr.forEach((data, i) => {
438
476
  obj[transformedResults[0][i]] = arr[i];
439
477
  });
440
- obj['unicode-validity'] = false;
478
+ obj['unicode-validity'] = true;
441
479
  obj['updated-sms-editor'] = '';
442
480
  obj['var-mapped'] = {};
443
481
  obj.header = obj.header.split(',');
@@ -673,14 +711,18 @@ export const SmsTraiCreate = (props) => {
673
711
  />
674
712
  <InstructionComp
675
713
  number={2}
676
- message={formatMessage(messages.firstRowInstruction)}
714
+ message={formatMessage(messages.uploadLimitInstruction)}
677
715
  />
678
716
  <InstructionComp
679
717
  number={3}
680
- message={formatMessage(messages.secondRowInstruction)}
718
+ message={formatMessage(messages.mandatoryColsInstruction)}
681
719
  />
682
720
  <InstructionComp
683
721
  number={4}
722
+ message={formatMessage(messages.statusInstruction)}
723
+ />
724
+ <InstructionComp
725
+ number={5}
684
726
  message={formatMessage(messages.duplicateEntriesInstruction)}
685
727
  />
686
728
  </div>
@@ -1,11 +1,5 @@
1
- /*
2
- * SmsTrai Messages
3
- *
4
- * This contains all the text for the SmsTrai component.
5
- */
6
1
  import { defineMessages } from 'react-intl';
7
2
  const prefix = 'app.v2containers.SmsTrai.Create';
8
-
9
3
  export default defineMessages({
10
4
  uploadFile: {
11
5
  id: `${prefix}.uploadFile`,
@@ -37,16 +31,20 @@ export default defineMessages({
37
31
  },
38
32
  downloadInstruction: {
39
33
  id: `${prefix}.downloadInstruction`,
40
- defaultMessage: 'Download {link} file',
34
+ defaultMessage: 'Download {link} file.',
41
35
  },
42
- firstRowInstruction: {
43
- id: `${prefix}.firstRowInstruction`,
36
+ uploadLimitInstruction: {
37
+ id: `${prefix}.uploadLimitInstruction`,
38
+ defaultMessage: 'Upload a file of <= 500 rows.',
39
+ },
40
+ mandatoryColsInstruction: {
41
+ id: `${prefix}.mandatoryColsInstruction`,
44
42
  defaultMessage:
45
- 'Please ensure that each template has the following mandatory fields: Template name,Template ID, Type, Sender ID, Approval status, Template message.',
43
+ 'Please ensure that each template has the following mandatory fields: Template name,Template ID, Type, Sender ID, Approval status, Status, Template message.',
46
44
  },
47
- secondRowInstruction: {
48
- id: `${prefix}.secondRowInstruction`,
49
- defaultMessage: 'Only the "Approved" templates will be uploaded.',
45
+ statusInstruction: {
46
+ id: `${prefix}.statusInstruction`,
47
+ defaultMessage: 'Only the "Approved" and “Active” templates will be uploaded.',
50
48
  },
51
49
  duplicateEntriesInstruction: {
52
50
  id: `${prefix}.duplicateEntriesInstruction`,
@@ -54,16 +52,16 @@ export default defineMessages({
54
52
  },
55
53
  fileMinlengthError: {
56
54
  id: `${prefix}.fileMinlengthError`,
57
- defaultMessage: 'Please select a CSV file with minimum 1 row of data and 1 row of headers',
55
+ defaultMessage: 'Please select a CSV file with minimum 1 row of data and 1 row of headers.',
58
56
  },
59
57
  fileMaxlengthError: {
60
58
  id: `${prefix}.fileMaxlengthError`,
61
59
  defaultMessage:
62
60
  'More then 500 records are not allowed for the selected file.',
63
61
  },
64
- invalidFileErrorDescription: {
65
- id: `${prefix}.invalidFileErrorDescription`,
66
- defaultMessage: 'Mandatory fields ({columns}) are required for templates.',
62
+ mandatoryColsErrorDescription: {
63
+ id: `${prefix}.mandatoryColsErrorDescription`,
64
+ defaultMessage: 'Mandatory fields: Template name, Template ID, Type, Sender ID, Approval status, Status and Template message are required for templates.',
67
65
  },
68
66
  repetitiveColsErrorDescription: {
69
67
  id: `${prefix}.repetitiveColsErrorDescription`,
@@ -85,6 +83,11 @@ export default defineMessages({
85
83
  defaultMessage:
86
84
  'Please include mandatory field template message. It can be {templateMessageAliases}.',
87
85
  },
86
+ statusAliasErrorDescription: {
87
+ id: `${prefix}.statusAliasErrorDescription`,
88
+ defaultMessage:
89
+ 'Please include mandatory field status. It can be {statusAliases}.',
90
+ },
88
91
  nonCsvErrorDescription: {
89
92
  id: `${prefix}.nonCsvErrorDescription`,
90
93
  defaultMessage: 'Please select a csv file.',