@capillarytech/creatives-library 6.13.4 → 6.13.5

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/app.js CHANGED
@@ -25,6 +25,7 @@ import initialState from './initialState';
25
25
  import './styles/vendor/semantic/dist/semantic.min.css';
26
26
  import './styles/main.scss';
27
27
  import pathConfig from './config/path';
28
+ import ignoredErrorMessages from './utils/ignoredErrorMessages';
28
29
  // addLocaleData([...en, ...es, ...fr, ...it, ...zh]);
29
30
 
30
31
  const browserHistory = useRouterHistory(createHistory)({
@@ -38,10 +39,12 @@ const history = syncHistoryWithStore(browserHistory, store, {
38
39
  });
39
40
 
40
41
  const bugSnagErrorCallback = (event) => {
41
- const { app: { releaseStage } = {} } = event || {};
42
+ const { app: { releaseStage } = {}, originalError } = event || {};
43
+ const errorMessage = originalError && originalError.message;
42
44
  if (
43
45
  (releaseStage || '').includes('nightly') ||
44
- process.env.NODE_ENV !== 'production'
46
+ process.env.NODE_ENV !== 'production' ||
47
+ ignoredErrorMessages.includes(errorMessage)
45
48
  ) {
46
49
  return false;
47
50
  }
@@ -204,7 +204,9 @@ class FormBuilder extends React.Component { // eslint-disable-line react/prefer-
204
204
 
205
205
  if (!_.isEmpty(nextProps.formData) && !_.isEqual(this.state.formData, nextProps.formData)) {
206
206
  if (nextProps.isNewVersionFlow) {
207
- const tabKey = (this.state.tabKey !== nextProps.formData[nextProps.currentTab - 1].tabKey) ? nextProps.formData[nextProps.currentTab - 1].tabKey : this.state.tabKey;
207
+ const nextPropsFormData = nextProps.formData[nextProps.currentTab - 1];
208
+ const nextPropsTabKey = nextPropsFormData && nextPropsFormData.tabKey;
209
+ const tabKey = (this.state.tabKey !== nextPropsTabKey) ? nextPropsTabKey: this.state.tabKey;
208
210
 
209
211
  this.setState({tabKey});
210
212
  }
@@ -1841,7 +1843,9 @@ class FormBuilder extends React.Component { // eslint-disable-line react/prefer-
1841
1843
  formData.base.tabKey = `${data}`;
1842
1844
  }
1843
1845
 
1844
- that.setState({formData, currentLangTab: formData[(this.state.currentTab - 1)].activeTab, tabKey: formData[(this.state.currentTab - 1)][formData[(this.state.currentTab - 1)].activeTab].tabKey}, () => {
1846
+ const formDataActiveKey = formData[(this.state.currentTab - 1)][formData[(this.state.currentTab - 1)].activeTab];
1847
+ const formDataTabKey = formDataActiveKey && formDataActiveKey.tabKey;
1848
+ that.setState({formData, currentLangTab: formData[(this.state.currentTab - 1)].activeTab, tabKey: formDataTabKey}, () => {
1845
1849
  val.injectedEvents[event].call(that.props.parent, this.state.currentTab, formData);
1846
1850
  });
1847
1851
  } else {
@@ -908,6 +908,9 @@ export class Ebill extends React.Component { // eslint-disable-line react/prefer
908
908
  injectEvents(schema) {
909
909
  console.log('now injecting events', schema);
910
910
  const temp = schema;
911
+ if (!temp.standalone) {
912
+ temp.standalone = {};
913
+ }
911
914
  temp.standalone.sections = this.injectSections(temp.standalone.sections);
912
915
  _.forEach(temp.containers, (container) => {
913
916
  let tempContainer = container;
@@ -1155,8 +1155,11 @@ export class Email extends React.Component { // eslint-disable-line react/prefer
1155
1155
  const msgString = JSON.stringify(msg);
1156
1156
  const langId = formData[this.state.currentTab - 1].activeTab;
1157
1157
  const langIndex = formData[this.state.currentTab - 1].selectedLanguages.indexOf(langId);
1158
- const win = document.getElementById(`edmeditor${(langIndex + 1) > 1 ? (langIndex + 1) : ''}`).contentWindow;
1159
- win.postMessage(msgString, '*');
1158
+ const elementToSelect = document.getElementById(`edmeditor${(langIndex + 1) > 1 ? (langIndex + 1) : ''}`);
1159
+ if (elementToSelect) {
1160
+ const win = elementToSelect.contentWindow;
1161
+ win.postMessage(msgString, '*');
1162
+ }
1160
1163
  } else {
1161
1164
  console.log('tag', this.state, this.state.editorInstanse);
1162
1165
  if (this.state.editorInstanse) {
@@ -1415,7 +1418,8 @@ export class Email extends React.Component { // eslint-disable-line react/prefer
1415
1418
 
1416
1419
  getMappedEvent = (id, event) => {
1417
1420
  console.log('Map ', this.map, id, event);
1418
- return this.map[id][event];
1421
+ const mapIdObject = this.map[id];
1422
+ return mapIdObject && mapIdObject[event] ? mapIdObject[event] : () => {};
1419
1423
  }
1420
1424
 
1421
1425
  getCurrentWindow = (e) => {
@@ -1511,8 +1515,11 @@ export class Email extends React.Component { // eslint-disable-line react/prefer
1511
1515
  _.forEach(data.selectedLanguages, (language, langIndex) => {
1512
1516
  if (data[language].is_drag_drop) {
1513
1517
  console.log('saving edm template', document.getElementById("edmeditor"), `edmeditor${(langIndex + 1) > 1 ? (langIndex + 1) : ''}`);
1514
- const win = document.getElementById(`edmeditor${(langIndex + 1) > 1 ? (langIndex + 1) : ''}`).contentWindow;
1515
- win.postMessage("saveProject", '*');
1518
+ const elementToSelect = document.getElementById(`edmeditor${(langIndex + 1) > 1 ? (langIndex + 1) : ''}`);
1519
+ if (elementToSelect) {
1520
+ const win = elementToSelect.contentWindow;
1521
+ win.postMessage("saveProject", '*');
1522
+ }
1516
1523
  }
1517
1524
  });
1518
1525
  });
@@ -2501,7 +2508,7 @@ export class Email extends React.Component { // eslint-disable-line react/prefer
2501
2508
  const tempEl = containerInputFieldCol;
2502
2509
  if (containerInputFieldCol.id === "tab-header") {
2503
2510
  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';
2504
- const supportedLanguages = this.props.Global.currentOrgDetails.basic_details.supported_languages;
2511
+ const supportedLanguages = this.props.Global.currentOrgDetails && this.props.Global.currentOrgDetails.basic_details && this.props.Global.currentOrgDetails.basic_details.supported_languages;
2505
2512
  if (!supportedLanguages) {
2506
2513
  tempEl.value = baseLanguage || 'English';
2507
2514
  return;
@@ -2655,12 +2662,13 @@ export class Email extends React.Component { // eslint-disable-line react/prefer
2655
2662
  if (languageIndex === -1) {
2656
2663
  languageIndex = 0;
2657
2664
  }
2665
+ const dataBase = data.base;
2658
2666
  const tempData = {
2659
- "is_drag_drop": data.base.is_drag_drop,
2667
+ "is_drag_drop": dataBase && dataBase.is_drag_drop,
2660
2668
  "lang_id": this.supportedLanguages[languageIndex].lang_id,
2661
2669
  "iso_code": this.supportedLanguages[languageIndex].iso_code,
2662
2670
  "language": this.supportedLanguages[languageIndex].language,
2663
- "template-content": !data.base.is_drag_drop && data.base.is_drag_drop !== 1 ? data.base.html_content : "",
2671
+ "template-content": dataBase && !dataBase.is_drag_drop && dataBase.is_drag_drop !== 1 ? dataBase.html_content : "",
2664
2672
  };
2665
2673
  formData[0].base = true;
2666
2674
  formData[0].selectedLanguages.push(this.supportedLanguages[languageIndex].iso_code);
@@ -297,7 +297,8 @@ export class Create extends React.Component { // eslint-disable-line react/prefe
297
297
  onTabChange: this.onTabChange,
298
298
  },
299
299
  };
300
- return map[id][event];
300
+ const mappedIdObject = map[id];
301
+ return mappedIdObject && mappedIdObject[event] ? mappedIdObject[event] : () => {};
301
302
  }
302
303
 
303
304
  setFormValidity(isFormValid) {
@@ -721,9 +721,6 @@ export class Templates extends React.Component { // eslint-disable-line react/pr
721
721
  }
722
722
  }
723
723
  switch (type) {
724
- case "getFormData":
725
- this.getFormData(e);
726
- break;
727
724
  case "startTemplateCreation":
728
725
  console.log('Starting to create template');
729
726
  //this.getFormData(e);
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@capillarytech/creatives-library",
3
3
  "author": "meharaj",
4
- "version": "6.13.4",
4
+ "version": "6.13.5",
5
5
  "description": "Capillary creatives ui",
6
6
  "main": "./index.js",
7
7
  "module": "./index.es.js",
@@ -15,7 +15,7 @@
15
15
  "@babel/polyfill": "7.4.3",
16
16
  "@bugsnag/js": "^7.2.1",
17
17
  "@bugsnag/plugin-react": "^7.2.1",
18
- "@capillarytech/cap-ui-utils": "1.3.2",
18
+ "@capillarytech/cap-ui-utils": "1.3.4",
19
19
  "@mailupinc/bee-plugin": "^1.2.0",
20
20
  "babel-cli": "^6.26.0",
21
21
  "chalk": "1.1.3",
package/services/api.js CHANGED
@@ -359,7 +359,6 @@ export const createLineTemplate = ({template}) => {
359
359
  };
360
360
 
361
361
  export const createViberTemplate = ({template}) => {
362
- console.log('VIBER : in api.js', template);
363
362
  const url = `${API_ENDPOINT}/templates/VIBER`;
364
363
  return request(url, getAPICallObject('POST', template));
365
364
  };
@@ -0,0 +1,4 @@
1
+ export default [
2
+ // ref: https://stackoverflow.com/questions/49384120/resizeobserver-loop-limit-exceeded
3
+ 'ResizeObserver loop limit exceeded'
4
+ ];
@@ -2362,7 +2362,9 @@ class FormBuilder extends React.Component { // eslint-disable-line react/prefer-
2362
2362
  this.renderTextAreaContent(styling, columns, val, isVersionEnable, rows, cols, val.offset);
2363
2363
  break;
2364
2364
  case "contentPreview":
2365
- content = isVersionEnable ? this.state.formData[this.state.currentTab - 1]['sms-editor'] : this.state.formData['sms-editor'];
2365
+ const { formData , currentTab } = this.state || {};
2366
+ const tab = formData && formData[currentTab - 1];
2367
+ content = isVersionEnable ? tab && tab['sms-editor'] : formData && formData['sms-editor'];
2366
2368
  charList = updateCharCount(content).char_list;
2367
2369
  columns.push(<CapColumn id={val.id} className={"preview-chars"} span={val.width}>
2368
2370
  {charList.map((char) => char)}
@@ -3175,7 +3177,7 @@ class FormBuilder extends React.Component { // eslint-disable-line react/prefer-
3175
3177
  }
3176
3178
  console.log('CKEditor Data 2', this.state.formData, this.state.formData[`${this.state.currentTab - 1}`], val, this.state.currentTab, this.state.currentLangTab, langIndex);
3177
3179
  const currentLang = ((!_.isEmpty(this.state.formData) && !_.isEmpty(this.state.formData[`${this.state.currentTab - 1}`]) && !_.isEmpty(this.state.formData[`${this.state.currentTab - 1}`].selectedLanguages) && this.state.formData[`${this.state.currentTab - 1}`].selectedLanguages[langIndex]) ? this.state.formData[`${this.state.currentTab - 1}`].selectedLanguages[langIndex] : this.props.baseLanguage) || 'en';
3178
- const content = (!_.isEmpty(this.state.formData) && this.state.formData[`${this.state.currentTab - 1}`][currentLang]['template-content'] ? this.state.formData[`${this.state.currentTab - 1}`][currentLang]['template-content'] : '');
3180
+ const content = (!_.isEmpty(this.state.formData) && this.state.formData[`${this.state.currentTab - 1}`] && this.state.formData[`${this.state.currentTab - 1}`][currentLang] && this.state.formData[`${this.state.currentTab - 1}`][currentLang]['template-content'] || '');
3179
3181
  columns.push(
3180
3182
  <CapColumn style={val.colStyle ? val.colStyle : {}} span={val.width}>
3181
3183
  <CKEditor
@@ -3198,7 +3200,7 @@ class FormBuilder extends React.Component { // eslint-disable-line react/prefer-
3198
3200
  }
3199
3201
  }
3200
3202
  const { currentTab, formData } = this.state;
3201
- const supportedLanguages = formData[currentTab - 1].selectedLanguages;
3203
+ const supportedLanguages = (formData[currentTab - 1] || {}).selectedLanguages || {};
3202
3204
  const currentLang = supportedLanguages[langTab - 1];
3203
3205
 
3204
3206
  let beeJson = '',
@@ -16,6 +16,7 @@ import {updateCharCount} from '../../utils/smsCharCountV2';
16
16
  import messages from './messages';
17
17
  import { WECHAT } from '../../v2Containers/CreativesContainer/constants';
18
18
  import Carousel from '../Carousel';
19
+ import { VIBER } from '../../v2Containers/App/constants';
19
20
  const wechatBodyNew = require('./assets/images/wechat_mobile_android.svg');
20
21
  const smsMobileAndroid = require('./assets/images/sms_mobile_android.svg');
21
22
  const lineMobileAndroid = require('../../assets/line.png');
@@ -26,6 +27,7 @@ const lineStickerPlaceholder = require('../../assets/smiley-placeholder.svg');
26
27
  const lineVideoPlaceholder = require('../../assets/rich-video-placeholder.svg');
27
28
  const androidPushMessagePhone = require('./assets/images/androidPushMessage.svg');
28
29
  const iPhonePushMessagePhone = require('./assets/images/iPhonePushMessage.svg');
30
+
29
31
  import { CAP_COLOR_03, CAP_WHITE, FONT_COLOR_01, CAP_G08, CAP_G06, CAP_G15, CAP_PURPLE01, CAP_G16 } from '@capillarytech/cap-ui-library/styled/variables';
30
32
  import { TEMPLATE, IMAGE_CAROUSEL, IMAGE, STICKER, TEXT, IMAGE_MAP, VIDEO } from '../../v2Containers/Line/Container/constants';
31
33
 
@@ -129,7 +131,8 @@ class TemplatePreview extends React.Component { // eslint-disable-line react/pre
129
131
 
130
132
  render() {
131
133
  let content = channel && channel.toLowerCase() === 'sms' ? [this.props.content] : this.props.content;
132
- const { channel, showTestAndPreviewIcon, module} = this.props;
134
+ const { channel, showTestAndPreviewIcon, module } = this.props;
135
+ const { buttonText, imageURL, messageContent: viberMessageContent } = content || {};
133
136
  let smsDetails = {};
134
137
  // let smsText = '';
135
138
  if (this.props.content && this.props.charCounterEnabled) {
@@ -555,7 +558,7 @@ class TemplatePreview extends React.Component { // eslint-disable-line react/pre
555
558
  ) : ''
556
559
  }
557
560
  {
558
- channel && channel.toLowerCase() === 'viber' ? (
561
+ channel && channel.toLowerCase() === VIBER ? (
559
562
  <div className="shell-v2 align-center" id="sms-preview">
560
563
  <CapImage className="preview-image" src={viberMobileAndroid} alt={this.props.intl.formatMessage(messages.previewGenerated)}/>
561
564
  <div
@@ -590,11 +593,11 @@ class TemplatePreview extends React.Component { // eslint-disable-line react/pre
590
593
  'font-size': '10px',
591
594
  "color": CAP_G16,
592
595
  "margin": '1.5px 6px 1px 7px',
593
- }}>{this.props.content.messageContent || ''}
596
+ }}>{viberMessageContent || ''}
594
597
  </p>
595
598
  {/* Image Viber preview */}
596
- {this.props.content.imageURL && <CapImage
597
- src={this.props.content.imageURL}
599
+ {imageURL && <CapImage
600
+ src={imageURL}
598
601
  alt="brand-name"
599
602
  rest={{
600
603
  style: {
@@ -605,7 +608,7 @@ class TemplatePreview extends React.Component { // eslint-disable-line react/pre
605
608
  />
606
609
  }
607
610
  {/* button viber preview */}
608
- {this.props.content.buttonText && <div
611
+ {buttonText && <div
609
612
  style={{
610
613
  'border-radius': '16px',
611
614
  'background-color': CAP_PURPLE01,
@@ -620,7 +623,7 @@ class TemplatePreview extends React.Component { // eslint-disable-line react/pre
620
623
  'font-weight': '500',
621
624
  "color": CAP_WHITE }}
622
625
  >
623
- {this.props.content.buttonText || ''}</p>
626
+ {buttonText || ''}</p>
624
627
  </div>
625
628
  }
626
629
  <div style={{ paddingBottom: 32}}></div>
@@ -20,7 +20,7 @@ export const TRACK_CREATE_WECHAT = 'createWeChat';
20
20
  export const TRACK_CREATE_IMAGE = 'createImage';
21
21
  export const TRACK_CREATE_LINE = 'createLine';
22
22
 
23
-
23
+ export const VIBER = 'viber';
24
24
  export const TRACK_EDIT_SMS = 'editSms';
25
25
  export const TRACK_EDIT_EMAIL = 'editEmail';
26
26
  export const TRACK_EDIT_MPUSH = 'editMpush';
@@ -33,7 +33,7 @@ import './_cap.scss';
33
33
  const gtm = window.dataLayer || [];
34
34
  const {
35
35
  logNewTab,
36
- getOrgNameFromId,
36
+ utilsGetOrgNameFromId,
37
37
  tabBeforeUnloadEventHandler,
38
38
  utilsHandleStorageChange,
39
39
  isMultipleTabsOpen,
@@ -297,18 +297,36 @@ export class Cap extends React.Component { // eslint-disable-line react/prefer-s
297
297
  }
298
298
  };
299
299
 
300
+ getOrgNameFromId = orgId => {
301
+ const {
302
+ Global: {
303
+ user: {
304
+ proxyOrgList,
305
+ orgName: defaultOrgName,
306
+ orgID: defaultOrgID,
307
+ } = {},
308
+ } = {},
309
+ } = this.props;
310
+ return utilsGetOrgNameFromId(
311
+ orgId,
312
+ proxyOrgList,
313
+ defaultOrgID,
314
+ defaultOrgName,
315
+ );
316
+ };
317
+
300
318
  renderOrgRefreshModal = () => {
301
319
  const {
302
320
  localStorageOrgInfo: { oldValue: oldOrgId, newValue: newOrgId } = {},
303
321
  showRefreshModal,
304
322
  refreshSeconds,
305
323
  } = this.state;
306
- const {
307
- Global: { user: { proxyOrgList } = {} } = {},
308
- intl: { formatMessage } = {},
309
- } = this.props;
310
- const oldOrgName = getOrgNameFromId(Number(oldOrgId), proxyOrgList);
311
- const newOrgName = getOrgNameFromId(Number(newOrgId), proxyOrgList);
324
+ const { intl: { formatMessage } = {} } = this.props;
325
+ const oldOrgName = this.getOrgNameFromId(Number(oldOrgId));
326
+ const newOrgName = this.getOrgNameFromId(Number(newOrgId));
327
+ // some users do not have entry for their default org in proxyOrgList.
328
+ // getOrgNameFromId returns back orgID if no matching entry is present in proxyOrgList
329
+ // so replacing with defaultOrgName if defaultOrgID is returned
312
330
  const modalData = (
313
331
  <CapModal
314
332
  title={formatMessage(messages.orgRefreshHeading)}
@@ -339,12 +357,15 @@ export class Cap extends React.Component { // eslint-disable-line react/prefer-s
339
357
  renderOrgChangeModal = () => {
340
358
  const { selectedOrgId, showOrgChangeModal } = this.state;
341
359
  const {
342
- Global: { user: { proxyOrgList } = {},
360
+ Global: {
343
361
  currentOrgDetails: { basic_details: { name: oldOrgName } = {} } = {},
344
362
  },
345
363
  intl: { formatMessage } = {},
346
364
  } = this.props;
347
- const newOrgName = getOrgNameFromId(selectedOrgId, proxyOrgList);
365
+ const newOrgName = this.getOrgNameFromId(selectedOrgId);
366
+ // some users do not have entry for their default org in proxyOrgList.
367
+ // getOrgNameFromId returns back orgID if no matching entry is present in proxyOrgList
368
+ // so replacing with defaultOrgName if defaultOrgID is returned
348
369
  return (
349
370
  <CapModal
350
371
  className="change-org-confirm"
@@ -254,7 +254,7 @@ class Creatives extends React.Component {
254
254
  type: constants.VIBER,
255
255
  isDefault,
256
256
  edit: true,
257
- name: "Campaign message VIBER content",
257
+ name: "",
258
258
  versions: {
259
259
  base: {
260
260
  content: {
@@ -65,7 +65,7 @@
65
65
  text-align:center;
66
66
  }
67
67
  }
68
- .truncate-text{
68
+ .truncate-text-viber{
69
69
  .ant-card-meta-description{
70
70
  display: -webkit-box;
71
71
  -webkit-line-clamp: 9;
@@ -31,7 +31,6 @@ import { makeSelectEmail as makeSelectCreateEmail } from '../Email/selectors';
31
31
  import { makeSelectEdit } from '../Sms/Edit/selectors';
32
32
  import { makeSelectLine } from '../Line/Container/selectors';
33
33
  import { makeSelectViber } from '../Viber/selectors';
34
-
35
34
  import { UserIsAuthenticated } from '../../utils/authWrapper';
36
35
  import messages from './messages';
37
36
  import {checkUnicode} from '../../utils/smsCharCountV2';
@@ -54,8 +53,13 @@ import Pagination from '../../v2Components/Pagination';
54
53
  import EmailPreview from '../../v2Components/EmailPreview';
55
54
  import CreativesContainer from '../CreativesContainer';
56
55
  import WechatRichmediaTemplatePreview from '../../v2Components/TemplatePreview/WechatRichmediaTemplatePreview';
57
- import { CHANNEL_CREATE_TRACK_MAPPING, CHANNEL_EDIT_TRACK_MAPPING } from '../App/constants';
56
+ import {
57
+ CHANNEL_CREATE_TRACK_MAPPING,
58
+ CHANNEL_EDIT_TRACK_MAPPING,
59
+ VIBER as VIBER_CHANNEL,
60
+ } from '../App/constants';
58
61
  import { MOBILE_PUSH, WECHAT, SMS, EMAIL, EBILL, LINE, VIBER } from '../CreativesContainer/constants';
62
+
59
63
  import emailIllustration from '../Assets/images/emailIllustration.svg';
60
64
  import smsIllustration from '../Assets/images/smsIllustration.svg';
61
65
  import pushIllustration from '../Assets/images/pushIllustration.svg';
@@ -192,7 +196,7 @@ export class Templates extends React.Component { // eslint-disable-line react/pr
192
196
  if (this.props.location.query.type === 'embedded') {
193
197
  this.props.actions.resetAccount();
194
198
  }
195
- if ((this.state.channel && (this.state.channel.toLowerCase() === 'line' || this.state.channel.toLowerCase() === 'viber' || 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))) {
199
+ if ((['line', VIBER_CHANNEL, 'sms', 'email', 'ebill'].includes((this.state.channel || '').toLowerCase())) || ((['wechat','mobilepush'].includes(this.state.channel.toLowerCase()) && !isEmpty(this.props.Templates.selectedWeChatAccount))) {
196
200
  const queryParams = {
197
201
  // name: this.state.searchText,
198
202
  // sortBy: this.state.sortBy,
@@ -252,12 +256,12 @@ export class Templates extends React.Component { // eslint-disable-line react/pr
252
256
  this.setState({defaultAccount: true});
253
257
  nextProps.actions.getWeCrmAccounts(channel);
254
258
  }
255
- } else if (nextProps.route.name.toLowerCase() === 'viber') {
259
+ } else if (nextProps.route.name.toLowerCase() === VIBER_CHANNEL) {
256
260
  channel = 'Viber';
257
261
  }
258
262
 
259
263
  this.setState({ channel }, () => {
260
- if ((this.state.channel.toLowerCase() === 'line' || this.state.channel.toLowerCase() === 'viber' || this.state.channel.toLowerCase() === 'sms' || this.state.channel.toLowerCase() === 'email' || this.state.channel.toLowerCase() === 'ebill') || (this.state.channel.toLowerCase() === 'wechat' && !isEmpty(nextProps.Templates.selectedWeChatAccount))) {
264
+ if (['line', VIBER_CHANNEL, 'sms', 'email', 'ebill'].includes(this.state.channel.toLowerCase()) || (this.state.channel.toLowerCase() === 'wechat' && !isEmpty(nextProps.Templates.selectedWeChatAccount))) {
261
265
  if (this.state.channel.toLowerCase() === 'wechat' && !isEmpty(nextProps.Templates.selectedWeChatAccount)) {
262
266
  params.wecrmId = (nextProps.Templates.selectedWeChatAccount.configs || {}).wecrm_app_id;
263
267
  params.wecrmToken = (nextProps.Templates.selectedWeChatAccount.configs || {}).wecrm_token;
@@ -346,7 +350,7 @@ export class Templates extends React.Component { // eslint-disable-line react/pr
346
350
  this.props.ebillActions.clearCreateResponse();
347
351
  } else if (this.state.channel.toLowerCase() === "line") {
348
352
  this.props.lineActions.clearCreateResponse();
349
- } else if (this.state.channel.toLowerCase() === "viber") {
353
+ } else if (this.state.channel.toLowerCase() === VIBER_CHANNEL) {
350
354
  this.props.viberActions.clearCreateResponse();
351
355
  }
352
356
  }
@@ -1206,7 +1210,7 @@ export class Templates extends React.Component { // eslint-disable-line react/pr
1206
1210
  this.props.lineActions.clearCreateResponse();
1207
1211
  }
1208
1212
  });
1209
- } else if (this.state.channel.toLowerCase() === "viber") {
1213
+ } else if (this.state.channel.toLowerCase() === VIBER_CHANNEL) {
1210
1214
  this.props.viberActions.createTemplate(duplicateObj, (response) => {
1211
1215
  if (response && response.templateId) {
1212
1216
  const message = `${this.state.channel} ${this.props.intl.formatMessage(messages.templateDuplicateSuccess)}`;
@@ -1296,7 +1300,7 @@ export class Templates extends React.Component { // eslint-disable-line react/pr
1296
1300
  pathName += `/${options.account}`;
1297
1301
  }
1298
1302
  }
1299
- if (this.state.channel.toLowerCase() === 'viber') {
1303
+ if (this.state.channel.toLowerCase() === VIBER_CHANNEL) {
1300
1304
  pathName = `/viber/edit/${id}/`;
1301
1305
  }
1302
1306
  if (this.state.channel.toUpperCase() === WECHAT) {
@@ -1597,7 +1601,7 @@ export class Templates extends React.Component { // eslint-disable-line react/pr
1597
1601
  } = Templates;
1598
1602
  const lineLoader = (getAllTemplatesInProgress && this.state.channel.toLowerCase() === 'line');
1599
1603
  const smsLoader = (getAllTemplatesInProgress && this.state.channel.toLowerCase() === 'sms');
1600
- const viberLoader = (getAllTemplatesInProgress && this.state.channel.toLowerCase() === 'viber');
1604
+ const viberLoader = (getAllTemplatesInProgress && this.state.channel.toLowerCase() === VIBER_CHANNEL);
1601
1605
  const wechatLoader = (((this.state.selectedAccount !== '' && getAllTemplatesInProgress) || (fetchingWeCrmAccounts)) && this.state.channel.toLowerCase() === 'wechat');
1602
1606
  const mobilePushLoader = (((getAllTemplatesInProgress) || (fetchingWeCrmAccounts)) && this.state.channel.toLowerCase() === 'mobilepush');
1603
1607
  const emailLoader = (
@@ -176,9 +176,6 @@ export class TemplatesV2 extends React.Component { // eslint-disable-line react/
176
176
  if (channel === 'line') {
177
177
  return this.getLineComponent();
178
178
  }
179
- if (channel === 'viber') {
180
- return this.getViberComponent();
181
- }
182
179
  }
183
180
  const location = {pathname: `/${channel}`, search: '', query};
184
181
  switch (channel) {
@@ -25,7 +25,6 @@ import { makeSelectViber, makeSelectCreateViber } from './selectors';
25
25
  import * as viberActions from './actions';
26
26
  import { validateTags } from '../../utils/tagValidations';
27
27
  import TemplatePreview from '../../v2Components/TemplatePreview';
28
- import './_viber.scss';
29
28
  import {
30
29
  CAP_G09,
31
30
  CAP_SPACE_08,
@@ -65,8 +64,10 @@ const Viber = (props) => {
65
64
  handleClose,
66
65
  onCreateComplete,
67
66
  params,
67
+ templateData,
68
68
  actions,
69
- viber,
69
+ viber = {},
70
+ getFormSubscriptionData,
70
71
  } = props || {};
71
72
 
72
73
  const { formatMessage } = intl;
@@ -105,7 +106,7 @@ const Viber = (props) => {
105
106
 
106
107
  useEffect(() => {
107
108
  const { id } = paramObj;
108
- if (id) {
109
+ if (id && !templateData) {
109
110
  updateEditLoading(true);
110
111
  actions.getTemplateDetails(id, updateEditLoading);
111
112
  checkEditFlow(true);
@@ -114,8 +115,8 @@ const Viber = (props) => {
114
115
 
115
116
  useEffect(() => {
116
117
  if (params && params.id) {
117
- const { viber: editViberContent = {} } = get(viber, `templateDetails.versions.base.content`, {});
118
- const editMessageTitle = get(viber, 'templateDetails.name');
118
+ const { viber: editViberContent = {} } = get(templateData, `versions.base.content`) || get(viber, `templateDetails.versions.base.content`) || {};
119
+ const editMessageTitle = (templateData || {}).name || get(viber, 'templateDetails.name');
119
120
  updateTextMessageTitle(editMessageTitle);
120
121
  updateTextMessageContent(editViberContent.text || '');
121
122
  updateButtonText(editViberContent.buttonText || '');
@@ -126,7 +127,7 @@ const Viber = (props) => {
126
127
  updateImageStatus(true);
127
128
  }
128
129
  }
129
- }, [viber[`templateDetails`]]);
130
+ }, [viber[`templateDetails`] || templateData]);
130
131
 
131
132
  // Common container for TEXT, IMAGE and Button
132
133
  const container = (icon, message, data) => (<CapRow
@@ -581,6 +582,7 @@ const Viber = (props) => {
581
582
  onCreateComplete();
582
583
  });
583
584
  };
585
+
584
586
  const onDoneCallback = () => {
585
587
  if (isFullMode) {
586
588
  if (isEditFlow) {
@@ -588,7 +590,12 @@ const Viber = (props) => {
588
590
  }
589
591
  return onCreateViber;
590
592
  }
591
- return '';
593
+ return () => getFormSubscriptionData({
594
+ value: formatSubmitPayload(),
595
+ _id: params && params.id,
596
+ validity: true,
597
+ type: 'VIBER',
598
+ });
592
599
  };
593
600
 
594
601
  const isDisableDone = () => {
@@ -876,7 +876,7 @@ export class MapTemplates extends React.Component { // eslint-disable-line react
876
876
  }
877
877
 
878
878
  getMappedEvent(id, event) {
879
- return this.state.map[id][event];
879
+ return (this.state.map[id] && this.state.map[id][event] ? this.state.map[id][event] : () => {});
880
880
  }
881
881
 
882
882
  handleOnTagsContextChange = (data) => {