@capillarytech/creatives-library 7.0.0 → 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.
@@ -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';
@@ -30,6 +30,7 @@ import { makeSelectEbill as makeSelectCreateEbill } from '../Ebill/selectors';
30
30
  import { makeSelectEmail as makeSelectCreateEmail } from '../Email/selectors';
31
31
  import { makeSelectEdit } from '../Sms/Edit/selectors';
32
32
  import { makeSelectLine } from '../Line/Container/selectors';
33
+ import { makeSelectViber } from '../Viber/selectors';
33
34
  import { UserIsAuthenticated } from '../../utils/authWrapper';
34
35
  import messages from './messages';
35
36
  import {checkUnicode} from '../../utils/smsCharCountV2';
@@ -40,6 +41,8 @@ import * as smsEditActions from '../Sms/Edit/actions';
40
41
  import * as ebillActions from '../Ebill/actions';
41
42
  import * as emailActions from '../Email/actions';
42
43
  import * as lineActions from '../Line/Container/actions';
44
+ import * as viberActions from '../Viber/actions';
45
+
43
46
  import CardGrid from '../../v2Components/CardGrid';
44
47
  import config from '../../config/app';
45
48
  import './_templates.scss';
@@ -50,8 +53,13 @@ import Pagination from '../../v2Components/Pagination';
50
53
  import EmailPreview from '../../v2Components/EmailPreview';
51
54
  import CreativesContainer from '../CreativesContainer';
52
55
  import WechatRichmediaTemplatePreview from '../../v2Components/TemplatePreview/WechatRichmediaTemplatePreview';
53
- import { CHANNEL_CREATE_TRACK_MAPPING, CHANNEL_EDIT_TRACK_MAPPING } from '../App/constants';
54
- import { MOBILE_PUSH, WECHAT, SMS, EMAIL, EBILL, LINE } from '../CreativesContainer/constants';
56
+ import {
57
+ CHANNEL_CREATE_TRACK_MAPPING,
58
+ CHANNEL_EDIT_TRACK_MAPPING,
59
+ VIBER as VIBER_CHANNEL,
60
+ } from '../App/constants';
61
+ import { MOBILE_PUSH, WECHAT, SMS, EMAIL, EBILL, LINE, VIBER } from '../CreativesContainer/constants';
62
+
55
63
  import emailIllustration from '../Assets/images/emailIllustration.svg';
56
64
  import smsIllustration from '../Assets/images/smsIllustration.svg';
57
65
  import pushIllustration from '../Assets/images/pushIllustration.svg';
