@capillarytech/creatives-library 7.10.40 → 7.10.41

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.40",
4
+ "version": "7.10.41",
5
5
  "description": "Capillary creatives ui",
6
6
  "main": "./index.js",
7
7
  "module": "./index.es.js",
@@ -371,6 +371,7 @@ function SlideBoxContent(props) {
371
371
  content={getChannelPreviewContent(templateData)}
372
372
  viberBrandName={selectedAccount || ""}
373
373
  viberAccountName={(selectedAccount || "")[0]}
374
+ whatsappAccountName={selectedAccount}
374
375
  unicodeEnabled={get(templateData, `versions.base['unicode-validity']`)}
375
376
  channel={(templateData.type || '').toLowerCase()}
376
377
  charCounterEnabled={channel === constants.SMS}
@@ -690,14 +691,20 @@ function SlideBoxContent(props) {
690
691
  {isCreateWhatsapp && (<Whatsapp
691
692
  isFullMode={isFullMode}
692
693
  onCreateComplete={onCreateComplete}
693
- handleClose={handleClose}
694
+ handleClose={handleClose}/>
695
+ )}
696
+
697
+ {isEditWhatsapp && (<Whatsapp
698
+ isFullMode={isFullMode}
694
699
  templateData={templateData}
700
+ params={{
701
+ id: templateData._id,
702
+ }}
695
703
  location={{
696
- pathname: `/whatsapp`,
704
+ pathname: `/whatsapp/edit`,
697
705
  query,
698
706
  search: '',
699
- }}
700
- selectedWeChatAccount={selectedWeChatAccount} />
707
+ }}/>
701
708
  )}
702
709
 
703
710
  </CreativesWrapper>
@@ -5,9 +5,18 @@ import { CapHeader, CapIcons, CapLabel, CapSteps } from '@capillarytech/cap-ui-l
5
5
  import moment from 'moment';
6
6
  import PropTypes from 'prop-types';
7
7
  import messages from './messages';
8
+ import whatsppMsg from '../Whatsapp/messages';
8
9
  import { MAP_TEMPLATE } from '../WeChat/Wrapper/constants';
9
10
  import { NO_COMMUNICATION, FTP } from '../App/constants';
10
11
  import { isTraiDLTEnable } from '../../utils/common';
12
+ import { formatString } from '../../utils/Formatter';
13
+ import {
14
+ CAP_SPACE_12,
15
+ } from '@capillarytech/cap-ui-library/styled/variables';
16
+ const { CapLabelInline } = CapLabel;
17
+ const StyledLabel = styled(CapLabelInline)`
18
+ margin-right: ${CAP_SPACE_12};
19
+ `;
11
20
  const PrefixWrapper = styled.div`
12
21
  margin-right: 16px;
13
22
  `;
@@ -19,18 +28,23 @@ function getChannelLabel(channel = '') {
19
28
  wechat: 'Wechat',
20
29
  no_communication: 'NO_COMMUNICATION',
21
30
  ftp: 'FTP',
22
- whatsapp: 'WhatsApp Template',
31
+ whatsapp: 'WhatsApp template',
23
32
  };
24
33
  return labels[channel.toLowerCase()];
25
34
  }
