@capillarytech/creatives-library 7.6.1 → 7.6.3

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 (37) hide show
  1. package/config/app.js +2 -0
  2. package/index.js +6 -0
  3. package/package.json +1 -1
  4. package/reducers.js +2 -1
  5. package/routes.js +5 -0
  6. package/services/api.js +30 -1
  7. package/utils/common.js +13 -1
  8. package/v2Components/CapVideoUpload/index.js +14 -6
  9. package/v2Components/TemplatePreview/index.js +23 -2
  10. package/v2Containers/App/constants.js +21 -0
  11. package/v2Containers/Cap/messages.js +30 -0
  12. package/v2Containers/CapFacebookPreview/actions.js +3 -15
  13. package/v2Containers/CapFacebookPreview/constants.js +3 -11
  14. package/v2Containers/CapFacebookPreview/index.js +6 -6
  15. package/v2Containers/CapFacebookPreview/reducer.js +3 -9
  16. package/v2Containers/CapFacebookPreview/sagas.js +6 -65
  17. package/v2Containers/CreativesContainer/SlideBoxContent.js +64 -1
  18. package/v2Containers/CreativesContainer/index.js +19 -8
  19. package/v2Containers/Facebook/Advertisement/index.js +38 -15
  20. package/v2Containers/Facebook/Advertisement/index.scss +9 -0
  21. package/v2Containers/Facebook/Advertisement/messages.js +2 -2
  22. package/v2Containers/Facebook/actions.js +63 -0
  23. package/v2Containers/Facebook/constants.js +25 -1
  24. package/v2Containers/Facebook/index.js +135 -107
  25. package/v2Containers/Facebook/reducer.js +98 -1
  26. package/v2Containers/Facebook/sagas.js +147 -0
  27. package/v2Containers/Facebook/selectors.js +10 -0
  28. package/v2Containers/Line/Container/Video/index.js +38 -41
  29. package/v2Containers/Templates/_templates.scss +26 -0
  30. package/v2Containers/Templates/actions.js +14 -1
  31. package/v2Containers/Templates/constants.js +8 -0
  32. package/v2Containers/Templates/index.js +138 -10
  33. package/v2Containers/Templates/messages.js +8 -4
  34. package/v2Containers/Templates/reducer.js +22 -0
  35. package/v2Containers/Templates/sagas.js +26 -1
  36. package/v2Containers/TemplatesV2/index.js +13 -13
  37. package/v2Containers/Viber/index.js +2 -1
@@ -46,7 +46,6 @@ export const LineVideo = ({
46
46
  updateUploadedAssetList,
47
47
  deleteUploadedImgList,
48
48
  }) => {
49
-
50
49
  if (activeKey !== 'video') {
51
50
  return null;
52
51
  }
@@ -118,7 +117,7 @@ export const LineVideo = ({
118
117
  updateVideoDuration(videoDuration);
119
118
  updateActionUrl(linkUri || actionUrl);
120
119
  updateActionLabel(videoActionLabel);
121
- updateSelectedAction(selectedAction || (!!videoActionLabel ? DISPLAY_ACTION_BUTTON : HIDE_ACTION_BUTTON));
120
+ updateSelectedAction(selectedAction || (videoActionLabel ? DISPLAY_ACTION_BUTTON : HIDE_ACTION_BUTTON));
122
121
  updateTitle(altText);
123
122
  if (videoPreviewUrl) {
124
123
  updateImagePreview(videoPreviewUrl);
@@ -224,11 +223,9 @@ export const LineVideo = ({
224
223
  messageType: 'videoSrc',
225
224
  });
226
225
  }
227
- }
226
+ };
228
227
 
229
- const checkAction = useCallback((label = actionLabel, url = actionUrl, type = selectedAction) => {
230
- return type === DISPLAY_ACTION_BUTTON ? (url && label && !updateActionLabelError(label) && !updateActionUrlError(url)) : true;
231
- }, [actionLabel, actionUrl, selectedAction]);
228
+ const checkAction = useCallback((label = actionLabel, url = actionUrl, type = selectedAction) => type === DISPLAY_ACTION_BUTTON ? (url && label && !updateActionLabelError(label) && !updateActionUrlError(url)) : true, [actionLabel, actionUrl, selectedAction]);
232
229
 
233
230
  const submitVideoAction = useCallback((data, incorrectFile) => {
234
231
  const {
@@ -305,7 +302,7 @@ export const LineVideo = ({
305
302
  selectedAction,
306
303
  messageType: 'videoSrc',
307
304
  });
308
- }
305
+ };
309
306
 
310
307
  const onReUpload = () => {
311
308
  updateVideoStatus(false);
@@ -332,24 +329,24 @@ export const LineVideo = ({
332
329
  selectedAction,
333
330
  messageType: 'videoSrc',
334
331
  });
335
- }
332
+ };
336
333
 
337
334
  const onSelectTemplate = useCallback((event) => {
338
335
  event.stopPropagation();
339
336
  updateTemplateDrawerRequirement(true);
340
- }, [])
337
+ }, []);
341
338
 