@@ -161,6 +169,13 @@ export class Templates extends React.Component { // eslint-disable-line react/pr
161
169
  case EBILL:
162
170
  channel = 'Ebill';
163
171
  break;
172
+ case VIBER:
173
+ channel = 'Viber';
174
+ if (!this.props.isFullMode) {
175
+ activeMode = ACCOUNT_SELECTION_MODE;
176
+ this.props.actions.getWeCrmAccounts(channel);
177
+ }
178
+ break;
164
179
  case LINE:
165
180
  channel = "Line";
166
181
  if (!this.props.isFullMode) {
@@ -185,7 +200,7 @@ export class Templates extends React.Component { // eslint-disable-line react/pr
185
200
  if (this.props.location.query.type === 'embedded') {
186
201
  this.props.actions.resetAccount();
187
202
  }
188
- if ((this.state.channel && (this.state.channel.toLowerCase() === 'line' || this.state.channel.toLowerCase() === 'sms' || this.state.channel.toLowerCase() === 'email' || this.state.channel.toLowerCase() === 'ebill')) || ((this.state.channel.toLowerCase() === 'wechat' || this.state.channel.toLowerCase() === 'mobilepush') && !isEmpty(this.props.Templates.selectedWeChatAccount))) {
203
+ if ((['line', VIBER_CHANNEL, 'sms', 'email', 'ebill'].includes((this.state.channel || '').toLowerCase())) || ((['wechat', 'mobilepush'].includes(this.state.channel.toLowerCase()) && !isEmpty(this.props.Templates.selectedWeChatAccount)))) {
189
204
  const queryParams = {
190
205
  // name: this.state.searchText,
191
206
  // sortBy: this.state.sortBy,
@@ -245,9 +260,16 @@ export class Templates extends React.Component { // eslint-disable-line react/pr
245
260
  this.setState({defaultAccount: true});
246
261
  nextProps.actions.getWeCrmAccounts(channel);
247
262
  }
263
+ } else if (nextProps.route.name.toLowerCase() === VIBER_CHANNEL) {
264
+ channel = 'Viber';
265
+ if (!this.props.isFullMode) {
266
+ this.setState({defaultAccount: true});
267
+ nextProps.actions.getWeCrmAccounts(channel);
268
+ }
248
269
  }
270
+
249
271
  this.setState({ channel }, () => {
250
- if ((this.state.channel.toLowerCase() === 'line' || this.state.channel.toLowerCase() === 'sms' || this.state.channel.toLowerCase() === 'email' || this.state.channel.toLowerCase() === 'ebill') || (this.state.channel.toLowerCase() === 'wechat' && !isEmpty(nextProps.Templates.selectedWeChatAccount))) {
272
+ if (['line', VIBER_CHANNEL, 'sms', 'email', 'ebill'].includes(this.state.channel.toLowerCase()) || (this.state.channel.toLowerCase() === 'wechat' && !isEmpty(nextProps.Templates.selectedWeChatAccount))) {
251
273
  if (this.state.channel.toLowerCase() === 'wechat' && !isEmpty(nextProps.Templates.selectedWeChatAccount)) {
252
274
  params.wecrmId = (nextProps.Templates.selectedWeChatAccount.configs || {}).wecrm_app_id;
253
275
  params.wecrmToken = (nextProps.Templates.selectedWeChatAccount.configs || {}).wecrm_token;
@@ -268,6 +290,20 @@ export class Templates extends React.Component { // eslint-disable-line react/pr
268
290
  if ((this.state.channel || '').toLowerCase() === "mobilepush" && nextProps.Templates.selectedWeChatAccount) {
269
291
  params.accountId = nextProps.Templates.selectedWeChatAccount.id;
270
292
  }
293
+ if (this.state.channel.toLowerCase() === VIBER_CHANNEL && isEmpty(nextProps.Templates.selectedViberAccount)) {
294
+ let selectedAccount = '';
295
+ if (isEmpty(nextProps.Templates.weCrmAccounts)) {
296
+ return;
297
+ }
298
+ selectedAccount = nextProps.Templates.weCrmAccounts[0];
299
+ this.setState({selectedAccount: selectedAccount.name}, () => {
300
+ params.wecrmId = selectedAccount.configs.wecrm_app_id;
301
+ params.wecrmToken = selectedAccount.configs.wecrm_token;
302
+ params.originalId = selectedAccount.sourceAccountIdentifier;
303
+ this.props.actions.setViberAccount(nextProps.Templates.weCrmAccounts[0]);
304
+ this.getAllTemplates({params});
305
+ });
306
+ }
271
307
  if ((this.state.channel.toLowerCase() === 'wechat' || this.state.channel.toLowerCase() === 'mobilepush') && isEmpty(nextProps.Templates.selectedWeChatAccount) && (this.props.location.query.type === 'embedded') && !this.isEnabledInLibraryModule("showAccountSelection")) {
272
308
  let selectedAccount = '';
273
309
  if (isEmpty(nextProps.Templates.weCrmAccounts)) {
@@ -336,6 +372,8 @@ export class Templates extends React.Component { // eslint-disable-line react/pr
336
372
  this.props.ebillActions.clearCreateResponse();
337
373
  } else if (this.state.channel.toLowerCase() === "line") {
338
374
  this.props.lineActions.clearCreateResponse();
375
+ } else if (this.state.channel.toLowerCase() === VIBER_CHANNEL) {
376
+ this.props.viberActions.clearCreateResponse();
339
377
  }
340
378
  }
341
379
  }
@@ -432,6 +470,7 @@ export class Templates extends React.Component { // eslint-disable-line react/pr
432
470
  } else if (this.state.channel.toLowerCase() === 'line') {
433
471
  this.props.actions.setLineAccount(this.props.Templates.weCrmAccounts.find((item) => item.name === this.state.selectedAccount));
434
472
  }
473
+
435
474
  this.setState({activeMode: TEMPLATES_MODE});
436
475
  console.log("getAllTemplates params: ", params);
437
476
  this.getAllTemplates({params, resetPage: true});
@@ -651,7 +690,7 @@ export class Templates extends React.Component { // eslint-disable-line react/pr
651
690
  <video height="279">
652
691
  <source src={originalVideoContentUrl} type="video/mp4" />
653
692
  </video>
654
- )
693
+ );
655
694
  }
656
695
  if (carouselTemplate) {
657
696
  const carouselContent = get(carouselTemplate, 'columns', [{}]).map(({ imageUrl, action: { label: actionLabel } = {} }) => ({ imageUrl, actionLabel }) );
@@ -677,6 +716,26 @@ export class Templates extends React.Component { // eslint-disable-line react/pr
677
716
  }
678
717
  break;
679
718
  }
719
+ case VIBER: {
720
+ const {
721
+ content: {
722
+ viber: {
723
+ text = '',
724
+ imageURL = '',
725
+ buttonURL = '',
726
+ buttonText = '',
727
+ } = {},
728
+ } = {},
729
+ } = template.versions.base;
730
+ templateData.content = text;
731
+ if (imageURL) {
732
+ templateData.url = imageURL;
733
+ }
734
+ if (buttonURL && buttonText) {
735
+ templateData.buttonText = buttonText;
736
+ }
737
+ break;
738
+ }
680
739
  default:
681
740
  templateData.content = "";
682
741
  }
@@ -1174,6 +1233,15 @@ export class Templates extends React.Component { // eslint-disable-line react/pr
1174
1233
  this.props.lineActions.clearCreateResponse();
1175
1234
  }
1176
1235
  });
1236
+ } else if (this.state.channel.toLowerCase() === VIBER_CHANNEL) {
1237
+ this.props.viberActions.createTemplate(duplicateObj, (response) => {
1238
+ if (response && response.templateId) {
1239
+ const message = `${this.state.channel} ${this.props.intl.formatMessage(messages.templateDuplicateSuccess)}`;
1240
+ CapNotification.success({key: 'duplicateSucess', message});
1241
+ this.getAllTemplates({params, resetPage: true});
1242
+ this.props.viberActions.clearCreateResponse();
1243
+ }
1244
+ });
1177
1245
  }
1178
1246
  }
1179
1247
 
@@ -1255,6 +1323,9 @@ export class Templates extends React.Component { // eslint-disable-line react/pr
1255
1323
  pathName += `/${options.account}`;
1256
1324
  }
1257
1325
  }
1326
+ if (this.state.channel.toLowerCase() === VIBER_CHANNEL) {
1327
+ pathName = `/viber/edit/${id}/`;
1328
+ }
1258
1329
  if (this.state.channel.toUpperCase() === WECHAT) {
1259
1330
  if (get(template, 'definition.msgcontent', '') === "RICH_MEDIA_WECHAT") {
1260
1331
  pathName = `/wechat/richmedia/edit/${id}`;
@@ -1553,6 +1624,7 @@ export class Templates extends React.Component { // eslint-disable-line react/pr
1553
1624
  } = Templates;
1554
1625
  const lineLoader = (getAllTemplatesInProgress && this.state.channel.toLowerCase() === 'line');
1555
1626
  const smsLoader = (getAllTemplatesInProgress && this.state.channel.toLowerCase() === 'sms');
1627
+ const viberLoader = (getAllTemplatesInProgress && this.state.channel.toLowerCase() === VIBER_CHANNEL);
1556
1628
  const wechatLoader = (((this.state.selectedAccount !== '' && getAllTemplatesInProgress) || (fetchingWeCrmAccounts)) && this.state.channel.toLowerCase() === 'wechat');
1557
1629
  const mobilePushLoader = (((getAllTemplatesInProgress) || (fetchingWeCrmAccounts)) && this.state.channel.toLowerCase() === 'mobilepush');
1558
1630
  const emailLoader = (
@@ -1566,7 +1638,8 @@ export class Templates extends React.Component { // eslint-disable-line react/pr
1566
1638
  (emailLoader !== undefined ? emailLoader : false) ||
1567
1639
  (ebillLoader !== undefined ? ebillLoader : false) ||
1568
1640
  (mobilePushLoader !== undefined ? mobilePushLoader : false) ||
1569
- (lineLoader !== undefined ? lineLoader : false);
1641
+ (lineLoader !== undefined ? lineLoader : false) ||
1642
+ (viberLoader !== undefined ? viberLoader : false);
1570
1643
  return isLoading;
1571
1644
  }
1572
1645
  getChannelTypeIllustrationInfo = (type) => {
@@ -1648,6 +1721,7 @@ export class Templates extends React.Component { // eslint-disable-line react/pr
1648
1721
  const isMobilePushChannel = channel === MOBILE_PUSH;
1649
1722
  const isLineChannel = channel === LINE;
1650
1723
 
1724
+
1651
1725
  if ((isWechatChannel || isMobilePushChannel || isLineChannel) && !isEmpty(weCrmAccounts)) {
1652
1726
  forEach(weCrmAccounts, (account) => {
1653
1727
  if ((isWechatChannel && account.configs && account.configs.is_wecrm_enabled) || isMobilePushChannel || isLineChannel) {
@@ -1706,6 +1780,10 @@ export class Templates extends React.Component { // eslint-disable-line react/pr
1706
1780
  noAccountHeader = messages.noAccountsPresentLine;
1707
1781
  break;
1708
1782
  }
1783
+ case VIBER: {
1784
+ noAccountHeader = messages.noAccountsPresentViber;
1785
+ break;
1786
+ }
1709
1787
  default:
1710
1788
  break;
1711
1789
  }
@@ -1764,7 +1842,8 @@ export class Templates extends React.Component { // eslint-disable-line react/pr
1764
1842
  render() {
1765
1843
  const isFullMode = this.isFullMode();
1766
1844
  const { activeMode, channel, wechatFilter, lineFilter } = this.state;
1767
- if (activeMode === ACCOUNT_SELECTION_MODE) {
1845
+ const showForViber = (channel.toLowerCase() !== VIBER_CHANNEL || (channel.toLowerCase() === VIBER_CHANNEL && isEmpty(get(this.props, 'Templates.selectedViberAccount', {}))));
1846
+ if (activeMode === ACCOUNT_SELECTION_MODE && showForViber ) {
1768
1847
  return this.renderAccountSelection();
1769
1848
  }
1770
1849
  const pageHeader = "";
@@ -1977,6 +2056,7 @@ Templates.propTypes = {
1977
2056
  isFullMode: PropTypes.bool,
1978
2057
  handlePeviewTemplate: PropTypes.func,
1979
2058
  router: PropTypes.object,
2059
+ viberActions: PropTypes.object,
1980
2060
  };
1981
2061
 
1982
2062
  const mapStateToProps = createStructuredSelector({
@@ -1989,6 +2069,7 @@ const mapStateToProps = createStructuredSelector({
1989
2069
  EmailCreate: makeSelectCreateEmail(),
1990
2070
  Global: makeSelectAuthenticated(),
1991
2071
  Line: makeSelectLine(),
2072
+ Viber: makeSelectViber(),
1992
2073
  });
1993
2074
 
1994
2075
  function mapDispatchToProps(dispatch) {
@@ -2001,6 +2082,7 @@ function mapDispatchToProps(dispatch) {
2001
2082
  emailActions: bindActionCreators(emailActions, dispatch),
2002
2083
  globalActions: bindActionCreators(globalActions, dispatch),
2003
2084
  lineActions: bindActionCreators(lineActions, dispatch),
2085
+ viberActions: bindActionCreators(viberActions, dispatch),
2004
2086
  };
2005
2087
  }
2006
2088
 
@@ -366,4 +366,8 @@ export default defineMessages({
366
366
  id: `${scope}.duplicatingTemplate`,
367
367
  defaultMessage: 'Duplicating template...'
368
368
  },
369
+ noAccountsPresentViber: {
370
+ id: `${scope}.noAccountsPresentViber`,
371
+ defaultMessage: "Viber accounts are not setup for your brand",
372
+ },
369
373
  });
@@ -73,6 +73,8 @@ function templatesReducer(state = initialState, action) {
73
73
  .set('selectedWeChatAccount', fromJS(action.weChatAccount));
74
74
  case types.SET_LINE_ACCOUNT:
75
75
  return state.set('selectedLineAccount', fromJS(action.lineAccount));
76
+ case types.SET_VIBER_ACCOUNT:
77
+ return state.set('selectedViberAccount', fromJS(action.viberAccount));
76
78
  case types.RESET_ACCOUNT:
77
79
  return state
78
80
  .remove('selectedWeChatAccount')