@capillarytech/creatives-library 7.0.1 → 7.0.4

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 (54) hide show
  1. package/assets/viber.png +0 -0
  2. package/index.js +8 -1
  3. package/package.json +2 -1
  4. package/reducers.js +2 -0
  5. package/routes.js +7 -1
  6. package/services/api.js +5 -0
  7. package/v2Components/TemplatePreview/_templatePreview.scss +8 -2
  8. package/v2Components/TemplatePreview/assets/images/viberMobile.svg +135 -0
  9. package/v2Components/TemplatePreview/index.js +104 -18
  10. package/v2Containers/App/constants.js +1 -1
  11. package/v2Containers/CreativesContainer/SlideBoxContent.js +65 -2
  12. package/v2Containers/CreativesContainer/constants.js +2 -0
  13. package/v2Containers/CreativesContainer/index.js +38 -4
  14. package/v2Containers/Templates/_templates.scss +57 -0
  15. package/v2Containers/Templates/actions.js +117 -110
  16. package/v2Containers/Templates/constants.js +2 -0
  17. package/v2Containers/Templates/index.js +89 -7
  18. package/v2Containers/Templates/messages.js +4 -0
  19. package/v2Containers/Templates/reducer.js +2 -0
  20. package/v2Containers/TemplatesV2/index.js +9 -1
  21. package/v2Containers/TemplatesV2/messages.js +4 -0
  22. package/v2Containers/Viber/actions.js +74 -0
  23. package/v2Containers/Viber/constants.js +30 -0
  24. package/v2Containers/Viber/index.js +719 -0
  25. package/v2Containers/Viber/messages.js +145 -0
  26. package/v2Containers/Viber/reducer.js +84 -0
  27. package/v2Containers/Viber/sagas.js +107 -0
  28. package/v2Containers/Viber/selectors.js +21 -0
  29. package/v2Components/TemplatePreview/assets/images/mobile.svg +0 -24
  30. package/v2Containers/Line/Create/_lineCreate.scss +0 -64
  31. package/v2Containers/Line/Create/actions.js +0 -94
  32. package/v2Containers/Line/Create/constants.js +0 -43
  33. package/v2Containers/Line/Create/index.js +0 -1132
  34. package/v2Containers/Line/Create/initialSchema.js +0 -378
  35. package/v2Containers/Line/Create/messages.js +0 -229
  36. package/v2Containers/Line/Create/reducer.js +0 -99
  37. package/v2Containers/Line/Create/sagas.js +0 -113
  38. package/v2Containers/Line/Create/selectors.js +0 -30
  39. package/v2Containers/Line/CreateWrapper/constants.js +0 -2
  40. package/v2Containers/Line/CreateWrapper/index.js +0 -117
  41. package/v2Containers/Line/CreateWrapper/messages.js +0 -55
  42. package/v2Containers/Line/Edit/_lineEdit.scss +0 -23
  43. package/v2Containers/Line/Edit/actions.js +0 -79
  44. package/v2Containers/Line/Edit/constants.js +0 -27
  45. package/v2Containers/Line/Edit/index.js +0 -1051
  46. package/v2Containers/Line/Edit/messages.js +0 -173
  47. package/v2Containers/Line/Edit/reducer.js +0 -83
  48. package/v2Containers/Line/Edit/sagas.js +0 -81
  49. package/v2Containers/Line/Edit/selectors.js +0 -29
  50. package/v2Containers/Line/Edit/tests/actions.test.js +0 -18
  51. package/v2Containers/Line/Edit/tests/index.test.js +0 -10
  52. package/v2Containers/Line/Edit/tests/reducer.test.js +0 -9
  53. package/v2Containers/Line/Edit/tests/sagas.test.js +0 -15
  54. package/v2Containers/Line/Edit/tests/selectors.test.js +0 -10
@@ -2,6 +2,7 @@ import React from 'react';
2
2
  import PropTypes from 'prop-types';
3
3
  import styled from 'styled-components';
4
4
  import get from 'lodash/get';
5
+ import cloneDeep from 'lodash/cloneDeep';
5
6
  import TemplatesV2 from '../TemplatesV2';
6
7
  import TemplatePreview from '../../v2Components/TemplatePreview';
7
8
  import SmsCreate from '../Sms/Create';
@@ -18,6 +19,7 @@ import CallTask from '../CallTask';
18
19
  import MobliPushEdit from '../MobilePush/Edit';
19
20
  import * as constants from './constants';
20
21
  import LineContainer from '../Line/Container';
