@capillarytech/creatives-library 6.0.4 → 6.1.0

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": "6.0.4",
4
+ "version": "6.1.0",
5
5
  "description": "Capillary creatives ui",
6
6
  "main": "./index.js",
7
7
  "module": "./index.es.js",
@@ -583,7 +583,7 @@ class FormBuilder extends React.Component { // eslint-disable-line react/prefer-
583
583
  if (this.props.schema && this.props.schema.channel && this.props.schema.channel.toUpperCase() === 'WECHAT') {
584
584
 
585
585
  _.forEach(this.state.formData, (val, index) => {
586
-
586
+
587
587
  if (index.indexOf('template') > -1 && this.state.formData[index] !== undefined) {
588
588
  const content = this.state.formData[index];
589
589
  if (content.trim() === '') {
@@ -2519,6 +2519,17 @@ class FormBuilder extends React.Component { // eslint-disable-line react/prefer-
2519
2519
  );
2520
2520
  }
2521
2521
  break;
2522
+ case "label": {
2523
+ columns.push(
2524
+ <CapHeading
2525
+ type={val.headingType || "h4"}
2526
+ style={val.style || {}}
2527
+ >
2528
+ {val.value}
2529
+ </CapHeading>
2530
+ );
2531
+ break;
2532
+ }
2522
2533
  default:
2523
2534
  break;
2524
2535
  }
@@ -2878,7 +2889,7 @@ class FormBuilder extends React.Component { // eslint-disable-line react/prefer-
2878
2889
  <div className={`image-container ${props.ifError ? 'error' : ''}`}>
2879
2890
 
2880
2891
  {isImage ?
2881
- <CapImage src={self.state.formData[`${self.state.currentTab - 1}`].image} alt={props.alt} style={props.style}/>
2892
+ <CapImage src={self.state.formData[`${self.state.currentTab - 1}`].image} alt={props.alt} style={props.style}/>
2882
2893
  :
2883
2894
  <div style={{width: "100%", textAlign: "center"}}><span className="image-placeholder">{props.placeholder}</span></div>
2884
2895
  }
@@ -6,13 +6,18 @@
6
6
 
7
7
  import React from 'react';
8
8
  import PropTypes from 'prop-types';
9
- import { CapRow, CapColumn, CapInput, CapButton, CapSpin } from '@capillarytech/cap-ui-library';
10
- import { injectIntl, intlShape } from 'react-intl';
9
+ import { CapRow, CapColumn, CapInput, CapButton, CapSpin, CapCheckbox } from '@capillarytech/cap-ui-library';
10
+ import { injectIntl, intlShape, FormattedMessage } from 'react-intl';
11
+ import {
12
+ FONT_SIZE_S,
13
+ } from '@capillarytech/cap-ui-library/styled/variables';
11
14
  import TagList from '../../v2Containers/TagList';
12
15
  import CallTaskPreview from '../CallTaskPreview';
13
16
  import messages from './messages';
14
17
  import './_newCallTask.scss';
15
18
 
19
+ const CALL = 'CALL';
20
+ const STOREMAX_WHATSAPP = 'STOREMAX_WHATSAPP';
16
21
  class NewCallTask extends React.Component { // eslint-disable-line react/prefer-stateless-function
17
22
  constructor(props) {
18
23
  super(props);
@@ -25,6 +30,7 @@ class NewCallTask extends React.Component { // eslint-disable-line react/prefer-
25
30
  subject: templateData && templateData.subject ? templateData.subject : '',
26
31
  messageBody: templateData && templateData.messageBody ? templateData.messageBody : '',
27
32
  description: templateData && templateData.description ? templateData.description : '',
33
+ callTaskActionType: CALL,
28
34
  };
29
35
  }
30
36
 
@@ -82,6 +88,14 @@ class NewCallTask extends React.Component { // eslint-disable-line react/prefer-
82
88
  this.props.onCallTaskSubmit(this.state);
83
89
  }
84
90
 
91
+ onS2DCheckChange = (e) => {
92
+ if (e.target.checked) {
93
+ this.setState({callTaskActionType: STOREMAX_WHATSAPP});
94
+ } else {
95
+ this.setState({callTaskActionType: CALL});
96
+ }
97
+ };
98
+
85
99
  render() {
86
100
  const { intl, isLoading, metaEntities, selectedOfferDetails } = this.props;
87
101
  const { formatMessage } = intl;
@@ -123,6 +137,13 @@ class NewCallTask extends React.Component { // eslint-disable-line react/prefer-
123
137
  value={description}
124
138
  isRequired
125
139
  />
140
+ <CapCheckbox
141
+ onChange={this.onS2DCheckChange}
142
+ checked={this.state.callTaskActionType !== CALL}
143
+ style={{marginTop: FONT_SIZE_S}}
144
+ >
145
+ <FormattedMessage {...messages.useInS2D}/>
146
+ </CapCheckbox>
126
147
  </div>
127
148
  <CapButton
128
149
  disabled={!subject || !messageBody || !description}
@@ -26,4 +26,8 @@ export default defineMessages({
26
26
  id: 'creatives.componentsV2.NewCallTask.personalisationTags',
27
27
  defaultMessage: 'Add Labels',
28
28
  },
29
+ useInS2D: {
30
+ id: 'creatives.componentsV2.NewCallTask.useInS2D',
31
+ defaultMessage: 'Use in Store2Door',
32
+ },
29
33
  });
@@ -1,3 +1,4 @@
1
+ @import '~@capillarytech/cap-ui-library/styles/_variables.scss';
1
2
  .wechat-container {
2
3
  #wechat-template {
3
4
  width: 100%;
@@ -21,4 +22,10 @@
21
22
  .link-row{
22
23
  margin-top: 16px;
23
24
  }
25
+ .mini-program-row {
26
+ margin-top: $CAP_SPACE_12;
27
+ .component-with-label-label {
28
+ font-size: $FONT_SIZE_M;
29
+ }
30
+ }
24
31
  }
@@ -34,6 +34,8 @@ import { TRACK_CREATE_WECHAT, TRACK_EDIT_WECHAT } from '../../App/constants';
34
34
 
35
35
  const SELECT_TEMPLATE_MODE = "selectTemplate";
36
36
  const MAP_TEMPLATE_MODE = "mapTemplateMode";
37
+ const URL = "URL";
38
+ const MINI_PROGRAM = "Mini-Program";
37
39
  const { CapCustomCardList } = CapCustomCard;
38
40
 
39
41
  export class MapTemplates extends React.Component { // eslint-disable-line react/prefer-stateless-function
@@ -66,6 +68,10 @@ export class MapTemplates extends React.Component { // eslint-disable-line react
66
68
  "is-internal-url": {
67
69
  onChange: this.internalUrlChecked,
68
70
  },
71
+ "template-redirect-options-radio": {
72
+ onChange: this.onRedirectOptionSelection,
73
+ },
74
+
69
75
  },
70
76
  selectedTemplateTags: [],
71
77
  isEdit: false,
@@ -438,6 +444,8 @@ export class MapTemplates extends React.Component { // eslint-disable-line react
438
444
  Title: editTemplateData.versions.base.Title,
439
445
  Tag: [],
440
446
  url: this.state.formData['is-internal-url'] ? this.maskTemplateUrl(this.state.formData['template-link']) : this.state.formData['template-link'],
447
+ userName: this.state.formData['template-mini-program-id'] ? this.state.formData['template-mini-program-id'] : '',
448
+ path: this.state.formData['template-mini-program-page-path'] ? this.state.formData['template-mini-program-page-path'] : '',
441
449
  TopColor: "#000000",
442
450
  data: {},
443
451
  BrandId: (selectedWeChatAccount.configs.brand_id ? selectedWeChatAccount.configs.brand_id : ''),
@@ -517,6 +525,7 @@ export class MapTemplates extends React.Component { // eslint-disable-line react
517
525
  }
518
526
 
519
527
  setSelectedTemplateData(weChatData) {
528
+ const { intl } = this.props;
520
529
  let schema = cloneDeep(this.state.baseSchema);
521
530
  // schema.standalone.sections[0].childSections[1].childSections[0].childSections[1].inputFields = [];
522
531
  if (isEmpty(weChatData)) {
@@ -616,82 +625,61 @@ export class MapTemplates extends React.Component { // eslint-disable-line react
616
625
 
617
626
  schema.standalone.sections[0].childSections[1].childSections[0].childSections.push(...colsData);
618
627
  });
619
-
620
- schema.standalone.sections[0].childSections[1].childSections[0].childSections.push(
621
- {
622
- type: "multicols",
623
- inputFields: [{
624
- rowClassName: 'link-row',
628
+
629
+ schema.standalone.sections[0].childSections[1].childSections[0].childSections.push({
630
+ type: "col-label",
631
+ inputFields: [{
632
+ id: 'redirect-options-heading',
633
+ type: "label",
634
+ metaType: "text",
635
+ datatype: "string",
636
+ value: intl.formatMessage(messages.redirectOptionsHeadingValue),
637
+ required: true,
638
+ fluid: true,
639
+ headingType: "h4",
640
+ disabled: (this.props.location.query.type === 'embedded' && this.state.isEdit),
641
+ styling: "semantic",
642
+ style: {
643
+ marginTop: 24
644
+ },
645
+ order: 1,
646
+ width: 23,
647
+ customComponent: false,
648
+ standalone: true,
649
+ },
650
+ ]},{
651
+ type: "multicols",
652
+ inputFields: [
653
+ {
654
+ rowClassName: 'redirect-options-row',
625
655
  cols: [
626
656
  {
627
- id: 'template-link',
628
- placeholder: 'Link',
629
- label: 'Link',
630
- type: "input", //Resembles component to be used
657
+ id: 'template-redirect-options-radio',
658
+ type: "radioGroup",
631
659
  metaType: "text",
632
660
  datatype: "string",
633
- errorMessage: 'Link cannot be empty.',
661
+ options: [intl.formatMessage(messages.redirectOptionURL), intl.formatMessage(messages.redirectOptionMiniProgram)],
662
+ errorMessage: intl.formatMessage(messages.redirectionOptionError),
634
663
  required: true,
635
664
  fluid: true,
636
665
  disabled: (this.props.location.query.type === 'embedded' && this.state.isEdit),
637
666
  style: {
638
- fontSize: '14px',
639
- fontStyle: 'normal',
667
+ marginTop: 8,
668
+ display: 'grid',
640
669
  },
641
670
  styling: "semantic",
642
671
  order: 1,
643
672
  width: 23,
644
- // offSet: 6,
645
673
  customComponent: false,
646
674
  standalone: true,
647
675
  supportedEvents: [
648
- 'onChange',
676
+ 'onChange'
649
677
  ],
650
- size: "large",
651
678
  },
652
679
  ],
653
680
  },
654
- {
655
- cols: [
656
- {
657
- id: "is-internal-url",
658
- label: 'Is this internal url',
659
- standalone: true,
660
- labelStyle: {
661
- backgroundColor: "white",
662
- },
663
- colStyle: {
664
- marginBottom: '24px',
665
- },
666
- style: {
667
- textAlign: 'left',
668
- color: '#262626',
669
- fontFamily: 'Open-Sans',
670
- lineHeight: '24px',
671
- fontSize: '14px',
672
- padding: '.5833em .833em',
673
- marginBottom: '24px',
674
- paddingLeft: '0',
675
- },
676
- type: "checkbox",
677
- disabled: (this.props.location.query.type === 'embedded' && this.state.isEdit),
678
- metaType: "text",
679
- datatype: "boolean",
680
- required: true,
681
- fluid: true,
682
- styling: "semantic",
683
- order: 1,
684
- width: 10,
685
- onlyDisplay: false,
686
- customComponent: false,
687
- supportedEvents: [
688
- 'onChange',
689
- ],
690
- },
691
- ],
692
- }],
693
- }
694
- );
681
+ ]});
682
+
695
683
  if (this.state.isEdit) {
696
684
  forEach(this.state.editTemplateData.versions.base.Tag, (tag) => {
697
685
  let tagName = tag;
@@ -704,11 +692,19 @@ export class MapTemplates extends React.Component { // eslint-disable-line react
704
692
  formData[`template-${tagName}`] = this.state.editTemplateData.versions.base.data[tag].value;
705
693
  });
706
694
  if (this.state.editTemplateData.versions.base.url) {
695
+ formData['template-redirect-options-radio'] = URL;
707
696
  formData[`template-link`] = this.state.editTemplateData.versions.base.isInternalUrl ? this.unMaskTemplateUrl(this.state.editTemplateData.versions.base.url) : this.state.editTemplateData.versions.base.url;
697
+ schema.standalone.sections[0].childSections[1].childSections[0].childSections.push(this.getURLSchema());
708
698
  }
709
699
  if (this.state.editTemplateData.versions.base.isInternalUrl) {
710
700
  formData['is-internal-url'] = this.state.editTemplateData.versions.base.isInternalUrl;
711
701
  }
702
+ if (this.state.editTemplateData.versions.base.userName && this.state.editTemplateData.versions.base.path) {
703
+ formData['template-redirect-options-radio'] = MINI_PROGRAM;
704
+ formData['template-mini-program-id'] = this.state.editTemplateData.versions.base.userName;
705
+ formData['template-mini-program-page-path'] = this.state.editTemplateData.versions.base.path;
706
+ schema.standalone.sections[0].childSections[1].childSections[0].childSections.push(this.getMiniProgramSchema());
707
+ }
712
708
  // schema.standalone.sections[0].childSections[1].childSections[1].inputFields[0].cols[0].content = weChatData.content;
713
709
  } else {
714
710
  // schema.standalone.sections[0].childSections[1].childSections[1].inputFields[0].cols[0].content = weChatData.content;
@@ -939,6 +935,155 @@ export class MapTemplates extends React.Component { // eslint-disable-line react
939
935
  internalUrlChecked() {
940
936
 
941
937
  }
938
+
939
+ getURLSchema = () => ({
940
+ type: "multicols",
941
+ inputFields: [{
942
+ rowClassName: 'link-row',
943
+ cols: [
944
+ {
945
+ id: 'template-link',
946
+ placeholder: this.props.intl.formatMessage(messages.templateLinkLabel),
947
+ label: this.props.intl.formatMessage(messages.templateLinkLabel),
948
+ type: "input",
949
+ metaType: "text",
950
+ datatype: "string",
951
+ errorMessage: this.props.intl.formatMessage(messages.templateLinkError),
952
+ required: true,
953
+ fluid: true,
954
+ disabled: (this.props.location.query.type === 'embedded' && this.state.isEdit),
955
+ style: {
956
+ fontSize: '14px',
957
+ fontStyle: 'normal',
958
+ },
959
+ styling: "semantic",
960
+ order: 1,
961
+ width: 23,
962
+ customComponent: false,
963
+ standalone: true,
964
+ supportedEvents: [
965
+ 'onChange',
966
+ ],
967
+ size: "large",
968
+ },
969
+ ],
970
+ },
971
+ {
972
+ cols: [
973
+ {
974
+ id: "is-internal-url",
975
+ label: this.props.intl.formatMessage(messages.internalUrlLabel),
976
+ standalone: true,
977
+ labelStyle: {
978
+ backgroundColor: "white",
979
+ },
980
+ colStyle: {
981
+ marginBottom: '24px',
982
+ },
983
+ style: {
984
+ textAlign: 'left',
985
+ color: '#262626',
986
+ fontFamily: 'Open-Sans',
987
+ lineHeight: '24px',
988
+ fontSize: '14px',
989
+ padding: '.5833em .833em',
990
+ marginBottom: '24px',
991
+ paddingLeft: '0',
992
+ },
993
+ type: "checkbox",
994
+ disabled: (this.props.location.query.type === 'embedded' && this.state.isEdit),
995
+ metaType: "text",
996
+ datatype: "boolean",
997
+ required: true,
998
+ fluid: true,
999
+ styling: "semantic",
1000
+ order: 1,
1001
+ width: 10,
1002
+ onlyDisplay: false,
1003
+ customComponent: false,
1004
+ supportedEvents: [
1005
+ 'onChange',
1006
+ ],
1007
+ },
1008
+ ],
1009
+ }],
1010
+ })
1011
+
1012
+ getMiniProgramSchema = () => ({
1013
+ type: "multicols",
1014
+ inputFields: [{
1015
+ rowClassName: 'mini-program-row',
1016
+ cols: [
1017
+ {
1018
+ id: 'template-mini-program-id',
1019
+ placeholder: this.props.intl.formatMessage(messages.miniWeChatPlaceholder),
1020
+ inductiveText: this.props.intl.formatMessage(messages.miniWechatIdInductive),
1021
+ label: this.props.intl.formatMessage(messages.miniWechatIdLabel),
1022
+ type: "input",
1023
+ metaType: "text",
1024
+ datatype: "string",
1025
+ errorMessage: this.props.intl.formatMessage(messages.miniWechatIdError),
1026
+ required: true,
1027
+ fluid: true,
1028
+ disabled: (this.props.location.query.type === 'embedded' && this.state.isEdit),
1029
+ styling: "semantic",
1030
+ order: 1,
1031
+ width: 23,
1032
+ customComponent: false,
1033
+ standalone: true,
1034
+ },
1035
+ ],
1036
+ },
1037
+ {
1038
+ rowClassName: 'mini-program-row',
1039
+ cols: [
1040
+ {
1041
+ id: 'template-mini-program-page-path',
1042
+ placeholder: this.props.intl.formatMessage(messages.pagePathPlaceholder),
1043
+ inductiveText: this.props.intl.formatMessage(messages.pagePathInductive),
1044
+ label: this.props.intl.formatMessage(messages.pagePathLabel),
1045
+ type: "input",
1046
+ metaType: "text",
1047
+ datatype: "string",
1048
+ errorMessage: this.props.intl.formatMessage(messages.pagePathError),
1049
+ required: true,
1050
+ fluid: true,
1051
+ disabled: (this.props.location.query.type === 'embedded' && this.state.isEdit),
1052
+ styling: "semantic",
1053
+ order: 1,
1054
+ width: 23,
1055
+ customComponent: false,
1056
+ standalone: true,
1057
+ }
1058
+ ],
1059
+ }],
1060
+ })
1061
+
1062
+ deletePreviousRedirectOptionSelection = () => {
1063
+ let schema = cloneDeep(this.state.schema);
1064
+ const formChildSections = get(schema, 'standalone.sections[0].childSections[1].childSections[0].childSections', []);
1065
+ const lastChildSection = formChildSections[formChildSections.length - 1];
1066
+ const lastInputField = get(lastChildSection, 'inputFields[0].rowClassName', '');
1067
+ if(lastInputField === 'mini-program-row' || lastInputField === 'link-row') {
1068
+ schema.standalone.sections[0].childSections[1].childSections[0].childSections.pop();
1069
+ }
1070
+ return schema;
1071
+ }
1072
+
1073
+ onRedirectOptionSelection = (paramOne, formData) => {
1074
+ let schema = this.deletePreviousRedirectOptionSelection();
1075
+ switch (formData['template-redirect-options-radio']) {
1076
+ case URL: {
1077
+ schema.standalone.sections[0].childSections[1].childSections[0].childSections.push(this.getURLSchema());
1078
+ break;
1079
+ }
1080
+ case MINI_PROGRAM: {
1081
+ schema.standalone.sections[0].childSections[1].childSections[0].childSections.push(this.getMiniProgramSchema());
1082
+ break;
1083
+ }
1084
+ }
1085
+ this.setState({schema});
1086
+ }
942
1087
 
943
1088
  discardValues() {
944
1089
  // this.setState({ schema: this.state.baseSchema, formData: {}});
@@ -980,6 +1125,8 @@ export class MapTemplates extends React.Component { // eslint-disable-line react
980
1125
  "template_id": selectedWechatData.template_id,
981
1126
  "Title": selectedWechatData.title,
982
1127
  Tag: [],
1128
+ userName: this.state.formData['template-mini-program-id'] ? this.state.formData['template-mini-program-id'] : '',
1129
+ path: this.state.formData['template-mini-program-page-path'] ? this.state.formData['template-mini-program-page-path'] : '',
983
1130
  url: this.state.formData['is-internal-url'] ? this.maskTemplateUrl(this.state.formData['template-link']) : this.state.formData['template-link'],
984
1131
  TopColor: "#000000",
985
1132
  data: {},
@@ -106,4 +106,64 @@ export default defineMessages({
106
106
  id: 'creatives.containersV2.WeChat.templateName',
107
107
  defaultMessage: 'Template Name',
108
108
  },
109
+ "redirectionOptionError": {
110
+ id: 'creatives.containersV2.WeChat.redirectionOptionError',
111
+ defaultMessage: 'Please select a redirect option',
112
+ },
113
+ "miniWechatIdInductive": {
114
+ id: 'creatives.containersV2.WeChat.miniWechatIdInductive',
115
+ defaultMessage: 'Unique alpha numeric code for this specific app',
116
+ },
117
+ "miniWechatIdLabel": {
118
+ id: 'creatives.containersV2.WeChat.miniWechatIdLabel',
119
+ defaultMessage: 'Mini-Program ID',
120
+ },
121
+ "miniWechatIdError": {
122
+ id: 'creatives.containersV2.WeChat.miniWechatIdError',
123
+ defaultMessage: 'Mini-Program ID cannot be empty',
124
+ },
125
+ "miniWeChatPlaceholder": {
126
+ id: 'creatives.containersV2.WeChat.miniWeChatPlaceholder',
127
+ defaultMessage: 'E.g. ab4892njkl4l2op',
128
+ },
129
+ "templateLinkLabel": {
130
+ id: 'creatives.containersV2.WeChat.templateLinkLabel',
131
+ defaultMessage: 'Link',
132
+ },
133
+ "templateLinkError": {
134
+ id: 'creatives.containersV2.WeChat.templateLinkError',
135
+ defaultMessage: 'Link cannot be empty.',
136
+ },
137
+ "internalUrlLabel": {
138
+ id: 'creatives.containersV2.WeChat.internalUrlLabel',
139
+ defaultMessage: 'Is this internal url',
140
+ },
141
+ "pagePathPlaceholder": {
142
+ id: 'creatives.containersV2.WeChat.pagePathPlaceholder',
143
+ defaultMessage: 'E.g. pages/user/profile',
144
+ },
145
+ "pagePathInductive": {
146
+ id: 'creatives.containersV2.WeChat.pagePathInductive',
147
+ defaultMessage: 'Provide the path within the Mini-Program user will taken to',
148
+ },
149
+ "pagePathLabel": {
150
+ id: 'creatives.containersV2.WeChat.pagePathLabel',
151
+ defaultMessage: 'Page path',
152
+ },
153
+ "pagePathError": {
154
+ id: 'creatives.containersV2.WeChat.pagePathError',
155
+ defaultMessage: 'Page path cannot be empty.',
156
+ },
157
+ "redirectOptionsHeadingValue": {
158
+ id: 'creatives.containersV2.WeChat.redirectOptionsHeadingValue',
159
+ defaultMessage: 'URL or Mini-Program',
160
+ },
161
+ "redirectOptionURL": {
162
+ id: 'creatives.containersV2.WeChat.redirectOptionURL',
163
+ defaultMessage: 'URL',
164
+ },
165
+ "redirectOptionMiniProgram": {
166
+ id: 'creatives.containersV2.WeChat.redirectOptionMiniProgram',
167
+ defaultMessage: 'Mini-Program',
168
+ },
109
169
  });