342
339
  const playVideo = (e) => {
343
340
  if (e.target.paused && !isPlaying) {
344
341
  e.target.play();
345
342
  }
346
- }
343
+ };
347
344
 
348
345
  const pauseVideo = (e) => {
349
346
  if (!e.target.paused && isPlaying) {
350
347
  e.target.pause();
351
348
  }
352
- }
349
+ };
353
350
 
354
351
  const getVideoSection = () => {
355
352
  if (!isVideo) {
@@ -412,7 +409,7 @@ export const LineVideo = ({
412
409
  onMouseOut={pauseVideo}
413
410
  ref={videoEl}
414
411
  >
415
- <source src={videoSrc} type="video/mp4" />
412
+ <source src={videoSrc} type="video/mp4" />
416
413
  </video>
417
414
  <div style={{ marginLeft: CAP_SPACE_24 }}>
418
415
  <CapHeading type="h6">
@@ -425,7 +422,7 @@ export const LineVideo = ({
425
422
  </div>
426
423
  </Fragment>
427
424
  );
428
- }
425
+ };
429
426
 
430
427
  const onTitleChange = ({ target: { value } }) => {
431
428
  updateTitle(value);
@@ -451,7 +448,7 @@ export const LineVideo = ({
451
448
  selectedAction,
452
449
  messageType: 'videoSrc',
453
450
  });
454
- }
451
+ };
455
452
 
456
453
  const onChangeSelectedAction = () => {
457
454
  event.stopPropagation();
@@ -474,7 +471,7 @@ export const LineVideo = ({
474
471
  selectedAction: value,
475
472
  messageType: 'videoSrc',
476
473
  });
477
- }
474
+ };
478
475
 
479
476
  const updateActionLabelError = (value = '') => {
480
477
  if (value.length > MAX_ACTION_LABEL_LENGTH) {
@@ -486,7 +483,7 @@ export const LineVideo = ({
486
483
  } else {
487
484
  updateActionLabelErrorMessage();
488
485
  }
489
- }
486
+ };
490
487
 
491
488
  const updateActionUrlError = (value) => {
492
489
  if (value === '') {
@@ -498,7 +495,7 @@ export const LineVideo = ({
498
495
  } else {
499
496
  updateActionUrlErrorMessage();
500
497
  }
501
- }
498
+ };
502
499
 
503
500
  const onActionLabelChange = ({ target: { value } }) => {
504
501
  updateActionLabel(value);
@@ -520,7 +517,7 @@ export const LineVideo = ({
520
517
  selectedAction,
521
518
  messageType: 'videoSrc',
522
519
  });
523
- }
520
+ };
524
521
 
525
522
  const onActionUrlChange = ({ target: { value } }) => {
526
523
  updateActionUrl(value);
@@ -542,10 +539,9 @@ export const LineVideo = ({
542
539
  selectedAction,
543
540
  messageType: 'videoSrc',
544
541
  });
545
- }
542
+ };
546
543
 
547
- const getActionSection = () => {
548
- return (
544
+ const getActionSection = () => (
549
545
  <>
550
546
  <CapHeading type="h6" style={{ marginTop: CAP_SPACE_12 }}>
551
547
  <FormattedMessage {...messages.actionButtonLabel} />
@@ -558,12 +554,12 @@ export const LineVideo = ({
558
554
  options={[
559
555
  {
560
556
  label: 'Hide',
561
- value: HIDE_ACTION_BUTTON
557
+ value: HIDE_ACTION_BUTTON,
562
558
  },
563
559
  {
564
560
  label: 'Display',
565
- value: DISPLAY_ACTION_BUTTON
566
- }
561
+ value: DISPLAY_ACTION_BUTTON,
562
+ },
567
563
  ]}
568
564
  />
569
565
  {
@@ -593,18 +589,18 @@ export const LineVideo = ({
593
589
  : null
594
590
  }
595
591
  </>
596
- )
597
- }
592
+ );
598
593
 
599
594
  const getLineVideoSection = () => {
600
595
  if (!isCreateNew) {
601
596
  return (
602
- <div className="form-builder-dragger" style={{
603
- textAlign: 'center',
604
- border: `1px dashed ${CAP_G06}`,
605
- minHeight: 120,
606
- padding: 60
607
- }}>
597
+ <div
598
+ className="form-builder-dragger" style={{
599
+ textAlign: 'center',
600
+ border: `1px dashed ${CAP_G06}`,
601
+ minHeight: 120,
602
+ padding: 60,
603
+ }}>
608
604
  <CapHeader
609
605
  className="choice-title"
610
606
  size="regular"
@@ -634,7 +630,8 @@ export const LineVideo = ({
634
630
  >
635
631
  <FormattedMessage {...messages.textMessageSelectTemplate} />
636
632
  </CapButton>
637
- </div>);
633
+ </div>
634
+ );
638
635
  } else {
639
636
  return (
640
637
  <>
@@ -652,7 +649,7 @@ export const LineVideo = ({
652
649
  </>
653
650
  );
654
651
  }
655
- }
652
+ };
656
653
 
657
654
  const setNewContent = useCallback(() => updateCreateNew(true), []);
658
655
 
@@ -688,9 +685,9 @@ export const LineVideo = ({
688
685
  updateVideoDuration(videoDuration);
689
686
  updateActionUrl(linkUri);
690
687
  updateActionLabel(label);
691
- updateSelectedAction(!!label ? DISPLAY_ACTION_BUTTON : HIDE_ACTION_BUTTON);
688
+ updateSelectedAction(label ? DISPLAY_ACTION_BUTTON : HIDE_ACTION_BUTTON);
692
689
  updateTitle(altText);
693
- }
690
+ };
694
691
 
695
692
  const getLineVideoDrawerContent = () => {
696
693
  const lineTextTemplates = Templates.templates;
@@ -699,8 +696,8 @@ export const LineVideo = ({
699
696
  }
700
697
 
701
698
  const cardDataList = [];
702
- lineTextTemplates.forEach(template => {
703
- let templateData = {};
699
+ lineTextTemplates.forEach((template) => {
700
+ const templateData = {};
704
701
  const {
705
702
  content: {
706
703
  messages: [{
@@ -780,7 +777,7 @@ export const LineVideo = ({
780
777
  />
781
778
  </form>
782
779
  </div>
783
- )
784
- }
780
+ );
781
+ };
785
782
 
786
- export default injectIntl(withStyles(LineVideo, style));
783
+ export default injectIntl(withStyles(LineVideo, style));
@@ -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
+ // console.log('get all templates action trigereed', channel, queryParams);
11
11
  return {
12
12
  type: types.GET_ALL_TEMPLATES_REQUEST, channel, queryParams,
13
13
  };
@@ -44,6 +44,12 @@ 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
54
  console.log('setting wechat account', weChatAccount);
49
55
  return {
@@ -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,
@@ -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
  }
@@ -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
  });