@capillarytech/creatives-library 7.9.18 → 7.9.20

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.9.18",
4
+ "version": "7.9.20",
5
5
  "description": "Capillary creatives ui",
6
6
  "main": "./index.js",
7
7
  "module": "./index.es.js",
package/utils/common.js CHANGED
@@ -240,3 +240,10 @@ export const bytes2Size = (bytes, decimals = 2) => {
240
240
 
241
241
  return `${Math.ceil((bytes / Math.pow(k, i)).toFixed(dm))} ${sizes[i]}`;
242
242
  };
243
+
244
+ export const isTraiDLTEnable = (isFullMode, smsRegister) => {
245
+ const isTraiDltFeatureForOrg = hasTraiDltFeature();
246
+ const isTariEnableforLib = (!isFullMode && smsRegister === "DLT" ) || isFullMode;
247
+ const isTraiDltFeature = isTraiDltFeatureForOrg && isTariEnableforLib;
248
+ return isTraiDltFeature;
249
+ };
@@ -202,13 +202,15 @@ function SlideBoxContent(props) {
202
202
 
203
203
  const getChannelPreviewContent = (templateDataObject) => {
204
204
  switch (templateDataObject.type.toUpperCase()) {
205
- case constants.SMS:
206
- if (!commonUtil.hasTraiDltFeature() || get(templateDataObject, `versions.base['updated-sms-editor']`) === "") {
205
+ case constants.SMS: {
206
+ const isTraiDlt = commonUtil.isTraiDLTEnable(isFullMode, smsRegister);
207
+
208
+ const updatedSMSEditior = get(templateDataObject, `versions.base['updated-sms-editor']`, '');
209
+ if (!isTraiDlt || updatedSMSEditior === "") {
207
210
  return get(templateDataObject, `versions.base['sms-editor']`);
208
- } else {
209
- return templateDataObject.versions.base['updated-sms-editor']?.join('');
210
211
  }
211
- return get(templateDataObject, `versions.base['sms-editor']`);
212
+ return updatedSMSEditior.join('');
213
+ }
212
214
  case constants.LINE: {
213
215
  const lineContents = get(templateDataObject, `versions.base.content.messages`, [{}]);
214
216
  const previewContent = [];
@@ -468,6 +470,7 @@ function SlideBoxContent(props) {
468
470
  onTestContentClicked={onTestContentClicked}
469
471
  onCreateComplete={onCreateComplete}
470
472
  smsRegister={smsRegister}
473
+ onShowTemplates={onShowTemplates}
471
474
  />
472
475
  )}
473
476
 
@@ -721,5 +724,6 @@ SlideBoxContent.propTypes = {
721
724
  fbAdManager: PropTypes.string,
722
725
  showDisabledFBInfo: PropTypes.boolean,
723
726
  orgUnitId: PropTypes.any,
727
+ smsRegister: PropTypes.any,
724
728
  };
725
729
  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;
@@ -795,6 +795,7 @@ class Creatives extends React.Component {
795
795
  weChatTemplateType={weChatTemplateType}
796
796
  showPrefix={!isUploading} // not show back button when email template is being uploaded
797
797
  templateStep={this.creativesTemplateSteps[templateStep]}
798
+ smsRegister={smsRegister}
798
799
  />}
799
800
  content={
800
801
  <SlideBoxContent
@@ -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('');
@@ -361,9 +366,7 @@ export const SmsTraiCreate = (props) => {
361
366
  tempArray.push(fileData[row]);
362
367
  }
363
368
  }
364
- tempArray = tempArray.map((row) => {
365
- return row.map((cell) => cell.replace(',', ' '));
366
- });
369
+ tempArray = tempArray.map((row) => row.map((cell) => cell.replace(',', ' ')));
367
370
  csvContent = tempArray
368
371
  .map((e) => e.join(','))
369
372
  .map((e) => e.replace(/(\r\n|\n|\r)/gm, ' '))
@@ -453,7 +456,11 @@ export const SmsTraiCreate = (props) => {
453
456
  { templates: savedData },
454
457
  (resp, errorMessage) => {
455
458
  createCallback({ errorMessage });
456
- onCreateComplete();
459
+ if (isFullMode) {
460
+ onCreateComplete();
461
+ } else {
462
+ onShowTemplates();
463
+ }
457
464
  },
458
465
  );
459
466
  };
@@ -531,7 +538,7 @@ export const SmsTraiCreate = (props) => {
531
538
  {previewFileIndex !== null && (
532
539
  <>
533
540
  <CapRow span={24} className="upload-type-group-create-container">
534
- <div className="upload-file-preview">
541
+ <>
535
542
  <CapDivider
536
543
  type="horizontal"
537
544
  className="upload-file-preview-divider-1"
@@ -636,7 +643,7 @@ export const SmsTraiCreate = (props) => {
636
643
  className="upload-file-preview-divider-2"
637
644
  />
638
645
  {errorText && <CapError>{errorText}</CapError>}
639
- </div>
646
+ </>
640
647
  </CapRow>
641
648
  </>
642
649
  )}
@@ -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';
@@ -28,6 +28,7 @@ const SmsWrapper = (props) => {
28
28
  onCreateComplete,
29
29
  handleClose,
30
30
  smsRegister,
31
+ onShowTemplates,
31
32
  } = props;
32
33
 
33
34
  const smsProps = {
@@ -44,15 +45,15 @@ const SmsWrapper = (props) => {
44
45
  onPreviewContentClicked,
45
46
  onTestContentClicked,
46
47
  };
47
- const isTraiDltFeatureForOrg = hasTraiDltFeature();
48
- const isTariEnableforLib = (!isFullMode && smsRegister === "DLT" ) || isFullMode;
49
- const isTraiDltFeature = isTraiDltFeatureForOrg && isTariEnableforLib;
48
+ const isTraiDlt = isTraiDLTEnable(isFullMode, smsRegister);
50
49
  return <>
51
50
  {
52
- isCreateSms && (isTraiDltFeature ?
51
+ isCreateSms && (isTraiDlt ?
53
52
  <SmsTraiCreate
54
53
  isComponent
55
- {...smsProps}/> :
54
+ {...smsProps}
55
+ onShowTemplates={onShowTemplates}
56
+ /> :
56
57
  <SmsCreate
57
58
  isComponent {
58
59
  ...smsProps
@@ -60,7 +61,7 @@ const SmsWrapper = (props) => {
60
61
  />
61
62
  )
62
63
  }
63
- {isEditSms && (isTraiDltFeature ?
64
+ {isEditSms && (isTraiDlt ?
64
65
  <SmsTraiEdit
65
66
  {...smsProps}
66
67
  params={{id: templateData._id}}
@@ -208,11 +208,9 @@ export class Templates extends React.Component { // eslint-disable-line react/pr
208
208
  }
209
209
  }
210
210
  checkDLTfeatureEnable = () => {
211
- const isTraiDltFeatureForOrg = commonUtil.hasTraiDltFeature();
212
211
  const {smsRegister, isFullMode} = this.props;
213
- const isTariEnableforLib = (!isFullMode && smsRegister === "DLT" ) || isFullMode;
214
- const isTraiDltFeature = isTraiDltFeatureForOrg && isTariEnableforLib;
215
- return isTraiDltFeature;
212
+ const isTraiDlt = commonUtil.isTraiDLTEnable(isFullMode, smsRegister);
213
+ return isTraiDlt;
216
214
  }
217
215
  componentDidMount() {
218
216
  if (this.props.location.query.type === 'embedded' && this.isEnabledInLibraryModule("setLocale")) {
@@ -2277,6 +2275,7 @@ Templates.propTypes = {
2277
2275
  router: PropTypes.object,
2278
2276
  viberActions: PropTypes.object,
2279
2277
  facebookActions: PropTypes.object,
2278
+ smsRegister: PropTypes.any,
2280
2279
  };
2281
2280
 
2282
2281
  const mapStateToProps = createStructuredSelector({