@capillarytech/creatives-library 7.6.1 → 7.6.2

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 (134) hide show
  1. package/assets/DeviceForEmail.png +0 -0
  2. package/components/CapTagList/index.js +5 -5
  3. package/components/Card/index.js +1 -1
  4. package/components/Ckeditor/index.js +5 -5
  5. package/components/CustomPopOver/index.js +3 -3
  6. package/components/Edmeditor/index.js +4 -4
  7. package/components/EmailPreview/index.js +1 -1
  8. package/components/PreviewSideBar/index.js +3 -3
  9. package/components/Sidebar/index.js +1 -1
  10. package/components/SmsTest/index.js +4 -4
  11. package/components/TemplatePreview/index.js +2 -2
  12. package/components/Toastr/index.js +1 -1
  13. package/config/app.js +2 -0
  14. package/containers/Assets/Gallery/index.js +2 -2
  15. package/containers/Assets/Gallery/sagas.js +1 -1
  16. package/containers/Cap/actions.js +2 -2
  17. package/containers/Cap/reducer.js +1 -1
  18. package/containers/Cap/sagas.js +3 -3
  19. package/containers/Cap/selectors.js +1 -1
  20. package/containers/Ebill/actions.js +1 -1
  21. package/containers/Ebill/index.js +34 -34
  22. package/containers/Ebill/sagas.js +3 -3
  23. package/containers/Email/actions.js +2 -2
  24. package/containers/Email/index.js +171 -171
  25. package/containers/Email/reducer.js +1 -1
  26. package/containers/Email/sagas.js +6 -6
  27. package/containers/LanguageProvider/actions.js +1 -1
  28. package/containers/Line/Create/actions.js +5 -5
  29. package/containers/Line/Create/index.js +37 -37
  30. package/containers/Line/Create/sagas.js +7 -7
  31. package/containers/Line/Edit/actions.js +3 -3
  32. package/containers/Line/Edit/index.js +24 -24
  33. package/containers/Line/Edit/sagas.js +4 -4
  34. package/containers/MobilePush/Create/actions.js +2 -2
  35. package/containers/MobilePush/Create/index.js +35 -35
  36. package/containers/MobilePush/Create/sagas.js +2 -2
  37. package/containers/MobilePush/Edit/actions.js +3 -3
  38. package/containers/MobilePush/Edit/index.js +32 -32
  39. package/containers/MobilePush/Edit/sagas.js +5 -5
  40. package/containers/Sms/Create/actions.js +2 -2
  41. package/containers/Sms/Create/index.js +57 -57
  42. package/containers/Sms/Create/sagas.js +2 -2
  43. package/containers/Sms/Edit/actions.js +3 -3
  44. package/containers/Sms/Edit/index.js +44 -44
  45. package/containers/Sms/Edit/sagas.js +3 -3
  46. package/containers/TagList/index.js +9 -9
  47. package/containers/Templates/actions.js +5 -5
  48. package/containers/Templates/index.js +44 -44
  49. package/containers/Templates/sagas.js +5 -5
  50. package/containers/WeChat/MapTemplates/actions.js +1 -1
  51. package/containers/WeChat/MapTemplates/index.js +34 -34
  52. package/containers/WeChat/MapTemplates/sagas.js +2 -2
  53. package/containers/WeChat/RichmediaTemplates/Create/index.js +9 -9
  54. package/containers/WeChat/RichmediaTemplates/Edit/actions.js +1 -1
  55. package/containers/WeChat/RichmediaTemplates/Edit/sagas.js +1 -1
  56. package/index.js +6 -0
  57. package/package.json +1 -1
  58. package/reducers.js +2 -1
  59. package/routes.js +5 -0
  60. package/services/api.js +43 -14
  61. package/utils/authWrapper.js +2 -2
  62. package/utils/common.js +13 -1
  63. package/utils/smsCharCount.js +5 -5
  64. package/v2Components/CapTagList/index.js +1 -1
  65. package/v2Components/CapVideoUpload/index.js +14 -6
  66. package/v2Components/Card/index.js +1 -1
  67. package/v2Components/Ckeditor/index.js +5 -5
  68. package/v2Components/CustomPopOver/index.js +3 -3
  69. package/v2Components/Edmeditor/index.js +4 -4
  70. package/v2Components/EmailMobilePreview/index.js +4 -4
  71. package/v2Components/EmailPreviewV2/index.js +4 -4
  72. package/v2Components/FormBuilder/index.js +3 -3
  73. package/v2Components/PreviewSideBar/index.js +3 -3
  74. package/v2Components/SmsTest/index.js +4 -4
  75. package/v2Components/TemplatePreview/index.js +24 -3
  76. package/v2Components/Toastr/index.js +1 -1
  77. package/v2Containers/App/constants.js +21 -0
  78. package/v2Containers/Assets/Gallery/sagas.js +1 -1
  79. package/v2Containers/Cap/actions.js +1 -1
  80. package/v2Containers/Cap/index.js +2 -2
  81. package/v2Containers/Cap/messages.js +30 -0
  82. package/v2Containers/Cap/reducer.js +1 -1
  83. package/v2Containers/Cap/sagas.js +3 -3
  84. package/v2Containers/Cap/selectors.js +1 -1
  85. package/v2Containers/CapFacebookPreview/actions.js +3 -15
  86. package/v2Containers/CapFacebookPreview/constants.js +3 -11
  87. package/v2Containers/CapFacebookPreview/index.js +6 -6
  88. package/v2Containers/CapFacebookPreview/reducer.js +3 -9
  89. package/v2Containers/CapFacebookPreview/sagas.js +6 -65
  90. package/v2Containers/CreativesContainer/SlideBoxContent.js +64 -1
  91. package/v2Containers/CreativesContainer/index.js +19 -8
  92. package/v2Containers/Ebill/actions.js +1 -1
  93. package/v2Containers/Ebill/index.js +34 -34
  94. package/v2Containers/Ebill/sagas.js +3 -3
  95. package/v2Containers/Email/reducer.js +1 -1
  96. package/v2Containers/EmailWrapper/index.js +4 -4
  97. package/v2Containers/Facebook/Advertisement/index.js +38 -15
  98. package/v2Containers/Facebook/Advertisement/index.scss +9 -0
  99. package/v2Containers/Facebook/Advertisement/messages.js +2 -2
  100. package/v2Containers/Facebook/actions.js +63 -0
  101. package/v2Containers/Facebook/constants.js +25 -1
  102. package/v2Containers/Facebook/index.js +135 -107
  103. package/v2Containers/Facebook/reducer.js +98 -1
  104. package/v2Containers/Facebook/sagas.js +147 -0
  105. package/v2Containers/Facebook/selectors.js +10 -0
  106. package/v2Containers/LanguageProvider/actions.js +1 -1
  107. package/v2Containers/Line/Container/Video/index.js +38 -41
  108. package/v2Containers/Line/Container/actions.js +5 -5
  109. package/v2Containers/Line/Container/sagas.js +4 -4
  110. package/v2Containers/MobilePush/Create/actions.js +2 -2
  111. package/v2Containers/MobilePush/Create/index.js +1 -1
  112. package/v2Containers/MobilePush/Create/sagas.js +2 -2
  113. package/v2Containers/MobilePush/Edit/actions.js +3 -3
  114. package/v2Containers/MobilePush/Edit/index.js +26 -26
  115. package/v2Containers/MobilePush/Edit/sagas.js +5 -5
  116. package/v2Containers/Sms/Create/index.js +4 -4
  117. package/v2Containers/TagList/index.js +6 -6
  118. package/v2Containers/Templates/_templates.scss +26 -0
  119. package/v2Containers/Templates/actions.js +18 -5
  120. package/v2Containers/Templates/constants.js +8 -0
  121. package/v2Containers/Templates/index.js +139 -11
  122. package/v2Containers/Templates/messages.js +8 -4
  123. package/v2Containers/Templates/reducer.js +22 -0
  124. package/v2Containers/Templates/sagas.js +30 -5
  125. package/v2Containers/TemplatesV2/index.js +13 -13
  126. package/v2Containers/Viber/actions.js +2 -2
  127. package/v2Containers/Viber/index.js +2 -1
  128. package/v2Containers/Viber/sagas.js +2 -2
  129. package/v2Containers/WeChat/MapTemplates/actions.js +1 -1
  130. package/v2Containers/WeChat/MapTemplates/index.js +19 -19
  131. package/v2Containers/WeChat/MapTemplates/sagas.js +3 -3
  132. package/v2Containers/WeChat/RichmediaTemplates/Create/actions.js +1 -1
  133. package/v2Containers/WeChat/RichmediaTemplates/Edit/actions.js +1 -1
  134. package/v2Containers/WeChat/RichmediaTemplates/Edit/sagas.js +1 -1
