@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
@@ -2067,12 +2067,12 @@ class FormBuilder extends React.Component { // eslint-disable-line react/prefer-
2067
2067
  // }
2068
2068
  return;
2069
2069
  }
2070
- console.log('Call Event ', event, data, this.props.parent);
2070
+
2071
2071
  // val.injectedEvents[event].call(this.props.parent, data);
2072
2072
  val.injectedEvents[event].call(this.props.parent, data, val.id);
2073
2073
  }
2074
2074
  openFileDialog = (e, parentID) => {
2075
- console.log("filedialog: ");
2075
+
2076
2076
  document.querySelector(`#${parentID} #fileName`).click();
2077
2077
  };
2078
2078
  handleOk = (ev) => {
@@ -3185,7 +3185,7 @@ class FormBuilder extends React.Component { // eslint-disable-line react/prefer-
3185
3185
  if (val.id.indexOf('template-content') > -1 && val.id !== 'template-content') {
3186
3186
  langIndex = parseInt(val.id.replace('template-content', ''), 10) - 1;
3187
3187
  }
3188
- console.log('CKEditor Data 2', this.state.formData, this.state.formData[`${this.state.currentTab - 1}`], val, this.state.currentTab, this.state.currentLangTab, langIndex);
3188
+
3189
3189
  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';
3190
3190
  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'] || '');
3191
3191
  columns.push(
@@ -47,10 +47,10 @@ class PreviewSideBar extends React.Component { // eslint-disable-line react/pref
47
47
  this.props.onEditClick(e, this.props.templateData._id, this.props.templateData.modeType, path);
48
48
  }
49
49
  render() {
50
- console.log('preview sidebar', this.props);
50
+
51
51
  let content = '';
52
52
  if ((this.props.channel || '').toLowerCase() === 'wechat') {
53
- console.log('Template Infog ', this.props.templateData);
53
+
54
54
  content = this.props.templateData.content;
55
55
  } else if ((this.props.channel || '').toLowerCase() === "mobilepush" && !_.isEmpty(this.props.templateData)) {
56
56
  const data = this.state.device === "android" ? this.props.templateData.versions.base.ANDROID : this.props.templateData.versions.base.IOS;
@@ -88,7 +88,7 @@ class PreviewSideBar extends React.Component { // eslint-disable-line react/pref
88
88
  if ((this.props.channel || '').toLowerCase() === 'wechat') {
89
89
  path = this.props.templateData && this.props.templateData.definition && this.props.templateData.definition.msgcontent === "RICH_MEDIA_WECHAT" ? `/wechat/richmedia/edit/${this.props.templateData._id}` : `/wechat/edit/${this.props.templateData._id}`;
90
90
  }
91
- console.log('final content is', content);
91
+
92
92
  return (
93
93
  <SlideBox
94
94
  header={this.props.templateData && this.props.templateData.name ? this.props.templateData.name : ''}
@@ -23,20 +23,20 @@ class SmsTest extends React.Component { // eslint-disable-line react/prefer-stat
23
23
  }
24
24
 
25
25
  onTemplateNameChange(name) {
26
- console.log('Template name changed to ', name);
26
+
27
27
  }
28
28
 
29
29
  onTemplateContentChange(content) {
30
- console.log('Template content changed to ', content);
30
+
31
31
  }
32
32
 
33
33
  onFormDataChange(formData) {
34
- console.log('Form data changed is ', formData);
34
+
35
35
  }
36
36
 
37
37
  saveFormData(formData) {
38
38
  //Logic to save in db etc
39
- console.log('Saving form data', formData);
39
+
40
40
  }
41
41
  render() {
42
42
  const schema = {
@@ -16,7 +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
+ import { VIBER, FACEBOOK } from '../../v2Containers/App/constants';
20
20
  const wechatBodyNew = require('./assets/images/wechat_mobile_android.svg');
21
21
  const smsMobileAndroid = require('./assets/images/sms_mobile_android.svg');
22
22
  const lineMobileAndroid = require('../../assets/line.png');
@@ -30,6 +30,7 @@ const iPhonePushMessagePhone = require('./assets/images/iPhonePushMessage.svg');
30
30
 
31
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';
32
32
  import { TEMPLATE, IMAGE_CAROUSEL, IMAGE, STICKER, TEXT, IMAGE_MAP, VIDEO } from '../../v2Containers/Line/Container/constants';
33
+ import CapFacebookPreview from '../../v2Containers/CapFacebookPreview';
33
34
 
34
35
  class TemplatePreview extends React.Component { // eslint-disable-line react/prefer-stateless-function
35
36
  onPreviewContentClicked = (channel) => {
@@ -145,7 +146,7 @@ class TemplatePreview extends React.Component { // eslint-disable-line react/pre
145
146
  document.getElementById("msg_count").val = smsDetails.parts;
146
147
  }
147
148
  //smsText = this.props.intl.formatMessage(messages.previewGenerationMessage);
148
- //console.log('message text', smsText);
149
+ //
149
150
  }
150
151
  const type = this.props.location && this.props.location.query.type ? this.props.location.query.type : '';
151
152
  let iosActions = [];
@@ -260,7 +261,7 @@ class TemplatePreview extends React.Component { // eslint-disable-line react/pre
260
261
 
261
262
  return (
262
263
  <CapRow>
263
- {this.props.showCount && <CapColumn span={16}>
264
+ {this.props.showCount && (channel && channel.toLowerCase() !== FACEBOOK) && <CapColumn span={16}>
264
265
  {channel && channel.toLowerCase() === 'sms' && <CapHeading type="h3">
265
266
  <FormattedMessage {...messages.charactersTotal} values={{smsCount: smsDetails.parts, charCount: smsDetails.chars_used}}/>
266
267
  {smsDetails.unicode &&
@@ -637,6 +638,22 @@ class TemplatePreview extends React.Component { // eslint-disable-line react/pre
637
638
  </div>
638
639
  ) : ''
639
640
  }
641
+ {channel && channel.toLowerCase() === FACEBOOK && (
642
+ <div style={{position: 'absolute', left: '80%'}} id="facebook-preview">
643
+ <CapFacebookPreview
644
+ disablePreviewButton={false}
645
+ selectedAd={content.selectedAd}
646
+ previewData={content.previewData}
647
+ primaryText={content.primaryText}
648
+ callToAction={content.callToAction}
649
+ displayLink={content.displayLink}
650
+ orgUnitFacebookPageSettingsMap={{pageAccessToken: content.pageAccessToken,
651
+ pageId: content.pageId}}
652
+ accountId={content.accountId}
653
+ accessToken={content.accessToken}
654
+ />
655
+ </div>
656
+ )}
640
657
  </div>
641
658
 
642
659
  </CapColumn>
@@ -660,6 +677,10 @@ TemplatePreview.propTypes = {
660
677
  onPreviewContentClicked: PropTypes.func,
661
678
  onTestContentClicked: PropTypes.func,
662
679
  showTestAndPreviewIcon: PropTypes.bool,
680
+ fbContent: PropTypes.oneOfType([
681
+ PropTypes.object,
682
+ PropTypes.any,
683
+ ]),
663
684
  };
664
685
 
665
686
  export default (injectIntl(TemplatePreview));
@@ -37,7 +37,7 @@ class Toastr extends React.Component { // eslint-disable-line react/prefer-state
37
37
  return (
38
38
  <StyledMessageContainer style={{ ...messagePositionConfig[this.props.position] }}>
39
39
  {this.props.messagesList.map((message) => {
40
- console.log('Messages', message);
40
+
41
41
  return <ToastrMessage key={message.messageId} timeout={this.props.timeout} messageId={message.messageId} title={message.title} text={message.text} type={message.type} handleMessageClose={this.closeMessagePopup} hideProgressBar={message.hideProgressBar} />;
42
42
  })}
43
43
  </StyledMessageContainer>
@@ -25,6 +25,8 @@ export const EDIT = 'edit';
25
25
  export const PREVIEW = 'preview';
26
26
 
27
27
  export const VIBER = 'viber';
28
+ export const FACEBOOK = 'facebook';
29
+
28
30
  export const TRACK_EDIT_SMS = 'editSms';
29
31
  export const TRACK_EDIT_EMAIL = 'editEmail';
30
32
  export const TRACK_EDIT_MPUSH = 'editMpush';
@@ -54,3 +56,22 @@ export const BEE_PLUGIN = 'BEE_PLUGIN';
54
56
  export const NO_COMMUNICATION = 'NO_COMMUNICATION';
55
57
  export const FTP = 'FTP';
56
58
  export const CREATIVES_UI_VIEW = 'CREATIVES_UI_VIEW';
59
+
60
+ export const APPLY_NOW = <FormattedMessage {...globalMessages.applyNow} />;
61
+ export const NO_CALL_TO_ACTION = <FormattedMessage {...globalMessages.noCallToAction} />;
62
+ export const LEARN_MORE = <FormattedMessage {...globalMessages.learnMore} />;
63
+ export const SHOP_NOW = <FormattedMessage {...globalMessages.shopNow} />;
64
+ export const SIGN_UP = <FormattedMessage {...globalMessages.signUp} />;
65
+ export const SUBSCRIBE = <FormattedMessage {...globalMessages.subscribe} />;
66
+ export const WATCH_MORE = <FormattedMessage {...globalMessages.watchMore} />;
67
+
68
+
69
+ export const FB_AD_CALL_TO_ACTION = {
70
+ NO_CALL_TO_ACTION,
71
+ APPLY_NOW,
72
+ LEARN_MORE,
73
+ SHOP_NOW,
74
+ SIGN_UP,
75
+ SUBSCRIBE,
76
+ WATCH_MORE,
77
+ };
@@ -24,7 +24,7 @@ export function* uploadAsset(file, assetType, fileParams) {
24
24
  export function* deleteAssetById(assetId, assetType) {
25
25
  try {
26
26
  const result = yield call(Api.deleteAssetById, assetId, assetType);
27
- console.log({"delete Asset Id": result});
27
+
28
28
  yield put({ type: types.DELETE_ASSET_SUCCESS, data: result.response });
29
29
  } catch (error) {
30
30
  yield put({ type: types.DELETE_ASSET_FAILURE, error });
@@ -45,7 +45,7 @@ export function getUserData(callback) {
45
45
  }
46
46
 
47
47
  export function fetchSchemaForEntity(queryParams) {
48
- console.log('fetch schema action');
48
+
49
49
  return {
50
50
  type: types.GET_SCHEMA_FOR_ENTITY_REQUEST, queryParams,
51
51
  };
@@ -103,7 +103,7 @@ export class Cap extends React.Component { // eslint-disable-line react/prefer-s
103
103
  }
104
104
  locale = this.getMappedLocale(locale);
105
105
  //locale = 'zh';
106
- console.log('Setting final locale as', locale);
106
+
107
107
  moment.locale(locale);
108
108
  window.addEventListener('storage', this.handleStorageChange, false);
109
109
  document.addEventListener(
@@ -404,7 +404,7 @@ export class Cap extends React.Component { // eslint-disable-line react/prefer-s
404
404
  const type = this.props.location.query.type;
405
405
  const toastMessages = this.props.Global.messages;
406
406
  const { isCreativesAccessible, showOrgChangeModal, showRefreshModal } = this.state;
407
- console.log('v2 locale loading', this.props.loader.localeLoading);
407
+
408
408
  return (
409
409
  <CapWrapper>
410
410
  { this.props.loader.localeLoading || this.props.Global.fetching_userdata ?
@@ -113,4 +113,34 @@ export default defineMessages({
113
113
  id: `creatives.containersV2.newOrgName`,
114
114
  defaultMessage: '{newOrgName}',
115
115
  },
116
+ "applyNow": {
117
+ id: `creatives.containersV2.applyNow`,
118
+ defaultMessage: 'Apply now',
119
+ },
120
+ "noCallToAction": {
121
+ id: `creatives.containersV2.noCallToAction`,
122
+ defaultMessage: 'No call to action',
123
+ },
124
+ "learnMore": {
125
+ id: `creatives.containersV2.learnMore`,
126
+ defaultMessage: 'Learn More',
127
+ },
128
+ "shopNow": {
129
+ id: `creatives.containersV2.shopNow`,
130
+ defaultMessage: 'Shop Now',
131
+ },
132
+ "signUp": {
133
+ id: `creatives.containersV2.signUp`,
134
+ defaultMessage: 'Sign Up',
135
+ },
136
+ "subscribe": {
137
+ id: `creatives.containersV2.subscribe`,
138
+ defaultMessage: 'Subscribe',
139
+ },
140
+ "watchMore": {
141
+ id: `creatives.containersV2.watchMore`,
142
+ defaultMessage: 'Watch More',
143
+ },
144
+
116
145
  });
146
+
@@ -82,7 +82,7 @@ function capReducer(state = fromJS(initialState.cap), action) {
82
82
  .set('fetchingSchema', false);
83
83
  case types.GET_SCHEMA_FOR_ENTITY_SUCCESS: {
84
84
  const stateMeta = state.get('metaEntities');
85
- console.log('stateMeta', stateMeta);
85
+
86
86
  return state
87
87
  .set('fetchingSchema', false)
88
88
  .set('metaEntities', {
@@ -106,9 +106,9 @@ export function* fetchUserInfo(option) {
106
106
 
107
107
  export function* fetchSchemaForEntity(queryParams) {
108
108
  try {
109
- console.log('saga fetch Schema For Entity', queryParams);
109
+
110
110
  const result = yield call(Api.fetchSchemaForEntity, queryParams);
111
- console.log('cap saga', result);
111
+
112
112
  // const sidebar = result.response.sidebar;
113
113
  yield put({ type: types.GET_SCHEMA_FOR_ENTITY_SUCCESS, data: result.response, statusCode: result.status ? result.status.code : '', entityType: queryParams.queryParams.type });
114
114
  } catch (error) {
@@ -129,7 +129,7 @@ function* getTopbarMenuData() {
129
129
 
130
130
 
131
131
  function* watchFetchSchemaForEntity() {
132
- console.log('inside watch get schema');
132
+
133
133
  const watcher = yield takeLatest(types.GET_SCHEMA_FOR_ENTITY_REQUEST, fetchSchemaForEntity);
134
134
  yield take(LOCATION_CHANGE);
135
135
  yield cancel(watcher);
@@ -31,7 +31,7 @@ const setInjectedTags = () => createSelector(
31
31
  const { tags } = metaEntities;
32
32
  const customTags = tags && (tags.custom || {});
33
33
  const extendedTags = tags && (tags.extended || {});
34
- console.log("selector cap: ", injectedTags, customTags, metaEntities, extendedTags);
34
+
35
35
  return (injectedTags = _.merge({}, injectedTags, customTags, extendedTags));
36
36
  }
37
37
  );
@@ -5,24 +5,12 @@
5
5
  */
6
6
 
7
7
  import {
8
- GENERATE_IMAGE_PREVIEW_REQUEST,
9
- GENERATE_VIDEO_PREVIEW_REQUEST,
10
- GENERATE_CAROUSEL_PREVIEW_REQUEST,
8
+ GENERATE_PREVIEW_REQUEST,
11
9
  CLEAR_PREVIEW,
12
10
  } from './constants';
13
11
 
14
- export const getImagePreview = (previewData) => ({
15
- type: GENERATE_IMAGE_PREVIEW_REQUEST,
16
- previewData,
17
- });
18
-
19
- export const getVideoPreview = (previewData) => ({
20
- type: GENERATE_VIDEO_PREVIEW_REQUEST,
21
- previewData,
22
- });
23
-
24
- export const getCarouselPreview = (previewData) => ({
25
- type: GENERATE_CAROUSEL_PREVIEW_REQUEST,
12
+ export const getPreview = (previewData) => ({
13
+ type: GENERATE_PREVIEW_REQUEST,
26
14
  previewData,
27
15
  });
28
16
 
@@ -5,17 +5,9 @@
5
5
  */
6
6
 
7
7
 
8
- export const GENERATE_IMAGE_PREVIEW_REQUEST = 'app/CapFacebookPreview/GET_IMAGE_PREVIEW_REQUEST';
9
- export const GENERATE_IMAGE_PREVIEW_SUCCESS = 'app/CapFacebookPreview/GET_IMAGE_PREVIEW_SUCCESS';
10
- export const GENERATE_IMAGE_PREVIEW_FAILURE = 'app/CapFacebookPreview/GET_IMAGE_PREVIEW_FAILURE';
11
-
12
- export const GENERATE_VIDEO_PREVIEW_REQUEST = 'app/CapFacebookPreview/GET_VIDEO_PREVIEW_REQUEST';
13
- export const GENERATE_VIDEO_PREVIEW_SUCCESS = 'app/CapFacebookPreview/GET_VIDEO_PREVIEW_SUCCESS';
14
- export const GENERATE_VIDEO_PREVIEW_FAILURE = 'app/CapFacebookPreview/GET_VIDEO_PREVIEW_FAILURE';
15
-
16
- export const GENERATE_CAROUSEL_PREVIEW_REQUEST = 'app/CapFacebookPreview/GET_CAROUSEL_PREVIEW_REQUEST';
17
- export const GENERATE_CAROUSEL_PREVIEW_SUCCESS = 'app/CapFacebookPreview/GET_CAROUSEL_PREVIEW_SUCCESS';
18
- export const GENERATE_CAROUSEL_PREVIEW_FAILURE = 'app/CapFacebookPreview/GET_CAROUSEL_PREVIEW_FAILURE';
8
+ export const GENERATE_PREVIEW_REQUEST = 'app/CapFacebookPreview/GET_PREVIEW_REQUEST';
9
+ export const GENERATE_PREVIEW_SUCCESS = 'app/CapFacebookPreview/GET_PREVIEW_SUCCESS';
10
+ export const GENERATE_PREVIEW_FAILURE = 'app/CapFacebookPreview/GET_PREVIEW_FAILURE';
19
11
 
20
12
  export const CLEAR_PREVIEW = 'app/CapFacebookPreview/CLEAR_PREVIEW';
21
13
 
@@ -42,7 +42,7 @@ export const CapFacebookPreview = (props) => {
42
42
  selectedAd,
43
43
  primaryText,
44
44
  callToAction,
45
- orgUnitFacebookPageSettingsMap,
45
+ orgUnitFacebookPageSettingsMap = {},
46
46
  accessToken,
47
47
  accountId,
48
48
  } = props;
@@ -222,11 +222,11 @@ export const CapFacebookPreview = (props) => {
222
222
  value: {link: webSiteLink},
223
223
  };
224
224
  }
225
- facebookPreviewActions.getImagePreview(data);
225
+ facebookPreviewActions.getPreview(data);
226
226
  } else {
227
227
  data.params.creative.object_story_spec.video_data = {
228
228
  image_url: videoData.previewUrl,
229
- videoUrl: videoData.videoSrc,
229
+ video_id: videoData.videoId,
230
230
  message: primaryText,
231
231
  link_description: linkDesc,
232
232
  };
@@ -236,7 +236,7 @@ export const CapFacebookPreview = (props) => {
236
236
  value: {link: webSiteLink},
237
237
  };
238
238
  }
239
- facebookPreviewActions.getVideoPreview(data);
239
+ facebookPreviewActions.getPreview(data);
240
240
  }
241
241
  } else {
242
242
  const childData = previewData.map((obj) => {
@@ -254,7 +254,7 @@ export const CapFacebookPreview = (props) => {
254
254
  if (obj.subType === VIDEO) {
255
255
  arrayData = {
256
256
  ...arrayData,
257
- videoUrl: obj.videoData.videoSrc,
257
+ video_id: obj.videoData.videoId,
258
258
  picture: obj.videoData.previewUrl,
259
259
  };
260
260
  } else {
@@ -273,7 +273,7 @@ export const CapFacebookPreview = (props) => {
273
273
  multi_share_end_card: false,
274
274
  },
275
275
  };
276
- facebookPreviewActions.getCarouselPreview(data);
276
+ facebookPreviewActions.getPreview(data);
277
277
  }
278
278
  setDisableAfterPreviewGenerate(true);
279
279
  };
@@ -16,20 +16,14 @@ const initialState = fromJS({
16
16
 
17
17
  function capFacebookPreviewReducer(state = initialState, action) {
18
18
  switch (action.type) {
19
- case types.GENERATE_IMAGE_PREVIEW_REQUEST:
20
- case types.GENERATE_VIDEO_PREVIEW_REQUEST:
21
- case types.GENERATE_CAROUSEL_PREVIEW_REQUEST:
19
+ case types.GENERATE_PREVIEW_REQUEST:
22
20
  return state.set('isFetchingPreview', true)
23
21
  .set('previewIframe', "")
24
22
  .set("previewIframeError", "");
25
- case types.GENERATE_IMAGE_PREVIEW_SUCCESS:
26
- case types.GENERATE_VIDEO_PREVIEW_SUCCESS:
27
- case types.GENERATE_CAROUSEL_PREVIEW_SUCCESS:
23
+ case types.GENERATE_PREVIEW_SUCCESS:
28
24
  return state.set('isFetchingPreview', false)
29
25
  .set('previewIframe', get(action, 'payload.fbPreview[0].body', ""));
30
- case types.GENERATE_IMAGE_PREVIEW_FAILURE:
31
- case types.GENERATE_VIDEO_PREVIEW_FAILURE:
32
- case types.GENERATE_CAROUSEL_PREVIEW_FAILURE:
26
+ case types.GENERATE_PREVIEW_FAILURE:
33
27
  return state.set('isFetchingPreview', false)
34
28
  .set('previewIframe', "")
35
29
  .set("previewIframeError", get(action, 'payload.message', ""));
@@ -3,70 +3,24 @@ import { LOCATION_CHANGE } from 'react-router-redux';
3
3
  import * as Api from '../../services/api';
4
4
  import * as type from './constants';
5
5
 
6
- export function* getImageFacebookPreview(previewData) {
6
+ export function* getFacebookPreview(previewData) {
7
7
  try {
8
- const response = yield call(Api.getImageFacebookPreview, previewData );
8
+ const response = yield call(Api.getFacebookPreview, previewData );
9
9
  const { status, response: responsePreview } = response;
10
10
  if (status && status.isError) {
11
11
  yield put({
12
- type: type.GENERATE_IMAGE_PREVIEW_FAILURE,
12
+ type: type.GENERATE_PREVIEW_FAILURE,
13
13
  payload: status,
14
14
  });
15
15
  } else {
16
16
  yield put({
17
- type: type.GENERATE_IMAGE_PREVIEW_SUCCESS,
17
+ type: type.GENERATE_PREVIEW_SUCCESS,
18
18
  payload: responsePreview,
19
19
  });
20
20
  }
21
21
  } catch (error) {
22
22
  yield put({
23
- type: type.GENERATE_IMAGE_PREVIEW_FAILURE,
24
- payload: error,
25
- });
26
- }
27
- }
28
-
29
- export function* getVideoFacebookPreview(previewData) {
30
- try {
31
- const response = yield call(Api.getVideoFacebookPreview, previewData);
32
- const { status, response: responsePreview } = response;
33
- if (status && status.isError) {
34
- yield put({
35
- type: type.GENERATE_VIDEO_PREVIEW_FAILURE,
36
- payload: status,
37
- });
38
- } else {
39
- yield put({
40
- type: type.GENERATE_VIDEO_PREVIEW_SUCCESS,
41
- payload: responsePreview,
42
- });
43
- }
44
- } catch (error) {
45
- yield put({
46
- type: type.GENERATE_VIDEO_PREVIEW_FAILURE,
47
- payload: error,
48
- });
49
- }
50
- }
51
-
52
- export function* getCarouselFacebookPreview(previewData) {
53
- try {
54
- const response = yield call(Api.getCarouselFacebookPreview, previewData);
55
- const { status, response: responsePreview } = response;
56
- if (status && status.isError) {
57
- yield put({
58
- type: type.GENERATE_CAROUSEL_PREVIEW_FAILURE,
59
- payload: status,
60
- });
61
- } else {
62
- yield put({
63
- type: type.GENERATE_CAROUSEL_PREVIEW_SUCCESS,
64
- payload: responsePreview,
65
- });
66
- }
67
- } catch (error) {
68
- yield put({
69
- type: type.GENERATE_CAROUSEL_PREVIEW_FAILURE,
23
+ type: type.GENERATE_PREVIEW_FAILURE,
70
24
  payload: error,
71
25
  });
72
26
  }
@@ -74,26 +28,13 @@ export function* getCarouselFacebookPreview(previewData) {
74
28
 
75
29
 
76
30
  function* watchImageFacebookPreview() {
77
- const watcher = yield takeLatest(type.GENERATE_IMAGE_PREVIEW_REQUEST, getImageFacebookPreview);
78
- yield take(LOCATION_CHANGE);
79
- yield cancel(watcher);
80
- }
81
-
82
- function* watchVideoFacebookPreview() {
83
- const watcher = yield takeLatest(type.GENERATE_VIDEO_PREVIEW_REQUEST, getVideoFacebookPreview);
31
+ const watcher = yield takeLatest(type.GENERATE_PREVIEW_REQUEST, getFacebookPreview);
84
32
  yield take(LOCATION_CHANGE);
85
33
  yield cancel(watcher);
86
34
  }
87
35
 
88
- function* watchCarouselFacebookPreview() {
89
- const watcher = yield takeLatest(type.GENERATE_CAROUSEL_PREVIEW_REQUEST, getCarouselFacebookPreview);
90
- yield take(LOCATION_CHANGE);
91
- yield cancel(watcher);
92
- }
93
36
 
94
37
  export default [
95
38
  watchImageFacebookPreview,
96
- watchVideoFacebookPreview,
97
- watchCarouselFacebookPreview,
98
39
  ];
99
40
 
@@ -136,6 +136,7 @@ function SlideBoxContent(props) {
136
136
  onShowTemplates,
137
137
  handleClose,
138
138
  onFTPSubmit,
139
+ campaignSettings,
139
140
  } = props;
140
141
  const type = (messageDetails.type || '').toLowerCase(); // type is context in get tags values : outbound | dvs | referral | loyalty | coupons
141
142
  const query = { type: !isFullMode && 'embedded', module: isFullMode ? 'default' : 'library', isEditFromCampaigns: (templateData || {}).isEditFromCampaigns};
@@ -164,6 +165,8 @@ function SlideBoxContent(props) {
164
165
 
165
166
 
166
167
  const isCreateSms = slidBoxContent === 'createTemplate' && channel === constants.SMS;
168
+ const isCreateFacebook = slidBoxContent === 'createTemplate' && channel === constants.FACEBOOK;
169
+
167
170
  const isCreateMPush = slidBoxContent === 'createTemplate' && channel === constants.MOBILE_PUSH;
168
171
  const isCreateCallTask = slidBoxContent === 'createTemplate' && channel === constants.CALL_TASK;
169
172
  let isEditSms = false;
@@ -185,7 +188,7 @@ function SlideBoxContent(props) {
185
188
  isEditEmailWithId = slidBoxContent === 'editTemplate' && channel === constants.EMAIL && templateData._id;
186
189
  isEmailEditWithContent = slidBoxContent === 'editTemplate' && channel === constants.EMAIL && !templateData._id;
187
190
  isEditFacebook = slidBoxContent === 'editTemplate' && channel === constants.FACEBOOK;
188
- isPreview = slidBoxContent === 'preview' && (channel === constants.SMS || channel === constants.LINE || channel === constants.VIBER);
191
+ isPreview = slidBoxContent === 'preview' && (channel === constants.SMS || channel === constants.LINE || channel === constants.VIBER || channel === constants.FACEBOOK);
189
192
  isEmailPreview = slidBoxContent === 'preview' && channel === constants.EMAIL;
190
193
  isMpushPreview = slidBoxContent === 'preview' && channel === constants.MOBILE_PUSH;
191
194
  isEditFTP = slidBoxContent === 'editTemplate' && [constants.NO_COMMUNICATION, constants.FTP].includes(channel);
@@ -263,6 +266,44 @@ function SlideBoxContent(props) {
263
266
  };
264
267
  return template.content;
265
268
  }
269
+ case constants.FACEBOOK: {
270
+ const template = cloneDeep(templateDataObject.versions.base) || {};
271
+ const {FacebookAd = [], pageOrgUnitId} = template.content || {};
272
+ const {
273
+ type: fbType = "",
274
+ primaryText = "",
275
+ callToAction = "",
276
+ displayLink = "",
277
+ } = FacebookAd[0] || {};
278
+ const previewData = Object.values(template.content.FacebookAd).map((obj) => ({
279
+ imageData: obj.imgSrc ? {imageSrc: obj.imgSrc} : {},
280
+ linkDesc: obj.linkDesc,
281
+ linkHeadLine: obj.linkHeadLine,
282
+ subType: obj.subType,
283
+ videoData: obj.video ? { videoSrc: obj.video.originalContentUrl,
284
+ videoName: obj.video.videoName,
285
+ previewUrl: obj.video.previewImageUrl,
286
+ videoId: obj.video.videoId,
287
+
288
+ } : {},
289
+ webSiteLink: obj.webSiteLink,
290
+ }));
291
+ const facebookAccountSettings = get(campaignSettings, 'accountSettings.socialAccountSettings.facebookAccountSettings', []);
292
+ const {accountId, employeeAccessToken: accessToken, orgUnitFacebookPageSettingsMap = {}} = facebookAccountSettings[0] || {};
293
+ const {pageAccessToken, pageId} = orgUnitFacebookPageSettingsMap[pageOrgUnitId];
294
+ const fbContent = {
295
+ selectedAd: fbType,
296
+ previewData,
297
+ primaryText,
298
+ callToAction,
299
+ displayLink,
300
+ pageAccessToken,
301
+ pageId,
302
+ accountId,
303
+ accessToken,
304
+ };
305
+ return fbContent;
306
+ }
266
307
  default:
267
308
  return get(templateDataObject, `versions.base.content`);
268
309
  }
@@ -505,6 +546,22 @@ function SlideBoxContent(props) {
505
546
  onPreviewContentClicked={onPreviewContentClicked}
506
547
  onTestContentClicked={onTestContentClicked}/>
507
548
  }
549
+ {
550
+ isCreateFacebook && (
551
+ <Facebook
552
+ templateData={templateData}
553
+ messageDetails={messageDetails}
554
+ cap={cap}
555
+ onFacebookSubmit={onFacebookSubmit}
556
+ onCreateComplete={onCreateComplete}
557
+ setIsLoadingContent={setIsLoadingContent}
558
+ isFullMode={isFullMode}
559
+ createNew
560
+ getFormSubscriptionData={getFormData}
561
+
562
+ />
563
+ )
564
+ }
508
565
  {
509
566
  isEditFacebook && (
510
567
  <Facebook
@@ -512,7 +569,12 @@ function SlideBoxContent(props) {
512
569
  messageDetails={messageDetails}
513
570
  cap={cap}
514
571
  onFacebookSubmit={onFacebookSubmit}
572
+ onCreateComplete={onCreateComplete}
515
573
  isFullMode={isFullMode}
574
+ params={{
575
+ id: templateData._id,
576
+ }}
577
+ getFormSubscriptionData={getFormData}
516
578
  />
517
579
  )
518
580
  }
@@ -596,6 +658,7 @@ SlideBoxContent.propTypes = {
596
658
  onChannelChange: PropTypes.func,
597
659
  currentChannel: PropTypes.string,
598
660
  onEmailModeChange: PropTypes.func,
661
+ onFacebookAdModeChange: PropTypes.func,
599
662
  emailCreateMode: PropTypes.string,
600
663
  templateStep: PropTypes.string,
601
664
  onCreateNextStep: PropTypes.func,