26
-
27
-
35
+ const renderWhatsappData = (type, value) => (
36
+ <StyledLabel type={type}>
37
+ {value}
38
+ </StyledLabel>
39
+ )
28
40
  function SlideBoxHeader(props) {
29
41
  const { slidBoxContent, templateData, onShowTemplates, creativesMode, isFullMode, showPrefix, shouldShowTemplateName, channel, templateNameRenderProp, weChatTemplateType, onWeChatMaptemplateStepChange, weChatMaptemplateStep, templateStep, smsRegister } = props;
30
42
  const showTemplateNameHeader = isFullMode && shouldShowTemplateName;
31
43
  const mapTemplateCreate = !showTemplateNameHeader && slidBoxContent === 'createTemplate' && weChatTemplateType === MAP_TEMPLATE && templateStep !== 'modeSelection';
32
44
  const isTraiDlt = isTraiDLTEnable(isFullMode, smsRegister);
33
45
  const showCreateTraiSMSHeader = isTraiDlt && channel.toLowerCase() === "sms";
46
+ const isWhatsappEdit = channel.toLowerCase() === 'whatsapp' && slidBoxContent === 'editTemplate';
47
+ const whatsappOverview = isWhatsappEdit && isFullMode;
34
48
 
35
49
  return (
36
50
  <div key="creatives-container-slidebox-header-content">
@@ -58,7 +72,20 @@ function SlideBoxHeader(props) {
58
72
  )}
59
73
  {!showTemplateNameHeader && slidBoxContent === 'editTemplate' && (
60
74
  <CapHeader
61
- title={<FormattedMessage {...messages.editMessageContent} values={{channel: getChannelLabel(channel)}}/>}
75
+ title={<FormattedMessage {...(whatsappOverview ? messages.whatsappOverview : messages.editMessageContent)} values={{channel: getChannelLabel(channel)}}/>}
76
+ description={
77
+ isWhatsappEdit && (
78
+ <>
79
+ {renderWhatsappData("label1", <FormattedMessage {...whatsppMsg.templateNameLabel} />)}
80
+ {renderWhatsappData("label2", templateData?.whatsappTemplateName)}
81
+ {renderWhatsappData("label3", <FormattedMessage {...whatsppMsg.labelSeperator} />)}
82
+ {renderWhatsappData("label1", <FormattedMessage {...whatsppMsg.templateCategoryLabel} />)}
83
+ {renderWhatsappData("label2", formatString(templateData?.whatsappTemplateCategory))}
84
+ {renderWhatsappData("label3", <FormattedMessage {...whatsppMsg.labelSeperator} />)}
85
+ {renderWhatsappData("label1", <FormattedMessage {...whatsppMsg.languageLabel} />)}
86
+ {renderWhatsappData("label2", <FormattedMessage {...whatsppMsg.templateLanguageEnglish} />)}
87
+ </>)
88
+ }
62
89
  prefix={creativesMode !== 'edit' && !isFullMode && showPrefix &&
63
90
  <PrefixWrapper>
64
91
  <CapIcons.backIcon onClick={onShowTemplates} />
@@ -306,4 +306,8 @@ export default defineMessages({
306
306
  id: `${scope}.UploadSMStemplates`,
307
307
  defaultMessage: `Upload SMS templates`,
308
308
  },
309
+ "whatsappOverview": {
310
+ id: `${scope}.whatsappOverview`,
311
+ defaultMessage: `WhatsApp template overview`,
312
+ },
309
313
  });
@@ -43,7 +43,7 @@ import * as emailActions from '../Email/actions';
43
43
  import * as lineActions from '../Line/Container/actions';
44
44
  import * as viberActions from '../Viber/actions';
45
45
  import * as facebookActions from '../Facebook/actions';
46
-
46
+ import * as whatsappActions from '../Whatsapp/actions';
47
47
  import CardGrid from '../../v2Components/CardGrid';
48
48
  import config from '../../config/app';
49
49
  import './_templates.scss';
@@ -439,6 +439,8 @@ export class Templates extends React.Component { // eslint-disable-line react/pr
439
439
  this.props.viberActions.clearCreateResponse();
440
440
  } else if (this.state.channel.toLowerCase() === FACEBOOK_CHANNEL) {
441
441
  this.props.facebookActions.clearCreateResponse();
442
+ }else if (this.state.channel.toLowerCase() === WHATSAPP_LOWERCASE) {
443
+ this.props.whatsappActions.clearCreateResponse();
442
444
  }
443
445
  }
444
446
  }
@@ -489,7 +491,16 @@ export class Templates extends React.Component { // eslint-disable-line react/pr
489
491
  paramsDefault.wecrmId = nextProps.Templates.weCrmAccounts[0].configs.wecrm_app_id;
490
492
  paramsDefault.wecrmToken = nextProps.Templates.weCrmAccounts[0].configs.wecrm_token;
491
493
  paramsDefault.originalId = nextProps.Templates.weCrmAccounts[0].sourceAccountIdentifier;
492
- nextProps.actions.setWeChatAccount(nextProps.Templates.weCrmAccounts[0]);
494
+ if (WHATSAPP_LOWERCASE === this.state.channel.toLowerCase()) {
495
+ nextProps.actions.setChannelAccount(
496
+ WHATSAPP,
497
+ nextProps.Templates.weCrmAccounts[0],
498
+ );
499
+ } else {
500
+ nextProps.actions.setWeChatAccount(
501
+ nextProps.Templates.weCrmAccounts[0],
502
+ );
503
+ }
493
504
  }
494
505
  this.setState({defaultAccount: false, activeMode: TEMPLATES_MODE, selectedAccount: nextProps.Templates.weCrmAccounts[0].name });
495
506
  this.getAllTemplates({params: paramsDefault}, true);
@@ -577,6 +588,11 @@ export class Templates extends React.Component { // eslint-disable-line react/pr
577
588
  creativesParams._id = pathname.split('/')[3];
578
589
  creativesParams.modeType = pathname.split('/')[4];
579
590
  creativesParams.account = pathname.split('/')[5];
591
+ if(this.state.channel.toLowerCase() === WHATSAPP_LOWERCASE){
592
+ const whatsappSelectedTemplateData = this.selectTemplate(creativesParams._id) || {};
593
+ creativesParams.whatsappTemplateName = get(whatsappSelectedTemplateData, `name`, '');
594
+ creativesParams.whatsappTemplateCategory = get(whatsappSelectedTemplateData, `versions.base.content.whatsapp.category`, '');
595
+ }
580
596
  }
581
597
  creativesParams.type = this.state.channel.toUpperCase();
582
598
  }
