@capillarytech/creatives-library 7.10.27 → 7.10.29
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
|
@@ -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
|
|
179
|
+
const statusIndexes = getIndexesofColumns(
|
|
170
180
|
transformedResults[0],
|
|
171
181
|
selectedStatusAlias,
|
|
172
182
|
);
|
|
@@ -180,29 +190,20 @@ 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
|
-
|
|
191
|
-
cell.toLowerCase() !== ACTIVE &&
|
|
192
|
-
cell.toLowerCase() !== REGISTERED &&
|
|
193
|
-
cell.toLowerCase() !== APPROVED
|
|
194
|
-
) {
|
|
195
|
-
columnErrorArray.push(
|
|
196
|
-
`Only templates with active/registered/approved status will be created.`,
|
|
197
|
-
);
|
|
200
|
+
} else if (statusIndexes.includes(index) && [ACTIVE, REGISTERED, APPROVED].includes(cell.toLowerCase())) {
|
|
201
|
+
statusErrorIndicator = false;
|
|
198
202
|
} else if (index === templateIdIndex && templateIdValidation(cell)) {
|
|
199
203
|
columnErrorArray.push(
|
|
200
204
|
`${selectedTemplateIdAlias.toUpperCase()} is mandatory and ${selectedTemplateIdAlias.toUpperCase()} must be numeric.`,
|
|
201
205
|
);
|
|
202
|
-
} else if (
|
|
203
|
-
!cell &&
|
|
204
|
-
![headerIndex, templateIdIndex, statusIndex].includes(index)
|
|
205
|
-
) {
|
|
206
|
+
} else if (!cell && ![headerIndex, templateIdIndex, ...statusIndexes].includes(index)) {
|
|
206
207
|
errorArray.push(`"${transformedResults[0][index]}"`);
|
|
207
208
|
} else if (index === templateNameIndex && cell) {
|
|
208
209
|
if (templateNameObj[cell]) {
|
|
@@ -214,6 +215,11 @@ export const SmsTraiCreate = (props) => {
|
|
|
214
215
|
}
|
|
215
216
|
});
|
|
216
217
|
|
|
218
|
+
if (statusErrorIndicator) {
|
|
219
|
+
columnErrorArray.push(
|
|
220
|
+
`Only templates with active/registered/approved status will be created.`,
|
|
221
|
+
);
|
|
222
|
+
}
|
|
217
223
|
if (errorArray.length !== 0) {
|
|
218
224
|
rejectionReasons = `${rejectionReasons} Please include these mandatory fields value: ${errorArray.join(
|
|
219
225
|
' ',
|
|
@@ -409,7 +415,7 @@ export const SmsTraiCreate = (props) => {
|
|
|
409
415
|
transformedResults,
|
|
410
416
|
headerAliasPresent[0],
|
|
411
417
|
templateIdAliasPresent[0],
|
|
412
|
-
statusAliasPresent
|
|
418
|
+
statusAliasPresent,
|
|
413
419
|
);
|
|
414
420
|
};
|
|
415
421
|
|
|
@@ -786,9 +792,7 @@ export const SmsTraiCreate = (props) => {
|
|
|
786
792
|
{formatMessage(messages.uploadInstructions)}
|
|
787
793
|
</CapHeading>
|
|
788
794
|
<div className="upload-instruction-list">
|
|
789
|
-
<InstructionComp
|
|
790
|
-
message={formatMessage(messages.deferEdit)}
|
|
791
|
-
/>
|
|
795
|
+
<InstructionComp message={formatMessage(messages.deferEdit)} />
|
|
792
796
|
<InstructionComp
|
|
793
797
|
message={
|
|
794
798
|
<FormattedMessage
|