@capillarytech/creatives-library 7.10.5 → 7.10.6
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/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 +5 -14
- package/v2Containers/SmsTrai/Edit/index.js +33 -90
- 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
|
-
};
|
|
@@ -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?.split(','),
|
|
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('');
|
|
@@ -456,11 +451,7 @@ export const SmsTraiCreate = (props) => {
|
|
|
456
451
|
{ templates: savedData },
|
|
457
452
|
(resp, errorMessage) => {
|
|
458
453
|
createCallback({ errorMessage });
|
|
459
|
-
|
|
460
|
-
onCreateComplete();
|
|
461
|
-
} else {
|
|
462
|
-
onShowTemplates();
|
|
463
|
-
}
|
|
454
|
+
onCreateComplete();
|
|
464
455
|
},
|
|
465
456
|
);
|
|
466
457
|
};
|
|
@@ -538,7 +529,7 @@ export const SmsTraiCreate = (props) => {
|
|
|
538
529
|
{previewFileIndex !== null && (
|
|
539
530
|
<>
|
|
540
531
|
<CapRow span={24} className="upload-type-group-create-container">
|
|
541
|
-
|
|
532
|
+
<div className="upload-file-preview">
|
|
542
533
|
<CapDivider
|
|
543
534
|
type="horizontal"
|
|
544
535
|
className="upload-file-preview-divider-1"
|
|
@@ -643,7 +634,7 @@ export const SmsTraiCreate = (props) => {
|
|
|
643
634
|
className="upload-file-preview-divider-2"
|
|
644
635
|
/>
|
|
645
636
|
{errorText && <CapError>{errorText}</CapError>}
|
|
646
|
-
|
|
637
|
+
</div>
|
|
647
638
|
</CapRow>
|
|
648
639
|
</>
|
|
649
640
|
)}
|
|
@@ -29,7 +29,6 @@ import messages from './messages';
|
|
|
29
29
|
import TagList from '../../TagList';
|
|
30
30
|
import TemplatePreview from '../../../v2Components/TemplatePreview';
|
|
31
31
|
import withCreatives from '../../../hoc/withCreatives';
|
|
32
|
-
import { validateTags } from '../../../utils/tagValidations';
|
|
33
32
|
|
|
34
33
|
import {
|
|
35
34
|
CHARLIMIT,
|
|
@@ -43,7 +42,6 @@ import {
|
|
|
43
42
|
LIBRARY,
|
|
44
43
|
} from './constants';
|
|
45
44
|
let varMap = {};
|
|
46
|
-
let traiData = {};
|
|
47
45
|
const { TextArea } = CapInput;
|
|
48
46
|
const { CapLabelInline } = CapLabel;
|
|
49
47
|
export const SmsTraiEdit = (props) => {
|
|
@@ -60,9 +58,6 @@ export const SmsTraiEdit = (props) => {
|
|
|
60
58
|
metaEntities,
|
|
61
59
|
injectedTags,
|
|
62
60
|
onCreateComplete,
|
|
63
|
-
isFullMode,
|
|
64
|
-
getFormSubscriptionData,
|
|
65
|
-
templateData = {},
|
|
66
61
|
} = props || {};
|
|
67
62
|
const { formatMessage } = intl;
|
|
68
63
|
const [loading, updateLoading] = useState(true);
|
|
@@ -71,7 +66,6 @@ export const SmsTraiEdit = (props) => {
|
|
|
71
66
|
const [tags, updateTags] = useState([]);
|
|
72
67
|
const [textAreaId, updateTextAreaId] = useState();
|
|
73
68
|
const [isValidationError, updateIsValidationError] = useState(false);
|
|
74
|
-
const [isTagValidationError, updateIsTagValidationError] = useState(false);
|
|
75
69
|
let totalVarCount = 0;
|
|
76
70
|
const SMSTraiFooter = styled.div`
|
|
77
71
|
background-color: ${CAP_WHITE};
|
|
@@ -92,35 +86,31 @@ export const SmsTraiEdit = (props) => {
|
|
|
92
86
|
}
|
|
93
87
|
`;
|
|
94
88
|
useEffect(() => {
|
|
95
|
-
//fetching tags
|
|
96
|
-
const { type, module } = location.query || {};
|
|
97
|
-
const isEmbedded = type === EMBEDDED;
|
|
98
|
-
const query = {
|
|
99
|
-
layout: SMS,
|
|
100
|
-
type: TAG,
|
|
101
|
-
context: isEmbedded ? module : DEFAULT,
|
|
102
|
-
embedded: isEmbedded ? type : FULL,
|
|
103
|
-
};
|
|
104
|
-
if (getDefaultTags) {
|
|
105
|
-
query.context = getDefaultTags;
|
|
106
|
-
}
|
|
107
|
-
globalActions.fetchSchemaForEntity(query);
|
|
108
|
-
|
|
109
89
|
const { id } = params || {};
|
|
110
90
|
if (id) {
|
|
111
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);
|
|
112
104
|
}
|
|
113
105
|
return () => {
|
|
114
106
|
actions.resetEditTemplate();
|
|
115
|
-
varMap = {};
|
|
116
107
|
};
|
|
117
108
|
}, []);
|
|
118
109
|
|
|
119
110
|
//computing placeholder array for mapping values and rendering dynamic form
|
|
120
111
|
useEffect(() => {
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
let msg = get(traiData, `versions.base.sms-editor`);
|
|
112
|
+
if (templateDetails && !isEmpty(templateDetails)) {
|
|
113
|
+
let msg = get(templateDetails, `versions.base.sms-editor`);
|
|
124
114
|
const templateMessageArray = [];
|
|
125
115
|
//converting sms-editor string to an array split at '{#var#}'
|
|
126
116
|
//split and push string before '{#var#}[0 to index]', push '{#var#}',
|
|
@@ -144,23 +134,16 @@ export const SmsTraiEdit = (props) => {
|
|
|
144
134
|
//stop spinner
|
|
145
135
|
updateLoading(false);
|
|
146
136
|
}
|
|
147
|
-
}, [templateDetails
|
|
137
|
+
}, [templateDetails]);
|
|
148
138
|
|
|
149
139
|
useEffect(() => {
|
|
150
140
|
if (tempMsgArray.length !== 0) {
|
|
151
|
-
const traiBase = traiData?.versions?.base || {};
|
|
152
|
-
const {
|
|
153
|
-
['var-mapped']: varMapped = {},
|
|
154
|
-
['updated-sms-editor']: traiSmsEditor = '',
|
|
155
|
-
} = traiBase;
|
|
156
141
|
//if varMapped and updated-sms-editor is already present on non first edits
|
|
157
|
-
if (!isEmpty(
|
|
158
|
-
varMap = cloneDeep(
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
computeUpdatedSmsEditor();
|
|
163
|
-
}
|
|
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
|
+
);
|
|
164
147
|
} else {
|
|
165
148
|
//computing varMap for first edit
|
|
166
149
|
let counter = 1;
|
|
@@ -193,22 +176,6 @@ export const SmsTraiEdit = (props) => {
|
|
|
193
176
|
}
|
|
194
177
|
}, []);
|
|
195
178
|
|
|
196
|
-
const computeUpdatedSmsEditor = () => {
|
|
197
|
-
const updatedSmsArray = [...tempMsgArray];
|
|
198
|
-
for (const key in varMap) {
|
|
199
|
-
let index = Number(key.slice(8)); //Eg: -> extracting index 1 from keys like {#var# } _1
|
|
200
|
-
for (let i = 0; i < varMap[key].count; i++) {
|
|
201
|
-
//when multiple "#var#" come continuously ,it is considered as 1 textbox
|
|
202
|
-
if (i === 0) {
|
|
203
|
-
updatedSmsArray[index] = varMap[key].data; //data for first #var# of the textbox
|
|
204
|
-
} else {
|
|
205
|
-
updatedSmsArray[index + i] = ''; //"" for remaining #var# of a textbox
|
|
206
|
-
}
|
|
207
|
-
}
|
|
208
|
-
}
|
|
209
|
-
setUpdatedSmsEditor(updatedSmsArray);
|
|
210
|
-
};
|
|
211
|
-
|
|
212
179
|
//Saving on done start
|
|
213
180
|
const onUpdateTemplateComplete = (editResponse, errorMsg) => {
|
|
214
181
|
if (editResponse?.templateId) {
|
|
@@ -230,21 +197,10 @@ export const SmsTraiEdit = (props) => {
|
|
|
230
197
|
} else {
|
|
231
198
|
//start spinner
|
|
232
199
|
updateLoading(true);
|
|
233
|
-
|
|
234
|
-
|
|
235
|
-
|
|
236
|
-
|
|
237
|
-
'updated-sms-editor': updatedSmsEditor,
|
|
238
|
-
};
|
|
239
|
-
traiVersions.history = [traiVersions.base];
|
|
240
|
-
isFullMode
|
|
241
|
-
? actions.editTemplate(traiData, onUpdateTemplateComplete)
|
|
242
|
-
: getFormSubscriptionData({
|
|
243
|
-
value: traiData.versions,
|
|
244
|
-
_id: params && params.id,
|
|
245
|
-
validity: true,
|
|
246
|
-
type: SMS,
|
|
247
|
-
});
|
|
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);
|
|
248
204
|
}
|
|
249
205
|
};
|
|
250
206
|
//Saving on done end
|
|
@@ -253,16 +209,17 @@ export const SmsTraiEdit = (props) => {
|
|
|
253
209
|
useEffect(() => {
|
|
254
210
|
let tag =
|
|
255
211
|
metaEntities && metaEntities.tags ? metaEntities.tags.standard : [];
|
|
256
|
-
|
|
257
|
-
|
|
212
|
+
if (
|
|
213
|
+
location.query.type === EMBEDDED &&
|
|
214
|
+
location.query.module === LIBRARY &&
|
|
215
|
+
!getDefaultTags
|
|
216
|
+
) {
|
|
258
217
|
tag = supportedTags;
|
|
259
218
|
}
|
|
260
219
|
updateTags(tag);
|
|
261
220
|
}, [metaEntities]);
|
|
262
221
|
|
|
263
222
|
const handleOnTagsContextChange = (data) => {
|
|
264
|
-
const { type } = location.query || {};
|
|
265
|
-
const isEmbedded = type === EMBEDDED;
|
|
266
223
|
const query = {
|
|
267
224
|
layout: SMS,
|
|
268
225
|
type: TAG,
|
|
@@ -270,7 +227,7 @@ export const SmsTraiEdit = (props) => {
|
|
|
270
227
|
(data || '').toLowerCase() === ALL
|
|
271
228
|
? DEFAULT
|
|
272
229
|
: (data || '').toLowerCase(),
|
|
273
|
-
embedded:
|
|
230
|
+
embedded: location.query.type === EMBEDDED ? location.query.type : FULL,
|
|
274
231
|
};
|
|
275
232
|
globalActions.fetchSchemaForEntity(query);
|
|
276
233
|
};
|
|
@@ -319,20 +276,6 @@ export const SmsTraiEdit = (props) => {
|
|
|
319
276
|
}
|
|
320
277
|
}
|
|
321
278
|
setUpdatedSmsEditor(arr);
|
|
322
|
-
if (!isFullMode) {
|
|
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
|
-
}
|
|
336
279
|
};
|
|
337
280
|
|
|
338
281
|
const textAreaValue = (idValue) => {
|
|
@@ -448,13 +391,13 @@ export const SmsTraiEdit = (props) => {
|
|
|
448
391
|
<>
|
|
449
392
|
<CapSpin spinning={loading}>
|
|
450
393
|
<CapRow>
|
|
451
|
-
{
|
|
394
|
+
{templateDetails && !isEmpty(templateDetails) && (
|
|
452
395
|
<TraiEditTemplateDetails>
|
|
453
396
|
<CapLabelInline type="label1">
|
|
454
397
|
{formatMessage(messages.templateLabel)}
|
|
455
398
|
</CapLabelInline>
|
|
456
399
|
<CapLabelInline type="label2">
|
|
457
|
-
{
|
|
400
|
+
{templateDetails.versions.base.template_name}
|
|
458
401
|
</CapLabelInline>
|
|
459
402
|
<CapLabelInline type="label1">
|
|
460
403
|
{formatMessage(messages.traiEditSeperator)}
|
|
@@ -463,7 +406,7 @@ export const SmsTraiEdit = (props) => {
|
|
|
463
406
|
{formatMessage(messages.senderIdlabel)}
|
|
464
407
|
</CapLabelInline>
|
|
465
408
|
<CapLabelInline type="label2">
|
|
466
|
-
{
|
|
409
|
+
{templateDetails.versions.base.header}
|
|
467
410
|
</CapLabelInline>
|
|
468
411
|
</TraiEditTemplateDetails>
|
|
469
412
|
)}
|
|
@@ -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
|
}
|