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