@@ -944,7 +960,24 @@ export class Templates extends React.Component { // eslint-disable-line react/pr
944
960
  </div>
945
961
  }
946
962
 
947
- { !isEmpty(this.props.Templates.selectedWeChatAccount) && ["mobilepush", WHATSAPP_LOWERCASE].includes(this.state.channel.toLowerCase()) && this.state.selectedAccountError ?
963
+ { !isEmpty(this.props.Templates.selectedWeChatAccount) && ["mobilepush"].includes(this.state.channel.toLowerCase()) && this.state.selectedAccountError ?
964
+ <div style={{ height: '65vh', textAlign: 'center', lineHeight: '65vh'}}>
965
+ <CapHeading type="h6" >
966
+ {this.props.intl.formatMessage(messages.accountConfigError)}
967
+ <InlineDiv>
968
+ <CapLink title="here" style={{display: 'inline'}} onClick={() => { window.open(config.production.accountConfig`${accountId}`); }}/>
969
+ </InlineDiv>
970
+ </CapHeading>
971
+ </div> : (
972
+ ["mobilepush"].includes(this.state.channel.toLowerCase()) &&
973
+ isEmpty(filteredTemplates) &&
974
+ isEmpty(this.state.searchText) &&
975
+ <div style={this.isFullMode() ? { height: "calc(100vh - 325px)", overflow: 'auto'} : {}}>
976
+ <CapIllustration buttonClassName={`create-new-${channelLowerCase}`} {...this.getChannelTypeIllustrationInfo(currentChannel)} />
977
+ </div>
978
+ )
979
+ }
980
+ { !isEmpty(this.props.Templates.selectedWhatsappAccount) && [WHATSAPP_LOWERCASE].includes(this.state.channel.toLowerCase()) && this.state.selectedAccountError ?
948
981
  <div style={{ height: '65vh', textAlign: 'center', lineHeight: '65vh'}}>
949
982
  <CapHeading type="h6" >
950
983
  {this.props.intl.formatMessage(messages.accountConfigError)}
@@ -953,9 +986,10 @@ export class Templates extends React.Component { // eslint-disable-line react/pr
953
986
  </InlineDiv>
954
987
  </CapHeading>
955
988
  </div> : (
956
- ["mobilepush", WHATSAPP_LOWERCASE].includes(this.state.channel.toLowerCase()) &&
989
+ [WHATSAPP_LOWERCASE].includes(this.state.channel.toLowerCase()) &&
957
990
  isEmpty(filteredTemplates) &&
958
991
  isEmpty(this.state.searchText) &&
992
+ !isLoading &&
959
993
  <div style={this.isFullMode() ? { height: "calc(100vh - 325px)", overflow: 'auto'} : {}}>
960
994
  <CapIllustration buttonClassName={`create-new-${channelLowerCase}`} {...this.getChannelTypeIllustrationInfo(currentChannel)} />
961
995
  </div>
@@ -2493,6 +2527,7 @@ Templates.propTypes = {
2493
2527
  router: PropTypes.object,
2494
2528
  viberActions: PropTypes.object,
2495
2529
  facebookActions: PropTypes.object,
2530
+ whatsappActions: PropTypes.object,
2496
2531
  smsRegister: PropTypes.any,
2497
2532
  };
2498
2533
 
@@ -2521,6 +2556,7 @@ function mapDispatchToProps(dispatch) {
2521
2556
  lineActions: bindActionCreators(lineActions, dispatch),
2522
2557
  viberActions: bindActionCreators(viberActions, dispatch),
2523
2558
  facebookActions: bindActionCreators(facebookActions, dispatch),
2559
+ whatsappActions: bindActionCreators(whatsappActions, dispatch),
2524
2560
  };
2525
2561
  }
2526
2562
 
@@ -82,11 +82,11 @@ function templatesReducer(state = initialState, action) {
82
82
  return state
83
83
  .set('selectedWeChatAccount', fromJS(action.weChatAccount));
84
84
  case types.SET_LINE_ACCOUNT:
85
- return state.set('selectedLineAccount', fromJS(action.lineAccount));
85
+ return state.set('selectedLineAccount', fromJS(action.account));
86
86
  case types.SET_VIBER_ACCOUNT:
87
87
  return state.set('selectedViberAccount', fromJS(action.viberAccount));
88
88
  case types.SET_WHATSAPP_ACCOUNT:
89
- return state.set('selectedWhatsappAccount', fromJS(action.whatsappAccount));
89
+ return state.set('selectedWhatsappAccount', fromJS(action.account));
90
90
  case types.SET_FACEBOOK_ACCOUNT:
91
91
  return state.set('selectedFacebookAccount', fromJS(action.faceBookAccount));
92
92
  case types.RESET_ACCOUNT:
@@ -1,17 +1,34 @@
1
1
  import {
2
- WHATSAPP_TEMPLATE_CREATE_REQUEST,
3
- CLEAR_WHATSAPP_TEMPLATE_REQUEST,
2
+ TEMPLATE_CREATE_REQUEST,
3
+ CLEAR_CREATE_RESPONSE_REQUEST,
4
+ GET_TEMPLATE_DETAILS_REQUEST,
5
+ RESET_EDIT_TEMPLATE,
6
+ WHATSAPP,
4
7
  } from './constants';
5
8
 
6
9
  export function createWhatsappTemplate(payload, callback) {
7
10
  return {
8
- type: WHATSAPP_TEMPLATE_CREATE_REQUEST,
11
+ type: TEMPLATE_CREATE_REQUEST,
9
12
  payload,
10
13
  callback,
11
14
  };
12
15
  }
13
16
  export function clearCreateResponse() {
14
17
  return {
15
- type: CLEAR_WHATSAPP_TEMPLATE_REQUEST,
18
+ type: CLEAR_CREATE_RESPONSE_REQUEST,
19
+ };
20
+ }
21
+ // FOR EDIT
22
+ export function getTemplateDetails(id, callback) {
23
+ return {
24
+ type: GET_TEMPLATE_DETAILS_REQUEST,
25
+ id,
26
+ channel: WHATSAPP,
27
+ callback,
28
+ };
29
+ }
30
+ export function resetEditTemplate() {
31
+ return {
32
+ type: RESET_EDIT_TEMPLATE,
16
33
  };
17
34
  }
@@ -1,20 +1,36 @@
1
1
  import React from 'react';
2
2
  import { FormattedMessage } from 'react-intl';
3
3
  import messages from './messages';
4
- import { CAP_ORANGE, CAP_PURPLE02, CAP_PURPLE03, CAP_ORANGE01, CAP_GREEN01, CAP_GREEN02 } from '@capillarytech/cap-ui-library/styled/variables';
4
+ import {
5
+ CAP_ORANGE,
6
+ CAP_PURPLE02,
7
+ CAP_PURPLE03,
8
+ CAP_ORANGE01,
9
+ CAP_GREEN01,
10
+ CAP_GREEN02,
11
+ } from '@capillarytech/cap-ui-library/styled/variables';
5
12
 
6
13
  export const UNSUBSCRIBE_TEXT_LENGTH = 36;
7
14
  export const TEMPLATE_MESSAGE_MAX_LENGTH = 1024;
8
15
  export const WHATSAPP = 'WHATSAPP';
9
16
 
10
- export const WHATSAPP_TEMPLATE_CREATE_REQUEST =
11
- 'app/v2Containers/Whatsapp/WHATSAPP_TEMPLATE_CREATE_REQUEST';
12
- export const WHATSAPP_TEMPLATE_CREATE_SUCCESS =
13
- 'app/v2Containers/Whatsapp/WHATSAPP_TEMPLATE_CREATE_SUCCESS';
14
- export const WHATSAPP_TEMPLATE_CREATE_FAILURE =
15
- 'app/v2Containers/Whatsapp/WHATSAPP_TEMPLATE_CREATE_FAILURE';
16
- export const CLEAR_WHATSAPP_TEMPLATE_REQUEST =
17
- 'app/v2Containers/Whatsapp/CLEAR_WHATSAPP_TEMPLATE_REQUEST';
17
+ export const TEMPLATE_CREATE_REQUEST =
18
+ 'app/v2Containers/Whatsapp/TEMPLATE_CREATE_REQUEST';
19
+ export const TEMPLATE_CREATE_SUCCESS =
20
+ 'app/v2Containers/Whatsapp/TEMPLATE_CREATE_SUCCESS';
21
+ export const TEMPLATE_CREATE_FAILURE =
22
+ 'app/v2Containers/Whatsapp/TEMPLATE_CREATE_FAILURE';
23
+ export const CLEAR_CREATE_RESPONSE_REQUEST =
24
+ 'app/v2Containers/Whatsapp/CLEAR_CREATE_RESPONSE_REQUEST';
25
+ // FOR EDIT
26
+ export const GET_TEMPLATE_DETAILS_REQUEST =
27
+ 'app/v2Containers/Whatsapp/Edit/GET_TEMPLATE_DETAILS_REQUEST';
28
+ export const GET_TEMPLATE_DETAILS_SUCCESS =
29
+ 'app/v2Containers/Whatsapp/Edit/GET_TEMPLATE_DETAILS_SUCCESS';
30
+ export const GET_TEMPLATE_DETAILS_FAILURE =
31
+ 'app/v2Containers/Whatsapp/Edit/GET_TEMPLATE_DETAILS_FAILURE';
32
+ export const RESET_EDIT_TEMPLATE =
33
+ 'app/v2Containers/Whatsapp/Edit//RESET_EDIT_TEMPLATE';
18
34
 
19
35
  export const STATUS = 'status';
20
36
  export const CATEGORY = 'category';
@@ -41,7 +57,7 @@ export const CATEGORY_OPTIONS = [
41
57
  key: 'accountUpdate',
42
58
  label: <FormattedMessage {...messages.accountUpdate} />,
43
59
  tooltipLabel: <FormattedMessage {...messages[`accountUpdate${tooltip}`]} />,
44
- value: WHATSAPP_CATEGORIES.alertUpdate,
60
+ value: WHATSAPP_CATEGORIES.accountUpdate,
45
61
  tagColor: CAP_ORANGE01,
46
62
  tagTextColor: CAP_ORANGE,
47
63
  },
@@ -49,7 +65,9 @@ export const CATEGORY_OPTIONS = [
49
65
  key: 'appointmentUpdate',
50
66
  value: WHATSAPP_CATEGORIES.appointmentUpdate,
51
67
  label: <FormattedMessage {...messages.appointmentUpdate} />,
52
- tooltipLabel: <FormattedMessage {...messages[`appointmentUpdate${tooltip}`]} />,
68
+ tooltipLabel: (
69
+ <FormattedMessage {...messages[`appointmentUpdate${tooltip}`]} />
70
+ ),
53
71
  tagColor: CAP_GREEN02,
54
72
  tagTextColor: CAP_GREEN01,
55
73
  },
@@ -65,7 +83,9 @@ export const CATEGORY_OPTIONS = [
65
83
  key: 'reservationUpdate',
66
84
  value: WHATSAPP_CATEGORIES.reservationUpdate,
67
85
  label: <FormattedMessage {...messages.reservationUpdate} />,
68
- tooltipLabel: <FormattedMessage {...messages[`reservationUpdate${tooltip}`]} />,
86
+ tooltipLabel: (
87
+ <FormattedMessage {...messages[`reservationUpdate${tooltip}`]} />
88
+ ),
69
89
  tagColor: CAP_ORANGE01,
70
90
  tagTextColor: CAP_ORANGE,
71
91
  },
@@ -96,3 +116,10 @@ export const STATUS_OPTIONS = [
96
116
  label: <FormattedMessage {...messages.rejected} />,
97
117
  },
98
118
  ];
119
+
120
+ export const TAG = 'TAG';
121
+ export const EMBEDDED = 'embedded';
122
+ export const DEFAULT = 'default';
123
+ export const FULL = 'full';
124
+ export const ALL = 'all';
125
+ export const LIBRARY = 'library';