@capillarytech/creatives-library 7.10.6 → 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 +1 -1
- package/services/api.js +0 -3
- package/utils/common.js +7 -0
- package/v2Containers/CreativesContainer/SlideBoxContent.js +16 -4
- package/v2Containers/CreativesContainer/SlideBoxHeader.js +6 -4
- package/v2Containers/CreativesContainer/index.js +53 -8
- package/v2Containers/SmsTrai/Create/index.js +26 -17
- package/v2Containers/SmsTrai/Edit/index.js +184 -75
- package/v2Containers/SmsTrai/Edit/messages.js +10 -0
- package/v2Containers/SmsWrapper/index.js +14 -10
- package/v2Containers/Templates/index.js +12 -7
- package/v2Containers/TemplatesV2/index.js +2 -1
package/package.json
CHANGED
package/services/api.js
CHANGED
|
@@ -281,9 +281,6 @@ export const deleteAssetById = ({assetId, assetType}) => {
|
|
|
281
281
|
};
|
|
282
282
|
|
|
283
283
|
export const uploadFile = ({file, assetType, fileParams, mode, wechatParams}) => {
|
|
284
|
-
if ( (assetType || '').toLowerCase() === 'image' && fileParams && typeof(fileParams) === 'object' ) {
|
|
285
|
-
fileParams.isGeneratePreview = true;
|
|
286
|
-
}
|
|
287
284
|
const data = new FormData();
|
|
288
285
|
data.append('file', file);
|
|
289
286
|
data.append('fileParam', JSON.stringify(fileParams));
|
package/utils/common.js
CHANGED
|
@@ -255,3 +255,10 @@ export const bytes2Size = (bytes, decimals = 2) => {
|
|
|
255
255
|
|
|
256
256
|
return `${Math.ceil((bytes / Math.pow(k, i)).toFixed(dm))} ${sizes[i]}`;
|
|
257
257
|
};
|
|
258
|
+
|
|
259
|
+
export const isTraiDLTEnable = (isFullMode, smsRegister) => {
|
|
260
|
+
const isTraiDltFeatureForOrg = hasTraiDltFeature();
|
|
261
|
+
const isTariEnableforLib = (!isFullMode && smsRegister === "DLT" ) || isFullMode;
|
|
262
|
+
const isTraiDltFeature = isTraiDltFeatureForOrg && isTariEnableforLib;
|
|
263
|
+
return isTraiDltFeature;
|
|
264
|
+
};
|
|
@@ -142,6 +142,7 @@ function SlideBoxContent(props) {
|
|
|
142
142
|
fbAdManager,
|
|
143
143
|
showDisabledFBInfo,
|
|
144
144
|
orgUnitId,
|
|
145
|
+
smsRegister,
|
|
145
146
|
} = props;
|
|
146
147
|
const type = (messageDetails.type || '').toLowerCase(); // type is context in get tags values : outbound | dvs | referral | loyalty | coupons
|
|
147
148
|
const query = { type: !isFullMode && 'embedded', module: isFullMode ? 'default' : 'library', isEditFromCampaigns: (templateData || {}).isEditFromCampaigns};
|
|
@@ -201,12 +202,18 @@ function SlideBoxContent(props) {
|
|
|
201
202
|
|
|
202
203
|
const getChannelPreviewContent = (templateDataObject) => {
|
|
203
204
|
switch (templateDataObject.type.toUpperCase()) {
|
|
204
|
-
case constants.SMS:
|
|
205
|
-
|
|
205
|
+
case constants.SMS: {
|
|
206
|
+
const isTraiDlt = commonUtil.isTraiDLTEnable(isFullMode, smsRegister);
|
|
207
|
+
const updatedSmsEditor = get(
|
|
208
|
+
templateDataObject,
|
|
209
|
+
`versions.base['updated-sms-editor']`,
|
|
210
|
+
'',
|
|
211
|
+
);
|
|
212
|
+
if (!isTraiDlt || updatedSmsEditor === '') {
|
|
206
213
|
return get(templateDataObject, `versions.base['sms-editor']`);
|
|
207
|
-
} else {
|
|
208
|
-
return templateDataObject.versions.base['updated-sms-editor']?.join('');
|
|
209
214
|
}
|
|
215
|
+
return updatedSmsEditor.join('');
|
|
216
|
+
}
|
|
210
217
|
case constants.LINE: {
|
|
211
218
|
const lineContents = get(templateDataObject, `versions.base.content.messages`, [{}]);
|
|
212
219
|
const previewContent = [];
|
|
@@ -347,6 +354,7 @@ function SlideBoxContent(props) {
|
|
|
347
354
|
messageStrategy={messageStrategy}
|
|
348
355
|
showDisabledFBInfo={showDisabledFBInfo}
|
|
349
356
|
orgUnitId={orgUnitId}
|
|
357
|
+
smsRegister={smsRegister}
|
|
350
358
|
/>
|
|
351
359
|
)}
|
|
352
360
|
{isPreview && (
|
|
@@ -416,6 +424,7 @@ function SlideBoxContent(props) {
|
|
|
416
424
|
onTestContentClicked={onTestContentClicked}
|
|
417
425
|
handleClose={handleClose}
|
|
418
426
|
onCreateComplete={onCreateComplete}
|
|
427
|
+
smsRegister={smsRegister}
|
|
419
428
|
/>
|
|
420
429
|
)}
|
|
421
430
|
{isEditFTP && (
|
|
@@ -463,6 +472,8 @@ function SlideBoxContent(props) {
|
|
|
463
472
|
onPreviewContentClicked={onPreviewContentClicked}
|
|
464
473
|
onTestContentClicked={onTestContentClicked}
|
|
465
474
|
onCreateComplete={onCreateComplete}
|
|
475
|
+
smsRegister={smsRegister}
|
|
476
|
+
onShowTemplates={onShowTemplates}
|
|
466
477
|
/>
|
|
467
478
|
)}
|
|
468
479
|
|
|
@@ -716,5 +727,6 @@ SlideBoxContent.propTypes = {
|
|
|
716
727
|
fbAdManager: PropTypes.string,
|
|
717
728
|
showDisabledFBInfo: PropTypes.boolean,
|
|
718
729
|
orgUnitId: PropTypes.any,
|
|
730
|
+
smsRegister: PropTypes.any,
|
|
719
731
|
};
|
|
720
732
|
export default SlideBoxContent;
|
|
@@ -7,7 +7,7 @@ import PropTypes from 'prop-types';
|
|
|
7
7
|
import messages from './messages';
|
|
8
8
|
import { MAP_TEMPLATE } from '../WeChat/Wrapper/constants';
|
|
9
9
|
import { NO_COMMUNICATION, FTP } from '../App/constants';
|
|
10
|
-
import {
|
|
10
|
+
import { isTraiDLTEnable } from '../../utils/common';
|
|
11
11
|
const PrefixWrapper = styled.div`
|
|
12
12
|
margin-right: 16px;
|
|
13
13
|
`;
|
|
@@ -25,11 +25,12 @@ function getChannelLabel(channel = '') {
|
|
|
25
25
|
|
|
26
26
|
|
|
27
27
|
function SlideBoxHeader(props) {
|
|
28
|
-
const { slidBoxContent, templateData, onShowTemplates, creativesMode, isFullMode, showPrefix, shouldShowTemplateName, channel, templateNameRenderProp, weChatTemplateType, onWeChatMaptemplateStepChange, weChatMaptemplateStep, templateStep } = props;
|
|
28
|
+
const { slidBoxContent, templateData, onShowTemplates, creativesMode, isFullMode, showPrefix, shouldShowTemplateName, channel, templateNameRenderProp, weChatTemplateType, onWeChatMaptemplateStepChange, weChatMaptemplateStep, templateStep, smsRegister } = props;
|
|
29
29
|
const showTemplateNameHeader = isFullMode && shouldShowTemplateName;
|
|
30
30
|
const mapTemplateCreate = !showTemplateNameHeader && slidBoxContent === 'createTemplate' && weChatTemplateType === MAP_TEMPLATE && templateStep !== 'modeSelection';
|
|
31
|
-
const
|
|
32
|
-
const showCreateTraiSMSHeader =
|
|
31
|
+
const isTraiDlt = isTraiDLTEnable(isFullMode, smsRegister);
|
|
32
|
+
const showCreateTraiSMSHeader = isTraiDlt && channel.toLowerCase() === "sms";
|
|
33
|
+
|
|
33
34
|
return (
|
|
34
35
|
<div key="creatives-container-slidebox-header-content">
|
|
35
36
|
{slidBoxContent === 'templates' && !showTemplateNameHeader && (
|
|
@@ -103,5 +104,6 @@ SlideBoxHeader.propTypes = {
|
|
|
103
104
|
channel: PropTypes.string,
|
|
104
105
|
shouldShowTemplateName: PropTypes.bool,
|
|
105
106
|
templateNameRenderProp: PropTypes.func,
|
|
107
|
+
smsRegister: PropTypes.any,
|
|
106
108
|
};
|
|
107
109
|
export default SlideBoxHeader;
|
|
@@ -156,7 +156,7 @@ class Creatives extends React.Component {
|
|
|
156
156
|
this.setState({ isGetFormData: false });
|
|
157
157
|
};
|
|
158
158
|
getTemplateData = (templateData) => { //from consumers to creatives
|
|
159
|
-
const {isFullMode, messageDetails = {}} = this.props;
|
|
159
|
+
const { isFullMode, messageDetails = {}, smsRegister } = this.props;
|
|
160
160
|
const { additionalProperties = {} } = messageDetails;
|
|
161
161
|
if (!isFullMode && templateData) { // for component mode
|
|
162
162
|
const {channel} = templateData;
|
|
@@ -170,9 +170,28 @@ class Creatives extends React.Component {
|
|
|
170
170
|
break;
|
|
171
171
|
}
|
|
172
172
|
case constants.SMS: {
|
|
173
|
-
const
|
|
174
|
-
|
|
175
|
-
|
|
173
|
+
const isTraiDlt = commonUtil.isTraiDLTEnable(isFullMode, smsRegister);
|
|
174
|
+
let formData = {};
|
|
175
|
+
if (isTraiDlt) {
|
|
176
|
+
const {
|
|
177
|
+
template_id = '',
|
|
178
|
+
header = '',
|
|
179
|
+
template_name = '',
|
|
180
|
+
'sms-editor': smsEditor = '',
|
|
181
|
+
'var-mapped': varMapped = {},
|
|
182
|
+
} = templateData;
|
|
183
|
+
formData = {
|
|
184
|
+
template_id,
|
|
185
|
+
header,
|
|
186
|
+
template_name,
|
|
187
|
+
'sms-editor': smsEditor,
|
|
188
|
+
'var-mapped': varMapped,
|
|
189
|
+
};
|
|
190
|
+
} else {
|
|
191
|
+
formData = {
|
|
192
|
+
'sms-editor': templateData.messageBody,
|
|
193
|
+
};
|
|
194
|
+
}
|
|
176
195
|
creativesTemplateData = {
|
|
177
196
|
type: channel,
|
|
178
197
|
name: "Campaign message SMS content",
|
|
@@ -286,14 +305,14 @@ class Creatives extends React.Component {
|
|
|
286
305
|
type: constants.FACEBOOK,
|
|
287
306
|
edit: true,
|
|
288
307
|
selectedFacebookAccount,
|
|
289
|
-
fbContentType
|
|
308
|
+
fbContentType,
|
|
290
309
|
};
|
|
291
310
|
} else {
|
|
292
311
|
creativesTemplateData = {
|
|
293
312
|
selectedMarketingObjective: templateData.selectedMarketingObjective,
|
|
294
313
|
edit: true,
|
|
295
314
|
type: channel,
|
|
296
|
-
fbContentType: templateData.fbContentType
|
|
315
|
+
fbContentType: templateData.fbContentType,
|
|
297
316
|
};
|
|
298
317
|
}
|
|
299
318
|
break;
|
|
@@ -357,7 +376,31 @@ class Creatives extends React.Component {
|
|
|
357
376
|
switch (channel) {
|
|
358
377
|
case constants.SMS:
|
|
359
378
|
if (template.value.base) {
|
|
360
|
-
|
|
379
|
+
const smsBase = template.value.base || {};
|
|
380
|
+
const { isFullMode, smsRegister } = this.props;
|
|
381
|
+
const isTraiDlt = commonUtil.isTraiDLTEnable(isFullMode, smsRegister);
|
|
382
|
+
const {
|
|
383
|
+
'updated-sms-editor': updatedSmsEditor,
|
|
384
|
+
'sms-editor': smsEditor,
|
|
385
|
+
} = smsBase;
|
|
386
|
+
if (!isTraiDlt) {
|
|
387
|
+
templateData.messageBody = smsEditor;
|
|
388
|
+
} else {
|
|
389
|
+
templateData.messageBody = updatedSmsEditor === "" ? smsEditor : updatedSmsEditor.join('');
|
|
390
|
+
const {
|
|
391
|
+
template_id,
|
|
392
|
+
template_name,
|
|
393
|
+
header,
|
|
394
|
+
'var-mapped': varMapped,
|
|
395
|
+
} = smsBase;
|
|
396
|
+
templateData.templateConfigs = {
|
|
397
|
+
templateId: template_id,
|
|
398
|
+
templateName: template_name,
|
|
399
|
+
template: smsEditor,
|
|
400
|
+
registeredSenderIds: header,
|
|
401
|
+
templateVariableMapping: varMapped,
|
|
402
|
+
};
|
|
403
|
+
}
|
|
361
404
|
}
|
|
362
405
|
break;
|
|
363
406
|
case constants.EMAIL:
|
|
@@ -771,7 +814,7 @@ class Creatives extends React.Component {
|
|
|
771
814
|
}
|
|
772
815
|
render() {
|
|
773
816
|
const {slidBoxContent, isGetFormData, showSlideBox, templateData, currentChannel, emailCreateMode, templateStep, isLoadingContent, mobilePushCreateMode, isDiscardMessage, weChatTemplateType, weChatMaptemplateStep} = this.state;
|
|
774
|
-
const {isFullMode, creativesMode, cap, isUploading, channelsToHide, selectedWeChatAccount, forwardedTags, channelsToDisable, selectedOfferDetails, onTestContentClicked, onPreviewContentClicked, getCreativesData, fetchingCmsData, editor} = this.props;
|
|
817
|
+
const {isFullMode, creativesMode, cap, isUploading, channelsToHide, selectedWeChatAccount, forwardedTags, channelsToDisable, selectedOfferDetails, onTestContentClicked, onPreviewContentClicked, getCreativesData, fetchingCmsData, editor, smsRegister} = this.props;
|
|
775
818
|
const mapTemplateCreate = slidBoxContent === 'createTemplate' && weChatTemplateType === MAP_TEMPLATE && templateStep !== 'modeSelection';
|
|
776
819
|
/* TODO: Instead of passing down same props separately to each component down, write common function to these props and pass it accordingly */
|
|
777
820
|
return (
|
|
@@ -795,6 +838,7 @@ class Creatives extends React.Component {
|
|
|
795
838
|
weChatTemplateType={weChatTemplateType}
|
|
796
839
|
showPrefix={!isUploading} // not show back button when email template is being uploaded
|
|
797
840
|
templateStep={this.creativesTemplateSteps[templateStep]}
|
|
841
|
+
smsRegister={smsRegister}
|
|
798
842
|
/>}
|
|
799
843
|
content={
|
|
800
844
|
<SlideBoxContent
|
|
@@ -848,6 +892,7 @@ class Creatives extends React.Component {
|
|
|
848
892
|
handleClose={this.handleCloseSlideBox}
|
|
849
893
|
onFTPSubmit={getCreativesData}
|
|
850
894
|
editor={editor}
|
|
895
|
+
smsRegister={smsRegister}
|
|
851
896
|
messageStrategy={this.props.strategy}
|
|
852
897
|
orgUnitId={this.props.orgUnitId}
|
|
853
898
|
/>
|
|
@@ -18,7 +18,6 @@ import CapNotification from '@capillarytech/cap-ui-library/CapNotification';
|
|
|
18
18
|
import Papa from 'papaparse';
|
|
19
19
|
import cloneDeep from 'lodash/cloneDeep';
|
|
20
20
|
import {
|
|
21
|
-
CAP_SPACE_12,
|
|
22
21
|
CAP_SPACE_16,
|
|
23
22
|
CAP_SPACE_24,
|
|
24
23
|
CAP_SPACE_32,
|
|
@@ -48,7 +47,13 @@ import messages from './messages';
|
|
|
48
47
|
import withCreatives from '../../../hoc/withCreatives';
|
|
49
48
|
|
|
50
49
|
export const SmsTraiCreate = (props) => {
|
|
51
|
-
const {
|
|
50
|
+
const {
|
|
51
|
+
intl,
|
|
52
|
+
actions,
|
|
53
|
+
onCreateComplete,
|
|
54
|
+
isFullMode,
|
|
55
|
+
onShowTemplates,
|
|
56
|
+
} = props;
|
|
52
57
|
const { formatMessage } = intl;
|
|
53
58
|
const [files, setFiles] = useState([]);
|
|
54
59
|
const [errorText, setErrorText] = useState('');
|
|
@@ -90,13 +95,13 @@ export const SmsTraiCreate = (props) => {
|
|
|
90
95
|
const numbersOnly = /^\d+$/;
|
|
91
96
|
let isError = false;
|
|
92
97
|
senderIdString.split(',').forEach((value) => {
|
|
93
|
-
|
|
94
|
-
if (
|
|
95
|
-
if (
|
|
98
|
+
const _value = value.trim();
|
|
99
|
+
if (_value) {
|
|
100
|
+
if (_value.length !== 6) {
|
|
96
101
|
isError = true;
|
|
97
102
|
return;
|
|
98
103
|
}
|
|
99
|
-
if (!(lettersOnly.test(
|
|
104
|
+
if (!(lettersOnly.test(_value) || numbersOnly.test(_value))) {
|
|
100
105
|
isError = true;
|
|
101
106
|
}
|
|
102
107
|
}
|
|
@@ -114,7 +119,7 @@ export const SmsTraiCreate = (props) => {
|
|
|
114
119
|
APPROVAL_STATUS,
|
|
115
120
|
);
|
|
116
121
|
|
|
117
|
-
for (let row = 1; row < transformedResults.length; row
|
|
122
|
+
for (let row = 1; row < transformedResults.length; row += 1) {
|
|
118
123
|
const errorArray = [];
|
|
119
124
|
const headerErrorArray = [];
|
|
120
125
|
const approvalErrorArray = [];
|
|
@@ -204,7 +209,7 @@ export const SmsTraiCreate = (props) => {
|
|
|
204
209
|
return;
|
|
205
210
|
}
|
|
206
211
|
//one of the mandatory template id alias should be available.
|
|
207
|
-
for (let i = 0; i < TEMPLATE_ID_ALIASES.length; i
|
|
212
|
+
for (let i = 0; i < TEMPLATE_ID_ALIASES.length; i += 1) {
|
|
208
213
|
if (cols.includes(TEMPLATE_ID_ALIASES[i])) {
|
|
209
214
|
templateIdAliasPresent.push(TEMPLATE_ID_ALIASES[i]);
|
|
210
215
|
}
|
|
@@ -218,7 +223,7 @@ export const SmsTraiCreate = (props) => {
|
|
|
218
223
|
return;
|
|
219
224
|
}
|
|
220
225
|
//one of the mandatory template message alias should be available.
|
|
221
|
-
for (let i = 0; i < TEMPLATE_MESSAGE_ALIASES.length; i
|
|
226
|
+
for (let i = 0; i < TEMPLATE_MESSAGE_ALIASES.length; i += 1) {
|
|
222
227
|
if (cols.includes(TEMPLATE_MESSAGE_ALIASES[i])) {
|
|
223
228
|
templateMessageAliasPresent.push(TEMPLATE_MESSAGE_ALIASES[i]);
|
|
224
229
|
}
|
|
@@ -306,7 +311,7 @@ export const SmsTraiCreate = (props) => {
|
|
|
306
311
|
});
|
|
307
312
|
}
|
|
308
313
|
//adding validated rejection reason column to original results
|
|
309
|
-
for (let i = 0; i < validatedResults.length; i
|
|
314
|
+
for (let i = 0; i < validatedResults.length; i += 1) {
|
|
310
315
|
results.data[i].push(validatedResults[i][6]);
|
|
311
316
|
}
|
|
312
317
|
updateSaveTemplate(true);
|
|
@@ -356,7 +361,7 @@ export const SmsTraiCreate = (props) => {
|
|
|
356
361
|
|
|
357
362
|
if (rejectionIndex !== -1) {
|
|
358
363
|
tempArray.push(fileData[0]);
|
|
359
|
-
for (let row = 1; row < fileData.length; row
|
|
364
|
+
for (let row = 1; row < fileData.length; row += 1) {
|
|
360
365
|
if (fileData[row][rejectionIndex]) {
|
|
361
366
|
tempArray.push(fileData[row]);
|
|
362
367
|
}
|
|
@@ -392,16 +397,15 @@ export const SmsTraiCreate = (props) => {
|
|
|
392
397
|
tempArray.push(fileData[0]);
|
|
393
398
|
|
|
394
399
|
// filter out non rejected rows
|
|
395
|
-
for (let row = 1; row < fileData.length; row
|
|
400
|
+
for (let row = 1; row < fileData.length; row += 1) {
|
|
396
401
|
if (!fileData[row][rejectionIndex]) {
|
|
397
402
|
tempArray.push(fileData[row]);
|
|
398
403
|
}
|
|
399
404
|
}
|
|
400
|
-
|
|
401
405
|
// Filter out the columns index that needs to save
|
|
402
406
|
const cols = getAllColumnNames(tempArray[0]);
|
|
403
407
|
const indexArray = [];
|
|
404
|
-
for (let i = 0; i < cols.length; i
|
|
408
|
+
for (let i = 0; i < cols.length; i += 1) {
|
|
405
409
|
if (
|
|
406
410
|
SAVED_COLUMNS.includes(cols[i]) ||
|
|
407
411
|
HEADER_ALIASES.includes(cols[i]) ||
|
|
@@ -436,6 +440,7 @@ export const SmsTraiCreate = (props) => {
|
|
|
436
440
|
obj['unicode-validity'] = false;
|
|
437
441
|
obj['updated-sms-editor'] = '';
|
|
438
442
|
obj['var-mapped'] = {};
|
|
443
|
+
obj.header = obj.header.split(',');
|
|
439
444
|
const history = obj;
|
|
440
445
|
history.tabKey = 1;
|
|
441
446
|
savedData.push({
|
|
@@ -451,7 +456,11 @@ export const SmsTraiCreate = (props) => {
|
|
|
451
456
|
{ templates: savedData },
|
|
452
457
|
(resp, errorMessage) => {
|
|
453
458
|
createCallback({ errorMessage });
|
|
454
|
-
|
|
459
|
+
if (isFullMode) {
|
|
460
|
+
onCreateComplete();
|
|
461
|
+
} else {
|
|
462
|
+
onShowTemplates();
|
|
463
|
+
}
|
|
455
464
|
},
|
|
456
465
|
);
|
|
457
466
|
};
|
|
@@ -529,7 +538,7 @@ export const SmsTraiCreate = (props) => {
|
|
|
529
538
|
{previewFileIndex !== null && (
|
|
530
539
|
<>
|
|
531
540
|
<CapRow span={24} className="upload-type-group-create-container">
|
|
532
|
-
|
|
541
|
+
<>
|
|
533
542
|
<CapDivider
|
|
534
543
|
type="horizontal"
|
|
535
544
|
className="upload-file-preview-divider-1"
|
|
@@ -634,7 +643,7 @@ export const SmsTraiCreate = (props) => {
|
|
|
634
643
|
className="upload-file-preview-divider-2"
|
|
635
644
|
/>
|
|
636
645
|
{errorText && <CapError>{errorText}</CapError>}
|
|
637
|
-
|
|
646
|
+
</>
|
|
638
647
|
</CapRow>
|
|
639
648
|
</>
|
|
640
649
|
)}
|
|
@@ -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,12 +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';
|
|
34
|
+
import { updateCharCount } from '../../../utils/smsCharCountV2';
|
|
33
35
|
import {
|
|
34
36
|
CHARLIMIT,
|
|
35
37
|
SMS,
|
|
@@ -41,9 +43,13 @@ import {
|
|
|
41
43
|
ALL,
|
|
42
44
|
LIBRARY,
|
|
43
45
|
} from './constants';
|
|
46
|
+
|
|
44
47
|
let varMap = {};
|
|
48
|
+
let traiData = {};
|
|
49
|
+
let tagValidationResponse = {};
|
|
45
50
|
const { TextArea } = CapInput;
|
|
46
51
|
const { CapLabelInline } = CapLabel;
|
|
52
|
+
|
|
47
53
|
export const SmsTraiEdit = (props) => {
|
|
48
54
|
const {
|
|
49
55
|
intl,
|
|
@@ -58,6 +64,9 @@ export const SmsTraiEdit = (props) => {
|
|
|
58
64
|
metaEntities,
|
|
59
65
|
injectedTags,
|
|
60
66
|
onCreateComplete,
|
|
67
|
+
isFullMode,
|
|
68
|
+
getFormSubscriptionData,
|
|
69
|
+
templateData = {},
|
|
61
70
|
} = props || {};
|
|
62
71
|
const { formatMessage } = intl;
|
|
63
72
|
const [loading, updateLoading] = useState(true);
|
|
@@ -66,7 +75,8 @@ export const SmsTraiEdit = (props) => {
|
|
|
66
75
|
const [tags, updateTags] = useState([]);
|
|
67
76
|
const [textAreaId, updateTextAreaId] = useState();
|
|
68
77
|
const [isValidationError, updateIsValidationError] = useState(false);
|
|
69
|
-
|
|
78
|
+
const [isTagValidationError, updateIsTagValidationError] = useState(false);
|
|
79
|
+
const [totalMessageLength, setTotalMessageLength] = useState(0);
|
|
70
80
|
const SMSTraiFooter = styled.div`
|
|
71
81
|
background-color: ${CAP_WHITE};
|
|
72
82
|
position: fixed;
|
|
@@ -85,32 +95,38 @@ export const SmsTraiEdit = (props) => {
|
|
|
85
95
|
margin-right: ${CAP_SPACE_12};
|
|
86
96
|
}
|
|
87
97
|
`;
|
|
98
|
+
|
|
88
99
|
useEffect(() => {
|
|
100
|
+
//fetching tags
|
|
101
|
+
const { type, module } = location.query || {};
|
|
102
|
+
const isEmbedded = type === EMBEDDED;
|
|
103
|
+
const query = {
|
|
104
|
+
layout: SMS,
|
|
105
|
+
type: TAG,
|
|
106
|
+
context: isEmbedded ? module : DEFAULT,
|
|
107
|
+
embedded: isEmbedded ? type : FULL,
|
|
108
|
+
};
|
|
109
|
+
if (getDefaultTags) {
|
|
110
|
+
query.context = getDefaultTags;
|
|
111
|
+
}
|
|
112
|
+
globalActions.fetchSchemaForEntity(query);
|
|
113
|
+
//fetching template data in fullmode
|
|
89
114
|
const { id } = params || {};
|
|
90
115
|
if (id) {
|
|
91
116
|
actions.getTemplateDetails(id);
|
|
92
|
-
//fetching tags
|
|
93
|
-
const query = {
|
|
94
|
-
layout: SMS,
|
|
95
|
-
type: TAG,
|
|
96
|
-
context:
|
|
97
|
-
location.query.type === EMBEDDED ? location.query.module : DEFAULT,
|
|
98
|
-
embedded: location.query.type === EMBEDDED ? location.query.type : FULL,
|
|
99
|
-
};
|
|
100
|
-
if (getDefaultTags) {
|
|
101
|
-
query.context = getDefaultTags;
|
|
102
|
-
}
|
|
103
|
-
globalActions.fetchSchemaForEntity(query);
|
|
104
117
|
}
|
|
118
|
+
//cleanup code
|
|
105
119
|
return () => {
|
|
106
120
|
actions.resetEditTemplate();
|
|
121
|
+
varMap = {};
|
|
107
122
|
};
|
|
108
123
|
}, []);
|
|
109
124
|
|
|
110
125
|
//computing placeholder array for mapping values and rendering dynamic form
|
|
111
126
|
useEffect(() => {
|
|
112
|
-
|
|
113
|
-
|
|
127
|
+
traiData = isFullMode ? templateDetails : templateData;
|
|
128
|
+
if (traiData && !isEmpty(traiData)) {
|
|
129
|
+
let msg = get(traiData, `versions.base.sms-editor`);
|
|
114
130
|
const templateMessageArray = [];
|
|
115
131
|
//converting sms-editor string to an array split at '{#var#}'
|
|
116
132
|
//split and push string before '{#var#}[0 to index]', push '{#var#}',
|
|
@@ -126,7 +142,6 @@ export const SmsTraiEdit = (props) => {
|
|
|
126
142
|
break;
|
|
127
143
|
}
|
|
128
144
|
}
|
|
129
|
-
|
|
130
145
|
const filteredTemplateMessageArray = templateMessageArray.filter(
|
|
131
146
|
(i) => i.trim() !== '',
|
|
132
147
|
);
|
|
@@ -134,36 +149,46 @@ export const SmsTraiEdit = (props) => {
|
|
|
134
149
|
//stop spinner
|
|
135
150
|
updateLoading(false);
|
|
136
151
|
}
|
|
137
|
-
}, [templateDetails]);
|
|
152
|
+
}, [templateDetails || templateData]);
|
|
138
153
|
|
|
154
|
+
//compute/get varMapped and updated-sms-editor
|
|
139
155
|
useEffect(() => {
|
|
140
156
|
if (tempMsgArray.length !== 0) {
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
157
|
+
const traiBase = traiData?.versions?.base || {};
|
|
158
|
+
const {
|
|
159
|
+
'var-mapped': varMapped = {},
|
|
160
|
+
'updated-sms-editor': traiSmsEditor = '',
|
|
161
|
+
} = traiBase;
|
|
162
|
+
//if varMap and updated-sms-editor is already present on non first edits,use those values
|
|
163
|
+
if (!isEmpty(varMapped)) {
|
|
164
|
+
varMap = cloneDeep(varMapped);
|
|
165
|
+
if (isFullMode) {
|
|
166
|
+
setUpdatedSmsEditor(traiSmsEditor);
|
|
167
|
+
} else {
|
|
168
|
+
computeUpdatedSmsEditor();
|
|
169
|
+
}
|
|
147
170
|
} else {
|
|
148
|
-
//computing varMap for first edit
|
|
171
|
+
//computing and setting varMap for first edit
|
|
149
172
|
let counter = 1;
|
|
150
|
-
for (let i = 0; i < tempMsgArray.length; i
|
|
173
|
+
for (let i = 0; i < tempMsgArray.length; i += 1) {
|
|
151
174
|
if (tempMsgArray[i] === SMS_TRAI_VAR) {
|
|
152
175
|
const nextElem =
|
|
153
176
|
tempMsgArray[i === tempMsgArray.length - 1 ? 0 : i + 1];
|
|
154
177
|
if (tempMsgArray[i] !== nextElem) {
|
|
155
|
-
varMap[`${tempMsgArray[i]}_${i - counter + 1}`] = {
|
|
178
|
+
varMap[`${tempMsgArray[i]}_${(i - counter) + 1}`] = {
|
|
156
179
|
data: '',
|
|
157
180
|
count: counter,
|
|
158
181
|
};
|
|
159
182
|
counter = 1;
|
|
160
183
|
} else {
|
|
161
|
-
counter
|
|
184
|
+
counter += 1;
|
|
162
185
|
}
|
|
163
186
|
}
|
|
164
187
|
}
|
|
165
188
|
setUpdatedSmsEditor(tempMsgArray);
|
|
166
189
|
}
|
|
190
|
+
// calcaulate message length here
|
|
191
|
+
calculateTotalMessageLength();
|
|
167
192
|
}
|
|
168
193
|
}, [tempMsgArray]);
|
|
169
194
|
|
|
@@ -176,6 +201,41 @@ export const SmsTraiEdit = (props) => {
|
|
|
176
201
|
}
|
|
177
202
|
}, []);
|
|
178
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
|
+
|
|
223
|
+
const computeUpdatedSmsEditor = () => {
|
|
224
|
+
const updatedSmsArray = [...tempMsgArray];
|
|
225
|
+
for (const key in varMap) {
|
|
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) {
|
|
228
|
+
//when multiple "#var#" come continuously ,it is considered as 1 textbox
|
|
229
|
+
if (i === 0) {
|
|
230
|
+
updatedSmsArray[index] = varMap[key].data; //data for first #var# of the textbox
|
|
231
|
+
} else {
|
|
232
|
+
updatedSmsArray[index + i] = ''; //"" for remaining #var# of a textbox
|
|
233
|
+
}
|
|
234
|
+
}
|
|
235
|
+
}
|
|
236
|
+
setUpdatedSmsEditor(updatedSmsArray);
|
|
237
|
+
};
|
|
238
|
+
|
|
179
239
|
//Saving on done start
|
|
180
240
|
const onUpdateTemplateComplete = (editResponse, errorMsg) => {
|
|
181
241
|
if (editResponse?.templateId) {
|
|
@@ -191,16 +251,29 @@ export const SmsTraiEdit = (props) => {
|
|
|
191
251
|
}
|
|
192
252
|
};
|
|
193
253
|
const onDoneCallback = () => {
|
|
194
|
-
if (updatedSmsEditor.includes(SMS_TRAI_VAR)) {
|
|
254
|
+
if (updatedSmsEditor.includes(SMS_TRAI_VAR) && !isFullMode) {
|
|
195
255
|
//during save textbox should not be empty
|
|
196
256
|
updateIsValidationError(true);
|
|
197
257
|
} else {
|
|
198
258
|
//start spinner
|
|
199
259
|
updateLoading(true);
|
|
200
|
-
|
|
201
|
-
|
|
202
|
-
|
|
203
|
-
|
|
260
|
+
const traiVersions = traiData.versions || {};
|
|
261
|
+
traiVersions.base = {
|
|
262
|
+
...traiVersions.base,
|
|
263
|
+
'var-mapped': varMap,
|
|
264
|
+
'updated-sms-editor': updatedSmsEditor,
|
|
265
|
+
};
|
|
266
|
+
traiVersions.history = [traiVersions.base];
|
|
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
|
+
}
|
|
204
277
|
}
|
|
205
278
|
};
|
|
206
279
|
//Saving on done end
|
|
@@ -209,17 +282,16 @@ export const SmsTraiEdit = (props) => {
|
|
|
209
282
|
useEffect(() => {
|
|
210
283
|
let tag =
|
|
211
284
|
metaEntities && metaEntities.tags ? metaEntities.tags.standard : [];
|
|
212
|
-
|
|
213
|
-
|
|
214
|
-
location.query.module === LIBRARY &&
|
|
215
|
-
!getDefaultTags
|
|
216
|
-
) {
|
|
285
|
+
const { type, module } = location.query || {};
|
|
286
|
+
if (type === EMBEDDED && module === LIBRARY && !getDefaultTags) {
|
|
217
287
|
tag = supportedTags;
|
|
218
288
|
}
|
|
219
289
|
updateTags(tag);
|
|
220
290
|
}, [metaEntities]);
|
|
221
291
|
|
|
222
292
|
const handleOnTagsContextChange = (data) => {
|
|
293
|
+
const { type } = location.query || {};
|
|
294
|
+
const isEmbedded = type === EMBEDDED;
|
|
223
295
|
const query = {
|
|
224
296
|
layout: SMS,
|
|
225
297
|
type: TAG,
|
|
@@ -227,7 +299,7 @@ export const SmsTraiEdit = (props) => {
|
|
|
227
299
|
(data || '').toLowerCase() === ALL
|
|
228
300
|
? DEFAULT
|
|
229
301
|
: (data || '').toLowerCase(),
|
|
230
|
-
embedded:
|
|
302
|
+
embedded: isEmbedded ? type : FULL,
|
|
231
303
|
};
|
|
232
304
|
globalActions.fetchSchemaForEntity(query);
|
|
233
305
|
};
|
|
@@ -240,7 +312,7 @@ export const SmsTraiEdit = (props) => {
|
|
|
240
312
|
for (
|
|
241
313
|
let i = 0;
|
|
242
314
|
i < varMap[`${SMS_TRAI_VAR}_${textAreaId}`].count;
|
|
243
|
-
i
|
|
315
|
+
i += 1
|
|
244
316
|
) {
|
|
245
317
|
tempArr[textAreaId + i] = '';
|
|
246
318
|
}
|
|
@@ -259,23 +331,24 @@ export const SmsTraiEdit = (props) => {
|
|
|
259
331
|
|
|
260
332
|
// on change event of Text Area
|
|
261
333
|
const textAreaValueChange = ({ target: { value, id } }) => {
|
|
262
|
-
|
|
334
|
+
const _id = Number(id);
|
|
263
335
|
const arr = [...updatedSmsEditor];
|
|
264
|
-
varMap[`${SMS_TRAI_VAR}_${
|
|
336
|
+
varMap[`${SMS_TRAI_VAR}_${_id}`].data = value;
|
|
265
337
|
if (value === '') {
|
|
266
|
-
for (let i = 0; i < varMap[`${SMS_TRAI_VAR}_${
|
|
267
|
-
arr[
|
|
338
|
+
for (let i = 0; i < varMap[`${SMS_TRAI_VAR}_${_id}`].count; i += 1) {
|
|
339
|
+
arr[_id + i] = SMS_TRAI_VAR;
|
|
268
340
|
}
|
|
269
341
|
} else {
|
|
270
|
-
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) {
|
|
271
343
|
if (i === 0) {
|
|
272
|
-
arr[
|
|
344
|
+
arr[_id] = varMap[`${SMS_TRAI_VAR}_${_id}`].data;
|
|
273
345
|
} else {
|
|
274
|
-
arr[
|
|
346
|
+
arr[_id + i] = '';
|
|
275
347
|
}
|
|
276
348
|
}
|
|
277
349
|
}
|
|
278
350
|
setUpdatedSmsEditor(arr);
|
|
351
|
+
calculateTotalMessageLength();
|
|
279
352
|
};
|
|
280
353
|
|
|
281
354
|
const textAreaValue = (idValue) => {
|
|
@@ -285,9 +358,8 @@ export const SmsTraiEdit = (props) => {
|
|
|
285
358
|
updatedSmsEditor[idValue] !== SMS_TRAI_VAR
|
|
286
359
|
) {
|
|
287
360
|
return updatedSmsEditor[idValue];
|
|
288
|
-
} else {
|
|
289
|
-
return '';
|
|
290
361
|
}
|
|
362
|
+
return '';
|
|
291
363
|
}
|
|
292
364
|
return '';
|
|
293
365
|
};
|
|
@@ -308,19 +380,19 @@ export const SmsTraiEdit = (props) => {
|
|
|
308
380
|
</CapHeading>
|
|
309
381
|
);
|
|
310
382
|
}
|
|
383
|
+
return <></>;
|
|
311
384
|
};
|
|
312
385
|
|
|
313
386
|
const renderedContent = () => {
|
|
314
387
|
const renderArray = [];
|
|
315
388
|
if (tempMsgArray?.length !== 0) {
|
|
316
389
|
let varCount = 0;
|
|
317
|
-
tempMsgArray.
|
|
390
|
+
tempMsgArray.forEach((elem, index) => {
|
|
318
391
|
let prevElem = '';
|
|
319
392
|
if (elem.includes(SMS_TRAI_VAR)) {
|
|
320
393
|
prevElem =
|
|
321
394
|
tempMsgArray[[index === 0 ? tempMsgArray.length - 1 : index - 1]];
|
|
322
|
-
varCount
|
|
323
|
-
totalVarCount++;
|
|
395
|
+
varCount += 1;
|
|
324
396
|
if (prevElem !== SMS_TRAI_VAR) {
|
|
325
397
|
renderArray.push(
|
|
326
398
|
<TextArea
|
|
@@ -371,42 +443,76 @@ export const SmsTraiEdit = (props) => {
|
|
|
371
443
|
return renderArray;
|
|
372
444
|
};
|
|
373
445
|
|
|
374
|
-
|
|
375
|
-
|
|
376
|
-
|
|
377
|
-
|
|
378
|
-
|
|
379
|
-
|
|
380
|
-
|
|
381
|
-
|
|
382
|
-
{formatMessage(messages.totalCharacters, {
|
|
383
|
-
smsCount: Math.ceil(totalMessageLength / 160),
|
|
384
|
-
number: totalMessageLength,
|
|
385
|
-
})}
|
|
386
|
-
</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>
|
|
387
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>;
|
|
388
492
|
};
|
|
389
493
|
|
|
390
494
|
return (
|
|
391
495
|
<>
|
|
392
496
|
<CapSpin spinning={loading}>
|
|
393
497
|
<CapRow>
|
|
394
|
-
{
|
|
498
|
+
{traiData && !isEmpty(traiData) && (
|
|
395
499
|
<TraiEditTemplateDetails>
|
|
396
500
|
<CapLabelInline type="label1">
|
|
397
501
|
{formatMessage(messages.templateLabel)}
|
|
398
502
|
</CapLabelInline>
|
|
399
503
|
<CapLabelInline type="label2">
|
|
400
|
-
{
|
|
504
|
+
{traiData.versions.base.template_name}
|
|
401
505
|
</CapLabelInline>
|
|
506
|
+
|
|
402
507
|
<CapLabelInline type="label1">
|
|
403
508
|
{formatMessage(messages.traiEditSeperator)}
|
|
404
509
|
</CapLabelInline>
|
|
510
|
+
|
|
405
511
|
<CapLabelInline type="label1">
|
|
406
512
|
{formatMessage(messages.senderIdlabel)}
|
|
407
513
|
</CapLabelInline>
|
|
408
514
|
<CapLabelInline type="label2">
|
|
409
|
-
{
|
|
515
|
+
{traiData.versions.base.header.join(', ')}
|
|
410
516
|
</CapLabelInline>
|
|
411
517
|
</TraiEditTemplateDetails>
|
|
412
518
|
)}
|
|
@@ -437,6 +543,7 @@ export const SmsTraiEdit = (props) => {
|
|
|
437
543
|
{renderedContent()}
|
|
438
544
|
</CapRow>
|
|
439
545
|
<CapRow>{smsLengthForVar()}</CapRow>
|
|
546
|
+
{isTagValidationError && tagValidationErrorMessage()}
|
|
440
547
|
<div style={{ marginBottom: '100px' }} />
|
|
441
548
|
</CapColumn>
|
|
442
549
|
<CapColumn span={10}>
|
|
@@ -447,7 +554,11 @@ export const SmsTraiEdit = (props) => {
|
|
|
447
554
|
</CapColumn>
|
|
448
555
|
</CapRow>
|
|
449
556
|
<SMSTraiFooter>
|
|
450
|
-
<CapButton
|
|
557
|
+
<CapButton
|
|
558
|
+
onClick={onDoneCallback}
|
|
559
|
+
className="create-msg"
|
|
560
|
+
disabled={isTagValidationError}
|
|
561
|
+
>
|
|
451
562
|
<FormattedMessage {...messages.saveButtonLabel} />
|
|
452
563
|
</CapButton>
|
|
453
564
|
<CapButton
|
|
@@ -469,11 +580,9 @@ const mapStateToProps = createStructuredSelector({
|
|
|
469
580
|
injectedTags: setInjectedTags(),
|
|
470
581
|
});
|
|
471
582
|
|
|
472
|
-
const mapDispatchToProps = (dispatch) => {
|
|
473
|
-
|
|
474
|
-
|
|
475
|
-
};
|
|
476
|
-
};
|
|
583
|
+
const mapDispatchToProps = (dispatch) => ({
|
|
584
|
+
actions: bindActionCreators(smsEditActions, dispatch),
|
|
585
|
+
});
|
|
477
586
|
|
|
478
587
|
export default withCreatives({
|
|
479
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
|
});
|
|
@@ -6,7 +6,7 @@
|
|
|
6
6
|
import PropTypes from 'prop-types';
|
|
7
7
|
import React from 'react';
|
|
8
8
|
import SmsCreate from '../Sms/Create';
|
|
9
|
-
import {
|
|
9
|
+
import { isTraiDLTEnable } from '../../utils/common';
|
|
10
10
|
import SmsEdit from '../Sms/Edit';
|
|
11
11
|
import SmsTraiCreate from '../SmsTrai/Create';
|
|
12
12
|
import SmsTraiEdit from '../SmsTrai/Edit';
|
|
@@ -26,7 +26,9 @@ const SmsWrapper = (props) => {
|
|
|
26
26
|
onPreviewContentClicked,
|
|
27
27
|
onTestContentClicked,
|
|
28
28
|
onCreateComplete,
|
|
29
|
-
handleClose
|
|
29
|
+
handleClose,
|
|
30
|
+
smsRegister,
|
|
31
|
+
onShowTemplates,
|
|
30
32
|
} = props;
|
|
31
33
|
|
|
32
34
|
const smsProps = {
|
|
@@ -43,13 +45,15 @@ const SmsWrapper = (props) => {
|
|
|
43
45
|
onPreviewContentClicked,
|
|
44
46
|
onTestContentClicked,
|
|
45
47
|
};
|
|
46
|
-
const
|
|
48
|
+
const isTraiDlt = isTraiDLTEnable(isFullMode, smsRegister);
|
|
47
49
|
return <>
|
|
48
50
|
{
|
|
49
|
-
isCreateSms && (
|
|
51
|
+
isCreateSms && (isTraiDlt ?
|
|
50
52
|
<SmsTraiCreate
|
|
51
53
|
isComponent
|
|
52
|
-
{...smsProps}
|
|
54
|
+
{...smsProps}
|
|
55
|
+
onShowTemplates={onShowTemplates}
|
|
56
|
+
/> :
|
|
53
57
|
<SmsCreate
|
|
54
58
|
isComponent {
|
|
55
59
|
...smsProps
|
|
@@ -57,16 +61,16 @@ const SmsWrapper = (props) => {
|
|
|
57
61
|
/>
|
|
58
62
|
)
|
|
59
63
|
}
|
|
60
|
-
{isEditSms && (
|
|
64
|
+
{isEditSms && (isTraiDlt ?
|
|
61
65
|
<SmsTraiEdit
|
|
62
66
|
{...smsProps}
|
|
63
67
|
params={{id: templateData._id}}
|
|
64
68
|
templateData={templateData}
|
|
65
69
|
handleClose={handleClose}
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
+
/> : <SmsEdit
|
|
71
|
+
{...smsProps}
|
|
72
|
+
params={{id: templateData._id}}
|
|
73
|
+
templateData={templateData}
|
|
70
74
|
/>
|
|
71
75
|
)}
|
|
72
76
|
</>;
|
|
@@ -155,7 +155,7 @@ export class Templates extends React.Component { // eslint-disable-line react/pr
|
|
|
155
155
|
this.prepareMobilePushPreviewData = this.prepareMobilePushPreviewData.bind(this);
|
|
156
156
|
this.menuOnClickEvent = this.menuOnClickEvent.bind(this);
|
|
157
157
|
}
|
|
158
|
-
|
|
158
|
+
|
|
159
159
|
componentWillMount() {
|
|
160
160
|
if (this.state.channel === '') {
|
|
161
161
|
let channel = '';
|
|
@@ -207,7 +207,11 @@ export class Templates extends React.Component { // eslint-disable-line react/pr
|
|
|
207
207
|
}
|
|
208
208
|
}
|
|
209
209
|
}
|
|
210
|
-
|
|
210
|
+
checkDLTfeatureEnable = () => {
|
|
211
|
+
const {smsRegister, isFullMode} = this.props;
|
|
212
|
+
const isTraiDlt = commonUtil.isTraiDLTEnable(isFullMode, smsRegister);
|
|
213
|
+
return isTraiDlt;
|
|
214
|
+
}
|
|
211
215
|
componentDidMount() {
|
|
212
216
|
if (this.props.location.query.type === 'embedded' && this.isEnabledInLibraryModule("setLocale")) {
|
|
213
217
|
this.setLocale();
|
|
@@ -223,7 +227,7 @@ export class Templates extends React.Component { // eslint-disable-line react/pr
|
|
|
223
227
|
queryParams.page = this.state.page;
|
|
224
228
|
queryParams.perPage = this.state.perPageLimit;
|
|
225
229
|
const channel = this.state.channel;
|
|
226
|
-
const isTraiDltFeature =
|
|
230
|
+
const isTraiDltFeature = this.checkDLTfeatureEnable();
|
|
227
231
|
if ((this.state.channel || '').toLowerCase() === "sms" && isTraiDltFeature) {
|
|
228
232
|
queryParams.traiEnable = true;
|
|
229
233
|
}
|
|
@@ -586,7 +590,7 @@ export class Templates extends React.Component { // eslint-disable-line react/pr
|
|
|
586
590
|
if (activeMode === ACCOUNT_SELECTION_MODE) {
|
|
587
591
|
this.setTemplatesMode();
|
|
588
592
|
}
|
|
589
|
-
const isTraiDltFeature =
|
|
593
|
+
const isTraiDltFeature = this.checkDLTfeatureEnable();
|
|
590
594
|
if ((this.state.channel || '').toLowerCase() === "sms" && isTraiDltFeature) {
|
|
591
595
|
queryParams.traiEnable = true;
|
|
592
596
|
}
|
|
@@ -628,7 +632,7 @@ export class Templates extends React.Component { // eslint-disable-line react/pr
|
|
|
628
632
|
}
|
|
629
633
|
}
|
|
630
634
|
}
|
|
631
|
-
|
|
635
|
+
|
|
632
636
|
this.setState({page, templatesCount}, () => {
|
|
633
637
|
queryParams.page = page;
|
|
634
638
|
queryParams.perPage = this.state.perPageLimit;
|
|
@@ -670,7 +674,7 @@ export class Templates extends React.Component { // eslint-disable-line react/pr
|
|
|
670
674
|
}
|
|
671
675
|
if (currentChannel === SMS) {
|
|
672
676
|
filteredTemplates = this.filterSMSTemplates(templates);
|
|
673
|
-
isTraiDltFeature =
|
|
677
|
+
isTraiDltFeature = this.checkDLTfeatureEnable();
|
|
674
678
|
}
|
|
675
679
|
const cardDataList = filteredTemplates && filteredTemplates.length ? map(filteredTemplates, (template) => {
|
|
676
680
|
const templateData =
|
|
@@ -2054,7 +2058,7 @@ export class Templates extends React.Component { // eslint-disable-line react/pr
|
|
|
2054
2058
|
const isfilterContentVisisble = true;
|
|
2055
2059
|
const isWechatEmbedded = !this.props.isFullMode && channel.toUpperCase() === WECHAT;
|
|
2056
2060
|
const channelLowerCase = (channel || '').toLowerCase();
|
|
2057
|
-
const isTraiDltFeature =
|
|
2061
|
+
const isTraiDltFeature = this.checkDLTfeatureEnable();
|
|
2058
2062
|
const filterContent = (( isfilterContentVisisble || [WECHAT, MOBILE_PUSH].includes(this.state.channel.toUpperCase())) && <div className="action-container">
|
|
2059
2063
|
{isfilterContentVisisble && <CapInput.Search
|
|
2060
2064
|
className="search-text"
|
|
@@ -2271,6 +2275,7 @@ Templates.propTypes = {
|
|
|
2271
2275
|
router: PropTypes.object,
|
|
2272
2276
|
viberActions: PropTypes.object,
|
|
2273
2277
|
facebookActions: PropTypes.object,
|
|
2278
|
+
smsRegister: PropTypes.any,
|
|
2274
2279
|
};
|
|
2275
2280
|
|
|
2276
2281
|
const mapStateToProps = createStructuredSelector({
|
|
@@ -199,7 +199,7 @@ export class TemplatesV2 extends React.Component { // eslint-disable-line react/
|
|
|
199
199
|
getTemplatesComponent(channel) {
|
|
200
200
|
// const templates = this.props.Templates[`${channel}Templates`];
|
|
201
201
|
let query = {};
|
|
202
|
-
const {isFullMode, messageStrategy} = this.props;
|
|
202
|
+
const {isFullMode, messageStrategy, smsRegister} = this.props;
|
|
203
203
|
if (!isFullMode) {
|
|
204
204
|
query = {type: 'embedded', module: 'library'};
|
|
205
205
|
switch (channel) {
|
|
@@ -232,6 +232,7 @@ export class TemplatesV2 extends React.Component { // eslint-disable-line react/
|
|
|
232
232
|
renderNewCardGrid={this.getTemplateDataForGrid}
|
|
233
233
|
handlePeviewTemplate={this.props.handlePeviewTemplate}
|
|
234
234
|
messageStrategy={this.props.messageStrategy}
|
|
235
|
+
smsRegister={smsRegister}
|
|
235
236
|
/>);
|
|
236
237
|
}
|
|
237
238
|
}
|