@@ -35,7 +35,7 @@ export class TagList extends React.Component { // eslint-disable-line react/pref
35
35
  }
36
36
 
37
37
  componentDidMount() {
38
- console.log('tags props', this.props);
38
+
39
39
  }
40
40
 
41
41
  componentWillReceiveProps(nextProps) {
@@ -43,11 +43,11 @@ export class TagList extends React.Component { // eslint-disable-line react/pref
43
43
  this.setState({loading: true});
44
44
  }
45
45
  if (!_.isEqual(nextProps.injectedTags, this.props.injectedTags)) {
46
- console.log('received new tags', nextProps);
46
+
47
47
  this.setState({loading: false});
48
48
  }
49
49
  if (!_.isEqual(nextProps.tags, this.props.tags)) {
50
- console.log('received new tags', nextProps);
50
+
51
51
  this.setState({loading: false});
52
52
  }
53
53
  }
@@ -57,7 +57,7 @@ export class TagList extends React.Component { // eslint-disable-line react/pref
57
57
  };
58
58
 
59
59
  onClick = (e, data) => {
60
- console.log('clicked ', e, data);
60
+
61
61
  };
62
62
 
63
63
  getTagsforContext = (data) => {
@@ -81,7 +81,7 @@ export class TagList extends React.Component { // eslint-disable-line react/pref
81
81
  } else if (tag['tag-header'] && mainTags[tag.value]) {
82
82
  mainTags[tag.value].subtags = _.concat(mainTags[tag.value].subtags, tag.subtags);
83
83
  } else if (!mainTags[tag.value]) {
84
- // console.log('Inside ', tag.label);
84
+ //
85
85
  mainTags[tag.value] = {
86
86
  'tag-header': true,
87
87
  "name": tag.label[userLocale] ? tag.label[userLocale] : tag.label.en,
@@ -225,7 +225,7 @@ export class TagList extends React.Component { // eslint-disable-line react/pref
225
225
  let injectedTags = {};
226
226
  if (this.props.injectedTags && !_.isEmpty(this.props.injectedTags)) {
227
227
  injectedTags = this.transformInjectedTags(this.props.injectedTags);
228
- console.log('transformed injected Tags', injectedTags);
228
+
229
229
  }
230
230
  if (this.props.tags && this.props.tags.length > 0) {
231
231
  tags = this.populateTags(this.props.tags);
@@ -20,6 +20,32 @@
20
20
 
21
21
  .creatives-templates-list {
22
22
  .pagination-container {
23
+ .FACEBOOK {
24
+ .ant-card-body {
25
+ background-color: $CAP_G09;
26
+ height: 320px;
27
+ }
28
+
29
+ &.no-image .ant-card-meta {
30
+ height: 276px;
31
+ background: $CAP_WHITE;
32
+ padding: $CAP_SPACE_16 $CAP_SPACE_12;
33
+
34
+ .ant-card-meta-description {
35
+ height: 250px;
36
+ word-wrap: break-word;
37
+ }
38
+ }
39
+
40
+ &.carousel-img-section {
41
+ .ant-card-body {
42
+ padding: $CAP_SPACE_24 0;
43
+ }
44
+ .ant-card-meta {
45
+ padding: 0;
46
+ }
47
+ }
48
+ }
23
49
  .LINE {
24
50
  .ant-card-body {
25
51
  background-color: $CAP_G09;
@@ -7,7 +7,7 @@
7
7
  import * as types from './constants';
8
8
 
9
9
  export function getAllTemplates(channel, queryParams) {
10
- console.log('get all templates action trigereed', channel, queryParams);
10
+ //
11
11
  return {
12
12
  type: types.GET_ALL_TEMPLATES_REQUEST, channel, queryParams,
13
13
  };
@@ -26,7 +26,7 @@ export function resetAccount() {
26
26
  }
27
27
 
28
28
  export function deleteTemplate(channel, id) {
29
- console.log('delete template action trigereed', channel, id);
29
+
30
30
  return {
31
31
  type: types.DELETE_TEMPLATE_REQUEST, channel, id,
32
32
  };
@@ -44,8 +44,14 @@ export function getWeCrmAccounts(source) {
44
44
  };
45
45
  }
46
46
 
47
+ export function getAccountsSettings() {
48
+ return {
49
+ type: types.GET_ORG_LEVEL_CAMPAIGN_SETTINGS_REQUEST,
50
+ };
51
+ }
52
+
47
53
  export function setWeChatAccount(weChatAccount) {
48
- console.log('setting wechat account', weChatAccount);
54
+
49
55
  return {
50
56
  type: types.SET_WECHAT_ACCOUNT,
51
57
  weChatAccount,
@@ -66,6 +72,13 @@ export function setViberAccount(viberAccount) {
66
72
  };
67
73
  }
68
74
 
75
+ export function setFacebookAccount(faceBookAccount) {
76
+ return {
77
+ type: types.SET_FACEBOOK_ACCOUNT,
78
+ faceBookAccount,
79
+ };
80
+ }
81
+
69
82
  export function handleHtmlUpload(selectedTemplate) {
70
83
  return {
71
84
  type: types.SET_SELECTED_LAYOUT,
@@ -101,7 +114,7 @@ export function setBEETemplate(template) {
101
114
  };
102
115
  }
103
116
  export function getTemplateDetails(id, channel) {
104
- console.log('getting template', id, channel);
117
+
105
118
  return {
106
119
  type: types.GET_TEMPLATE_DETAILS_REQUEST,
107
120
  id,
@@ -116,7 +129,7 @@ export function resetTemplateData() {
116
129
  }
117
130
 
118
131
  export function resetUploadData() {
119
- console.log('clearing upload data');
132
+
120
133
  return {
121
134
  type: types.RESET_UPLOAD_DATA,
122
135
  };
@@ -44,8 +44,16 @@ export const CLEAR_TEMPLATE_STORE_DATA = "app/v2Containers/Templates/CLEAR_TEMPL
44
44
 
45
45
  export const SET_LINE_ACCOUNT = "app/v2Containers/Templates/SET_LINE_ACCOUNT";
46
46
  export const SET_VIBER_ACCOUNT = "app/v2Containers/Templates/SET_VIBER_ACCOUNT";
47
+ export const SET_FACEBOOK_ACCOUNT = "app/v2Containers/Templates/SET_FACEBOOK_ACCOUNT";
47
48
 
48
49
 
49
50
  export const GET_DEAFULT_BEE_TEMPLATES_REQUEST = 'app/v2Containers/Templates/GET_DEAFULT_BEE_TEMPLATES_REQUEST';
50
51
  export const GET_DEAFULT_BEE_TEMPLATES_SUCCESS = 'app/v2Containers/Templates/GET_DEAFULT_BEE_TEMPLATES_SUCCESS';
51
52
  export const GET_DEAFULT_BEE_TEMPLATES_FAILURE = 'app/v2Containers/Templates/GET_DEAFULT_BEE_TEMPLATES_FAILURE';
53
+
54
+ export const GET_ORG_LEVEL_CAMPAIGN_SETTINGS_REQUEST =
55
+ 'app/v2Containers/Templates/GET_ORG_LEVEL_CAMPAIGN_SETTINGS_REQUEST';
56
+ export const GET_ORG_LEVEL_CAMPAIGN_SETTINGS_SUCCESS =
57
+ 'app/v2Containers/Templates/GET_ORG_LEVEL_CAMPAIGN_SETTINGS_SUCCESS';
58
+ export const GET_ORG_LEVEL_CAMPAIGN_SETTINGS_FAILURE =
59
+ 'app/v2Containers/Templates/GET_ORG_LEVEL_CAMPAIGN_SETTINGS_FAILURE';
@@ -42,6 +42,7 @@ import * as ebillActions from '../Ebill/actions';
42
42
  import * as emailActions from '../Email/actions';
43
43
  import * as lineActions from '../Line/Container/actions';
44
44
  import * as viberActions from '../Viber/actions';
45
+ import * as facebookActions from '../Facebook/actions';
45
46
 
46
47
  import CardGrid from '../../v2Components/CardGrid';
47
48
  import config from '../../config/app';
@@ -57,8 +58,9 @@ import {
57
58
  CHANNEL_CREATE_TRACK_MAPPING,
58
59
  CHANNEL_EDIT_TRACK_MAPPING,
59
60
  VIBER as VIBER_CHANNEL,
61
+ FACEBOOK as FACEBOOK_CHANNEL,
60
62
  } from '../App/constants';
61
- import { MOBILE_PUSH, WECHAT, SMS, EMAIL, EBILL, LINE, VIBER } from '../CreativesContainer/constants';
63
+ import { MOBILE_PUSH, WECHAT, SMS, EMAIL, EBILL, LINE, VIBER, FACEBOOK } from '../CreativesContainer/constants';
62
64
 
63
65
  import emailIllustration from '../Assets/images/emailIllustration.svg';
64
66
  import smsIllustration from '../Assets/images/smsIllustration.svg';
@@ -181,6 +183,11 @@ export class Templates extends React.Component { // eslint-disable-line react/pr
181
183
  this.props.actions.getWeCrmAccounts(channel);
182
184
  }
183
185
  break;
186
+ case FACEBOOK:
187
+ channel = 'Facebook';
188
+ activeMode = ACCOUNT_SELECTION_MODE;
189
+ this.props.actions.getAccountsSettings();
190
+ break;
184
191
  default:
185
192
  channel = '';
186
193
  }
@@ -198,7 +205,7 @@ export class Templates extends React.Component { // eslint-disable-line react/pr
198
205
  if (this.props.location.query.type === 'embedded') {
199
206
  this.props.actions.resetAccount();
200
207
  }
201
- if ((['line', VIBER_CHANNEL, 'sms', 'email', 'ebill'].includes((this.state.channel || '').toLowerCase())) || ((['wechat', 'mobilepush'].includes(this.state.channel.toLowerCase()) && !isEmpty(this.props.Templates.selectedWeChatAccount)))) {
208
+ if ((['line', VIBER_CHANNEL, FACEBOOK_CHANNEL, 'sms', 'email', 'ebill'].includes((this.state.channel || '').toLowerCase())) || ((['wechat', 'mobilepush'].includes(this.state.channel.toLowerCase()) && !isEmpty(this.props.Templates.selectedWeChatAccount)))) {
202
209
  const queryParams = {
203
210
  // name: this.state.searchText,
204
211
  // sortBy: this.state.sortBy,
@@ -262,10 +269,14 @@ export class Templates extends React.Component { // eslint-disable-line react/pr
262
269
  channel = 'Viber';
263
270
  this.setState({defaultAccount: true});
264
271
  nextProps.actions.getWeCrmAccounts(channel);
272
+ } else if ( nextProps.route.name.toLowerCase() === FACEBOOK_CHANNEL) {
273
+ channel = 'Facebook';
274
+ this.setState({defaultAccount: true});
275
+ nextProps.actions.getAccountsSettings();
265
276
  }
266
277
 
267
278
  this.setState({ channel }, () => {
268
- if (['line', VIBER_CHANNEL, 'sms', 'email', 'ebill'].includes(this.state.channel.toLowerCase()) || (this.state.channel.toLowerCase() === 'wechat' && !isEmpty(nextProps.Templates.selectedWeChatAccount))) {
279
+ if (['line', VIBER_CHANNEL, FACEBOOK_CHANNEL, 'sms', 'email', 'ebill'].includes(this.state.channel.toLowerCase()) || (this.state.channel.toLowerCase() === 'wechat' && !isEmpty(nextProps.Templates.selectedWeChatAccount))) {
269
280
  if (this.state.channel.toLowerCase() === 'wechat' && !isEmpty(nextProps.Templates.selectedWeChatAccount)) {
270
281
  params.wecrmId = (nextProps.Templates.selectedWeChatAccount.configs || {}).wecrm_app_id;
271
282
  params.wecrmToken = (nextProps.Templates.selectedWeChatAccount.configs || {}).wecrm_token;
@@ -286,7 +297,8 @@ export class Templates extends React.Component { // eslint-disable-line react/pr
286
297
  if ((this.state.channel || '').toLowerCase() === "mobilepush" && nextProps.Templates.selectedWeChatAccount) {
287
298
  params.accountId = nextProps.Templates.selectedWeChatAccount.id;
288
299
  }
289
- if (this.state.channel.toLowerCase() === VIBER_CHANNEL && isEmpty(nextProps.Templates.selectedViberAccount)) {
300
+ const selectedChannel = this.state.channel.toLowerCase();
301
+ if (selectedChannel === VIBER_CHANNEL && isEmpty(nextProps.Templates.selectedViberAccount)) {
290
302
  let selectedAccount = '';
291
303
  if (isEmpty(nextProps.Templates.weCrmAccounts)) {
292
304
  return;
@@ -302,6 +314,31 @@ export class Templates extends React.Component { // eslint-disable-line react/pr
302
314
  this.getAllTemplates({params});
303
315
  });
304
316
  }
317
+
318
+ if (selectedChannel === FACEBOOK_CHANNEL && isEmpty(nextProps.Templates.selectedFacebookAccount)) {
319
+ if (isEmpty(nextProps.Templates.campaignSettings)) {
320
+ return;
321
+ }
322
+ const fbSetting = get(nextProps.Templates, 'campaignSettings.accountSettings.socialAccountSettings.facebookAccountSettings', []);
323
+ const { accountName = "",
324
+ orgUnitFacebookPageSettingsMap = {},
325
+ } = fbSetting[0] || {};
326
+ let pageAccessToken = false;
327
+ if (!isEmpty(orgUnitFacebookPageSettingsMap)) {
328
+ Object.values(orgUnitFacebookPageSettingsMap).forEach((obj) => {
329
+ if (obj.pageAccessToken) {
330
+ pageAccessToken = true;
331
+ }
332
+ });
333
+ if (!pageAccessToken) {
334
+ return;
335
+ }
336
+ this.setState({selectedAccount: accountName}, () => {
337
+ this.props.actions.setFacebookAccount(fbSetting[0]);
338
+ this.getAllTemplates({params});
339
+ });
340
+ }
341
+ }
305
342
  if ((this.state.channel.toLowerCase() === 'wechat' || this.state.channel.toLowerCase() === 'mobilepush') && isEmpty(nextProps.Templates.selectedWeChatAccount) && (this.props.location.query.type === 'embedded') && !this.isEnabledInLibraryModule("showAccountSelection")) {
306
343
  let selectedAccount = '';
307
344
  if (isEmpty(nextProps.Templates.weCrmAccounts)) {
@@ -374,6 +411,8 @@ export class Templates extends React.Component { // eslint-disable-line react/pr
374
411
  this.props.lineActions.clearCreateResponse();
375
412
  } else if (this.state.channel.toLowerCase() === VIBER_CHANNEL) {
376
413
  this.props.viberActions.clearCreateResponse();
414
+ } else if (this.state.channel.toLowerCase() === FACEBOOK_CHANNEL) {
415
+ this.props.facebookActions.clearCreateResponse();
377
416
  }
378
417
  }
379
418
  }
@@ -383,7 +422,7 @@ export class Templates extends React.Component { // eslint-disable-line react/pr
383
422
  }
384
423
  if (!nextProps.Templates.deleteTemplateInProgress && !isEqual(nextProps.Templates.deleteTemplateInProgress, this.props.Templates.deleteTemplateInProgress) &&
385
424
  nextProps.Templates.deleteResponse) {
386
- const message = `${this.state.channel.toUpperCase()} ${this.props.intl.formatMessage(messages['Template deleted successfully'])}`;
425
+ const message = `${this.state.channel} ${this.props.intl.formatMessage(messages['Template deleted successfully'])}`;
387
426
  CapNotification.success({key: 'deleteSucess', message});
388
427
  this.getAllTemplates({params, resetPage: true});
389
428
  }
@@ -472,7 +511,7 @@ export class Templates extends React.Component { // eslint-disable-line react/pr
472
511
  }
473
512
 
474
513
  this.setState({activeMode: TEMPLATES_MODE});
475
- console.log("getAllTemplates params: ", params);
514
+
476
515
  this.getAllTemplates({params, resetPage: true});
477
516
  });
478
517
  }
@@ -667,6 +706,27 @@ export class Templates extends React.Component { // eslint-disable-line react/pr
667
706
  case WECHAT:
668
707
  templateData.content = this.prepareWeChatPreviewData(template);
669
708
  break;
709
+ case FACEBOOK:
710
+ const { FacebookAd = {} } = get(template.versions.base, 'content', {});
711
+ const isCarousel = get(FacebookAd, '[0].type', '') === 'CAROUSEL';
712
+ const fbAdImages = Object.values(FacebookAd).map((obj) => {
713
+ if (obj.subType === "VIDEO") {
714
+ return {url: obj.video.previewImageUrl};
715
+ }
716
+ return {url: obj.imgSrc};
717
+ });
718
+ templateData.content = (<div style={{ display: 'flex'}}>{
719
+ (fbAdImages.map((img) => <img
720
+ width={208}
721
+ height={279}
722
+ src={img.url}
723
+ alt={"test"}
724
+ key={`${img.url}_`}
725
+ /> ))
726
+ }
727
+ </div>);
728
+ templateData.className = isCarousel ? 'carousel-img-section' : '';
729
+ break;
670
730
  case LINE: {
671
731
  const {
672
732
  content: {
@@ -750,7 +810,13 @@ export class Templates extends React.Component { // eslint-disable-line react/pr
750
810
  {!isLoading && <div>
751
811
  {!isEmpty(filteredTemplates) || !isEmpty(this.state.searchText) || !isEmpty(this.props.Templates.templateError) ? (
752
812
  <div className={!isEmpty(this.state.searchText) && isEmpty(cardDataList) ? '' : "pagination-container"}>
753
- <CapCustomCardList key={`${currentChannel}-card-list`} cardList={cardDataList} type={currentChannel} style={{marginLeft: '16px'}}/>
813
+ <CapCustomCardList
814
+ key={`${currentChannel}-card-list`}
815
+ cardList={cardDataList}
816
+ type={currentChannel}
817
+ style={{marginLeft: '16px'}}
818
+ fbType={"list"}
819
+ />
754
820
  </div>)
755
821
  : ['sms', "email"].includes(this.state.channel.toLowerCase()) && <CapIllustration buttonClassName={`create-new-${channelLowerCase}`} {...this.getChannelTypeIllustrationInfo(currentChannel)} />
756
822
  }
@@ -1242,6 +1308,15 @@ export class Templates extends React.Component { // eslint-disable-line react/pr
1242
1308
  this.props.viberActions.clearCreateResponse();
1243
1309
  }
1244
1310
  });
1311
+ } else if (this.state.channel.toLowerCase() === FACEBOOK_CHANNEL) {
1312
+ this.props.facebookActions.createTemplate(duplicateObj, (response) => {
1313
+ if (response && response.templateId) {
1314
+ const message = `${this.state.channel} ${this.props.intl.formatMessage(messages.templateDuplicateSuccess)}`;
1315
+ CapNotification.success({key: 'duplicateSucess', message});
1316
+ this.getAllTemplates({params, resetPage: true});
1317
+ this.props.facebookActions.clearCreateResponse();
1318
+ }
1319
+ });
1245
1320
  }
1246
1321
  }
1247
1322
 
@@ -1326,6 +1401,9 @@ export class Templates extends React.Component { // eslint-disable-line react/pr
1326
1401
  if (this.state.channel.toLowerCase() === VIBER_CHANNEL) {
1327
1402
  pathName = `/viber/edit/${id}/`;
1328
1403
  }
1404
+ if (this.state.channel.toLowerCase() === FACEBOOK_CHANNEL) {
1405
+ pathName = `/facebook/edit/${id}/`;
1406
+ }
1329
1407
  if (this.state.channel.toUpperCase() === WECHAT) {
1330
1408
  if (get(template, 'definition.msgcontent', '') === "RICH_MEDIA_WECHAT") {
1331
1409
  pathName = `/wechat/richmedia/edit/${id}`;
@@ -1625,6 +1703,8 @@ export class Templates extends React.Component { // eslint-disable-line react/pr
1625
1703
  const lineLoader = (getAllTemplatesInProgress && this.state.channel.toLowerCase() === 'line');
1626
1704
  const smsLoader = (getAllTemplatesInProgress && this.state.channel.toLowerCase() === 'sms');
1627
1705
  const viberLoader = (getAllTemplatesInProgress && this.state.channel.toLowerCase() === VIBER_CHANNEL);
1706
+ const facebookLoader = (getAllTemplatesInProgress && this.state.channel.toLowerCase() === FACEBOOK_CHANNEL);
1707
+
1628
1708
  const wechatLoader = (((this.state.selectedAccount !== '' && getAllTemplatesInProgress) || (fetchingWeCrmAccounts)) && this.state.channel.toLowerCase() === 'wechat');
1629
1709
  const mobilePushLoader = (((getAllTemplatesInProgress) || (fetchingWeCrmAccounts)) && this.state.channel.toLowerCase() === 'mobilepush');
1630
1710
  const emailLoader = (
@@ -1639,6 +1719,7 @@ export class Templates extends React.Component { // eslint-disable-line react/pr
1639
1719
  (ebillLoader !== undefined ? ebillLoader : false) ||
1640
1720
  (mobilePushLoader !== undefined ? mobilePushLoader : false) ||
1641
1721
  (lineLoader !== undefined ? lineLoader : false) ||
1722
+ (facebookLoader !== undefined ? facebookLoader : false) ||
1642
1723
  (viberLoader !== undefined ? viberLoader : false);
1643
1724
  return isLoading;
1644
1725
  }
@@ -1716,7 +1797,7 @@ export class Templates extends React.Component { // eslint-disable-line react/pr
1716
1797
  channel = channel.toUpperCase();
1717
1798
  const { Templates: templates = {}, location = {} } = this.props;
1718
1799
  const { query = {} } = location;
1719
- const { weCrmAccounts = [], fetchingWeCrmAccounts = false } = templates;
1800
+ const { weCrmAccounts = [], fetchingWeCrmAccounts = false, campaignSettings = {} } = templates;
1720
1801
  const isWechatChannel = channel === WECHAT;
1721
1802
  const isMobilePushChannel = channel === MOBILE_PUSH;
1722
1803
  const isLineChannel = channel === LINE;
@@ -1784,11 +1865,31 @@ export class Templates extends React.Component { // eslint-disable-line react/pr
1784
1865
  noAccountHeader = messages.noAccountsPresentViber;
1785
1866
  break;
1786
1867
  }
1868
+ case FACEBOOK: {
1869
+ noAccountHeader = messages.noAccountsPresentFacebook;
1870
+ break;
1871
+ }
1787
1872
  default:
1788
1873
  break;
1789
1874
  }
1875
+ let showNoAccountHeader = isEmpty(weCrmAccounts) && !fetchingWeCrmAccounts;
1876
+ if (channel === FACEBOOK && !isEmpty(campaignSettings) ) {
1877
+ const fbSetting = get(campaignSettings, 'accountSettings.socialAccountSettings.facebookAccountSettings', []);
1878
+ const { orgUnitFacebookPageSettingsMap } = fbSetting[0] || {};
1879
+ let pageAccessToken = false;
1880
+ if (!isEmpty(orgUnitFacebookPageSettingsMap)) {
1881
+ Object.values(orgUnitFacebookPageSettingsMap).forEach((obj) => {
1882
+ if (obj.pageAccessToken) {
1883
+ pageAccessToken = true;
1884
+ }
1885
+ });
1886
+ showNoAccountHeader = !pageAccessToken;
1887
+ } else {
1888
+ showNoAccountHeader = true;
1889
+ }
1890
+ }
1790
1891
  return (<CapSpin spinning={fetchingWeCrmAccounts}>
1791
- {isEmpty(weCrmAccounts) && !fetchingWeCrmAccounts ? <FormattedMessage {...noAccountHeader} /> :
1892
+ {showNoAccountHeader ? <FormattedMessage {...noAccountHeader} /> :
1792
1893
  <div style={{ overflowX: "auto", paddingBottom: CAP_SPACE_16 }}>
1793
1894
  <CapHeader
1794
1895
  title={accountHeader}
@@ -1842,11 +1943,36 @@ export class Templates extends React.Component { // eslint-disable-line react/pr
1842
1943
  render() {
1843
1944
  const isFullMode = this.isFullMode();
1844
1945
  const { activeMode, channel, wechatFilter, lineFilter } = this.state;
1845
- const showForViber = (channel.toLowerCase() !== VIBER_CHANNEL ||
1846
- (channel.toLowerCase() === VIBER_CHANNEL && !this.props.isFullMode && isEmpty(get(this.props, 'Templates.selectedViberAccount', {}))));
1946
+ let showForFacebook = true;
1947
+ if (channel.toLowerCase() === FACEBOOK_CHANNEL) {
1948
+ if (isEmpty(this.props.Templates.campaignSettings)) {
1949
+ showForFacebook = false;
1950
+ }
1951
+ const fbSetting = get(this.props.Templates, 'campaignSettings.accountSettings.socialAccountSettings.facebookAccountSettings', []);
1952
+ const { orgUnitFacebookPageSettingsMap = {} } = fbSetting[0] || {};
1953
+ let pageAccessToken = false;
1954
+ if (!isEmpty(orgUnitFacebookPageSettingsMap)) {
1955
+ Object.values(orgUnitFacebookPageSettingsMap).forEach((obj) => {
1956
+ if (obj.pageAccessToken) {
1957
+ pageAccessToken = true;
1958
+ }
1959
+ });
1960
+ if (!pageAccessToken) {
1961
+ showForFacebook = false;
1962
+ }
1963
+ }
1964
+ }
1965
+ const showForViber = (![VIBER_CHANNEL, FACEBOOK_CHANNEL].includes(channel.toLowerCase()) ||
1966
+ (channel.toLowerCase() === VIBER_CHANNEL && !this.props.isFullMode && isEmpty(get(this.props, 'Templates.selectedViberAccount', {}))) ||
1967
+ (channel.toLowerCase() === FACEBOOK_CHANNEL && showForFacebook)
1968
+ );
1969
+
1970
+
1847
1971
  if (activeMode === ACCOUNT_SELECTION_MODE && showForViber ) {
1848
1972
  return this.renderAccountSelection();
1849
1973
  }
1974
+
1975
+
1850
1976
  const pageHeader = "";
1851
1977
  const pageHeaderDvs = "";
1852
1978
  const isLoading = this.isLoading();
@@ -2058,6 +2184,7 @@ Templates.propTypes = {
2058
2184
  handlePeviewTemplate: PropTypes.func,
2059
2185
  router: PropTypes.object,
2060
2186
  viberActions: PropTypes.object,
2187
+ facebookActions: PropTypes.object,
2061
2188
  };
2062
2189
 
2063
2190
  const mapStateToProps = createStructuredSelector({
@@ -2084,6 +2211,7 @@ function mapDispatchToProps(dispatch) {
2084
2211
  globalActions: bindActionCreators(globalActions, dispatch),
2085
2212
  lineActions: bindActionCreators(lineActions, dispatch),
2086
2213
  viberActions: bindActionCreators(viberActions, dispatch),
2214
+ facebookActions: bindActionCreators(facebookActions, dispatch),
2087
2215
  };
2088
2216
  }
2089
2217
 
@@ -358,16 +358,20 @@ export default defineMessages({
358
358
  id: `${scope}.richMediaTemplates`,
359
359
  defaultMessage: 'Rich media templates',
360
360
  },
361
- deletingTemplate: {
361
+ "deletingTemplate": {
362
362
  id: `${scope}.deletingTemplate`,
363
363
  defaultMessage: 'Deleting template...',
364
364
  },
365
- duplicatingTemplate: {
365
+ "duplicatingTemplate": {
366
366
  id: `${scope}.duplicatingTemplate`,
367
- defaultMessage: 'Duplicating template...'
367
+ defaultMessage: 'Duplicating template...',
368
368
  },
369
- noAccountsPresentViber: {
369
+ "noAccountsPresentViber": {
370
370
  id: `${scope}.noAccountsPresentViber`,
371
371
  defaultMessage: "Viber accounts are not setup for your brand",
372
372
  },
373
+ "noAccountsPresentFacebook": {
374
+ id: `${scope}.noAccountsPresentFacebook`,
375
+ defaultMessage: "Facebook accounts or Facebook Page are not setup for your brand",
376
+ },
373
377
  });
@@ -9,10 +9,18 @@ import * as types from './constants';
9
9
 
10
10
  const initialState = fromJS({
11
11
  getAllTemplatesInProgress: false,
12
+ fetchingOrgLevelCampaignSettings: true,
12
13
  templates: [],
13
14
  deleteResponse: {},
14
15
  deleteTemplateInProgress: false,
15
16
  templateError: {},
17
+ campaignSettings: {
18
+ messageSettings: {
19
+ enableLinkTracking: false,
20
+ },
21
+ alertsSettings: {},
22
+ reportsSettings: {},
23
+ },
16
24
  });
17
25
 
18
26
  function templatesReducer(state = initialState, action) {
@@ -75,6 +83,8 @@ function templatesReducer(state = initialState, action) {
75
83
  return state.set('selectedLineAccount', fromJS(action.lineAccount));
76
84
  case types.SET_VIBER_ACCOUNT:
77
85
  return state.set('selectedViberAccount', fromJS(action.viberAccount));
86
+ case types.SET_FACEBOOK_ACCOUNT:
87
+ return state.set('selectedFacebookAccount', fromJS(action.faceBookAccount));
78
88
  case types.RESET_ACCOUNT:
79
89
  return state
80
90
  .remove('selectedWeChatAccount')
@@ -147,6 +157,18 @@ function templatesReducer(state = initialState, action) {
147
157
  return state
148
158
  .set('templates', [])
149
159
  .set('weCRMtemplates', fromJS({}));
160
+ case types.GET_ORG_LEVEL_CAMPAIGN_SETTINGS_REQUEST:
161
+ return state.set('fetchingOrgLevelCampaignSettings', true);
162
+ case types.GET_ORG_LEVEL_CAMPAIGN_SETTINGS_SUCCESS:
163
+ return state.set('fetchingOrgLevelCampaignSettings', false).set(
164
+ 'campaignSettings',
165
+ fromJS({
166
+ ...state.get('campaignSettings'),
167
+ ...(action.result || {}).entity,
168
+ }),
169
+ );
170
+ case types.GET_ORG_LEVEL_CAMPAIGN_SETTINGS_FAILURE:
171
+ return state.set('fetchingOrgLevelCampaignSettings', false);
150
172
  default:
151
173
  return state;
152
174
  }
@@ -1,4 +1,4 @@
1
- import { call, put, takeLatest, take, cancel } from 'redux-saga/effects';
1
+ import { call, put, takeLatest, take, cancel, select } from 'redux-saga/effects';
2
2
  import { LOCATION_CHANGE } from 'react-router-redux';
3
3
  // import { schema, normalize } from 'normalizr';
4
4
  import * as Api from '../../services/api';
@@ -73,6 +73,30 @@ export function* fetchWeCrmAccounts(action) {
73
73
  }
74
74
  }
75
75
 
76
+ export function* getOrgLevelCampaignSettings() {
77
+ try {
78
+ const result = yield call(Api.getOrgLevelCampaignSettings);
79
+ yield put({
80
+ type: types.GET_ORG_LEVEL_CAMPAIGN_SETTINGS_SUCCESS,
81
+ result,
82
+ });
83
+ } catch (error) {
84
+ yield put({ type: types.GET_ORG_LEVEL_CAMPAIGN_SETTINGS_FAILURE, error });
85
+ }
86
+ }
87
+
88
+ export function* watchGetOrgLevelCampaignSettings() {
89
+ const watcher = yield takeLatest(
90
+ types.GET_ORG_LEVEL_CAMPAIGN_SETTINGS_REQUEST,
91
+ getOrgLevelCampaignSettings,
92
+ );
93
+ yield take(LOCATION_CHANGE);
94
+ const store = yield select();
95
+ if (!store.getIn(['router', 'location', 'pathname']).includes('/settings/')) {
96
+ yield cancel(watcher);
97
+ }
98
+ }
99
+
76
100
  export function* sendZippedFile({selectedFile, errorHandler, successHandler}) {
77
101
  let errorMessage = "";
78
102
  try {
@@ -82,7 +106,7 @@ export function* sendZippedFile({selectedFile, errorHandler, successHandler}) {
82
106
  yield errorHandler(errorMessage);
83
107
  }
84
108
 
85
- console.log("Got Result ", result);
109
+
86
110
  console.log("Got decoded result", decodeURIComponent(result.response.metaEntity.htmlContent));
87
111
  yield [
88
112
  put({
@@ -104,7 +128,7 @@ export function* sendZippedFile({selectedFile, errorHandler, successHandler}) {
104
128
 
105
129
  export function* getDefaultBeeTemplates() {
106
130
  try {
107
- console.log('saga getAllTemplates');
131
+
108
132
  const result = yield call(Api.getDefaultBeeTemplates);
109
133
  const edmTemplates = result.response;
110
134
  yield put({ type: types.GET_DEAFULT_BEE_TEMPLATES_SUCCESS, data: edmTemplates });
@@ -115,7 +139,7 @@ export function* getDefaultBeeTemplates() {
115
139
 
116
140
  export function* getTemplateDetails(id, channel) {
117
141
  try {
118
- console.log('saga get Template details', id);
142
+
119
143
  const result = yield call(Api.getTemplateDetails, id, channel);
120
144
  // const sidebar = result.response.sidebar;
121
145
  yield put({ type: types.GET_TEMPLATE_DETAILS_SUCCESS, data: result.response });
@@ -143,7 +167,7 @@ function* watchGetUserList() {
143
167
  }
144
168
 
145
169
  function* watchFetchWeCrmAccounts() {
146
- console.log('watching wecrm accounts');
170
+
147
171
  const watcher = yield takeLatest(types.GET_WECRM_ACCOUNTS_REQUEST, fetchWeCrmAccounts);
148
172
  yield take(LOCATION_CHANGE);
149
173
  yield cancel(watcher);
@@ -176,4 +200,5 @@ export default [
176
200
  watchSendingFile,
177
201
  watchGetDefaultBeeTemplates,
178
202
  watchGetTemplateDetails,
203
+ watchGetOrgLevelCampaignSettings,
179
204
  ];