@capillarytech/creatives-library 0.1.27 → 0.1.29

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.
Files changed (36) hide show
  1. package/components/CardGrid/index.js +1 -1
  2. package/components/FormBuilder/index.js +72 -0
  3. package/components/PreviewSideBar/index.js +10 -1
  4. package/components/TemplatePreview/index.js +16 -1
  5. package/containers/Cap/constants.js +1 -0
  6. package/containers/Cap/index.js +5 -1
  7. package/containers/Cap/reducer.js +6 -0
  8. package/containers/Email/index.js +12 -2
  9. package/containers/Email/reducer.js +1 -1
  10. package/containers/Line/Create/_lineCreate.scss +43 -0
  11. package/containers/Line/Create/actions.js +90 -0
  12. package/containers/Line/Create/constants.js +39 -0
  13. package/containers/Line/Create/index.js +814 -0
  14. package/containers/Line/Create/messages.js +173 -0
  15. package/containers/Line/Create/reducer.js +99 -0
  16. package/containers/Line/Create/sagas.js +108 -0
  17. package/containers/Line/Create/selectors.js +36 -0
  18. package/containers/Line/Edit/_lineEdit.scss +25 -0
  19. package/containers/Line/Edit/actions.js +72 -0
  20. package/containers/Line/Edit/constants.js +27 -0
  21. package/containers/Line/Edit/index.js +1043 -0
  22. package/containers/Line/Edit/messages.js +157 -0
  23. package/containers/Line/Edit/reducer.js +83 -0
  24. package/containers/Line/Edit/sagas.js +81 -0
  25. package/containers/Line/Edit/selectors.js +29 -0
  26. package/containers/Line/Edit/tests/actions.test.js +18 -0
  27. package/containers/Line/Edit/tests/index.test.js +10 -0
  28. package/containers/Line/Edit/tests/reducer.test.js +9 -0
  29. package/containers/Line/Edit/tests/sagas.test.js +15 -0
  30. package/containers/Line/Edit/tests/selectors.test.js +10 -0
  31. package/containers/MobilePush/Create/index.js +0 -1
  32. package/containers/Templates/index.js +105 -22
  33. package/containers/Templates/messages.js +4 -0
  34. package/package.json +1 -1
  35. package/routes.js +110 -0
  36. package/services/api.js +8 -0
