@capillarytech/creatives-library 7.10.9 → 7.10.10

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@capillarytech/creatives-library",
3
3
  "author": "meharaj",
4
- "version": "7.10.9",
4
+ "version": "7.10.10",
5
5
  "description": "Capillary creatives ui",
6
6
  "main": "./index.js",
7
7
  "module": "./index.es.js",
package/utils/common.js CHANGED
@@ -255,3 +255,10 @@ export const bytes2Size = (bytes, decimals = 2) => {
255
255
 
256
256
  return `${Math.ceil((bytes / Math.pow(k, i)).toFixed(dm))} ${sizes[i]}`;
257
257
  };
258
+
259
+ export const isTraiDLTEnable = (isFullMode, smsRegister) => {
260
+ const isTraiDltFeatureForOrg = hasTraiDltFeature();
261
+ const isTariEnableforLib = (!isFullMode && smsRegister === "DLT" ) || isFullMode;
262
+ const isTraiDltFeature = isTraiDltFeatureForOrg && isTariEnableforLib;
263
+ return isTraiDltFeature;
264
+ };
@@ -142,6 +142,7 @@ function SlideBoxContent(props) {
142
142
  fbAdManager,
143
143
  showDisabledFBInfo,
144
144
  orgUnitId,
145
+ smsRegister,
145
146
  } = props;
146
147
  const type = (messageDetails.type || '').toLowerCase(); // type is context in get tags values : outbound | dvs | referral | loyalty | coupons
147
148
  const query = { type: !isFullMode && 'embedded', module: isFullMode ? 'default' : 'library', isEditFromCampaigns: (templateData || {}).isEditFromCampaigns};
