@capillarytech/creatives-library 7.5.4 → 7.5.6
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/assets/facebookEmptyPlaceholder.png +0 -0
- package/config/app.js +2 -0
- package/index.js +6 -0
- package/package.json +1 -1
- package/reducers.js +2 -1
- package/routes.js +5 -0
- package/services/api.js +34 -1
- package/utils/common.js +13 -1
- package/v2Components/CapImageUpload/index.js +260 -0
- package/v2Components/CapImageUpload/index.scss +32 -0
- package/v2Components/CapImageUpload/messages.js +49 -0
- package/v2Components/CapRadioCardCustom/index.js +66 -0
- package/v2Components/CapVideoUpload/index.js +299 -0
- package/v2Components/CapVideoUpload/index.scss +29 -0
- package/v2Components/CapVideoUpload/messages.js +54 -0
- package/v2Components/TemplatePreview/index.js +19 -2
- package/v2Containers/App/constants.js +21 -0
- package/v2Containers/Cap/messages.js +30 -0
- package/v2Containers/CapFacebookPreview/actions.js +31 -0
- package/v2Containers/CapFacebookPreview/constants.js +21 -0
- package/v2Containers/CapFacebookPreview/index.js +396 -0
- package/v2Containers/CapFacebookPreview/messages.js +138 -0
- package/v2Containers/CapFacebookPreview/reducer.js +37 -0
- package/v2Containers/CapFacebookPreview/sagas.js +99 -0
- package/v2Containers/CapFacebookPreview/selectors.js +25 -0
- package/v2Containers/CreativesContainer/SlideBoxContent.js +55 -1
- package/v2Containers/CreativesContainer/index.js +19 -9
- package/v2Containers/Facebook/Advertisement/constant.js +12 -0
- package/v2Containers/Facebook/Advertisement/index.js +955 -0
- package/v2Containers/Facebook/Advertisement/index.scss +49 -0
- package/v2Containers/Facebook/Advertisement/messages.js +155 -0
- package/v2Containers/Facebook/Advertisement/video.js +0 -0
- package/v2Containers/Facebook/actions.js +62 -0
- package/v2Containers/Facebook/constants.js +25 -1
- package/v2Containers/Facebook/index.js +133 -107
- package/v2Containers/Facebook/reducer.js +95 -1
- package/v2Containers/Facebook/sagas.js +136 -0
- package/v2Containers/Facebook/selectors.js +10 -0
- package/v2Containers/Line/Container/Video/index.js +38 -41
- package/v2Containers/Templates/_templates.scss +26 -0
- package/v2Containers/Templates/actions.js +14 -1
- package/v2Containers/Templates/constants.js +8 -0
- package/v2Containers/Templates/index.js +117 -10
- package/v2Containers/Templates/messages.js +8 -4
- package/v2Containers/Templates/reducer.js +22 -0
- package/v2Containers/Templates/sagas.js +26 -1
- package/v2Containers/TemplatesV2/index.js +13 -13
- package/v2Containers/Viber/index.js +2 -1
|
@@ -0,0 +1,396 @@
|
|
|
1
|
+
/*
|
|
2
|
+
*
|
|
3
|
+
* CapFacebookPreview
|
|
4
|
+
*
|
|
5
|
+
*/
|
|
6
|
+
import PropTypes from 'prop-types';
|
|
7
|
+
import React, { useState, useEffect} from "react";
|
|
8
|
+
import { connect } from 'react-redux';
|
|
9
|
+
import { bindActionCreators } from 'redux';
|
|
10
|
+
import { createStructuredSelector } from 'reselect';
|
|
11
|
+
import { injectIntl, FormattedMessage, intlShape } from 'react-intl';
|
|
12
|
+
import {makeSelectCapFacebookPreview} from './selectors';
|
|
13
|
+
|
|
14
|
+
import messages from './messages';
|
|
15
|
+
import * as actions from './actions';
|
|
16
|
+
import {
|
|
17
|
+
CapLabel,
|
|
18
|
+
CapSelect,
|
|
19
|
+
CapButton,
|
|
20
|
+
CapImage,
|
|
21
|
+
CapSpin,
|
|
22
|
+
CapIcon,
|
|
23
|
+
} from "@capillarytech/cap-ui-library";
|
|
24
|
+
import facebookEmptyPlaceholder from '../../assets/facebookEmptyPlaceholder.png';
|
|
25
|
+
import {
|
|
26
|
+
IMAGE,
|
|
27
|
+
VIDEO,
|
|
28
|
+
CAROUSEL,
|
|
29
|
+
} from '../../v2Containers/Facebook/Advertisement/constant';
|
|
30
|
+
|
|
31
|
+
const NO_CALL_TO_ACTION = 'NO_CALL_TO_ACTION';
|
|
32
|
+
|
|
33
|
+
export const CapFacebookPreview = (props) => {
|
|
34
|
+
const {
|
|
35
|
+
intl,
|
|
36
|
+
disablePreviewButton,
|
|
37
|
+
previewData,
|
|
38
|
+
facebookPreviewActions,
|
|
39
|
+
facebookPreviewData = {},
|
|
40
|
+
selectedAd,
|
|
41
|
+
primaryText,
|
|
42
|
+
callToAction,
|
|
43
|
+
orgUnitFacebookPageSettingsMap,
|
|
44
|
+
accessToken,
|
|
45
|
+
accountId,
|
|
46
|
+
} = props;
|
|
47
|
+
const {
|
|
48
|
+
formatMessage,
|
|
49
|
+
} = intl || {};
|
|
50
|
+
const [adPreviewFormat, setAdPreviewFormat] = useState("DESKTOP_FEED_STANDARD");
|
|
51
|
+
const [random, setRandom] = useState(0);
|
|
52
|
+
const {pageAccessToken, pageId} = orgUnitFacebookPageSettingsMap;
|
|
53
|
+
const {previewIframe = "", isFetchingPreview = false} = facebookPreviewData;
|
|
54
|
+
const facebookAdOptions = [
|
|
55
|
+
{
|
|
56
|
+
value: "DESKTOP_FEED_STANDARD",
|
|
57
|
+
label: formatMessage(messages.desktopFeedStandard),
|
|
58
|
+
},
|
|
59
|
+
{
|
|
60
|
+
value: "FACEBOOK_STORY_MOBILE",
|
|
61
|
+
label: formatMessage(messages.facebookStoryMobile),
|
|
62
|
+
},
|
|
63
|
+
{
|
|
64
|
+
value: "INSTANT_ARTICLE_STANDARD",
|
|
65
|
+
label: formatMessage(messages.instantArticleStandard),
|
|
66
|
+
},
|
|
67
|
+
{
|
|
68
|
+
value: "INSTREAM_VIDEO_DESKTOP",
|
|
69
|
+
label: formatMessage(messages.instreamVideoDesktop),
|
|
70
|
+
},
|
|
71
|
+
{
|
|
72
|
+
value: "INSTREAM_VIDEO_MOBILE",
|
|
73
|
+
label: formatMessage(messages.instreamVideoMobile),
|
|
74
|
+
},
|
|
75
|
+
{
|
|
76
|
+
value: "MARKETPLACE_DESKTOP",
|
|
77
|
+
label: formatMessage(messages.marketplaceDesktop),
|
|
78
|
+
},
|
|
79
|
+
{
|
|
80
|
+
value: "MOBILE_FEED_BASIC",
|
|
81
|
+
label: formatMessage(messages.mobileFeedBasic),
|
|
82
|
+
},
|
|
83
|
+
{
|
|
84
|
+
value: "MARKETPLACE_MOBILE",
|
|
85
|
+
label: formatMessage(messages.marketplaceMobile),
|
|
86
|
+
},
|
|
87
|
+
{
|
|
88
|
+
value: "MOBILE_FEED_STANDARD",
|
|
89
|
+
label: formatMessage(messages.mobileFeedStandard),
|
|
90
|
+
},
|
|
91
|
+
{
|
|
92
|
+
value: "RIGHT_COLUMN_STANDARD",
|
|
93
|
+
label: formatMessage(messages.rightColumnStandard),
|
|
94
|
+
},
|
|
95
|
+
{
|
|
96
|
+
value: "SUGGESTED_VIDEO_DESKTOP",
|
|
97
|
+
label: formatMessage(messages.suggestedVideoDesktop),
|
|
98
|
+
},
|
|
99
|
+
{
|
|
100
|
+
value: "SUGGESTED_VIDEO_MOBILE",
|
|
101
|
+
label: formatMessage(messages.suggestedVideoMobile),
|
|
102
|
+
},
|
|
103
|
+
{
|
|
104
|
+
value: "WATCH_FEED_MOBILE",
|
|
105
|
+
label: formatMessage(messages.watchFeedMobile),
|
|
106
|
+
},
|
|
107
|
+
];
|
|
108
|
+
const instaAdOptions = [
|
|
109
|
+
{
|
|
110
|
+
value: "INSTAGRAM_STANDARD",
|
|
111
|
+
label: formatMessage(messages.instagramStandard),
|
|
112
|
+
},
|
|
113
|
+
{
|
|
114
|
+
value: "INSTAGRAM_STORY",
|
|
115
|
+
label: formatMessage(messages.instagramStory),
|
|
116
|
+
},
|
|
117
|
+
{
|
|
118
|
+
value: "INSTAGRAM_EXPLORE_CONTEXTUAL",
|
|
119
|
+
label: formatMessage(messages.instagramExploreContextual),
|
|
120
|
+
},
|
|
121
|
+
{
|
|
122
|
+
value: "INSTAGRAM_EXPLORE_IMMERSIVE",
|
|
123
|
+
label: formatMessage(messages.instagramExploreImmersive),
|
|
124
|
+
},
|
|
125
|
+
];
|
|
126
|
+
const messangerAdOptions = [
|
|
127
|
+
{
|
|
128
|
+
value: "MESSENGER_MOBILE_INBOX_MEDIA",
|
|
129
|
+
label: formatMessage(messages.messengerMobileInboxMedia),
|
|
130
|
+
},
|
|
131
|
+
];
|
|
132
|
+
const audienceNetworkOptions = [
|
|
133
|
+
{
|
|
134
|
+
value: "AUDIENCE_NETWORK_INSTREAM_VIDEO",
|
|
135
|
+
label: formatMessage(messages.audienceNetworkInstreamVideo),
|
|
136
|
+
},
|
|
137
|
+
{
|
|
138
|
+
value: "AUDIENCE_NETWORK_INSTREAM_VIDEO_MOBILE",
|
|
139
|
+
label: formatMessage(messages.audienceNetworkInstreamVideoMobile),
|
|
140
|
+
},
|
|
141
|
+
{
|
|
142
|
+
value: "AUDIENCE_NETWORK_OUTSTREAM_VIDEO",
|
|
143
|
+
label: formatMessage(messages.audienceNetworkOutstreamVideo),
|
|
144
|
+
},
|
|
145
|
+
{
|
|
146
|
+
value: "AUDIENCE_NETWORK_REWARDED_VIDEO",
|
|
147
|
+
label: formatMessage(messages.audienceNetworkRewardedVideo),
|
|
148
|
+
},
|
|
149
|
+
{
|
|
150
|
+
value: "MOBILE_BANNER",
|
|
151
|
+
label: formatMessage(messages.mobileBanner),
|
|
152
|
+
},
|
|
153
|
+
{
|
|
154
|
+
value: "MOBILE_FULLWIDTH",
|
|
155
|
+
label: formatMessage(messages.mobileFullwidth),
|
|
156
|
+
},
|
|
157
|
+
{
|
|
158
|
+
value: "MOBILE_INTERSTITIAL",
|
|
159
|
+
label: formatMessage(messages.mobileInterstitial),
|
|
160
|
+
},
|
|
161
|
+
{
|
|
162
|
+
value: "MOBILE_MEDIUM_RECTANGLE",
|
|
163
|
+
label: formatMessage(messages.mobileMediumRectangle),
|
|
164
|
+
},
|
|
165
|
+
{
|
|
166
|
+
value: "MOBILE_NATIVE",
|
|
167
|
+
label: formatMessage(messages.mobileNative),
|
|
168
|
+
},
|
|
169
|
+
];
|
|
170
|
+
|
|
171
|
+
const adOptions = [
|
|
172
|
+
...facebookAdOptions,
|
|
173
|
+
...instaAdOptions,
|
|
174
|
+
...messangerAdOptions,
|
|
175
|
+
...audienceNetworkOptions,
|
|
176
|
+
];
|
|
177
|
+
const onChangeAdPreviewFormat = (value) => {
|
|
178
|
+
setAdPreviewFormat(value);
|
|
179
|
+
};
|
|
180
|
+
|
|
181
|
+
const generatePreview = () => {
|
|
182
|
+
const data = {
|
|
183
|
+
accessToken,
|
|
184
|
+
pageAccessToken,
|
|
185
|
+
pageId,
|
|
186
|
+
actId: `act_${accountId}`,
|
|
187
|
+
params: {
|
|
188
|
+
creative: {
|
|
189
|
+
object_story_spec: {
|
|
190
|
+
page_id: pageId,
|
|
191
|
+
message: primaryText,
|
|
192
|
+
},
|
|
193
|
+
},
|
|
194
|
+
ad_format: adPreviewFormat,
|
|
195
|
+
},
|
|
196
|
+
};
|
|
197
|
+
if (selectedAd !== CAROUSEL) {
|
|
198
|
+
const {
|
|
199
|
+
imageData = {},
|
|
200
|
+
webSiteLink,
|
|
201
|
+
linkDesc,
|
|
202
|
+
linkHeadLine,
|
|
203
|
+
subType,
|
|
204
|
+
videoData,
|
|
205
|
+
} = previewData[0];
|
|
206
|
+
if (subType === IMAGE) {
|
|
207
|
+
data.params.creative.object_story_spec = {
|
|
208
|
+
...data.params.creative.object_story_spec,
|
|
209
|
+
link_data: {
|
|
210
|
+
description: linkDesc,
|
|
211
|
+
link: webSiteLink,
|
|
212
|
+
name: linkHeadLine,
|
|
213
|
+
picture: imageData.imageSrc,
|
|
214
|
+
} };
|
|
215
|
+
if (callToAction !== NO_CALL_TO_ACTION) {
|
|
216
|
+
data.params.creative.object_story_spec.link_data.call_to_action = {
|
|
217
|
+
type: callToAction,
|
|
218
|
+
value: {link: webSiteLink},
|
|
219
|
+
};
|
|
220
|
+
}
|
|
221
|
+
facebookPreviewActions.getImagePreview(data);
|
|
222
|
+
} else {
|
|
223
|
+
data.params.creative.object_story_spec.video_data = {
|
|
224
|
+
image_url: videoData.previewUrl,
|
|
225
|
+
videoUrl: videoData.videoSrc,
|
|
226
|
+
message: primaryText,
|
|
227
|
+
link_description: linkDesc,
|
|
228
|
+
};
|
|
229
|
+
if (callToAction !== NO_CALL_TO_ACTION) {
|
|
230
|
+
data.params.creative.object_story_spec.video_data.call_to_action = {
|
|
231
|
+
type: callToAction,
|
|
232
|
+
value: {link: webSiteLink},
|
|
233
|
+
};
|
|
234
|
+
}
|
|
235
|
+
facebookPreviewActions.getVideoPreview(data);
|
|
236
|
+
}
|
|
237
|
+
} else {
|
|
238
|
+
const childData = previewData.map((obj) => {
|
|
239
|
+
let arrayData = {
|
|
240
|
+
link: obj.webSiteLink,
|
|
241
|
+
name: obj.linkHeadLine,
|
|
242
|
+
description: obj.linkDesc,
|
|
243
|
+
};
|
|
244
|
+
if (callToAction !== NO_CALL_TO_ACTION) {
|
|
245
|
+
arrayData.call_to_action = {
|
|
246
|
+
type: callToAction,
|
|
247
|
+
value: {link: obj.webSiteLink},
|
|
248
|
+
};
|
|
249
|
+
}
|
|
250
|
+
if (obj.subType === VIDEO) {
|
|
251
|
+
arrayData = {
|
|
252
|
+
...arrayData,
|
|
253
|
+
videoUrl: obj.videoData.videoSrc,
|
|
254
|
+
picture: obj.videoData.previewUrl,
|
|
255
|
+
};
|
|
256
|
+
} else {
|
|
257
|
+
arrayData = {
|
|
258
|
+
...arrayData,
|
|
259
|
+
picture: obj.imageData.imageSrc,
|
|
260
|
+
};
|
|
261
|
+
}
|
|
262
|
+
return arrayData;
|
|
263
|
+
});
|
|
264
|
+
data.params.creative.object_story_spec = {
|
|
265
|
+
...data.params.creative.object_story_spec,
|
|
266
|
+
link_data: {
|
|
267
|
+
message: primaryText,
|
|
268
|
+
child_attachments: childData,
|
|
269
|
+
multi_share_end_card: false,
|
|
270
|
+
},
|
|
271
|
+
};
|
|
272
|
+
facebookPreviewActions.getCarouselPreview(data);
|
|
273
|
+
}
|
|
274
|
+
};
|
|
275
|
+
const resetIframe = () => {
|
|
276
|
+
const r = random + 1;
|
|
277
|
+
setRandom(r);
|
|
278
|
+
};
|
|
279
|
+
const getIframe = (iframe) => {
|
|
280
|
+
const divTag = document.createElement('div');
|
|
281
|
+
divTag.innerHTML = iframe;
|
|
282
|
+
const src = divTag.getElementsByTagName('iframe')[0].getAttribute('src');
|
|
283
|
+
const width = divTag.getElementsByTagName('iframe')[0].getAttribute('width');
|
|
284
|
+
const height = divTag.getElementsByTagName('iframe')[0].getAttribute('height');
|
|
285
|
+
return (<>
|
|
286
|
+
<iframe
|
|
287
|
+
src={src}
|
|
288
|
+
key={random}
|
|
289
|
+
scrolling="yes"
|
|
290
|
+
style={{border: "none"}}
|
|
291
|
+
width={width}
|
|
292
|
+
height={height}
|
|
293
|
+
loading="lazy"
|
|
294
|
+
/>
|
|
295
|
+
</>);
|
|
296
|
+
};
|
|
297
|
+
const showRefreshButton = () => {
|
|
298
|
+
let isRefresh = false;
|
|
299
|
+
props.previewData.forEach((obj) => {
|
|
300
|
+
if (obj.subType === VIDEO) {
|
|
301
|
+
isRefresh = true;
|
|
302
|
+
return isRefresh;
|
|
303
|
+
}
|
|
304
|
+
});
|
|
305
|
+
return isRefresh && previewIframe !== "";
|
|
306
|
+
};
|
|
307
|
+
const isRefreshButton = showRefreshButton();
|
|
308
|
+
useEffect(() => {
|
|
309
|
+
facebookPreviewActions.clearPreview();
|
|
310
|
+
}, []);
|
|
311
|
+
return (
|
|
312
|
+
<CapSpin spinning={isFetchingPreview}>
|
|
313
|
+
<div style={{display: 'inline-block'}}>
|
|
314
|
+
<CapSelect
|
|
315
|
+
label={formatMessage(messages.previewBasedonAdPlacement)}
|
|
316
|
+
key={"select-previewBasedonAdPlacement"}
|
|
317
|
+
onChange={onChangeAdPreviewFormat}
|
|
318
|
+
style={{width: '328px', paddingBottom: 16 }}
|
|
319
|
+
options={adOptions}
|
|
320
|
+
value={adPreviewFormat}
|
|
321
|
+
>
|
|
322
|
+
</CapSelect>
|
|
323
|
+
</div>
|
|
324
|
+
<CapLabel
|
|
325
|
+
type="label1"
|
|
326
|
+
style={{paddingBottom: 16, textAlign: 'left', width: 392}}
|
|
327
|
+
>
|
|
328
|
+
{formatMessage(messages.previewAdDesc)}
|
|
329
|
+
</CapLabel>
|
|
330
|
+
<div style={{marginBottom: 16}}>
|
|
331
|
+
<CapButton
|
|
332
|
+
type="secondary"
|
|
333
|
+
disabled={disablePreviewButton}
|
|
334
|
+
onClick={generatePreview}
|
|
335
|
+
>
|
|
336
|
+
<FormattedMessage {...messages.generatePreview} />
|
|
337
|
+
</CapButton>
|
|
338
|
+
{isRefreshButton && (<CapButton
|
|
339
|
+
onClick={resetIframe}
|
|
340
|
+
type="secondary"
|
|
341
|
+
style={{marginLeft: 16}}
|
|
342
|
+
>
|
|
343
|
+
{formatMessage(messages.refreshPreview)}
|
|
344
|
+
</CapButton>)}
|
|
345
|
+
</div>
|
|
346
|
+
{isRefreshButton && <div style={{marginBottom: 16}}>
|
|
347
|
+
<CapIcon
|
|
348
|
+
type="info"
|
|
349
|
+
svgProps={{
|
|
350
|
+
width: 16,
|
|
351
|
+
height: 16,
|
|
352
|
+
}}
|
|
353
|
+
>
|
|
354
|
+
</CapIcon>
|
|
355
|
+
<CapLabel.CapLabelInline
|
|
356
|
+
type="label1"
|
|
357
|
+
size="s"
|
|
358
|
+
style={{marginBottom: 16, width: 392}}
|
|
359
|
+
>
|
|
360
|
+
{formatMessage(messages.videoNotePreview)}
|
|
361
|
+
</CapLabel.CapLabelInline>
|
|
362
|
+
</div>}
|
|
363
|
+
{previewIframe === "" ? <CapImage
|
|
364
|
+
src={facebookEmptyPlaceholder}
|
|
365
|
+
alt="default"
|
|
366
|
+
width="316px"
|
|
367
|
+
height="392px"
|
|
368
|
+
/> : getIframe(previewIframe)}
|
|
369
|
+
</CapSpin>
|
|
370
|
+
);
|
|
371
|
+
};
|
|
372
|
+
|
|
373
|
+
CapFacebookPreview.propTypes = {
|
|
374
|
+
disablePreviewButton: PropTypes.bool,
|
|
375
|
+
intl: intlShape,
|
|
376
|
+
previewData: PropTypes.array,
|
|
377
|
+
selectedAd: PropTypes.string,
|
|
378
|
+
facebookPreviewActions: PropTypes.func,
|
|
379
|
+
facebookPreviewData: PropTypes.any,
|
|
380
|
+
primaryText: PropTypes.string,
|
|
381
|
+
callToAction: PropTypes.string,
|
|
382
|
+
orgUnitFacebookPageSettingsMap: PropTypes.object,
|
|
383
|
+
accessToken: PropTypes.string,
|
|
384
|
+
accountId: PropTypes.string,
|
|
385
|
+
};
|
|
386
|
+
|
|
387
|
+
const mapStateToProps = createStructuredSelector({
|
|
388
|
+
facebookPreviewData: makeSelectCapFacebookPreview(),
|
|
389
|
+
});
|
|
390
|
+
|
|
391
|
+
const mapDispatchToProps = (dispatch) => ({
|
|
392
|
+
facebookPreviewActions: bindActionCreators(actions, dispatch),
|
|
393
|
+
});
|
|
394
|
+
|
|
395
|
+
|
|
396
|
+
export default connect(mapStateToProps, mapDispatchToProps)(injectIntl(CapFacebookPreview));
|
|
@@ -0,0 +1,138 @@
|
|
|
1
|
+
/*
|
|
2
|
+
* CapFacebookPreview Messages
|
|
3
|
+
*
|
|
4
|
+
* This contains all the text for the CapFacebookPreview component.
|
|
5
|
+
*/
|
|
6
|
+
import { defineMessages } from 'react-intl';
|
|
7
|
+
const messagePrefix = 'creatives.containersV2.CapFacebookPreview';
|
|
8
|
+
|
|
9
|
+
export default defineMessages({
|
|
10
|
+
previewBasedonAdPlacement: {
|
|
11
|
+
id: `${messagePrefix}.previewBasedonAdPlacement`,
|
|
12
|
+
defaultMessage: 'Preview based on ad placement',
|
|
13
|
+
},
|
|
14
|
+
previewAdDesc: {
|
|
15
|
+
id: `${messagePrefix}.previewAdDesc`,
|
|
16
|
+
defaultMessage: 'Please add Media, Primary text & Website link & click on “Generate preview” to view preview.',
|
|
17
|
+
},
|
|
18
|
+
generatePreview: {
|
|
19
|
+
id: `${messagePrefix}.generatePreview`,
|
|
20
|
+
defaultMessage: 'Generate preview',
|
|
21
|
+
},
|
|
22
|
+
desktopFeedStandard: {
|
|
23
|
+
id: `${messagePrefix}.desktopFeedStandard`,
|
|
24
|
+
defaultMessage: 'Desktop feed standard',
|
|
25
|
+
},
|
|
26
|
+
facebookStoryMobile: {
|
|
27
|
+
id: `${messagePrefix}.facebookStoryMobile`,
|
|
28
|
+
defaultMessage: 'Facebook story mobile',
|
|
29
|
+
},
|
|
30
|
+
instantArticleStandard: {
|
|
31
|
+
id: `${messagePrefix}.instantArticleStandard`,
|
|
32
|
+
defaultMessage: 'Instant article standard',
|
|
33
|
+
},
|
|
34
|
+
instreamVideoDesktop: {
|
|
35
|
+
id: `${messagePrefix}.instreamVideoDesktop`,
|
|
36
|
+
defaultMessage: 'Instream video desktop',
|
|
37
|
+
},
|
|
38
|
+
instreamVideoMobile: {
|
|
39
|
+
id: `${messagePrefix}.instreamVideoMobile`,
|
|
40
|
+
defaultMessage: 'Instream video mobile',
|
|
41
|
+
},
|
|
42
|
+
marketplaceDesktop: {
|
|
43
|
+
id: `${messagePrefix}.marketplaceDesktop`,
|
|
44
|
+
defaultMessage: 'Marketplace desktop',
|
|
45
|
+
},
|
|
46
|
+
marketplaceMobile: {
|
|
47
|
+
id: `${messagePrefix}.marketplaceMobile`,
|
|
48
|
+
defaultMessage: 'Marketplace mobile',
|
|
49
|
+
},
|
|
50
|
+
mobileFeedBasic: {
|
|
51
|
+
id: `${messagePrefix}.mobileFeedBasic`,
|
|
52
|
+
defaultMessage: 'Mobile feed basic',
|
|
53
|
+
},
|
|
54
|
+
mobileFeedStandard: {
|
|
55
|
+
id: `${messagePrefix}.mobileFeedStandard`,
|
|
56
|
+
defaultMessage: 'Mobile feed standard',
|
|
57
|
+
},
|
|
58
|
+
rightColumnStandard: {
|
|
59
|
+
id: `${messagePrefix}.rightColumnStandard`,
|
|
60
|
+
defaultMessage: 'Right column standard',
|
|
61
|
+
},
|
|
62
|
+
suggestedVideoDesktop: {
|
|
63
|
+
id: `${messagePrefix}.suggestedVideoDesktop`,
|
|
64
|
+
defaultMessage: 'Suggested video desktop',
|
|
65
|
+
},
|
|
66
|
+
suggestedVideoMobile: {
|
|
67
|
+
id: `${messagePrefix}.suggestedVideoMobile`,
|
|
68
|
+
defaultMessage: 'Suggested video mobile',
|
|
69
|
+
},
|
|
70
|
+
watchFeedMobile: {
|
|
71
|
+
id: `${messagePrefix}.watchFeedMobile`,
|
|
72
|
+
defaultMessage: 'Watch feed mobile',
|
|
73
|
+
},
|
|
74
|
+
instagramStandard: {
|
|
75
|
+
id: `${messagePrefix}.instagramStandard`,
|
|
76
|
+
defaultMessage: 'instagram_standard',
|
|
77
|
+
},
|
|
78
|
+
instagramStory: {
|
|
79
|
+
id: `${messagePrefix}.instagramStory`,
|
|
80
|
+
defaultMessage: 'Instagram story',
|
|
81
|
+
},
|
|
82
|
+
instagramExploreContextual: {
|
|
83
|
+
id: `${messagePrefix}.instagramExploreContextual`,
|
|
84
|
+
defaultMessage: 'instagram_explore_contextual',
|
|
85
|
+
},
|
|
86
|
+
instagramExploreImmersive: {
|
|
87
|
+
id: `${messagePrefix}.instagramExploreImmersive`,
|
|
88
|
+
defaultMessage: 'Instagram explore immersive',
|
|
89
|
+
},
|
|
90
|
+
messengerMobileInboxMedia: {
|
|
91
|
+
id: `${messagePrefix}.messengerMobileInboxMedia`,
|
|
92
|
+
defaultMessage: 'Messenger mobile inbox media',
|
|
93
|
+
},
|
|
94
|
+
audienceNetworkInstreamVideo: {
|
|
95
|
+
id: `${messagePrefix}.audienceNetworkInstreamVideo`,
|
|
96
|
+
defaultMessage: 'Audience network instream video',
|
|
97
|
+
},
|
|
98
|
+
audienceNetworkInstreamVideoMobile: {
|
|
99
|
+
id: `${messagePrefix}.audienceNetworkInstreamVideoMobile`,
|
|
100
|
+
defaultMessage: 'Audience network instream video mobile',
|
|
101
|
+
},
|
|
102
|
+
audienceNetworkOutstreamVideo: {
|
|
103
|
+
id: `${messagePrefix}.audienceNetworkOutstreamVideo`,
|
|
104
|
+
defaultMessage: 'Audience network outstream video',
|
|
105
|
+
},
|
|
106
|
+
audienceNetworkRewardedVideo: {
|
|
107
|
+
id: `${messagePrefix}.audienceNetworkRewardedVideo`,
|
|
108
|
+
defaultMessage: 'Audience network rewarded video',
|
|
109
|
+
},
|
|
110
|
+
mobileBanner: {
|
|
111
|
+
id: `${messagePrefix}.mobileBanner`,
|
|
112
|
+
defaultMessage: 'Mobile banner',
|
|
113
|
+
},
|
|
114
|
+
mobileFullwidth: {
|
|
115
|
+
id: `${messagePrefix}.mobileFullwidth`,
|
|
116
|
+
defaultMessage: 'Mobile fullwidth',
|
|
117
|
+
},
|
|
118
|
+
mobileInterstitial: {
|
|
119
|
+
id: `${messagePrefix}.mobileInterstitial`,
|
|
120
|
+
defaultMessage: 'Mobile interstitial',
|
|
121
|
+
},
|
|
122
|
+
mobileMediumRectangle: {
|
|
123
|
+
id: `${messagePrefix}.mobileMediumRectangle`,
|
|
124
|
+
defaultMessage: 'Mobile medium rectangle',
|
|
125
|
+
},
|
|
126
|
+
mobileNative: {
|
|
127
|
+
id: `${messagePrefix}.mobileNative`,
|
|
128
|
+
defaultMessage: 'Mobile native',
|
|
129
|
+
},
|
|
130
|
+
refreshPreview: {
|
|
131
|
+
id: `${messagePrefix}.refreshPreview`,
|
|
132
|
+
defaultMessage: 'Refresh preview',
|
|
133
|
+
},
|
|
134
|
+
videoNotePreview: {
|
|
135
|
+
id: `${messagePrefix}.videoNotePreview`,
|
|
136
|
+
defaultMessage: 'Facebook may take time to upload the video. Please try Refreshing.',
|
|
137
|
+
},
|
|
138
|
+
});
|
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
/*
|
|
2
|
+
*
|
|
3
|
+
* CapFacebookPreview reducer
|
|
4
|
+
*
|
|
5
|
+
*/
|
|
6
|
+
|
|
7
|
+
import { fromJS } from 'immutable';
|
|
8
|
+
import get from 'lodash/get';
|
|
9
|
+
import * as types from './constants';
|
|
10
|
+
|
|
11
|
+
const initialState = fromJS({
|
|
12
|
+
isFetchingPreview: false,
|
|
13
|
+
previewIframe: "",
|
|
14
|
+
});
|
|
15
|
+
|
|
16
|
+
function capFacebookPreviewReducer(state = initialState, action) {
|
|
17
|
+
switch (action.type) {
|
|
18
|
+
case types.GENERATE_IMAGE_PREVIEW_REQUEST:
|
|
19
|
+
case types.GENERATE_VIDEO_PREVIEW_REQUEST:
|
|
20
|
+
case types.GENERATE_CAROUSEL_PREVIEW_REQUEST:
|
|
21
|
+
return state.set('isFetchingPreview', true).set('previewIframe', "");
|
|
22
|
+
case types.GENERATE_IMAGE_PREVIEW_SUCCESS:
|
|
23
|
+
case types.GENERATE_VIDEO_PREVIEW_SUCCESS:
|
|
24
|
+
case types.GENERATE_CAROUSEL_PREVIEW_SUCCESS:
|
|
25
|
+
return state.set('isFetchingPreview', false).set('previewIframe', get(action, 'payload.fbPreview[0].body', ""));
|
|
26
|
+
case types.GENERATE_IMAGE_PREVIEW_FAILURE:
|
|
27
|
+
case types.GENERATE_VIDEO_PREVIEW_FAILURE:
|
|
28
|
+
case types.GENERATE_CAROUSEL_PREVIEW_FAILURE:
|
|
29
|
+
return state.set('isFetchingPreview', false).set('previewIframe', "");
|
|
30
|
+
case types.CLEAR_PREVIEW:
|
|
31
|
+
return state.set('isFetchingPreview', false).set('previewIframe', "");
|
|
32
|
+
default:
|
|
33
|
+
return state;
|
|
34
|
+
}
|
|
35
|
+
}
|
|
36
|
+
|
|
37
|
+
export default capFacebookPreviewReducer;
|
|
@@ -0,0 +1,99 @@
|
|
|
1
|
+
import { take, call, put, takeLatest, cancel } from 'redux-saga/effects';
|
|
2
|
+
import { LOCATION_CHANGE } from 'react-router-redux';
|
|
3
|
+
import * as Api from '../../services/api';
|
|
4
|
+
import * as type from './constants';
|
|
5
|
+
|
|
6
|
+
export function* getImageFacebookPreview(previewData) {
|
|
7
|
+
try {
|
|
8
|
+
const response = yield call(Api.getImageFacebookPreview, previewData );
|
|
9
|
+
const { errors, response: responsePreview } = response;
|
|
10
|
+
if (errors && errors.length) {
|
|
11
|
+
yield put({
|
|
12
|
+
type: type.GENERATE_IMAGE_PREVIEW_FAILURE,
|
|
13
|
+
payload: errors,
|
|
14
|
+
});
|
|
15
|
+
} else {
|
|
16
|
+
yield put({
|
|
17
|
+
type: type.GENERATE_IMAGE_PREVIEW_SUCCESS,
|
|
18
|
+
payload: responsePreview,
|
|
19
|
+
});
|
|
20
|
+
}
|
|
21
|
+
} catch (error) {
|
|
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 { errors, response: responsePreview } = response;
|
|
33
|
+
if (errors && errors.length) {
|
|
34
|
+
yield put({
|
|
35
|
+
type: type.GENERATE_VIDEO_PREVIEW_FAILURE,
|
|
36
|
+
payload: errors,
|
|
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 { errors, response: responsePreview } = response;
|
|
56
|
+
if (errors && errors.length) {
|
|
57
|
+
yield put({
|
|
58
|
+
type: type.GENERATE_CAROUSEL_PREVIEW_FAILURE,
|
|
59
|
+
payload: errors,
|
|
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,
|
|
70
|
+
payload: error,
|
|
71
|
+
});
|
|
72
|
+
}
|
|
73
|
+
}
|
|
74
|
+
|
|
75
|
+
|
|
76
|
+
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);
|
|
84
|
+
yield take(LOCATION_CHANGE);
|
|
85
|
+
yield cancel(watcher);
|
|
86
|
+
}
|
|
87
|
+
|
|
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
|
+
|
|
94
|
+
export default [
|
|
95
|
+
watchImageFacebookPreview,
|
|
96
|
+
watchVideoFacebookPreview,
|
|
97
|
+
watchCarouselFacebookPreview,
|
|
98
|
+
];
|
|
99
|
+
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
import { createSelector } from 'reselect';
|
|
2
|
+
|
|
3
|
+
/**
|
|
4
|
+
* Direct selector to the capFacebookPreview state domain
|
|
5
|
+
*/
|
|
6
|
+
const selectCapFacebookPreviewDomain = () => (state) => state.get('facebookPreview');
|
|
7
|
+
|
|
8
|
+
/**
|
|
9
|
+
* Other specific selectors
|
|
10
|
+
*/
|
|
11
|
+
|
|
12
|
+
|
|
13
|
+
/**
|
|
14
|
+
* Default selector used by CapFacebookPreview
|
|
15
|
+
*/
|
|
16
|
+
|
|
17
|
+
const makeSelectCapFacebookPreview = () => createSelector(
|
|
18
|
+
selectCapFacebookPreviewDomain(),
|
|
19
|
+
(substate) => substate && substate.toJS()
|
|
20
|
+
);
|
|
21
|
+
|
|
22
|
+
export {
|
|
23
|
+
selectCapFacebookPreviewDomain,
|
|
24
|
+
makeSelectCapFacebookPreview,
|
|
25
|
+
};
|