@capillarytech/creatives-library 7.10.5 → 7.10.7
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
|
@@ -177,15 +177,15 @@ class Creatives extends React.Component {
|
|
|
177
177
|
template_id = '',
|
|
178
178
|
header = '',
|
|
179
179
|
template_name = '',
|
|
180
|
-
|
|
181
|
-
|
|
180
|
+
'sms-editor': smsEditor = '',
|
|
181
|
+
'var-mapped': varMapped = {},
|
|
182
182
|
} = templateData;
|
|
183
183
|
formData = {
|
|
184
184
|
template_id,
|
|
185
185
|
header,
|
|
186
186
|
template_name,
|
|
187
187
|
'sms-editor': smsEditor,
|
|
188
|
-
'var-mapped': varMapped
|
|
188
|
+
'var-mapped': varMapped,
|
|
189
189
|
};
|
|
190
190
|
} else {
|
|
191
191
|
formData = {
|
|
@@ -380,8 +380,8 @@ class Creatives extends React.Component {
|
|
|
380
380
|
const { isFullMode, smsRegister } = this.props;
|
|
381
381
|
const isTraiDlt = commonUtil.isTraiDLTEnable(isFullMode, smsRegister);
|
|
382
382
|
const {
|
|
383
|
-
|
|
384
|
-
|
|
383
|
+
'updated-sms-editor': updatedSmsEditor,
|
|
384
|
+
'sms-editor': smsEditor,
|
|
385
385
|
} = smsBase;
|
|
386
386
|
if (!isTraiDlt) {
|
|
387
387
|
templateData.messageBody = smsEditor;
|
|
@@ -391,14 +391,14 @@ class Creatives extends React.Component {
|
|
|
391
391
|
template_id,
|
|
392
392
|
template_name,
|
|
393
393
|
header,
|
|
394
|
-
|
|
394
|
+
'var-mapped': varMapped,
|
|
395
395
|
} = smsBase;
|
|
396
396
|
templateData.templateConfigs = {
|
|
397
397
|
templateId: template_id,
|
|
398
398
|
templateName: template_name,
|
|
399
399
|
template: smsEditor,
|
|
400
|
-
registeredSenderIds: header
|
|
401
|
-
templateVariableMapping: varMapped
|
|
400
|
+
registeredSenderIds: header,
|
|
401
|
+
templateVariableMapping: varMapped,
|
|
402
402
|
};
|
|
403
403
|
}
|
|
404
404
|
}
|
|
@@ -95,13 +95,13 @@ export const SmsTraiCreate = (props) => {
|
|
|
95
95
|
const numbersOnly = /^\d+$/;
|
|
96
96
|
let isError = false;
|
|
97
97
|
senderIdString.split(',').forEach((value) => {
|
|
98
|
-
|
|
99
|
-
if (
|
|
100
|
-
if (
|
|
98
|
+
const _value = value.trim();
|
|
99
|
+
if (_value) {
|
|
100
|
+
if (_value.length !== 6) {
|
|
101
101
|
isError = true;
|
|
102
102
|
return;
|
|
103
103
|
}
|
|
104
|
-
if (!(lettersOnly.test(
|
|
104
|
+
if (!(lettersOnly.test(_value) || numbersOnly.test(_value))) {
|
|
105
105
|
isError = true;
|
|
106
106
|
}
|
|
107
107
|
}
|
|
@@ -119,7 +119,7 @@ export const SmsTraiCreate = (props) => {
|
|
|
119
119
|
APPROVAL_STATUS,
|
|
120
120
|
);
|
|
121
121
|
|
|
122
|
-
for (let row = 1; row < transformedResults.length; row
|
|
122
|
+
for (let row = 1; row < transformedResults.length; row += 1) {
|
|
123
123
|
const errorArray = [];
|
|
124
124
|
const headerErrorArray = [];
|
|
125
125
|
const approvalErrorArray = [];
|
|
@@ -209,7 +209,7 @@ export const SmsTraiCreate = (props) => {
|
|
|
209
209
|
return;
|
|
210
210
|
}
|
|
211
211
|
//one of the mandatory template id alias should be available.
|
|
212
|
-
for (let i = 0; i < TEMPLATE_ID_ALIASES.length; i
|
|
212
|
+
for (let i = 0; i < TEMPLATE_ID_ALIASES.length; i += 1) {
|
|
213
213
|
if (cols.includes(TEMPLATE_ID_ALIASES[i])) {
|
|
214
214
|
templateIdAliasPresent.push(TEMPLATE_ID_ALIASES[i]);
|
|
215
215
|
}
|
|
@@ -223,7 +223,7 @@ export const SmsTraiCreate = (props) => {
|
|
|
223
223
|
return;
|
|
224
224
|
}
|
|
225
225
|
//one of the mandatory template message alias should be available.
|
|
226
|
-
for (let i = 0; i < TEMPLATE_MESSAGE_ALIASES.length; i
|
|
226
|
+
for (let i = 0; i < TEMPLATE_MESSAGE_ALIASES.length; i += 1) {
|
|
227
227
|
if (cols.includes(TEMPLATE_MESSAGE_ALIASES[i])) {
|
|
228
228
|
templateMessageAliasPresent.push(TEMPLATE_MESSAGE_ALIASES[i]);
|
|
229
229
|
}
|
|
@@ -311,7 +311,7 @@ export const SmsTraiCreate = (props) => {
|
|
|
311
311
|
});
|
|
312
312
|
}
|
|
313
313
|
//adding validated rejection reason column to original results
|
|
314
|
-
for (let i = 0; i < validatedResults.length; i
|
|
314
|
+
for (let i = 0; i < validatedResults.length; i += 1) {
|
|
315
315
|
results.data[i].push(validatedResults[i][6]);
|
|
316
316
|
}
|
|
317
317
|
updateSaveTemplate(true);
|
|
@@ -361,7 +361,7 @@ export const SmsTraiCreate = (props) => {
|
|
|
361
361
|
|
|
362
362
|
if (rejectionIndex !== -1) {
|
|
363
363
|
tempArray.push(fileData[0]);
|
|
364
|
-
for (let row = 1; row < fileData.length; row
|
|
364
|
+
for (let row = 1; row < fileData.length; row += 1) {
|
|
365
365
|
if (fileData[row][rejectionIndex]) {
|
|
366
366
|
tempArray.push(fileData[row]);
|
|
367
367
|
}
|
|
@@ -397,16 +397,15 @@ export const SmsTraiCreate = (props) => {
|
|
|
397
397
|
tempArray.push(fileData[0]);
|
|
398
398
|
|
|
399
399
|
// filter out non rejected rows
|
|
400
|
-
for (let row = 1; row < fileData.length; row
|
|
400
|
+
for (let row = 1; row < fileData.length; row += 1) {
|
|
401
401
|
if (!fileData[row][rejectionIndex]) {
|
|
402
402
|
tempArray.push(fileData[row]);
|
|
403
403
|
}
|
|
404
404
|
}
|
|
405
|
-
|
|
406
405
|
// Filter out the columns index that needs to save
|
|
407
406
|
const cols = getAllColumnNames(tempArray[0]);
|
|
408
407
|
const indexArray = [];
|
|
409
|
-
for (let i = 0; i < cols.length; i
|
|
408
|
+
for (let i = 0; i < cols.length; i += 1) {
|
|
410
409
|
if (
|
|
411
410
|
SAVED_COLUMNS.includes(cols[i]) ||
|
|
412
411
|
HEADER_ALIASES.includes(cols[i]) ||
|
|
@@ -441,6 +440,7 @@ export const SmsTraiCreate = (props) => {
|
|
|
441
440
|
obj['unicode-validity'] = false;
|
|
442
441
|
obj['updated-sms-editor'] = '';
|
|
443
442
|
obj['var-mapped'] = {};
|
|
443
|
+
obj.header = obj.header.split(',');
|
|
444
444
|
const history = obj;
|
|
445
445
|
history.tabKey = 1;
|
|
446
446
|
savedData.push({
|
|
@@ -13,6 +13,7 @@ import CapLabel from '@capillarytech/cap-ui-library/CapLabel';
|
|
|
13
13
|
import CapHeading from '@capillarytech/cap-ui-library/CapHeading';
|
|
14
14
|
import CapSpin from '@capillarytech/cap-ui-library/CapSpin';
|
|
15
15
|
import CapNotification from '@capillarytech/cap-ui-library/CapNotification';
|
|
16
|
+
import CapError from '@capillarytech/cap-ui-library/CapError';
|
|
16
17
|
import {
|
|
17
18
|
CAP_SPACE_16,
|
|
18
19
|
CAP_SPACE_12,
|
|
@@ -24,13 +25,13 @@ import {
|
|
|
24
25
|
} from '@capillarytech/cap-ui-library/styled/variables';
|
|
25
26
|
import { makeSelectTemplateDetailsResponse } from '../../Sms/Edit/selectors';
|
|
26
27
|
import { makeSelectMetaEntities, setInjectedTags } from '../../Cap/selectors';
|
|
27
|
-
import * as
|
|
28
|
+
import * as smsEditActions from '../../Sms/Edit/actions';
|
|
28
29
|
import messages from './messages';
|
|
29
30
|
import TagList from '../../TagList';
|
|
30
31
|
import TemplatePreview from '../../../v2Components/TemplatePreview';
|
|
31
32
|
import withCreatives from '../../../hoc/withCreatives';
|
|
32
33
|
import { validateTags } from '../../../utils/tagValidations';
|
|
33
|
-
|
|
34
|
+
import { updateCharCount } from '../../../utils/smsCharCountV2';
|
|
34
35
|
import {
|
|
35
36
|
CHARLIMIT,
|
|
36
37
|
SMS,
|
|
@@ -42,10 +43,13 @@ import {
|
|
|
42
43
|
ALL,
|
|
43
44
|
LIBRARY,
|
|
44
45
|
} from './constants';
|
|
46
|
+
|
|
45
47
|
let varMap = {};
|
|
46
48
|
let traiData = {};
|
|
49
|
+
let tagValidationResponse = {};
|
|
47
50
|
const { TextArea } = CapInput;
|
|
48
51
|
const { CapLabelInline } = CapLabel;
|
|
52
|
+
|
|
49
53
|
export const SmsTraiEdit = (props) => {
|
|
50
54
|
const {
|
|
51
55
|
intl,
|
|
@@ -72,7 +76,7 @@ export const SmsTraiEdit = (props) => {
|
|
|
72
76
|
const [textAreaId, updateTextAreaId] = useState();
|
|
73
77
|
const [isValidationError, updateIsValidationError] = useState(false);
|
|
74
78
|
const [isTagValidationError, updateIsTagValidationError] = useState(false);
|
|
75
|
-
|
|
79
|
+
const [totalMessageLength, setTotalMessageLength] = useState(0);
|
|
76
80
|
const SMSTraiFooter = styled.div`
|
|
77
81
|
background-color: ${CAP_WHITE};
|
|
78
82
|
position: fixed;
|
|
@@ -91,6 +95,7 @@ export const SmsTraiEdit = (props) => {
|
|
|
91
95
|
margin-right: ${CAP_SPACE_12};
|
|
92
96
|
}
|
|
93
97
|
`;
|
|
98
|
+
|
|
94
99
|
useEffect(() => {
|
|
95
100
|
//fetching tags
|
|
96
101
|
const { type, module } = location.query || {};
|
|
@@ -105,11 +110,12 @@ export const SmsTraiEdit = (props) => {
|
|
|
105
110
|
query.context = getDefaultTags;
|
|
106
111
|
}
|
|
107
112
|
globalActions.fetchSchemaForEntity(query);
|
|
108
|
-
|
|
113
|
+
//fetching template data in fullmode
|
|
109
114
|
const { id } = params || {};
|
|
110
115
|
if (id) {
|
|
111
116
|
actions.getTemplateDetails(id);
|
|
112
117
|
}
|
|
118
|
+
//cleanup code
|
|
113
119
|
return () => {
|
|
114
120
|
actions.resetEditTemplate();
|
|
115
121
|
varMap = {};
|
|
@@ -136,7 +142,6 @@ export const SmsTraiEdit = (props) => {
|
|
|
136
142
|
break;
|
|
137
143
|
}
|
|
138
144
|
}
|
|
139
|
-
|
|
140
145
|
const filteredTemplateMessageArray = templateMessageArray.filter(
|
|
141
146
|
(i) => i.trim() !== '',
|
|
142
147
|
);
|
|
@@ -146,14 +151,15 @@ export const SmsTraiEdit = (props) => {
|
|
|
146
151
|
}
|
|
147
152
|
}, [templateDetails || templateData]);
|
|
148
153
|
|
|
154
|
+
//compute/get varMapped and updated-sms-editor
|
|
149
155
|
useEffect(() => {
|
|
150
156
|
if (tempMsgArray.length !== 0) {
|
|
151
157
|
const traiBase = traiData?.versions?.base || {};
|
|
152
158
|
const {
|
|
153
|
-
|
|
154
|
-
|
|
159
|
+
'var-mapped': varMapped = {},
|
|
160
|
+
'updated-sms-editor': traiSmsEditor = '',
|
|
155
161
|
} = traiBase;
|
|
156
|
-
//if
|
|
162
|
+
//if varMap and updated-sms-editor is already present on non first edits,use those values
|
|
157
163
|
if (!isEmpty(varMapped)) {
|
|
158
164
|
varMap = cloneDeep(varMapped);
|
|
159
165
|
if (isFullMode) {
|
|
@@ -162,25 +168,27 @@ export const SmsTraiEdit = (props) => {
|
|
|
162
168
|
computeUpdatedSmsEditor();
|
|
163
169
|
}
|
|
164
170
|
} else {
|
|
165
|
-
//computing varMap for first edit
|
|
171
|
+
//computing and setting varMap for first edit
|
|
166
172
|
let counter = 1;
|
|
167
|
-
for (let i = 0; i < tempMsgArray.length; i
|
|
173
|
+
for (let i = 0; i < tempMsgArray.length; i += 1) {
|
|
168
174
|
if (tempMsgArray[i] === SMS_TRAI_VAR) {
|
|
169
175
|
const nextElem =
|
|
170
176
|
tempMsgArray[i === tempMsgArray.length - 1 ? 0 : i + 1];
|
|
171
177
|
if (tempMsgArray[i] !== nextElem) {
|
|
172
|
-
varMap[`${tempMsgArray[i]}_${i - counter + 1}`] = {
|
|
178
|
+
varMap[`${tempMsgArray[i]}_${(i - counter) + 1}`] = {
|
|
173
179
|
data: '',
|
|
174
180
|
count: counter,
|
|
175
181
|
};
|
|
176
182
|
counter = 1;
|
|
177
183
|
} else {
|
|
178
|
-
counter
|
|
184
|
+
counter += 1;
|
|
179
185
|
}
|
|
180
186
|
}
|
|
181
187
|
}
|
|
182
188
|
setUpdatedSmsEditor(tempMsgArray);
|
|
183
189
|
}
|
|
190
|
+
// calcaulate message length here
|
|
191
|
+
calculateTotalMessageLength();
|
|
184
192
|
}
|
|
185
193
|
}, [tempMsgArray]);
|
|
186
194
|
|
|
@@ -193,11 +201,30 @@ export const SmsTraiEdit = (props) => {
|
|
|
193
201
|
}
|
|
194
202
|
}, []);
|
|
195
203
|
|
|
204
|
+
//performs tag validation
|
|
205
|
+
useEffect(() => {
|
|
206
|
+
if (
|
|
207
|
+
!isFullMode &&
|
|
208
|
+
updatedSmsEditor?.length > 0 &&
|
|
209
|
+
!updatedSmsEditor.includes(SMS_TRAI_VAR)
|
|
210
|
+
) {
|
|
211
|
+
tagValidationResponse =
|
|
212
|
+
validateTags({
|
|
213
|
+
content: updatedSmsEditor.join(''),
|
|
214
|
+
tagsParam: tags,
|
|
215
|
+
injectedTagsParams: injectedTags,
|
|
216
|
+
location,
|
|
217
|
+
tagModule: getDefaultTags,
|
|
218
|
+
}) || {};
|
|
219
|
+
updateIsTagValidationError(!tagValidationResponse.valid);
|
|
220
|
+
}
|
|
221
|
+
}, [updatedSmsEditor, tags]);
|
|
222
|
+
|
|
196
223
|
const computeUpdatedSmsEditor = () => {
|
|
197
224
|
const updatedSmsArray = [...tempMsgArray];
|
|
198
225
|
for (const key in varMap) {
|
|
199
|
-
|
|
200
|
-
for (let i = 0; i < varMap[key].count; i
|
|
226
|
+
const index = Number(key.slice(8)); //Eg: -> extracting index 1 from keys like {#var# } _1
|
|
227
|
+
for (let i = 0; i < varMap[key].count; i += 1) {
|
|
201
228
|
//when multiple "#var#" come continuously ,it is considered as 1 textbox
|
|
202
229
|
if (i === 0) {
|
|
203
230
|
updatedSmsArray[index] = varMap[key].data; //data for first #var# of the textbox
|
|
@@ -224,7 +251,7 @@ export const SmsTraiEdit = (props) => {
|
|
|
224
251
|
}
|
|
225
252
|
};
|
|
226
253
|
const onDoneCallback = () => {
|
|
227
|
-
if (updatedSmsEditor.includes(SMS_TRAI_VAR)) {
|
|
254
|
+
if (updatedSmsEditor.includes(SMS_TRAI_VAR) && !isFullMode) {
|
|
228
255
|
//during save textbox should not be empty
|
|
229
256
|
updateIsValidationError(true);
|
|
230
257
|
} else {
|
|
@@ -237,14 +264,16 @@ export const SmsTraiEdit = (props) => {
|
|
|
237
264
|
'updated-sms-editor': updatedSmsEditor,
|
|
238
265
|
};
|
|
239
266
|
traiVersions.history = [traiVersions.base];
|
|
240
|
-
isFullMode
|
|
241
|
-
|
|
242
|
-
|
|
243
|
-
|
|
244
|
-
|
|
245
|
-
|
|
246
|
-
|
|
247
|
-
|
|
267
|
+
if (isFullMode) {
|
|
268
|
+
actions.editTemplate(traiData, onUpdateTemplateComplete);
|
|
269
|
+
} else {
|
|
270
|
+
getFormSubscriptionData({
|
|
271
|
+
value: traiData.versions,
|
|
272
|
+
_id: params && params.id,
|
|
273
|
+
validity: true,
|
|
274
|
+
type: SMS,
|
|
275
|
+
});
|
|
276
|
+
}
|
|
248
277
|
}
|
|
249
278
|
};
|
|
250
279
|
//Saving on done end
|
|
@@ -283,7 +312,7 @@ export const SmsTraiEdit = (props) => {
|
|
|
283
312
|
for (
|
|
284
313
|
let i = 0;
|
|
285
314
|
i < varMap[`${SMS_TRAI_VAR}_${textAreaId}`].count;
|
|
286
|
-
i
|
|
315
|
+
i += 1
|
|
287
316
|
) {
|
|
288
317
|
tempArr[textAreaId + i] = '';
|
|
289
318
|
}
|
|
@@ -302,37 +331,24 @@ export const SmsTraiEdit = (props) => {
|
|
|
302
331
|
|
|
303
332
|
// on change event of Text Area
|
|
304
333
|
const textAreaValueChange = ({ target: { value, id } }) => {
|
|
305
|
-
|
|
334
|
+
const _id = Number(id);
|
|
306
335
|
const arr = [...updatedSmsEditor];
|
|
307
|
-
varMap[`${SMS_TRAI_VAR}_${
|
|
336
|
+
varMap[`${SMS_TRAI_VAR}_${_id}`].data = value;
|
|
308
337
|
if (value === '') {
|
|
309
|
-
for (let i = 0; i < varMap[`${SMS_TRAI_VAR}_${
|
|
310
|
-
arr[
|
|
338
|
+
for (let i = 0; i < varMap[`${SMS_TRAI_VAR}_${_id}`].count; i += 1) {
|
|
339
|
+
arr[_id + i] = SMS_TRAI_VAR;
|
|
311
340
|
}
|
|
312
341
|
} else {
|
|
313
|
-
for (let i = 0; i < varMap[`${SMS_TRAI_VAR}_${id}`].count; i
|
|
342
|
+
for (let i = 0; i < varMap[`${SMS_TRAI_VAR}_${id}`].count; i += 1) {
|
|
314
343
|
if (i === 0) {
|
|
315
|
-
arr[
|
|
344
|
+
arr[_id] = varMap[`${SMS_TRAI_VAR}_${_id}`].data;
|
|
316
345
|
} else {
|
|
317
|
-
arr[
|
|
346
|
+
arr[_id + i] = '';
|
|
318
347
|
}
|
|
319
348
|
}
|
|
320
349
|
}
|
|
321
350
|
setUpdatedSmsEditor(arr);
|
|
322
|
-
|
|
323
|
-
const tagValidationResponse =
|
|
324
|
-
validateTags({
|
|
325
|
-
content: arr.join(''),
|
|
326
|
-
tagsParam: tags,
|
|
327
|
-
injectedTagsParams: injectedTags,
|
|
328
|
-
location,
|
|
329
|
-
tagModule: getDefaultTags,
|
|
330
|
-
}) || {};
|
|
331
|
-
if (!tagValidationResponse.valid) {
|
|
332
|
-
updateIsTagValidationError(true);
|
|
333
|
-
console.log(tagValidationResponse);
|
|
334
|
-
}
|
|
335
|
-
}
|
|
351
|
+
calculateTotalMessageLength();
|
|
336
352
|
};
|
|
337
353
|
|
|
338
354
|
const textAreaValue = (idValue) => {
|
|
@@ -342,9 +358,8 @@ export const SmsTraiEdit = (props) => {
|
|
|
342
358
|
updatedSmsEditor[idValue] !== SMS_TRAI_VAR
|
|
343
359
|
) {
|
|
344
360
|
return updatedSmsEditor[idValue];
|
|
345
|
-
} else {
|
|
346
|
-
return '';
|
|
347
361
|
}
|
|
362
|
+
return '';
|
|
348
363
|
}
|
|
349
364
|
return '';
|
|
350
365
|
};
|
|
@@ -365,19 +380,19 @@ export const SmsTraiEdit = (props) => {
|
|
|
365
380
|
</CapHeading>
|
|
366
381
|
);
|
|
367
382
|
}
|
|
383
|
+
return <></>;
|
|
368
384
|
};
|
|
369
385
|
|
|
370
386
|
const renderedContent = () => {
|
|
371
387
|
const renderArray = [];
|
|
372
388
|
if (tempMsgArray?.length !== 0) {
|
|
373
389
|
let varCount = 0;
|
|
374
|
-
tempMsgArray.
|
|
390
|
+
tempMsgArray.forEach((elem, index) => {
|
|
375
391
|
let prevElem = '';
|
|
376
392
|
if (elem.includes(SMS_TRAI_VAR)) {
|
|
377
393
|
prevElem =
|
|
378
394
|
tempMsgArray[[index === 0 ? tempMsgArray.length - 1 : index - 1]];
|
|
379
|
-
varCount
|
|
380
|
-
totalVarCount++;
|
|
395
|
+
varCount += 1;
|
|
381
396
|
if (prevElem !== SMS_TRAI_VAR) {
|
|
382
397
|
renderArray.push(
|
|
383
398
|
<TextArea
|
|
@@ -428,20 +443,52 @@ export const SmsTraiEdit = (props) => {
|
|
|
428
443
|
return renderArray;
|
|
429
444
|
};
|
|
430
445
|
|
|
431
|
-
|
|
432
|
-
|
|
433
|
-
|
|
434
|
-
|
|
435
|
-
|
|
436
|
-
|
|
437
|
-
|
|
438
|
-
|
|
439
|
-
{formatMessage(messages.totalCharacters, {
|
|
440
|
-
smsCount: Math.ceil(totalMessageLength / 160),
|
|
441
|
-
number: totalMessageLength,
|
|
442
|
-
})}
|
|
443
|
-
</CapHeading>
|
|
446
|
+
|
|
447
|
+
const smsLengthForVar = () => (
|
|
448
|
+
<CapHeading type="h5" style={{ marginTop: CAP_SPACE_04, float: 'right' }}>
|
|
449
|
+
{formatMessage(messages.totalCharacters, {
|
|
450
|
+
smsCount: Math.ceil(totalMessageLength / 160),
|
|
451
|
+
number: totalMessageLength,
|
|
452
|
+
})}
|
|
453
|
+
</CapHeading>
|
|
444
454
|
);
|
|
455
|
+
|
|
456
|
+
// to compute the length of the message
|
|
457
|
+
//30 characters is blocked per'{#var#}' if textbox is empty otherwise it will be textbox length
|
|
458
|
+
// and the remaining string length is added to it
|
|
459
|
+
const calculateTotalMessageLength = () => {
|
|
460
|
+
const msgLenWithoutVar = tempMsgArray?.filter((i) => i !== SMS_TRAI_VAR).join('');
|
|
461
|
+
const charDetails = updateCharCount(msgLenWithoutVar, false);
|
|
462
|
+
const varLen = calculateLenForTextBox();
|
|
463
|
+
const totalMsgLen = charDetails.chars_used + varLen;
|
|
464
|
+
setTotalMessageLength(totalMsgLen);
|
|
465
|
+
};
|
|
466
|
+
|
|
467
|
+
const calculateLenForTextBox = () => {
|
|
468
|
+
let countVarChar = 0;
|
|
469
|
+
Object.keys(varMap).forEach((i) => {
|
|
470
|
+
if (varMap[i].data) {
|
|
471
|
+
const charDetails = updateCharCount(varMap[i].data, false);
|
|
472
|
+
countVarChar += charDetails.chars_used;
|
|
473
|
+
} else {
|
|
474
|
+
countVarChar += varMap[i].count * CHARLIMIT;
|
|
475
|
+
}
|
|
476
|
+
});
|
|
477
|
+
return countVarChar;
|
|
478
|
+
};
|
|
479
|
+
const tagValidationErrorMessage = () => {
|
|
480
|
+
const { missingTags = [], unsupportedTags = [] } = tagValidationResponse;
|
|
481
|
+
let tagError = '';
|
|
482
|
+
if (missingTags.length > 0) {
|
|
483
|
+
tagError = formatMessage(messages.missingTagsValidationError, {
|
|
484
|
+
missingTags,
|
|
485
|
+
});
|
|
486
|
+
} else if (unsupportedTags.length > 0) {
|
|
487
|
+
tagError = formatMessage(messages.unsupportedTagsValidationError, {
|
|
488
|
+
unsupportedTags,
|
|
489
|
+
});
|
|
490
|
+
}
|
|
491
|
+
return <CapError>{tagError}</CapError>;
|
|
445
492
|
};
|
|
446
493
|
|
|
447
494
|
return (
|
|
@@ -456,14 +503,16 @@ export const SmsTraiEdit = (props) => {
|
|
|
456
503
|
<CapLabelInline type="label2">
|
|
457
504
|
{traiData.versions.base.template_name}
|
|
458
505
|
</CapLabelInline>
|
|
506
|
+
|
|
459
507
|
<CapLabelInline type="label1">
|
|
460
508
|
{formatMessage(messages.traiEditSeperator)}
|
|
461
509
|
</CapLabelInline>
|
|
510
|
+
|
|
462
511
|
<CapLabelInline type="label1">
|
|
463
512
|
{formatMessage(messages.senderIdlabel)}
|
|
464
513
|
</CapLabelInline>
|
|
465
514
|
<CapLabelInline type="label2">
|
|
466
|
-
{traiData.versions.base.header}
|
|
515
|
+
{traiData.versions.base.header.join(', ')}
|
|
467
516
|
</CapLabelInline>
|
|
468
517
|
</TraiEditTemplateDetails>
|
|
469
518
|
)}
|
|
@@ -494,6 +543,7 @@ export const SmsTraiEdit = (props) => {
|
|
|
494
543
|
{renderedContent()}
|
|
495
544
|
</CapRow>
|
|
496
545
|
<CapRow>{smsLengthForVar()}</CapRow>
|
|
546
|
+
{isTagValidationError && tagValidationErrorMessage()}
|
|
497
547
|
<div style={{ marginBottom: '100px' }} />
|
|
498
548
|
</CapColumn>
|
|
499
549
|
<CapColumn span={10}>
|
|
@@ -504,7 +554,11 @@ export const SmsTraiEdit = (props) => {
|
|
|
504
554
|
</CapColumn>
|
|
505
555
|
</CapRow>
|
|
506
556
|
<SMSTraiFooter>
|
|
507
|
-
<CapButton
|
|
557
|
+
<CapButton
|
|
558
|
+
onClick={onDoneCallback}
|
|
559
|
+
className="create-msg"
|
|
560
|
+
disabled={isTagValidationError}
|
|
561
|
+
>
|
|
508
562
|
<FormattedMessage {...messages.saveButtonLabel} />
|
|
509
563
|
</CapButton>
|
|
510
564
|
<CapButton
|
|
@@ -526,11 +580,9 @@ const mapStateToProps = createStructuredSelector({
|
|
|
526
580
|
injectedTags: setInjectedTags(),
|
|
527
581
|
});
|
|
528
582
|
|
|
529
|
-
const mapDispatchToProps = (dispatch) => {
|
|
530
|
-
|
|
531
|
-
|
|
532
|
-
};
|
|
533
|
-
};
|
|
583
|
+
const mapDispatchToProps = (dispatch) => ({
|
|
584
|
+
actions: bindActionCreators(smsEditActions, dispatch),
|
|
585
|
+
});
|
|
534
586
|
|
|
535
587
|
export default withCreatives({
|
|
536
588
|
WrappedComponent: injectIntl(SmsTraiEdit),
|
|
@@ -55,4 +55,14 @@ export default defineMessages({
|
|
|
55
55
|
id: `${prefix}.senderIdlabel`,
|
|
56
56
|
defaultMessage: 'Sender ID',
|
|
57
57
|
},
|
|
58
|
+
missingTagsValidationError: {
|
|
59
|
+
id: `${prefix}.missingTagsValidationError`,
|
|
60
|
+
defaultMessage:
|
|
61
|
+
'Missing tags: {missingTags}. Please add them to this message.',
|
|
62
|
+
},
|
|
63
|
+
unsupportedTagsValidationError: {
|
|
64
|
+
id: `${prefix}.unsupportedTagsValidationError`,
|
|
65
|
+
defaultMessage:
|
|
66
|
+
'Unsupported tags: {unsupportedTags}. Please remove them from this message.',
|
|
67
|
+
},
|
|
58
68
|
});
|