22
+ import Viber from '../Viber';
21
23
  const CreativesWrapper = styled.div`
22
24
  .ant-popover,
23
25
  .ant-notification,
@@ -32,7 +34,6 @@ function getWechatTemplateType(mode, templateData, weChatTemplateType = '') {
32
34
  }
33
35
  return weChatTemplateType;
34
36
  }
35
-
36
37
  const getLineType = ({
37
38
  slidBoxContent,
38
39
  channel,
@@ -70,6 +71,22 @@ const getLineType = ({
70
71
  }
71
72
  return {};
72
73
  };
74
+ const getViber = ({
75
+ slidBoxContent,
76
+ channel,
77
+ isFullMode,
78
+ templateData,
79
+ }) => {
80
+ if ((channel === constants.VIBER || (slidBoxContent === 'editTemplate' && templateData && templateData.type === constants.VIBER)) && slidBoxContent !== 'templates') {
81
+ const isCreate = slidBoxContent === 'createTemplate';
82
+ const isEdit = slidBoxContent === 'editTemplate';
83
+ return {
84
+ isCreate,
85
+ isEdit,
86
+ };
87
+ }
88
+ return {};
89
+ };
73
90
 
74
91
  function SlideBoxContent(props) {
75
92
  const {
@@ -135,6 +152,15 @@ function SlideBoxContent(props) {
135
152
  isFullMode,
136
153
  templateData,
137
154
  });
155
+ const {isCreate: isCreateViber = false,
156
+ isEdit: isEditViber = false } = getViber({
157
+ slidBoxContent,
158
+ channel,
159
+ isFullMode,
160
+ templateData,
161
+ });
162
+
163
+
138
164
  const isCreateSms = slidBoxContent === 'createTemplate' && channel === constants.SMS;
139
165
  const isCreateMPush = slidBoxContent === 'createTemplate' && channel === constants.MOBILE_PUSH;
140
166
  const isCreateCallTask = slidBoxContent === 'createTemplate' && channel === constants.CALL_TASK;
@@ -156,7 +182,7 @@ function SlideBoxContent(props) {
156
182
  isEditEmailWithId = slidBoxContent === 'editTemplate' && channel === constants.EMAIL && templateData._id;
157
183
  isEmailEditWithContent = slidBoxContent === 'editTemplate' && channel === constants.EMAIL && !templateData._id;
158
184
  isEditFacebook = slidBoxContent === 'editTemplate' && channel === constants.FACEBOOK;
159
- isPreview = slidBoxContent === 'preview' && (channel === constants.SMS || channel === constants.LINE);
185
+ isPreview = slidBoxContent === 'preview' && (channel === constants.SMS || channel === constants.LINE || channel === constants.VIBER);
160
186
  isEmailPreview = slidBoxContent === 'preview' && channel === constants.EMAIL;
161
187
  isMpushPreview = slidBoxContent === 'preview' && channel === constants.MOBILE_PUSH;
162
188
  }
@@ -223,6 +249,16 @@ function SlideBoxContent(props) {
223
249
  return previewContent;
224
250
  });
225
251
  }
252
+ case constants.VIBER: {
253
+ const template = cloneDeep(templateDataObject);
254
+ const { text = "", imageURL = "", buttonText = "" } = get(template, 'versions.base.content.viber', {});
255
+ template.content = {
256
+ messageContent: text,
257
+ imageURL,
258
+ buttonText,
259
+ };
260
+ return template.content;
261
+ }
226
262
  default:
227
263
  return get(templateDataObject, `versions.base.content`);
228
264
  }
@@ -500,6 +536,33 @@ function SlideBoxContent(props) {
500
536
  />
501
537
  )
502
538
  }
539
+ {isCreateViber && (
540
+ <Viber
541
+ location={creativesLocationProps}
542
+ onCreateComplete={onCreateComplete}
543
+ isFullMode={isFullMode}
544
+ handleClose={handleClose}
545
+ isGetFormData={isGetFormData}
546
+ getFormSubscriptionData={getFormData}
547
+ onShowTemplates={onShowTemplates}
548
+ templateData={templateData}
549
+ createNew/>
550
+ )}
551
+
552
+ {isEditViber && <Viber
553
+ location={creativesLocationProps}
554
+ params={{
555
+ id: templateData._id,
556
+ }}
557
+ onCreateComplete={onCreateComplete}
558
+ isFullMode={isFullMode}
559
+ handleClose={handleClose}
560
+ isGetFormData={isGetFormData}
561
+ getFormSubscriptionData={getFormData}
562
+ onShowTemplates={onShowTemplates}
563
+ templateData={templateData}
564
+ createNew/> }
565
+
503
566
  </CreativesWrapper>
504
567
  );
505
568
  }
@@ -13,5 +13,7 @@ export const CALL_TASK = "CALL_TASK";
13
13
  export const MOBILE_PUSH = "MOBILEPUSH";
14
14
  export const WECHAT = "WECHAT";
15
15
  export const FACEBOOK = "FACEBOOK";
16
+ export const VIBER = "VIBER";
17
+
16
18
  export const SHOW_CONTANER_LOADER = "app/CreativesContainer/SHOW_CONTANER_LOADER";
17
19
  export const HIDE_CONTAINER_LOADER = "app/CreativesContainer/HIDE_CONTAINER_LOADER";
@@ -5,7 +5,7 @@ import {
5
5
  } from '@capillarytech/cap-ui-library';
6
6
  import { injectIntl, FormattedMessage } from 'react-intl';
7
7
  import classnames from 'classnames';
8
- import {isEmpty, get, forEach} from 'lodash';
8
+ import {isEmpty, get, forEach, cloneDeep} from 'lodash';
9
9
  import { connect } from 'react-redux';
10
10
  import { createStructuredSelector } from 'reselect';
11
11
  import { bindActionCreators } from 'redux';
@@ -18,7 +18,6 @@ import SlideBoxHeader from './SlideBoxHeader';
18
18
  import SlideBoxFooter from './SlideBoxFooter';
19
19
  import * as constants from './constants';
20
20
  import * as commonUtil from '../../utils/common';
21
-
22
21
  import './index.scss';
23
22
  import * as templateActions from '../Templates/actions';
24
23
  import * as globalActions from '../Cap/actions';
@@ -247,6 +246,24 @@ class Creatives extends React.Component {
247
246
  };
248
247
  break;
249
248
  }
249
+ case constants.VIBER: {
250
+ const { messageBody, isDefault } = templateData;
251
+ const viber = JSON.parse(messageBody || '{}');
252
+ creativesTemplateData = {
253
+ type: constants.VIBER,
254
+ isDefault,
255
+ edit: true,
256
+ name: "",
257
+ versions: {
258
+ base: {
259
+ content: {
260
+ ...viber,
261
+ },
262
+ },
263
+ },
264
+ };
265
+ break;
266
+ }
250
267
  default:
251
268
  break;
252
269
  }
@@ -332,6 +349,23 @@ class Creatives extends React.Component {
332
349
  };
333
350
  }
334
351
  break;
352
+ case constants.VIBER:
353
+ if (template.value) {
354
+ const { Templates = {} } = this.props || {};
355
+ const selectedViberAccount = Templates && Templates.selectedViberAccount;
356
+ const accountDetails = selectedViberAccount ? JSON.stringify(selectedViberAccount) : '';
357
+ const accountId = selectedViberAccount ? selectedViberAccount.id : '';
358
+ const { versions } = template.value;
359
+ const content = cloneDeep(versions.base.content);
360
+ content.scenarioKey = get(accountDetails, 'configs.scenario_key');
361
+ templateData = {
362
+ channel,
363
+ accountId,
364
+ accountDetails,
365
+ messageBody: JSON.stringify(content),
366
+ };
367
+ }
368
+ break;
335
369
  default:
336
370
  break;
337
371
  }
@@ -446,8 +480,8 @@ class Creatives extends React.Component {
446
480
  }
447
481
  }
448
482
 
449
- const isLineChannel = templateData && templateData.type === constants.LINE;
450
- if (channel === constants.LINE || isLineChannel) {
483
+ const isLineViberChannel = templateData && [constants.LINE, constants.VIBER].includes(templateData);
484
+ if ([constants.LINE, constants.VIBER].includes(channel) || isLineViberChannel) {
451
485
  showFooter = false;
452
486
  }
453
487
 
@@ -46,6 +46,63 @@
46
46
  }
47
47
  }
48
48
  }
49
+ .VIBER {
50
+ &.cap-custom-card{
51
+ height: 241px;
52
+ .ant-card-body {
53
+ padding:0px 24px 0px;
54
+ .button-content {
55
+ .ant-card-meta-description {
56
+ min-width: 108px;
57
+ max-width: 160px;
58
+ height: 24px;
59
+ padding: 1px 23px 2px 22px;
60
+ border-radius: 16px;
61
+ font-size: 14px;
62
+ font-weight: 500;
63
+ background-color:$CAP_PURPLE01;
64
+ color:$CAP_WHITE;
65
+ text-align:center;
66
+ }
67
+ }
68
+ .truncate-text-viber{
69
+ .ant-card-meta-description{
70
+ display: -webkit-box;
71
+ -webkit-line-clamp: 9;
72
+ -webkit-box-orient: vertical;
73
+ }
74
+ }
75
+ .truncate-text-with-button{
76
+ .ant-card-meta-description{
77
+ -webkit-line-clamp: 8;
78
+ }
79
+ }
80
+ .truncate-text-with-image{
81
+ .ant-card-meta-description{
82
+ -webkit-line-clamp: 2;
83
+ }
84
+ }
85
+
86
+ }
87
+
88
+ &.no-image .ant-card-meta {
89
+ .ant-card-meta-description {
90
+ word-wrap: break-word;
91
+ }
92
+ }
93
+
94
+
95
+ &.carousel-img-section {
96
+ .ant-card-body {
97
+ padding: $CAP_SPACE_24 0;
98
+ }
99
+ .ant-card-meta {
100
+ padding: 0;
101
+ }
102
+ }
103
+ }
104
+
105
+ }
49
106
  }
50
107
  }
51
108
 
@@ -4,119 +4,126 @@
4
4
  *
5
5
  */
6
6
 
7
- import * as types from './constants';
8
-
9
- export function getAllTemplates(channel, queryParams) {
10
- console.log('get all templates action trigereed', channel, queryParams);
11
- return {
12
- type: types.GET_ALL_TEMPLATES_REQUEST, channel, queryParams,
13
- };
14
- }
15
-
16
- export function resetTemplate() {
17
- return {
18
- type: types.RESET_TEMPLATE,
19
- };
20
- }
21
-
22
- export function resetAccount() {
23
- return {
24
- type: types.RESET_ACCOUNT,
25
- };
26
- }
27
-
28
- export function deleteTemplate(channel, id) {
29
- console.log('delete template action trigereed', channel, id);
30
- return {
31
- type: types.DELETE_TEMPLATE_REQUEST, channel, id,
32
- };
33
- }
34
-
35
- export function getUserList() {
36
- return {
37
- type: types.GET_USER_LIST_REQUEST,
38
- };
39
- }
40
-
41
- export function getWeCrmAccounts(source) {
42
- return {
43
- type: types.GET_WECRM_ACCOUNTS_REQUEST, source,
44
- };
45
- }
46
-
47
- export function setWeChatAccount(weChatAccount) {
48
- console.log('setting wechat account', weChatAccount);
49
- return {
50
- type: types.SET_WECHAT_ACCOUNT,
51
- weChatAccount,
52
- };
53
- }
54
-
55
- export function setLineAccount(lineAccount) {
7
+ import * as types from './constants';
8
+
9
+ export function getAllTemplates(channel, queryParams) {
10
+ console.log('get all templates action trigereed', channel, queryParams);
11
+ return {
12
+ type: types.GET_ALL_TEMPLATES_REQUEST, channel, queryParams,
13
+ };
14
+ }
15
+
16
+ export function resetTemplate() {
17
+ return {
18
+ type: types.RESET_TEMPLATE,
19
+ };
20
+ }
21
+
22
+ export function resetAccount() {
23
+ return {
24
+ type: types.RESET_ACCOUNT,
25
+ };
26
+ }
27
+
28
+ export function deleteTemplate(channel, id) {
29
+ console.log('delete template action trigereed', channel, id);
30
+ return {
31
+ type: types.DELETE_TEMPLATE_REQUEST, channel, id,
32
+ };
33
+ }
34
+
35
+ export function getUserList() {
36
+ return {
37
+ type: types.GET_USER_LIST_REQUEST,
38
+ };
39
+ }
40
+
41
+ export function getWeCrmAccounts(source) {
42
+ return {
43
+ type: types.GET_WECRM_ACCOUNTS_REQUEST, source,
44
+ };
45
+ }
46
+
47
+ export function setWeChatAccount(weChatAccount) {
48
+ console.log('setting wechat account', weChatAccount);
49
+ return {
50
+ type: types.SET_WECHAT_ACCOUNT,
51
+ weChatAccount,
52
+ };
53
+ }
54
+
55
+ export function setLineAccount(lineAccount) {
56
56
  return {
57
57
  type: types.SET_LINE_ACCOUNT,
58
58
  lineAccount,
59
59
  };
60
60
  }
61
61
 
62
- export function handleHtmlUpload(selectedTemplate) {
63
- return {
64
- type: types.SET_SELECTED_LAYOUT,
65
- selectedTemplate,
66
- };
67
- }
68
-
69
- export function handleZipUpload(selectedFile, successHandler, errorHandler) {
70
- return {
71
- type: types.SEND_ZIPPED_FILE_REQUEST,
72
- selectedFile,
73
- successHandler,
74
- errorHandler,
75
- };
76
- }
77
-
78
- export function getDefaultBeeTemplates() {
79
- return {
80
- type: types.GET_DEAFULT_BEE_TEMPLATES_REQUEST,
81
- };
82
- }
83
-
84
- export function setEdmTemplate(template) {
85
- return {
86
- type: types.SET_EDM_TEMPLATE,
87
- template,
88
- };
89
- }
90
- export function setBEETemplate(template) {
91
- return {
92
- type: types.SET_BEE_TEMPLATE,
93
- template,
94
- };
95
- }
96
- export function getTemplateDetails(id, channel) {
97
- console.log('getting template', id, channel);
98
- return {
99
- type: types.GET_TEMPLATE_DETAILS_REQUEST,
100
- id,
101
- channel,
102
- };
103
- }
104
-
105
- export function resetTemplateData() {
106
- return {
107
- type: types.RESET_TEMPLATE_DATA,
108
- };
109
- }
110
-
111
- export function resetUploadData() {
112
- console.log('clearing upload data');
113
- return {
114
- type: types.RESET_UPLOAD_DATA,
115
- };
116
- }
117
-
118
- export function resetTemplateStoreData() {
119
- return {
120
- type: types.CLEAR_TEMPLATE_STORE_DATA,
121
- };
122
- }
62
+ export function setViberAccount(viberAccount) {
63
+ return {
64
+ type: types.SET_VIBER_ACCOUNT,
65
+ viberAccount,
66
+ };
67
+ }
68
+
69
+ export function handleHtmlUpload(selectedTemplate) {
70
+ return {
71
+ type: types.SET_SELECTED_LAYOUT,
72
+ selectedTemplate,
73
+ };
74
+ }
75
+
76
+ export function handleZipUpload(selectedFile, successHandler, errorHandler) {
77
+ return {
78
+ type: types.SEND_ZIPPED_FILE_REQUEST,
79
+ selectedFile,
80
+ successHandler,
81
+ errorHandler,
82
+ };
83
+ }
84
+
85
+ export function getDefaultBeeTemplates() {
86
+ return {
87
+ type: types.GET_DEAFULT_BEE_TEMPLATES_REQUEST,
88
+ };
89
+ }
90
+
91
+ export function setEdmTemplate(template) {
92
+ return {
93
+ type: types.SET_EDM_TEMPLATE,
94
+ template,
95
+ };
96
+ }
97
+ export function setBEETemplate(template) {
98
+ return {
99
+ type: types.SET_BEE_TEMPLATE,
100
+ template,
101
+ };
102
+ }
103
+ export function getTemplateDetails(id, channel) {
104
+ console.log('getting template', id, channel);
105
+ return {
106
+ type: types.GET_TEMPLATE_DETAILS_REQUEST,
107
+ id,
108
+ channel,
109
+ };
110
+ }
111
+
112
+ export function resetTemplateData() {
113
+ return {
114
+ type: types.RESET_TEMPLATE_DATA,
115
+ };
116
+ }
117
+
118
+ export function resetUploadData() {
119
+ console.log('clearing upload data');
120
+ return {
121
+ type: types.RESET_UPLOAD_DATA,
122
+ };
123
+ }
124
+
125
+ export function resetTemplateStoreData() {
126
+ return {
127
+ type: types.CLEAR_TEMPLATE_STORE_DATA,
128
+ };
129
+ }
@@ -43,6 +43,8 @@ export const RESET_UPLOAD_DATA = "app/v2Containers/Templates/RESET_UPLOAD_DATA";
43
43
  export const CLEAR_TEMPLATE_STORE_DATA = "app/v2Containers/Templates/CLEAR_TEMPLATE_STORE_DATA";
44
44
 
45
45
  export const SET_LINE_ACCOUNT = "app/v2Containers/Templates/SET_LINE_ACCOUNT";
46
+ export const SET_VIBER_ACCOUNT = "app/v2Containers/Templates/SET_VIBER_ACCOUNT";
47
+
46
48
 
47
49
  export const GET_DEAFULT_BEE_TEMPLATES_REQUEST = 'app/v2Containers/Templates/GET_DEAFULT_BEE_TEMPLATES_REQUEST';
48
50
  export const GET_DEAFULT_BEE_TEMPLATES_SUCCESS = 'app/v2Containers/Templates/GET_DEAFULT_BEE_TEMPLATES_SUCCESS';