@capillarytech/creatives-library 7.9.15 → 7.9.16
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
|
@@ -21,6 +21,7 @@ import * as constants from './constants';
|
|
|
21
21
|
import LineContainer from '../Line/Container';
|
|
22
22
|
import FTP from '../FTP';
|
|
23
23
|
import Viber from '../Viber';
|
|
24
|
+
import * as commonUtil from '../../utils/common';
|
|
24
25
|
const CreativesWrapper = styled.div`
|
|
25
26
|
.ant-popover,
|
|
26
27
|
.ant-notification,
|
|
@@ -201,7 +202,11 @@ function SlideBoxContent(props) {
|
|
|
201
202
|
const getChannelPreviewContent = (templateDataObject) => {
|
|
202
203
|
switch (templateDataObject.type.toUpperCase()) {
|
|
203
204
|
case constants.SMS:
|
|
204
|
-
|
|
205
|
+
if (!commonUtil.hasTraiDltFeature() || get(templateDataObject, `versions.base['updated-sms-editor']`) === "") {
|
|
206
|
+
return get(templateDataObject, `versions.base['sms-editor']`);
|
|
207
|
+
} else {
|
|
208
|
+
return templateDataObject.versions.base['updated-sms-editor']?.join('');
|
|
209
|
+
}
|
|
205
210
|
case constants.LINE: {
|
|
206
211
|
const lineContents = get(templateDataObject, `versions.base.content.messages`, [{}]);
|
|
207
212
|
const previewContent = [];
|
|
@@ -78,6 +78,32 @@ export const SmsTraiCreate = (props) => {
|
|
|
78
78
|
(column) => column.toLowerCase().trim() === columnName,
|
|
79
79
|
);
|
|
80
80
|
|
|
81
|
+
const headerValidationHandler = (senderIdString) => {
|
|
82
|
+
//each row must contain atleast 1 header
|
|
83
|
+
//each header can be either 6 letters or 6 numbers, no mixing
|
|
84
|
+
//it cannot contain special characters.
|
|
85
|
+
//eg: valid: "123456" "abcdef" invalid: "abc123" "abc$ef" "1234567"
|
|
86
|
+
if (senderIdString.length < 6) {
|
|
87
|
+
return true;
|
|
88
|
+
}
|
|
89
|
+
const lettersOnly = /^[a-zA-Z]*$/;
|
|
90
|
+
const numbersOnly = /^\d+$/;
|
|
91
|
+
let isError = false;
|
|
92
|
+
senderIdString.split(',').forEach((value) => {
|
|
93
|
+
value = value.trim();
|
|
94
|
+
if (value) {
|
|
95
|
+
if (value.length !== 6) {
|
|
96
|
+
isError = true;
|
|
97
|
+
return;
|
|
98
|
+
}
|
|
99
|
+
if (!(lettersOnly.test(value) || numbersOnly.test(value))) {
|
|
100
|
+
isError = true;
|
|
101
|
+
}
|
|
102
|
+
}
|
|
103
|
+
});
|
|
104
|
+
return isError;
|
|
105
|
+
};
|
|
106
|
+
|
|
81
107
|
const checkCSVRowsValidation = (transformedResults, selectedHeaderAlias) => {
|
|
82
108
|
const headerIndex = getIndexofColumn(
|
|
83
109
|
transformedResults[0],
|
|
@@ -95,9 +121,9 @@ export const SmsTraiCreate = (props) => {
|
|
|
95
121
|
let rejectionReasons = '';
|
|
96
122
|
//adding rejection reasons
|
|
97
123
|
transformedResults[row].forEach((cell, index) => {
|
|
98
|
-
if (index === headerIndex && cell
|
|
124
|
+
if (index === headerIndex && headerValidationHandler(cell)) {
|
|
99
125
|
headerErrorArray.push(
|
|
100
|
-
`${selectedHeaderAlias.toUpperCase()} is mandatory and
|
|
126
|
+
`${selectedHeaderAlias.toUpperCase()} is mandatory and each ${selectedHeaderAlias.toUpperCase()} must contain either 6 letters or 6 numbers. It cannot contain special characters`,
|
|
101
127
|
);
|
|
102
128
|
} else if (index === approvalIndex && cell.toLowerCase() !== APPROVED) {
|
|
103
129
|
approvalErrorArray.push(`Template is not approved. `);
|
|
@@ -324,7 +350,7 @@ export const SmsTraiCreate = (props) => {
|
|
|
324
350
|
|
|
325
351
|
const downloadIssuesCSV = (event) => {
|
|
326
352
|
let csvContent = [];
|
|
327
|
-
|
|
353
|
+
let tempArray = [];
|
|
328
354
|
const fileData = files[0].fileResult.data;
|
|
329
355
|
const rejectionIndex = fileData[0].indexOf(CAPILLARY_REJECTION_REASON);
|
|
330
356
|
|
|
@@ -335,6 +361,9 @@ export const SmsTraiCreate = (props) => {
|
|
|
335
361
|
tempArray.push(fileData[row]);
|
|
336
362
|
}
|
|
337
363
|
}
|
|
364
|
+
tempArray = tempArray.map((row) => {
|
|
365
|
+
return row.map((cell) => cell.replace(',', ' '));
|
|
366
|
+
});
|
|
338
367
|
csvContent = tempArray
|
|
339
368
|
.map((e) => e.join(','))
|
|
340
369
|
.map((e) => e.replace(/(\r\n|\n|\r)/gm, ' '))
|