@@ -37,7 +37,7 @@ class CardGrid extends React.Component { // eslint-disable-line react/prefer-sta
37
37
  <div style={{ marginBottom: '16px' }}>{this.props.filterContent}</div>
38
38
  <div className={this.props.enablePagination ? 'pagination-container' : ''}>
39
39
  <Row gutter={this.props.gutterSize}>
40
- { this.props.listItem ? this.props.listItem.map( (item) => (
40
+ { this.props.listItem.length > 0 ? this.props.listItem.map( (item) => (
41
41
  <Col style={{ width: `${100 / this.props.colNumber}%`, paddingBottom: '16px'}} key={item.id} span={parseInt(24 / this.props.colNumber, 10)}>
42
42
  <CustomCard id={item.id} onHover={this.handleOnItemHover} onClick={this.handleOnItemClick} content={item.content} footer={item.footer} height={item.footer ? "312px" : "258px"}></CustomCard>
43
43
  </Col>
@@ -446,6 +446,7 @@ class FormBuilder extends React.Component { // eslint-disable-line react/prefer-
446
446
  /* eslint-disable */
447
447
  validateForm(tags, injectedTags, isSave, showMessages) {
448
448
  console.log('validating form', this.state.formData);
449
+ console.log("mmm", this.props );
449
450
  let isValid = true;
450
451
  const type = (this.props.location && this.props.location.query.type) ? this.props.location.query.type : 'full';
451
452
  const currentModule = (this.props.location && this.props.location.query.module) ? this.props.location.query.module : 'default';
@@ -491,6 +492,47 @@ class FormBuilder extends React.Component { // eslint-disable-line react/prefer-
491
492
  errorData['template-name'] = false;
492
493
  }
493
494
  }
495
+
496
+ //validation for LINE
497
+ if (this.props.schema.channel === 'LINE') {
498
+ console.log('line error validation form data', this.state.formData);
499
+ if (this.state.formData['0']['message-editor'] !== undefined ) {
500
+ const content = this.state.formData['0']['message-editor'];
501
+ console.log('tag valid response', content);
502
+ const tagValidationResponse = this.validateTags(content, tags, injectedTags);
503
+ console.log('tag valid response', tagValidationResponse);
504
+ if (tagValidationResponse.valid) {
505
+ errorData['0']['message-editor'] = false;
506
+ } else {
507
+ console.log('message error validation tags issue');
508
+ errorData['0']['message-editor'] = true;
509
+ isValid = false;
510
+ }
511
+ if (content.trim() === '') {
512
+ console.log('line error validation content is empty');
513
+ errorData['0']['message-editor'] = true;
514
+ isValid = false;
515
+ }
516
+ }
517
+
518
+ if ( (this.state.formData['0'].image !== undefined)){
519
+ const imgContentLength = this.state.formData['0'].image.length;
520
+ if (imgContentLength < 1) {
521
+ console.log('line error validation image content is empty');
522
+ errorData['0'].image = true;
523
+ isValid = false;
524
+ }else{
525
+ errorData['0'].image = false;
526
+ }
527
+ }
528
+ if(type !== 'embedded' && (!this.state.formData['template-name'] || this.state.formData['template-name'] === '')) {
529
+ errorData['template-name'] = true;
530
+ isValid = false;
531
+ } else {
532
+ errorData['template-name'] = false;
533
+ }
534
+ }
535
+
494
536
  if (this.props.schema && this.props.schema.channel && this.props.schema.channel.toUpperCase() === 'WECHAT') {
495
537
  console.log('Validating Form Now ', this.state.formData);
496
538
  _.forEach(this.state.formData, (val, index) => {
@@ -995,6 +1037,10 @@ class FormBuilder extends React.Component { // eslint-disable-line react/prefer-
995
1037
  const ifSkipped = this.skipTags(tagValue);
996
1038
  if (ifSkipped) {
997
1039
  ifSupported = true;
1040
+ const missingTagIndex = response.missingTags.indexOf(tagValue);
1041
+ if(missingTagIndex != -1) { //skip regex tags for mandatory tags also
1042
+ response.missingTags.splice(missingTagIndex, 1);
1043
+ }
998
1044
  }
999
1045
  ifSupported = ifSupported || this.checkIfSupportedTag(tagValue, injectedTags);
1000
1046
  if (!ifSupported) {
@@ -1821,6 +1867,9 @@ class FormBuilder extends React.Component { // eslint-disable-line react/prefer-
1821
1867
  return true;
1822
1868
  };
1823
1869
  callChildEvent(data, val, event, e) {
1870
+ console.log("lks 1", data);
1871
+ console.log("lks 2", val);
1872
+ console.log("lks 3", event);
1824
1873
  if (!event) {
1825
1874
  console.log('rogue event');
1826
1875
  return;
@@ -2736,6 +2785,29 @@ class FormBuilder extends React.Component { // eslint-disable-line react/prefer-
2736
2785
  );
2737
2786
  }
2738
2787
  break;
2788
+ case "line-preview": {
2789
+ console.log("lipak inside", this.state.formData['0'].image);
2790
+ const content = {
2791
+ bodyText: isVersionEnable ? this.state.formData[`${this.state.currentTab - 1}`][`message-editor${this.state.currentTab > 1 ? this.state.currentTab : ''}`] : this.state.formData[val.id],
2792
+ bodyImage: this.state.formData[`${this.state.currentTab - 1}`].image,
2793
+ };
2794
+ if (!this.state.formData[`${this.state.currentTab - 1}`]) {
2795
+ return true;
2796
+ }
2797
+ console.log("lipak inside formdata@@@", content);
2798
+ columns.push(
2799
+ <Col key="input" span={23} offset={1}>
2800
+ <TemplatePreview
2801
+ key={val.id}
2802
+ style={val.customStyling ? val.customStyling : {}}
2803
+ channel={val.channel}
2804
+ content={content}
2805
+ >
2806
+ </TemplatePreview>
2807
+ </Col>
2808
+ );
2809
+ }
2810
+ break;
2739
2811
  case "mobile-push-preview":
2740
2812
  if (!this.state.formData[`${this.state.currentTab - 1}`]) {
2741
2813
  return true;
@@ -43,10 +43,11 @@ class PreviewSideBar extends React.Component { // eslint-disable-line react/pref
43
43
  this.setState({device: ev.target.value});
44
44
  }
45
45
  goToEdit(e) {
46
- this.props.onEditClick(e, this.props.templateData._id);
46
+ this.props.onEditClick(e, this.props.templateData._id, this.props.templateData.modeType);
47
47
  }
48
48
  render() {
49
49
  console.log('preview sidebar', this.props);
50
+ const modeTypeLine = this.props.templateData.modeType; // expected: (text or image)
50
51
  let content = '';
51
52
  if (this.props.channel.toLowerCase() === 'wechat') {
52
53
  console.log('Template Infog ', this.props.templateData);
@@ -67,6 +68,14 @@ class PreviewSideBar extends React.Component { // eslint-disable-line react/pref
67
68
  content.actions = [{label: data.expandableDetails.ctas[0].actionLabel}, {label: data.expandableDetails.ctas[0].actionLabel2}];
68
69
  }
69
70
  }
71
+ } else if (this.props.channel.toLowerCase() === "line") {
72
+ const isMsgReady = (this.props.templateData && this.props.templateData.versions && this.props.templateData.versions.base);
73
+ if (isMsgReady) {
74
+ content = {
75
+ bodyText: this.props.templateData.versions.base.content.messages[0].text ? this.props.templateData.versions.base.content.messages[0].text : '',
76
+ bodyImage: this.props.templateData.versions.base.content.messages[0].previewImageUrl ? this.props.templateData.versions.base.content.messages[0].previewImageUrl : '',
77
+ };
78
+ }
70
79
  } else {
71
80
  content = this.props.templateData && this.props.templateData.versions && this.props.templateData.versions.base ? this.props.templateData.versions.base['sms-editor'] : '';
72
81
  for (let idx = 2; idx <= 5; idx += 1) {
@@ -58,7 +58,7 @@ class TemplatePreview extends React.Component { // eslint-disable-line react/pre
58
58
  </div>
59
59
  ) : ''
60
60
  }
61
- { channel && channel.toLowerCase() === 'mobilepush' &&
61
+ { channel && (channel.toLowerCase() === 'mobilepush') &&
62
62
  (<div className="shell align-center" id="mobilepush-preview">
63
63
  <img className="preview-image" src={this.props.device === "android" ? androidPushMessagePhone : iPhonePushMessagePhone} alt="Preview is being generated"/>
64
64
  {(!!content.header || !!content.bodyText || !!content.bodyImage) &&
@@ -106,6 +106,21 @@ class TemplatePreview extends React.Component { // eslint-disable-line react/pre
106
106
  </div>
107
107
  )
108
108
  }
109
+ {
110
+ channel && channel.toLowerCase() === 'line' ? (
111
+ <div className="shell align-center" id="sms-preview">
112
+ <img className="preview-image" src={wechatBody} alt="Preview is being generated"/>
113
+ <div className="msgContainer">
114
+ <div className="sms-icon" style={{ width: '25px', height: '25px', background: '#2E89DF' }}></div>
115
+ <div className="message-pop align-left" style={{ background: '#ffffff', color: '#333333' }}>
116
+ { (content && content.bodyImage) ? <img src={content.bodyImage} alt="ddd" style={{maxWidth: '100%'}}/> : '' }
117
+ { (content && content.bodyText) ? content.bodyText : ''}
118
+ </div>
119
+ </div>
120
+ { (content && content.bodyText) ? <p style={{fontSize: 16, fontWeight: "bold"}}>Chars Count: {content.bodyText.length} / (1600)</p> : '' }
121
+ </div>
122
+ ) : ''
123
+ }
109
124
  {
110
125
  this.props.charCounterEnabled && !_.isEmpty(smsDetails) ?
111
126
  <p style={{margin: '16px 0'}} className="preview-info">{`${smsDetails.msgCount} ${this.props.intl.formatMessage(messages.sms)}(${smsDetails.totalLength} ${this.props.intl.formatMessage(messages.characters)})`}</p> : ''
@@ -19,3 +19,4 @@ export const GET_SCHEMA_FOR_ENTITY_FAILURE = 'cap/GET_SCHEMA_FOR_ENTITY_FAILURE'
19
19
  export const GET_SCHEMA_FOR_ENTITY_REQUEST = 'cap/GET_SCHEMA_FOR_ENTITY_REQUEST';
20
20
  export const GET_SCHEMA_FOR_ENTITY_SUCCESS = 'cap/GET_SCHEMA_FOR_ENTITY_SUCCESS';
21
21
  export const CLEAR_META_ENTITIES = 'cap/CLEAR_META_ENTITIES';
22
+ export const HIDE_TAGS = 'cap/HIDE_TAGS';
@@ -220,7 +220,11 @@ export class Cap extends React.Component { // eslint-disable-line react/prefer-s
220
220
  text: this.props.intl.formatMessage(messages.ebill),
221
221
  value: 'EBILL',
222
222
  },
223
-
223
+ {
224
+ link: '/line',
225
+ text: 'Line',
226
+ value: 'LINE',
227
+ },
224
228
  ],
225
229
  },
226
230
  {
@@ -95,6 +95,12 @@ function capReducer(state = fromJS(initialState), action) {
95
95
  layouts: [],
96
96
  tags: [],
97
97
  });
98
+ case types.HIDE_TAGS: {
99
+ const metaEntities = {tags: {}, layouts: state.get('metaEntities').layouts};
100
+ metaEntities.tags.standard = _.filter(state.get('metaEntities').tags.standard, (tag) => action.tagList.indexOf(tag.definition.value) === -1);
101
+ metaEntities.tags.custom = _.filter(state.get('metaEntities').tags.custom, (tag) => action.tagList.indexOf(tag.name) === -1);
102
+ return state.setIn(['metaEntities'], metaEntities);
103
+ }
98
104
  default:
99
105
  return state;
100
106
  }
@@ -2493,8 +2493,18 @@ export class Email extends React.Component { // eslint-disable-line react/prefer
2493
2493
  _.forEach(container.tabContent.sections[0].inputFields[0].cols, (containerInputFieldCol) => {
2494
2494
  const tempEl = containerInputFieldCol;
2495
2495
  if (containerInputFieldCol.id === "tab-header") {
2496
- const baseLanguage = this.props.Global.currentOrgDetails && this.props.Global.currentOrgDetails.basic_details && this.props.Global.currentOrgDetails.basic_details.base_language && this.props.Global.currentOrgDetails.basic_details.base_language !== "" ? this.props.Global.currentOrgDetails.basic_details.base_language : 'English';
2497
- tempEl.value = baseLanguage;
2496
+ const baseLanguage = this.props.Global.currentOrgDetails && this.props.Global.currentOrgDetails.basic_details && this.props.Global.currentOrgDetails.basic_details.base_language && this.props.Global.currentOrgDetails.basic_details.base_language !== "" ? this.props.Global.currentOrgDetails.basic_details.base_language : 'en';
2497
+ const supportedLanguages = this.props.Global.currentOrgDetails.basic_details.supported_languages;
2498
+ if (!supportedLanguages) {
2499
+ tempEl.value = 'English';
2500
+ return;
2501
+ }
2502
+ const langObject = supportedLanguages.find( (lang) => lang.iso_code === baseLanguage);
2503
+ if (langObject) {
2504
+ tempEl.value = langObject.language;
2505
+ } else {
2506
+ tempEl.value = 'English';
2507
+ }
2498
2508
  }
2499
2509
  });
2500
2510
  _.forEach(container.tabBarExtraContent.sections[0].inputFields[0].cols, (containerInputFieldCol) => {
@@ -14,7 +14,7 @@ const initialState = fromJS({
14
14
  });
15
15
 
16
16
  function emailReducer(state = initialState, action) {
17
- console.log('email reducer', action);
17
+ //console.log('email reducer', action);
18
18
  switch (action.type) {
19
19
  case types.CREATE_TEMPLATE_REQUEST:
20
20
  return state
@@ -0,0 +1,43 @@
1
+ .line-row{
2
+ margin-bottom: 16px;
3
+ }
4
+ .image-container{
5
+ display: flex;
6
+ height: 150px;
7
+ width: 320px;
8
+ border: solid 1px #C2C2C2;
9
+ border-radius: 5px;
10
+ .image-placeholder{
11
+ line-height: 150px;
12
+ }
13
+ img {
14
+ object-fit: cover;
15
+ max-width: 100%;
16
+ max-height: 100%;
17
+ height: auto !important;
18
+ width: auto !important;
19
+ }
20
+ }
21
+ //.ant-tabs-bar{
22
+ // margin-bottom: 0 !important;
23
+ // display: flex;
24
+ // align-items: center;
25
+ // flex-direction: row-reverse;
26
+ // justify-content: flex-end;
27
+ //}
28
+ //.ant-tabs-tabpane{
29
+ // padding: 16px 16px 16px 0;
30
+ // border: solid 1px #D6D6D6;
31
+ //}
32
+ //.ant-radio-wrapper{
33
+ // font-size: 14px;
34
+ // font-family: 'open-sans';
35
+ //}
36
+
37
+ .sms-text {
38
+ img {
39
+ display: block;
40
+ max-width: 100%;
41
+ object-fit: cover;
42
+ }
43
+ }
@@ -0,0 +1,90 @@
1
+ /*
2
+ *
3
+ * Create actions
4
+ *
5
+ */
6
+
7
+ import * as types from './constants';
8
+
9
+ export function createTemplate(template) {
10
+ console.log('action trigereed createtemplate');
11
+ return {
12
+ type: types.CREATE_TEMPLATE_REQUEST, template,
13
+ };
14
+ }
15
+
16
+ export function clearCreateResponse() {
17
+ console.log('clearCreateResponse');
18
+ return {
19
+ type: types.CLEAR_CREATE_RESPONSE_REQUEST,
20
+ };
21
+ }
22
+
23
+ export function defaultAction() {
24
+ return {
25
+ type: types.DEFAULT_ACTION,
26
+ };
27
+ }
28
+
29
+ export function uploadAsset(file, assetType, fileParams) {
30
+ return {
31
+ type: types.UPLOAD_ASSET_REQUEST,
32
+ file,
33
+ assetType,
34
+ fileParams,
35
+ };
36
+ }
37
+
38
+ export function clearAsset() {
39
+ return {
40
+ type: types.CLEAR_ASSET,
41
+ };
42
+ }
43
+
44
+
45
+ // FOR EDIT
46
+
47
+
48
+ export function editTemplate(template) {
49
+ console.log('action trigereed editTemplate line @@@');
50
+ return {
51
+ type: types.EDIT_TEMPLATE_REQUEST, template,
52
+ };
53
+ };
54
+
55
+ export function getTemplateDetails(id) {
56
+ console.log('getting template line @@@', id);
57
+ return {
58
+ type: types.GET_TEMPLATE_DETAILS_REQUEST,
59
+ id,
60
+ channel: 'LINE',
61
+ };
62
+ };
63
+
64
+ export function clearEditResponse() {
65
+ console.log('clearEditResponse');
66
+ return {
67
+ type: types.CLEAR_EDIT_RESPONSE_REQUEST,
68
+ };
69
+ };
70
+
71
+ export function clearData() {
72
+ return {
73
+ type: types.CLEAR_DATA,
74
+ };
75
+ }
76
+
77
+ export function getLineTemplatesList(channel, queryParams) {
78
+ return {
79
+ type: types.GET_LINE_TEMPLATES_LIST_REQUEST,
80
+ channel,
81
+ queryParams,
82
+ };
83
+ };
84
+
85
+ export function setSelectedTemplate(templateData) {
86
+ return {
87
+ type: types.SET_SELECTED_TEMPLATE,
88
+ data: templateData,
89
+ };
90
+ };
@@ -0,0 +1,39 @@
1
+ /*
2
+ *
3
+ * Create constants
4
+ *
5
+ */
6
+
7
+ export const DEFAULT_ACTION = 'app/Create/DEFAULT_ACTION';
8
+
9
+
10
+ export const CREATE_TEMPLATE_REQUEST = 'app/containers/Line/Create/CREATE_TEMPLATE_REQUEST';
11
+ export const CREATE_TEMPLATE_SUCCESS = 'app/containers/Line/Create/CREATE_TEMPLATE_SUCCESS';
12
+ export const CREATE_TEMPLATE_FAILURE = 'app/containers/Line/Create/CREATE_TEMPLATE_FAILURE';
13
+ export const UPLOAD_ASSET_REQUEST = 'app/containers/Line/Create/UPLOAD_ASSET_REQUEST';
14
+ export const UPLOAD_ASSET_SUCCESS = 'app/containers/Line/Create/UPLOAD_ASSET_SUCCESS';
15
+ export const UPLOAD_ASSET_FAILURE = 'app/containers/Line/Create/UPLOAD_ASSET_FAILURE';
16
+ export const CLEAR_ASSET = 'app/containers/Line/Create/CLEAR_ASSET';
17
+
18
+ export const CLEAR_CREATE_RESPONSE_REQUEST = 'app/containers/Line/Create/CLEAR_CREATE_RESPONSE_REQUEST';
19
+ export const CLEAR_CREATE_RESPONSE_SUCCESS = 'app/containers/Line/Create/CLEAR_CREATE_RESPONSE_SUCCESS';
20
+ export const CLEAR_CREATE_RESPONSE_FAILURE = 'app/containers/Line/Create/CLEAR_CREATE_RESPONSE_FAILURE';
21
+
22
+
23
+ // edit
24
+
25
+ export const GET_TEMPLATE_DETAILS_REQUEST = 'app/containers/line/Edit/GET_TEMPLATE_DETAILS_REQUEST';
26
+ export const GET_TEMPLATE_DETAILS_SUCCESS = 'app/containers/line/Edit/GET_TEMPLATE_DETAILS_SUCCESS';
27
+ export const GET_TEMPLATE_DETAILS_FAILURE = 'app/containers/line/Edit/GET_TEMPLATE_DETAILS_FAILURE';
28
+
29
+ export const EDIT_TEMPLATE_REQUEST = 'app/containers/line/Edit/EDIT_TEMPLATE_REQUEST';
30
+ export const EDIT_TEMPLATE_SUCCESS = 'app/containers/line/Edit/EDIT_TEMPLATE_SUCCESS';
31
+ export const EDIT_TEMPLATE_FAILURE = 'app/containers/line/Edit/EDIT_TEMPLATE_FAILURE';
32
+
33
+ export const CLEAR_EDIT_RESPONSE_REQUEST = 'app/containers/line/Edit/CLEAR_EDIT_RESPONSE_REQUEST';
34
+ export const CLEAR_DATA = 'app/containers/Line/Edit/CLEAR_DATA';
35
+ export const SET_SELECTED_TEMPLATE = 'app/containers/Line/Edit/SET_SELECTED_TEMPLATE';
36
+
37
+ export const GET_LINE_TEMPLATES_LIST_REQUEST = 'app/containers/Line/GET_LINE_TEMPLATES_LIST_REQUEST';
38
+ export const GET_LINE_TEMPLATES_LIST_SUCCESS = 'app/containers/Line/GET_LINE_TEMPLATES_LIST_SUCCESS';
39
+ export const GET_LINE_TEMPLATES_LIST_FAILURE = 'app/containers/Line/GET_LINE_TEMPLATES_LIST_FAILURE';