@capillarytech/creatives-library 7.10.3 → 7.10.5
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/containers/App/constants.js +1 -0
- package/package.json +1 -1
- package/utils/common.js +25 -5
- package/v2Components/CapTagList/index.js +2 -1
- package/v2Containers/Cap/reducer.js +1 -2
- package/v2Containers/Cap/selectors.js +0 -1
- 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 +14 -5
- package/v2Containers/SmsTrai/Edit/index.js +90 -33
- package/v2Containers/SmsWrapper/index.js +14 -10
- package/v2Containers/Templates/index.js +12 -7
- package/v2Containers/TemplatesV2/index.js +2 -1
|
@@ -4,6 +4,7 @@ export const GET_SIDEBAR_FAILURE = 'app/App/GET_SIDEBAR_FAILURE';
|
|
|
4
4
|
|
|
5
5
|
export const STORE2DOOR_PLUS_ENABLED = 'STORE2DOOR_PLUS_ENABLED';
|
|
6
6
|
export const TRAI_DLT = 'TRAI_DLT';
|
|
7
|
+
export const CARD_BASED_SCOPE = 'CARD_BASED_SCOPE';
|
|
7
8
|
|
|
8
9
|
export const CARD_RELATED_TAGS = [
|
|
9
10
|
'card_series',
|
package/package.json
CHANGED
package/utils/common.js
CHANGED
|
@@ -1,6 +1,11 @@
|
|
|
1
1
|
import _ from 'lodash';
|
|
2
2
|
import { Auth } from '@capillarytech/cap-ui-utils';
|
|
3
|
-
import {
|
|
3
|
+
import {
|
|
4
|
+
STORE2DOOR_PLUS_ENABLED,
|
|
5
|
+
TRAI_DLT,
|
|
6
|
+
CARD_RELATED_TAGS,
|
|
7
|
+
CARD_BASED_SCOPE,
|
|
8
|
+
} from '../containers/App/constants';
|
|
4
9
|
|
|
5
10
|
export function getUserNameById(userId, allUserList) {
|
|
6
11
|
let userName = "";
|
|
@@ -43,14 +48,22 @@ export const hasTraiDltFeature = Auth.hasFeatureAccess.bind(
|
|
|
43
48
|
TRAI_DLT,
|
|
44
49
|
);
|
|
45
50
|
|
|
51
|
+
export const hasCardBasedScope = Auth.hasFeatureAccess.bind(
|
|
52
|
+
null,
|
|
53
|
+
CARD_BASED_SCOPE,
|
|
54
|
+
);
|
|
55
|
+
|
|
46
56
|
export function getTreeStructuredTags({tagsList, userLocale = 'en', offerDetails = [], disableTagsDetails = {}}) {
|
|
47
57
|
console.log('populating tags', (tagsList || []).length);
|
|
48
58
|
const mainTags = {};
|
|
49
|
-
const { disableRelatedTags, childTagsToDisable, parentTagstoDisable
|
|
59
|
+
const { disableRelatedTags, childTagsToDisable, parentTagstoDisable} = disableTagsDetails;
|
|
50
60
|
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
61
|
+
let clonedTags = tagsList;
|
|
62
|
+
if (!hasCardBasedScope()) {
|
|
63
|
+
clonedTags = _.filter(tagsList, (tag) =>
|
|
64
|
+
!CARD_RELATED_TAGS.includes(tag?.definition?.value)
|
|
65
|
+
);
|
|
66
|
+
}
|
|
54
67
|
_.forEach(clonedTags, (temp) => {
|
|
55
68
|
const tag = temp.definition;
|
|
56
69
|
if (!tag['tag-header']) { //if tag doesn't have subtag(s), which means this tag itself is tag and not a tag header.
|
|
@@ -242,3 +255,10 @@ export const bytes2Size = (bytes, decimals = 2) => {
|
|
|
242
255
|
|
|
243
256
|
return `${Math.ceil((bytes / Math.pow(k, i)).toFixed(dm))} ${sizes[i]}`;
|
|
244
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
|
+
};
|
|
@@ -16,6 +16,7 @@ import { createStructuredSelector } from 'reselect';
|
|
|
16
16
|
import messages from './messages';
|
|
17
17
|
import { makeSelectLoyaltyPromotionDisplay } from '../../v2Containers/Cap/selectors';
|
|
18
18
|
import { CARD_RELATED_TAGS } from '../../containers/App/constants';
|
|
19
|
+
import { hasCardBasedScope } from '../../utils/common';
|
|
19
20
|
|
|
20
21
|
const {Search} = CapInput;
|
|
21
22
|
const {CapTreeNode} = CapTree;
|
|
@@ -139,7 +140,7 @@ class CapTagList extends React.Component { // eslint-disable-line react/prefer-s
|
|
|
139
140
|
const list = [];
|
|
140
141
|
const loyaltyAttrDisableText = <FormattedMessage {...messages.loyaltyAttributeDisable} />;
|
|
141
142
|
let clonedTags = _.cloneDeep(tags);
|
|
142
|
-
if (!
|
|
143
|
+
if (!hasCardBasedScope()) {
|
|
143
144
|
clonedTags = _.omit(clonedTags, CARD_RELATED_TAGS);
|
|
144
145
|
}
|
|
145
146
|
_.forEach(clonedTags, (val = '', key) => {
|
|
@@ -119,8 +119,7 @@ function capReducer(state = fromJS(initialState.cap), action) {
|
|
|
119
119
|
case types.SET_LOYALTY_PROMOTION_RELATED_CREATIVE_TAGS_DISPLAY: {
|
|
120
120
|
return state.set('disableLoyaltyPromotionRelatedTags', action.disable)
|
|
121
121
|
.set('tagsToDisable', action.tagsToDisable)
|
|
122
|
-
.set('parentTagsToDisable', action.parentTagsToDisable)
|
|
123
|
-
.set('showCardsRelatedTags', action.showCardsRelatedTags);
|
|
122
|
+
.set('parentTagsToDisable', action.parentTagsToDisable);
|
|
124
123
|
}
|
|
125
124
|
default:
|
|
126
125
|
return state;
|
|
@@ -79,7 +79,6 @@ const makeSelectLoyaltyPromotionDisplay = () => createSelector(
|
|
|
79
79
|
disableRelatedTags: globalState.get('disableLoyaltyPromotionRelatedTags'),
|
|
80
80
|
childTagsToDisable: globalState.get('tagsToDisable') || [],
|
|
81
81
|
parentTagstoDisable: globalState.get('parentTagsToDisable') || [],
|
|
82
|
-
showCardsRelatedTags: globalState.get('showCardsRelatedTags') || false,
|
|
83
82
|
}),
|
|
84
83
|
);
|
|
85
84
|
|
|
@@ -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?.split(','),
|
|
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('');
|
|
@@ -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
|
)}
|
|
@@ -29,6 +29,7 @@ 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';
|
|
32
33
|
|
|
33
34
|
import {
|
|
34
35
|
CHARLIMIT,
|
|
@@ -42,6 +43,7 @@ import {
|
|
|
42
43
|
LIBRARY,
|
|
43
44
|
} from './constants';
|
|
44
45
|
let varMap = {};
|
|
46
|
+
let traiData = {};
|
|
45
47
|
const { TextArea } = CapInput;
|
|
46
48
|
const { CapLabelInline } = CapLabel;
|
|
47
49
|
export const SmsTraiEdit = (props) => {
|
|
@@ -58,6 +60,9 @@ export const SmsTraiEdit = (props) => {
|
|
|
58
60
|
metaEntities,
|
|
59
61
|
injectedTags,
|
|
60
62
|
onCreateComplete,
|
|
63
|
+
isFullMode,
|
|
64
|
+
getFormSubscriptionData,
|
|
65
|
+
templateData = {},
|
|
61
66
|
} = props || {};
|
|
62
67
|
const { formatMessage } = intl;
|
|
63
68
|
const [loading, updateLoading] = useState(true);
|
|
@@ -66,6 +71,7 @@ export const SmsTraiEdit = (props) => {
|
|
|
66
71
|
const [tags, updateTags] = useState([]);
|
|
67
72
|
const [textAreaId, updateTextAreaId] = useState();
|
|
68
73
|
const [isValidationError, updateIsValidationError] = useState(false);
|
|
74
|
+
const [isTagValidationError, updateIsTagValidationError] = useState(false);
|
|
69
75
|
let totalVarCount = 0;
|
|
70
76
|
const SMSTraiFooter = styled.div`
|
|
71
77
|
background-color: ${CAP_WHITE};
|
|
@@ -86,31 +92,35 @@ export const SmsTraiEdit = (props) => {
|
|
|
86
92
|
}
|
|
87
93
|
`;
|
|
88
94
|
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
|
+
|
|
89
109
|
const { id } = params || {};
|
|
90
110
|
if (id) {
|
|
91
111
|
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
112
|
}
|
|
105
113
|
return () => {
|
|
106
114
|
actions.resetEditTemplate();
|
|
115
|
+
varMap = {};
|
|
107
116
|
};
|
|
108
117
|
}, []);
|
|
109
118
|
|
|
110
119
|
//computing placeholder array for mapping values and rendering dynamic form
|
|
111
120
|
useEffect(() => {
|
|
112
|
-
|
|
113
|
-
|
|
121
|
+
traiData = isFullMode ? templateDetails : templateData;
|
|
122
|
+
if (traiData && !isEmpty(traiData)) {
|
|
123
|
+
let msg = get(traiData, `versions.base.sms-editor`);
|
|
114
124
|
const templateMessageArray = [];
|
|
115
125
|
//converting sms-editor string to an array split at '{#var#}'
|
|
116
126
|
//split and push string before '{#var#}[0 to index]', push '{#var#}',
|
|
@@ -134,16 +144,23 @@ export const SmsTraiEdit = (props) => {
|
|
|
134
144
|
//stop spinner
|
|
135
145
|
updateLoading(false);
|
|
136
146
|
}
|
|
137
|
-
}, [templateDetails]);
|
|
147
|
+
}, [templateDetails || templateData]);
|
|
138
148
|
|
|
139
149
|
useEffect(() => {
|
|
140
150
|
if (tempMsgArray.length !== 0) {
|
|
151
|
+
const traiBase = traiData?.versions?.base || {};
|
|
152
|
+
const {
|
|
153
|
+
['var-mapped']: varMapped = {},
|
|
154
|
+
['updated-sms-editor']: traiSmsEditor = '',
|
|
155
|
+
} = traiBase;
|
|
141
156
|
//if varMapped and updated-sms-editor is already present on non first edits
|
|
142
|
-
if (!isEmpty(
|
|
143
|
-
varMap = cloneDeep(
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
157
|
+
if (!isEmpty(varMapped)) {
|
|
158
|
+
varMap = cloneDeep(varMapped);
|
|
159
|
+
if (isFullMode) {
|
|
160
|
+
setUpdatedSmsEditor(traiSmsEditor);
|
|
161
|
+
} else {
|
|
162
|
+
computeUpdatedSmsEditor();
|
|
163
|
+
}
|
|
147
164
|
} else {
|
|
148
165
|
//computing varMap for first edit
|
|
149
166
|
let counter = 1;
|
|
@@ -176,6 +193,22 @@ export const SmsTraiEdit = (props) => {
|
|
|
176
193
|
}
|
|
177
194
|
}, []);
|
|
178
195
|
|
|
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
|
+
|
|
179
212
|
//Saving on done start
|
|
180
213
|
const onUpdateTemplateComplete = (editResponse, errorMsg) => {
|
|
181
214
|
if (editResponse?.templateId) {
|
|
@@ -197,10 +230,21 @@ export const SmsTraiEdit = (props) => {
|
|
|
197
230
|
} else {
|
|
198
231
|
//start spinner
|
|
199
232
|
updateLoading(true);
|
|
200
|
-
|
|
201
|
-
|
|
202
|
-
|
|
203
|
-
|
|
233
|
+
const traiVersions = traiData.versions || {};
|
|
234
|
+
traiVersions.base = {
|
|
235
|
+
...traiVersions.base,
|
|
236
|
+
'var-mapped': varMap,
|
|
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
|
+
});
|
|
204
248
|
}
|
|
205
249
|
};
|
|
206
250
|
//Saving on done end
|
|
@@ -209,17 +253,16 @@ export const SmsTraiEdit = (props) => {
|
|
|
209
253
|
useEffect(() => {
|
|
210
254
|
let tag =
|
|
211
255
|
metaEntities && metaEntities.tags ? metaEntities.tags.standard : [];
|
|
212
|
-
|
|
213
|
-
|
|
214
|
-
location.query.module === LIBRARY &&
|
|
215
|
-
!getDefaultTags
|
|
216
|
-
) {
|
|
256
|
+
const { type, module } = location.query || {};
|
|
257
|
+
if (type === EMBEDDED && module === LIBRARY && !getDefaultTags) {
|
|
217
258
|
tag = supportedTags;
|
|
218
259
|
}
|
|
219
260
|
updateTags(tag);
|
|
220
261
|
}, [metaEntities]);
|
|
221
262
|
|
|
222
263
|
const handleOnTagsContextChange = (data) => {
|
|
264
|
+
const { type } = location.query || {};
|
|
265
|
+
const isEmbedded = type === EMBEDDED;
|
|
223
266
|
const query = {
|
|
224
267
|
layout: SMS,
|
|
225
268
|
type: TAG,
|
|
@@ -227,7 +270,7 @@ export const SmsTraiEdit = (props) => {
|
|
|
227
270
|
(data || '').toLowerCase() === ALL
|
|
228
271
|
? DEFAULT
|
|
229
272
|
: (data || '').toLowerCase(),
|
|
230
|
-
embedded:
|
|
273
|
+
embedded: isEmbedded ? type : FULL,
|
|
231
274
|
};
|
|
232
275
|
globalActions.fetchSchemaForEntity(query);
|
|
233
276
|
};
|
|
@@ -276,6 +319,20 @@ export const SmsTraiEdit = (props) => {
|
|
|
276
319
|
}
|
|
277
320
|
}
|
|
278
321
|
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
|
+
}
|
|
279
336
|
};
|
|
280
337
|
|
|
281
338
|
const textAreaValue = (idValue) => {
|
|
@@ -391,13 +448,13 @@ export const SmsTraiEdit = (props) => {
|
|
|
391
448
|
<>
|
|
392
449
|
<CapSpin spinning={loading}>
|
|
393
450
|
<CapRow>
|
|
394
|
-
{
|
|
451
|
+
{traiData && !isEmpty(traiData) && (
|
|
395
452
|
<TraiEditTemplateDetails>
|
|
396
453
|
<CapLabelInline type="label1">
|
|
397
454
|
{formatMessage(messages.templateLabel)}
|
|
398
455
|
</CapLabelInline>
|
|
399
456
|
<CapLabelInline type="label2">
|
|
400
|
-
{
|
|
457
|
+
{traiData.versions.base.template_name}
|
|
401
458
|
</CapLabelInline>
|
|
402
459
|
<CapLabelInline type="label1">
|
|
403
460
|
{formatMessage(messages.traiEditSeperator)}
|
|
@@ -406,7 +463,7 @@ export const SmsTraiEdit = (props) => {
|
|
|
406
463
|
{formatMessage(messages.senderIdlabel)}
|
|
407
464
|
</CapLabelInline>
|
|
408
465
|
<CapLabelInline type="label2">
|
|
409
|
-
{
|
|
466
|
+
{traiData.versions.base.header}
|
|
410
467
|
</CapLabelInline>
|
|
411
468
|
</TraiEditTemplateDetails>
|
|
412
469
|
)}
|
|
@@ -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
|
}
|