@@ -201,12 +202,18 @@ function SlideBoxContent(props) {
201
202
 
202
203
  const getChannelPreviewContent = (templateDataObject) => {
203
204
  switch (templateDataObject.type.toUpperCase()) {
204
- case constants.SMS:
205
- if (!commonUtil.hasTraiDltFeature() || get(templateDataObject, `versions.base['updated-sms-editor']`) === "") {
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 { hasTraiDltFeature } from '../../utils/common';
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 isTraiDltFeature = hasTraiDltFeature();
32
- const showCreateTraiSMSHeader = isTraiDltFeature && channel.toLowerCase() === "sms";
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 formData = {
174
- "sms-editor": templateData.messageBody,
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
- templateData.messageBody = template.value.base['sms-editor'];
379
+ const smsBase = template.value.base || {};
380
+ const { isFullMode, smsRegister } = this.props;
381
+ const isTraiDlt = commonUtil.isTraiDLTEnable(isFullMode, smsRegister);
382
+ const {
383
+ 'updated-sms-editor': updatedSmsEditor,
384
+ 'sms-editor': smsEditor,
385
+ } = smsBase;
386
+ if (!isTraiDlt) {
387
+ templateData.messageBody = smsEditor;
388
+ } else {
389
+ templateData.messageBody = updatedSmsEditor === "" ? smsEditor : updatedSmsEditor.join('');
390
+ const {
391
+ template_id,
392
+ template_name,
393
+ header,
394
+ 'var-mapped': varMapped,
395
+ } = smsBase;
396
+ templateData.templateConfigs = {
397
+ templateId: template_id,
398
+ templateName: template_name,
399
+ template: smsEditor,
400
+ registeredSenderIds: header,
401
+ templateVariableMapping: varMapped,
402
+ };
403
+ }
361
404
  }
362
405
  break;
363
406
  case constants.EMAIL:
@@ -771,7 +814,7 @@ class Creatives extends React.Component {
771
814
  }
772
815
  render() {
773
816
  const {slidBoxContent, isGetFormData, showSlideBox, templateData, currentChannel, emailCreateMode, templateStep, isLoadingContent, mobilePushCreateMode, isDiscardMessage, weChatTemplateType, weChatMaptemplateStep} = this.state;
774
- const {isFullMode, creativesMode, cap, isUploading, channelsToHide, selectedWeChatAccount, forwardedTags, channelsToDisable, selectedOfferDetails, onTestContentClicked, onPreviewContentClicked, getCreativesData, fetchingCmsData, editor} = this.props;
817
+ const {isFullMode, creativesMode, cap, isUploading, channelsToHide, selectedWeChatAccount, forwardedTags, channelsToDisable, selectedOfferDetails, onTestContentClicked, onPreviewContentClicked, getCreativesData, fetchingCmsData, editor, smsRegister} = this.props;
775
818
  const mapTemplateCreate = slidBoxContent === 'createTemplate' && weChatTemplateType === MAP_TEMPLATE && templateStep !== 'modeSelection';
776
819
  /* TODO: Instead of passing down same props separately to each component down, write common function to these props and pass it accordingly */
777
820
  return (
@@ -795,6 +838,7 @@ class Creatives extends React.Component {
795
838
  weChatTemplateType={weChatTemplateType}
796
839
  showPrefix={!isUploading} // not show back button when email template is being uploaded
797
840
  templateStep={this.creativesTemplateSteps[templateStep]}
841
+ smsRegister={smsRegister}
798
842
  />}
799
843
  content={
800
844
  <SlideBoxContent
@@ -848,6 +892,7 @@ class Creatives extends React.Component {
848
892
  handleClose={this.handleCloseSlideBox}
849
893
  onFTPSubmit={getCreativesData}
850
894
  editor={editor}
895
+ smsRegister={smsRegister}
851
896
  messageStrategy={this.props.strategy}
852
897
  orgUnitId={this.props.orgUnitId}
853
898
  />
@@ -13,20 +13,20 @@ export const TEMPLATE_ID = 'template id';
13
13
  export const SMS = 'SMS';
14
14
 
15
15
  export const MAPPED_SAVED_COLUMN = {
16
- "TEMPLATE ID": "template_id",
17
- "TEMPLATE NAME": "template_name",
18
- "TYPE": "type",
19
- "HEADER": "header",
20
- "CATEGORY": "category",
21
- "TEMPLATE MESSAGE": "sms-editor",
22
- 'SENDER ID': "header",
23
- 'SENDERS': "header",
24
- 'HEADER ID': "header",
25
- 'HEADERS': "header",
26
- 'TEMPLATE REGISTRATION NUMBER': "template_id",
27
- 'TEMPLATE CONTENT': "template_name",
28
- "COMMUNICATION TYPE": "consent-type",
29
- "CONSENT TYPE": "consent-type",
16
+ 'TEMPLATE ID': 'template_id',
17
+ 'TEMPLATE REGISTRATION NUMBER': 'template_id',
18
+ 'TEMPLATE NAME': 'template_name',
19
+ 'TYPE': 'type',
20
+ 'HEADER': 'header',
21
+ 'SENDER ID': 'header',
22
+ 'SENDERS': 'header',
23
+ 'HEADER ID': 'header',
24
+ 'HEADERS': 'header',
25
+ 'CATEGORY': 'category',
26
+ 'TEMPLATE MESSAGE': 'sms-editor',
27
+ 'TEMPLATE CONTENT': 'sms-editor',
28
+ 'CONSENT TYPE': 'consent-type',
29
+ 'COMMUNICATION TYPE': 'consent-type',
30
30
  };
31
31
 
32
32
  export const HEADER_ALIASES = [
@@ -48,8 +48,7 @@ export const TEMPLATE_MESSAGE_ALIASES = [
48
48
  ];
49
49
 
50
50
  export const MANDATORY_COLUMNS = [TEMPLATE_NAME, TYPE, APPROVAL_STATUS];
51
- export const SAVED_COLUMNS = [TEMPLATE_NAME, TYPE, "category", "consent type"];
52
-
51
+ export const SAVED_COLUMNS = [TEMPLATE_NAME, TYPE, 'category', 'consent type'];
53
52
 
54
53
  export const SAMPLE_CSV_DATA = [
55
54
  [
@@ -67,8 +66,11 @@ export const SAMPLE_CSV = 'Sample.csv';
67
66
  export const CAPILLARY_REJECTION_REASON = 'CAPILLARY REJECTION REASON';
68
67
  export const APPROVED = 'approved';
69
68
 
70
-
71
- export const CREATE_TRAI_SMS_TEMPLATE_REQUEST = 'app/v2Containers/SmsTrai/Create/CREATE_TRAI_SMS_TEMPLATE_REQUEST';
72
- export const CREATE_TRAI_SMS_TEMPLATE_SUCCESS = 'app/v2Containers/SmsTrai/Create/CREATE_TRAI_SMS_TEMPLATE_SUCCESS';
73
- export const CREATE_TRAI_SMS_TEMPLATE_FAILURE = 'app/v2Containers/SmsTrai/Create/CREATE_TRAI_SMS_TEMPLATE_FAILURE';
74
- export const CLEAR_TRAI_SMS_TEMPLATE_CREATE_RESPONSE_REQUEST = 'app/v2Containers/SmsTrai/Create/CLEAR_TRAI_SMS_TEMPLATE_CREATE_RESPONSE_REQUEST';
69
+ export const CREATE_TRAI_SMS_TEMPLATE_REQUEST =
70
+ 'app/v2Containers/SmsTrai/Create/CREATE_TRAI_SMS_TEMPLATE_REQUEST';
71
+ export const CREATE_TRAI_SMS_TEMPLATE_SUCCESS =
72
+ 'app/v2Containers/SmsTrai/Create/CREATE_TRAI_SMS_TEMPLATE_SUCCESS';
73
+ export const CREATE_TRAI_SMS_TEMPLATE_FAILURE =
74
+ 'app/v2Containers/SmsTrai/Create/CREATE_TRAI_SMS_TEMPLATE_FAILURE';
75
+ export const CLEAR_TRAI_SMS_TEMPLATE_CREATE_RESPONSE_REQUEST =
76
+ 'app/v2Containers/SmsTrai/Create/CLEAR_TRAI_SMS_TEMPLATE_CREATE_RESPONSE_REQUEST';
@@ -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 { intl, actions, onCreateComplete } = props;
50
+ const {
51
+ intl,
52
+ actions,
53
+ onCreateComplete,
54
+ isFullMode,
55
+ onShowTemplates,
56
+ } = props;
52
57
  const { formatMessage } = intl;
53
58
  const [files, setFiles] = useState([]);
54
59
  const [errorText, setErrorText] = useState('');
@@ -90,13 +95,13 @@ export const SmsTraiCreate = (props) => {
90
95
  const numbersOnly = /^\d+$/;
91
96
  let isError = false;
92
97
  senderIdString.split(',').forEach((value) => {
93
- value = value.trim();
94
- if (value) {
95
- if (value.length !== 6) {
98
+ const _value = value.trim();
99
+ if (_value) {
100
+ if (_value.length !== 6) {
96
101
  isError = true;
97
102
  return;
98
103
  }
99
- if (!(lettersOnly.test(value) || numbersOnly.test(value))) {
104
+ if (!(lettersOnly.test(_value) || numbersOnly.test(_value))) {
100
105
  isError = true;
101
106
  }
102
107
  }
@@ -114,7 +119,7 @@ export const SmsTraiCreate = (props) => {
114
119
  APPROVAL_STATUS,
115
120
  );
116
121
 
117
- for (let row = 1; row < transformedResults.length; row++) {
122
+ for (let row = 1; row < transformedResults.length; row += 1) {
118
123
  const errorArray = [];
119
124
  const headerErrorArray = [];
120
125
  const approvalErrorArray = [];
@@ -204,7 +209,7 @@ export const SmsTraiCreate = (props) => {
204
209
  return;
205
210
  }
206
211
  //one of the mandatory template id alias should be available.
207
- for (let i = 0; i < TEMPLATE_ID_ALIASES.length; i++) {
212
+ for (let i = 0; i < TEMPLATE_ID_ALIASES.length; i += 1) {
208
213
  if (cols.includes(TEMPLATE_ID_ALIASES[i])) {
209
214
  templateIdAliasPresent.push(TEMPLATE_ID_ALIASES[i]);
210
215
  }
@@ -218,7 +223,7 @@ export const SmsTraiCreate = (props) => {
218
223
  return;
219
224
  }
220
225
  //one of the mandatory template message alias should be available.
221
- for (let i = 0; i < TEMPLATE_MESSAGE_ALIASES.length; i++) {
226
+ for (let i = 0; i < TEMPLATE_MESSAGE_ALIASES.length; i += 1) {
222
227
  if (cols.includes(TEMPLATE_MESSAGE_ALIASES[i])) {
223
228
  templateMessageAliasPresent.push(TEMPLATE_MESSAGE_ALIASES[i]);
224
229
  }
@@ -306,7 +311,7 @@ export const SmsTraiCreate = (props) => {
306
311
  });
307
312
  }
308
313
  //adding validated rejection reason column to original results
309
- for (let i = 0; i < validatedResults.length; i++) {
314
+ for (let i = 0; i < validatedResults.length; i += 1) {
310
315
  results.data[i].push(validatedResults[i][6]);
311
316
  }
312
317
  updateSaveTemplate(true);
@@ -356,7 +361,7 @@ export const SmsTraiCreate = (props) => {
356
361
 
357
362
  if (rejectionIndex !== -1) {
358
363
  tempArray.push(fileData[0]);
359
- for (let row = 1; row < fileData.length; row++) {
364
+ for (let row = 1; row < fileData.length; row += 1) {
360
365
  if (fileData[row][rejectionIndex]) {
361
366
  tempArray.push(fileData[row]);
362
367
  }
@@ -392,16 +397,15 @@ export const SmsTraiCreate = (props) => {
392
397
  tempArray.push(fileData[0]);
393
398
 
394
399
  // filter out non rejected rows
395
- for (let row = 1; row < fileData.length; row++) {
400
+ for (let row = 1; row < fileData.length; row += 1) {
396
401
  if (!fileData[row][rejectionIndex]) {
397
402
  tempArray.push(fileData[row]);
398
403
  }
399
404
  }
400
-
401
405
  // Filter out the columns index that needs to save
402
406
  const cols = getAllColumnNames(tempArray[0]);
403
407
  const indexArray = [];
404
- for (let i = 0; i < cols.length; i++) {
408
+ for (let i = 0; i < cols.length; i += 1) {
405
409
  if (
406
410
  SAVED_COLUMNS.includes(cols[i]) ||
407
411
  HEADER_ALIASES.includes(cols[i]) ||
@@ -418,7 +422,7 @@ export const SmsTraiCreate = (props) => {
418
422
  transformedResults.push(
419
423
  indexArray.map((i) => {
420
424
  if (key === '0') {
421
- return MAPPED_SAVED_COLUMN[tempArray[key][i]];
425
+ return MAPPED_SAVED_COLUMN[tempArray[key][i]?.toUpperCase()];
422
426
  }
423
427
  return tempArray[key][i];
424
428
  }),
@@ -452,7 +456,11 @@ export const SmsTraiCreate = (props) => {
452
456
  { templates: savedData },
453
457
  (resp, errorMessage) => {
454
458
  createCallback({ errorMessage });
455
- onCreateComplete();
459
+ if (isFullMode) {
460
+ onCreateComplete();
461
+ } else {
462
+ onShowTemplates();
463
+ }
456
464
  },
457
465
  );
458
466
  };
@@ -530,7 +538,7 @@ export const SmsTraiCreate = (props) => {
530
538
  {previewFileIndex !== null && (
531
539
  <>
532
540
  <CapRow span={24} className="upload-type-group-create-container">
533
- <div className="upload-file-preview">
541
+ <>
534
542
  <CapDivider
535
543
  type="horizontal"
536
544
  className="upload-file-preview-divider-1"
@@ -635,7 +643,7 @@ export const SmsTraiCreate = (props) => {
635
643
  className="upload-file-preview-divider-2"
636
644
  />
637
645
  {errorText && <CapError>{errorText}</CapError>}
638
- </div>
646
+ </>
639
647
  </CapRow>
640
648
  </>
641
649
  )}
@@ -13,6 +13,8 @@ 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
+ import CapCheckbox from '@capillarytech/cap-ui-library/CapCheckbox';
16
18
  import {
17
19
  CAP_SPACE_16,
18
20
  CAP_SPACE_12,
@@ -24,12 +26,13 @@ import {
24
26
  } from '@capillarytech/cap-ui-library/styled/variables';
25
27
  import { makeSelectTemplateDetailsResponse } from '../../Sms/Edit/selectors';
26
28
  import { makeSelectMetaEntities, setInjectedTags } from '../../Cap/selectors';
27
- import * as actions from '../../Sms/Edit/actions';
29
+ import * as smsEditActions from '../../Sms/Edit/actions';
28
30
  import messages from './messages';
29
31
  import TagList from '../../TagList';
30
32
  import TemplatePreview from '../../../v2Components/TemplatePreview';
31
33
  import withCreatives from '../../../hoc/withCreatives';
32
-
34
+ import { validateTags } from '../../../utils/tagValidations';
35
+ import { updateCharCount } from '../../../utils/smsCharCountV2';
33
36
  import {
34
37
  CHARLIMIT,
35
38
  SMS,
@@ -41,9 +44,13 @@ import {
41
44
  ALL,
42
45
  LIBRARY,
43
46
  } from './constants';
47
+
44
48
  let varMap = {};
49
+ let traiData = {};
50
+ let tagValidationResponse = {};
45
51
  const { TextArea } = CapInput;
46
52
  const { CapLabelInline } = CapLabel;
53
+
47
54
  export const SmsTraiEdit = (props) => {
48
55
  const {
49
56
  intl,
@@ -58,6 +65,9 @@ export const SmsTraiEdit = (props) => {
58
65
  metaEntities,
59
66
  injectedTags,
60
67
  onCreateComplete,
68
+ isFullMode,
69
+ getFormSubscriptionData,
70
+ templateData = {},
61
71
  } = props || {};
62
72
  const { formatMessage } = intl;
63
73
  const [loading, updateLoading] = useState(true);
@@ -66,7 +76,9 @@ export const SmsTraiEdit = (props) => {
66
76
  const [tags, updateTags] = useState([]);
67
77
  const [textAreaId, updateTextAreaId] = useState();
68
78
  const [isValidationError, updateIsValidationError] = useState(false);
69
- let totalVarCount = 0;
79
+ const [isTagValidationError, updateIsTagValidationError] = useState(false);
80
+ const [totalMessageLength, setTotalMessageLength] = useState(0);
81
+ const [isUnicodeAllowed, updateIsUnicodeAllowed] = useState(false);
70
82
  const SMSTraiFooter = styled.div`
71
83
  background-color: ${CAP_WHITE};
72
84
  position: fixed;
@@ -85,32 +97,38 @@ export const SmsTraiEdit = (props) => {
85
97
  margin-right: ${CAP_SPACE_12};
86
98
  }
87
99
  `;
100
+
88
101
  useEffect(() => {
102
+ //fetching tags
103
+ const { type, module } = location.query || {};
104
+ const isEmbedded = type === EMBEDDED;
105
+ const query = {
106
+ layout: SMS,
107
+ type: TAG,
108
+ context: isEmbedded ? module : DEFAULT,
109
+ embedded: isEmbedded ? type : FULL,
110
+ };
111
+ if (getDefaultTags) {
112
+ query.context = getDefaultTags;
113
+ }
114
+ globalActions.fetchSchemaForEntity(query);
115
+ //fetching template data in fullmode
89
116
  const { id } = params || {};
90
117
  if (id) {
91
118
  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
119
  }
120
+ //cleanup code
105
121
  return () => {
106
122
  actions.resetEditTemplate();
123
+ varMap = {};
107
124
  };
108
125
  }, []);
109
126
 
110
127
  //computing placeholder array for mapping values and rendering dynamic form
111
128
  useEffect(() => {
112
- if (templateDetails && !isEmpty(templateDetails)) {
113
- let msg = get(templateDetails, `versions.base.sms-editor`);
129
+ traiData = isFullMode ? templateDetails : templateData;
130
+ if (traiData && !isEmpty(traiData)) {
131
+ let msg = get(traiData, `versions.base.sms-editor`);
114
132
  const templateMessageArray = [];
115
133
  //converting sms-editor string to an array split at '{#var#}'
116
134
  //split and push string before '{#var#}[0 to index]', push '{#var#}',
@@ -126,44 +144,57 @@ export const SmsTraiEdit = (props) => {
126
144
  break;
127
145
  }
128
146
  }
129
-
130
147
  const filteredTemplateMessageArray = templateMessageArray.filter(
131
148
  (i) => i.trim() !== '',
132
149
  );
133
150
  updateTempMsgArray(filteredTemplateMessageArray);
151
+ //updating unicode-validity
152
+ updateIsUnicodeAllowed(
153
+ get(traiData, `versions.base.unicode-validity`, false),
154
+ );
134
155
  //stop spinner
135
156
  updateLoading(false);
136
157
  }
137
- }, [templateDetails]);
158
+ }, [templateDetails || templateData]);
138
159
 
160
+ //compute/get varMapped and updated-sms-editor
139
161
  useEffect(() => {
140
162
  if (tempMsgArray.length !== 0) {
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
- );
163
+ const traiBase = traiData?.versions?.base || {};
164
+ const {
165
+ 'var-mapped': varMapped = {},
166
+ 'updated-sms-editor': traiSmsEditor = '',
167
+ } = traiBase;
168
+ //if varMap and updated-sms-editor is already present on non first edits,use those values
169
+ if (!isEmpty(varMapped)) {
170
+ varMap = cloneDeep(varMapped);
171
+ if (isFullMode) {
172
+ setUpdatedSmsEditor(traiSmsEditor);
173
+ } else {
174
+ computeUpdatedSmsEditor();
175
+ }
147
176
  } else {
148
- //computing varMap for first edit
177
+ //computing and setting varMap for first edit
149
178
  let counter = 1;
150
- for (let i = 0; i < tempMsgArray.length; i++) {
179
+ for (let i = 0; i < tempMsgArray.length; i += 1) {
151
180
  if (tempMsgArray[i] === SMS_TRAI_VAR) {
152
181
  const nextElem =
153
182
  tempMsgArray[i === tempMsgArray.length - 1 ? 0 : i + 1];
154
183
  if (tempMsgArray[i] !== nextElem) {
155
- varMap[`${tempMsgArray[i]}_${i - counter + 1}`] = {
184
+ varMap[`${tempMsgArray[i]}_${(i - counter) + 1}`] = {
156
185
  data: '',
157
186
  count: counter,
158
187
  };
159
188
  counter = 1;
160
189
  } else {
161
- counter++;
190
+ counter += 1;
162
191
  }
163
192
  }
164
193
  }
165
194
  setUpdatedSmsEditor(tempMsgArray);
166
195
  }
196
+ // calcaulate message length here
197
+ calculateTotalMessageLength();
167
198
  }
168
199
  }, [tempMsgArray]);
169
200
 
@@ -176,6 +207,43 @@ export const SmsTraiEdit = (props) => {
176
207
  }
177
208
  }, []);
178
209
 
210
+ //performs tag validation
211
+ useEffect(() => {
212
+ if (
213
+ !isFullMode &&
214
+ updatedSmsEditor?.length > 0 &&
215
+ !updatedSmsEditor.includes(SMS_TRAI_VAR)
216
+ ) {
217
+ tagValidationResponse =
218
+ validateTags({
219
+ content: updatedSmsEditor.join(''),
220
+ tagsParam: tags,
221
+ injectedTagsParams: injectedTags,
222
+ location,
223
+ tagModule: getDefaultTags,
224
+ }) || {};
225
+ updateIsTagValidationError(
226
+ tagValidationResponse.unsupportedTags.length > 0,
227
+ );
228
+ }
229
+ }, [updatedSmsEditor, tags]);
230
+
231
+ const computeUpdatedSmsEditor = () => {
232
+ const updatedSmsArray = [...tempMsgArray];
233
+ for (const key in varMap) {
234
+ const index = Number(key.slice(8)); //Eg: -> extracting index 1 from keys like {#var# } _1
235
+ for (let i = 0; i < varMap[key].count; i += 1) {
236
+ //when multiple "#var#" come continuously ,it is considered as 1 textbox
237
+ if (i === 0) {
238
+ updatedSmsArray[index] = varMap[key].data; //data for first #var# of the textbox
239
+ } else {
240
+ updatedSmsArray[index + i] = ''; //"" for remaining #var# of a textbox
241
+ }
242
+ }
243
+ }
244
+ setUpdatedSmsEditor(updatedSmsArray);
245
+ };
246
+
179
247
  //Saving on done start
180
248
  const onUpdateTemplateComplete = (editResponse, errorMsg) => {
181
249
  if (editResponse?.templateId) {
@@ -191,16 +259,30 @@ export const SmsTraiEdit = (props) => {
191
259
  }
192
260
  };
193
261
  const onDoneCallback = () => {
194
- if (updatedSmsEditor.includes(SMS_TRAI_VAR)) {
262
+ if (updatedSmsEditor.includes(SMS_TRAI_VAR) && !isFullMode) {
195
263
  //during save textbox should not be empty
196
264
  updateIsValidationError(true);
197
265
  } else {
198
266
  //start spinner
199
267
  updateLoading(true);
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);
268
+ const traiVersions = traiData.versions || {};
269
+ traiVersions.base = {
270
+ ...traiVersions.base,
271
+ 'var-mapped': varMap,
272
+ 'updated-sms-editor': updatedSmsEditor,
273
+ 'unicode-validity': isUnicodeAllowed,
274
+ };
275
+ traiVersions.history = [traiVersions.base];
276
+ if (isFullMode) {
277
+ actions.editTemplate(traiData, onUpdateTemplateComplete);
278
+ } else {
279
+ getFormSubscriptionData({
280
+ value: traiData.versions,
281
+ _id: params && params.id,
282
+ validity: true,
283
+ type: SMS,
284
+ });
285
+ }
204
286
  }
205
287
  };
206
288
  //Saving on done end
@@ -209,17 +291,16 @@ export const SmsTraiEdit = (props) => {
209
291
  useEffect(() => {
210
292
  let tag =
211
293
  metaEntities && metaEntities.tags ? metaEntities.tags.standard : [];
212
- if (
213
- location.query.type === EMBEDDED &&
214
- location.query.module === LIBRARY &&
215
- !getDefaultTags
216
- ) {
294
+ const { type, module } = location.query || {};
295
+ if (type === EMBEDDED && module === LIBRARY && !getDefaultTags) {
217
296
  tag = supportedTags;
218
297
  }
219
298
  updateTags(tag);
220
299
  }, [metaEntities]);
221
300
 
222
301
  const handleOnTagsContextChange = (data) => {
302
+ const { type } = location.query || {};
303
+ const isEmbedded = type === EMBEDDED;
223
304
  const query = {
224
305
  layout: SMS,
225
306
  type: TAG,
@@ -227,7 +308,7 @@ export const SmsTraiEdit = (props) => {
227
308
  (data || '').toLowerCase() === ALL
228
309
  ? DEFAULT
229
310
  : (data || '').toLowerCase(),
230
- embedded: location.query.type === EMBEDDED ? location.query.type : FULL,
311
+ embedded: isEmbedded ? type : FULL,
231
312
  };
232
313
  globalActions.fetchSchemaForEntity(query);
233
314
  };
@@ -240,7 +321,7 @@ export const SmsTraiEdit = (props) => {
240
321
  for (
241
322
  let i = 0;
242
323
  i < varMap[`${SMS_TRAI_VAR}_${textAreaId}`].count;
243
- i++
324
+ i += 1
244
325
  ) {
245
326
  tempArr[textAreaId + i] = '';
246
327
  }
@@ -259,23 +340,24 @@ export const SmsTraiEdit = (props) => {
259
340
 
260
341
  // on change event of Text Area
261
342
  const textAreaValueChange = ({ target: { value, id } }) => {
262
- id = Number(id);
343
+ const _id = Number(id);
263
344
  const arr = [...updatedSmsEditor];
264
- varMap[`${SMS_TRAI_VAR}_${id}`].data = value;
345
+ varMap[`${SMS_TRAI_VAR}_${_id}`].data = value;
265
346
  if (value === '') {
266
- for (let i = 0; i < varMap[`${SMS_TRAI_VAR}_${id}`].count; i++) {
267
- arr[id + i] = SMS_TRAI_VAR;
347
+ for (let i = 0; i < varMap[`${SMS_TRAI_VAR}_${_id}`].count; i += 1) {
348
+ arr[_id + i] = SMS_TRAI_VAR;
268
349
  }
269
350
  } else {
270
- for (let i = 0; i < varMap[`${SMS_TRAI_VAR}_${id}`].count; i++) {
351
+ for (let i = 0; i < varMap[`${SMS_TRAI_VAR}_${id}`].count; i += 1) {
271
352
  if (i === 0) {
272
- arr[id] = varMap[`${SMS_TRAI_VAR}_${id}`].data;
353
+ arr[_id] = varMap[`${SMS_TRAI_VAR}_${_id}`].data;
273
354
  } else {
274
- arr[id + i] = '';
355
+ arr[_id + i] = '';
275
356
  }
276
357
  }
277
358
  }
278
359
  setUpdatedSmsEditor(arr);
360
+ calculateTotalMessageLength();
279
361
  };
280
362
 
281
363
  const textAreaValue = (idValue) => {
@@ -285,9 +367,8 @@ export const SmsTraiEdit = (props) => {
285
367
  updatedSmsEditor[idValue] !== SMS_TRAI_VAR
286
368
  ) {
287
369
  return updatedSmsEditor[idValue];
288
- } else {
289
- return '';
290
370
  }
371
+ return '';
291
372
  }
292
373
  return '';
293
374
  };
@@ -308,19 +389,19 @@ export const SmsTraiEdit = (props) => {
308
389
  </CapHeading>
309
390
  );
310
391
  }
392
+ return <></>;
311
393
  };
312
394
 
313
395
  const renderedContent = () => {
314
396
  const renderArray = [];
315
397
  if (tempMsgArray?.length !== 0) {
316
398
  let varCount = 0;
317
- tempMsgArray.map((elem, index) => {
399
+ tempMsgArray.forEach((elem, index) => {
318
400
  let prevElem = '';
319
401
  if (elem.includes(SMS_TRAI_VAR)) {
320
402
  prevElem =
321
403
  tempMsgArray[[index === 0 ? tempMsgArray.length - 1 : index - 1]];
322
- varCount++;
323
- totalVarCount++;
404
+ varCount += 1;
324
405
  if (prevElem !== SMS_TRAI_VAR) {
325
406
  renderArray.push(
326
407
  <TextArea
@@ -371,42 +452,77 @@ export const SmsTraiEdit = (props) => {
371
452
  return renderArray;
372
453
  };
373
454
 
455
+ const smsLengthForVar = () => (
456
+ <CapHeading type="h5" style={{ marginTop: CAP_SPACE_04, float: 'right' }}>
457
+ {formatMessage(messages.totalCharacters, {
458
+ smsCount: Math.ceil(totalMessageLength / 160),
459
+ number: totalMessageLength,
460
+ })}
461
+ </CapHeading>
462
+ );
463
+
374
464
  // to compute the length of the message
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
- );
465
+ //30 characters is blocked per'{#var#}' if textbox is empty otherwise it will be textbox length
466
+ // and the remaining string length is added to it
467
+ const calculateTotalMessageLength = () => {
468
+ const msgLenWithoutVar = tempMsgArray
469
+ ?.filter((i) => i !== SMS_TRAI_VAR)
470
+ .join('');
471
+ const charDetails = updateCharCount(msgLenWithoutVar, false);
472
+ const varLen = calculateLenForTextBox();
473
+ const totalMsgLen = charDetails.chars_used + varLen;
474
+ setTotalMessageLength(totalMsgLen);
475
+ };
476
+
477
+ const calculateLenForTextBox = () => {
478
+ let countVarChar = 0;
479
+ Object.keys(varMap).forEach((i) => {
480
+ if (varMap[i].data) {
481
+ const charDetails = updateCharCount(varMap[i].data, false);
482
+ countVarChar += charDetails.chars_used;
483
+ } else {
484
+ countVarChar += varMap[i].count * CHARLIMIT;
485
+ }
486
+ });
487
+ return countVarChar;
488
+ };
489
+ const tagValidationErrorMessage = () => {
490
+ const { unsupportedTags = [] } = tagValidationResponse;
491
+ let tagError = '';
492
+ if (unsupportedTags.length > 0) {
493
+ tagError = formatMessage(messages.unsupportedTagsValidationError, {
494
+ unsupportedTags,
495
+ });
496
+ }
497
+ return <CapError>{tagError}</CapError>;
498
+ };
499
+
500
+ const unicodeHandler = ({ target: { checked } }) => {
501
+ updateIsUnicodeAllowed(checked);
388
502
  };
389
503
 
390
504
  return (
391
505
  <>
392
506
  <CapSpin spinning={loading}>
393
507
  <CapRow>
394
- {templateDetails && !isEmpty(templateDetails) && (
508
+ {traiData && !isEmpty(traiData) && (
395
509
  <TraiEditTemplateDetails>
396
510
  <CapLabelInline type="label1">
397
511
  {formatMessage(messages.templateLabel)}
398
512
  </CapLabelInline>
399
513
  <CapLabelInline type="label2">
400
- {templateDetails.versions.base.template_name}
514
+ {traiData.versions.base.template_name}
401
515
  </CapLabelInline>
516
+
402
517
  <CapLabelInline type="label1">
403
518
  {formatMessage(messages.traiEditSeperator)}
404
519
  </CapLabelInline>
520
+
405
521
  <CapLabelInline type="label1">
406
522
  {formatMessage(messages.senderIdlabel)}
407
523
  </CapLabelInline>
408
524
  <CapLabelInline type="label2">
409
- {templateDetails.versions.base.header}
525
+ {traiData.versions.base.header.join(', ')}
410
526
  </CapLabelInline>
411
527
  </TraiEditTemplateDetails>
412
528
  )}
@@ -437,17 +553,27 @@ export const SmsTraiEdit = (props) => {
437
553
  {renderedContent()}
438
554
  </CapRow>
439
555
  <CapRow>{smsLengthForVar()}</CapRow>
556
+ {isTagValidationError && tagValidationErrorMessage()}
557
+ <CapCheckbox onChange={unicodeHandler} checked={isUnicodeAllowed}>
558
+ {formatMessage(messages.unicodeLabel)}
559
+ </CapCheckbox>
440
560
  <div style={{ marginBottom: '100px' }} />
441
561
  </CapColumn>
442
562
  <CapColumn span={10}>
443
563
  <TemplatePreview
444
564
  channel={SMS}
445
- content={[updatedSmsEditor.join('')]}
565
+ content={updatedSmsEditor.join('')}
566
+ unicodeEnabled={isUnicodeAllowed}
567
+ charCounterEnabled={true}
446
568
  />
447
569
  </CapColumn>
448
570
  </CapRow>
449
571
  <SMSTraiFooter>
450
- <CapButton onClick={onDoneCallback} className="create-msg">
572
+ <CapButton
573
+ onClick={onDoneCallback}
574
+ className="create-msg"
575
+ disabled={isTagValidationError}
576
+ >
451
577
  <FormattedMessage {...messages.saveButtonLabel} />
452
578
  </CapButton>
453
579
  <CapButton
@@ -469,11 +595,9 @@ const mapStateToProps = createStructuredSelector({
469
595
  injectedTags: setInjectedTags(),
470
596
  });
471
597
 
472
- const mapDispatchToProps = (dispatch) => {
473
- return {
474
- actions: bindActionCreators(actions, dispatch),
475
- };
476
- };
598
+ const mapDispatchToProps = (dispatch) => ({
599
+ actions: bindActionCreators(smsEditActions, dispatch),
600
+ });
477
601
 
478
602
  export default withCreatives({
479
603
  WrappedComponent: injectIntl(SmsTraiEdit),
@@ -55,4 +55,18 @@ 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
+ unicodeLabel: {
69
+ id: `${prefix}.unicodeLabel`,
70
+ defaultMessage: 'Allow unicode characters',
71
+ },
58
72
  });
@@ -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 { hasTraiDltFeature } from '../../utils/common';
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 isTraiDltFeature = hasTraiDltFeature();
48
+ const isTraiDlt = isTraiDLTEnable(isFullMode, smsRegister);
47
49
  return <>
48
50
  {
49
- isCreateSms && (isTraiDltFeature ?
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 && (isTraiDltFeature ?
64
+ {isEditSms && (isTraiDlt ?
61
65
  <SmsTraiEdit
62
66
  {...smsProps}
63
67
  params={{id: templateData._id}}
64
68
  templateData={templateData}
65
69
  handleClose={handleClose}
66
- />:<SmsEdit
67
- {...smsProps}
68
- params={{id: templateData._id}}
69
- templateData={templateData}
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 = commonUtil.hasTraiDltFeature();
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 = commonUtil.hasTraiDltFeature();
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 = commonUtil.hasTraiDltFeature();
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 = commonUtil.hasTraiDltFeature();
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
  }