@capillarytech/creatives-library 7.10.27 → 7.10.28

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.27",
4
+ "version": "7.10.28",
5
5
  "description": "Capillary creatives ui",
6
6
  "main": "./index.js",
7
7
  "module": "./index.es.js",
@@ -88,6 +88,16 @@ export const SmsTraiCreate = (props) => {
88
88
  (column) => column.toLowerCase().trim() === columnName,
89
89
  );
90
90
 
91
+ const getIndexesofColumns = (allColumnNames, columnNames) => {
92
+ const indexes = [];
93
+ allColumnNames.forEach((colName, index) => {
94
+ if (columnNames.includes(colName.toLowerCase().trim())) {
95
+ indexes.push(index);
96
+ }
97
+ });
98
+ return indexes;
99
+ };
100
+
91
101
  const headerValidationHandler = (senderIdString) => {
92
102
  //each row must contain atleast 1 header
93
103
  //each header can be either 6 letters or 6 numbers, no mixing
@@ -166,7 +176,7 @@ export const SmsTraiCreate = (props) => {
166
176
  transformedResults[0],
167
177
  selectedTemplateIdAlias,
168
178
  );
169
- const statusIndex = getIndexofColumn(
179
+ const statusIndexes = getIndexesofColumns(
170
180
  transformedResults[0],
171
181
  selectedStatusAlias,
172
182
  );
@@ -180,29 +190,24 @@ export const SmsTraiCreate = (props) => {
180
190
  const errorArray = [];
181
191
  const columnErrorArray = [];
182
192
  let rejectionReasons = '';
193
+ let statusErrorIndicator = true;
183
194
  //adding rejection reasons
184
195
  transformedResults[row].forEach((cell, index) => {
185
196
  if (index === headerIndex && headerValidationHandler(cell)) {
186
197
  columnErrorArray.push(
187
198
  `${selectedHeaderAlias.toUpperCase()} is mandatory and each ${selectedHeaderAlias.toUpperCase()} must contain either 6 letters or 6 digits. It cannot contain special characters. `,
188
199
  );
189
- } else if (
190
- index === statusIndex &&
191
- cell.toLowerCase() !== ACTIVE &&
192
- cell.toLowerCase() !== REGISTERED &&
193
- cell.toLowerCase() !== APPROVED
200
+ } else if (statusIndexes.includes(index) &&
201
+ (cell.toLowerCase() === ACTIVE ||
202
+ cell.toLowerCase() === REGISTERED ||
203
+ cell.toLowerCase() === APPROVED)
194
204
  ) {
195
- columnErrorArray.push(
196
- `Only templates with active/registered/approved status will be created.`,
197
- );
205
+ statusErrorIndicator = false;
198
206
  } else if (index === templateIdIndex && templateIdValidation(cell)) {
199
207
  columnErrorArray.push(
200
208
  `${selectedTemplateIdAlias.toUpperCase()} is mandatory and ${selectedTemplateIdAlias.toUpperCase()} must be numeric.`,
201
209
  );
202
- } else if (
203
- !cell &&
204
- ![headerIndex, templateIdIndex, statusIndex].includes(index)
205
- ) {
210
+ } else if (!cell && ![headerIndex, templateIdIndex, ...statusIndexes].includes(index)) {
206
211
  errorArray.push(`"${transformedResults[0][index]}"`);
207
212
  } else if (index === templateNameIndex && cell) {
208
213
  if (templateNameObj[cell]) {
@@ -214,6 +219,11 @@ export const SmsTraiCreate = (props) => {
214
219
  }
215
220
  });
216
221
 
222
+ if (statusErrorIndicator) {
223
+ columnErrorArray.push(
224
+ `Only templates with active/registered/approved status will be created.`,
225
+ );
226
+ }
217
227
  if (errorArray.length !== 0) {
218
228
  rejectionReasons = `${rejectionReasons} Please include these mandatory fields value: ${errorArray.join(
219
229
  ' ',
@@ -409,7 +419,7 @@ export const SmsTraiCreate = (props) => {
409
419
  transformedResults,
410
420
  headerAliasPresent[0],
411
421
  templateIdAliasPresent[0],
412
- statusAliasPresent[0],
422
+ statusAliasPresent,
413
423
  );
414
424
  };
415
425
 
@@ -786,9 +796,7 @@ export const SmsTraiCreate = (props) => {
786
796
  {formatMessage(messages.uploadInstructions)}
787
797
  </CapHeading>
788
798
  <div className="upload-instruction-list">
789
- <InstructionComp
790
- message={formatMessage(messages.deferEdit)}
791
- />
799
+ <InstructionComp message={formatMessage(messages.deferEdit)} />
792
800
  <InstructionComp
793
801
  message={
794
802
  <FormattedMessage