@capillarytech/creatives-library 7.7.10 → 7.7.12
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/index.js +3 -3
- package/package.json +1 -3
- package/v2Components/TemplatePreview/index.js +0 -1
- package/v2Containers/CapFacebookPreview/index.js +11 -15
- package/v2Containers/CapFacebookPreview/messages.js +2 -2
- package/v2Containers/CreativesContainer/SlideBoxContent.js +1 -16
- package/v2Containers/CreativesContainer/index.js +12 -125
- package/v2Containers/Facebook/Advertisement/index.js +41 -80
- package/v2Containers/Facebook/Advertisement/index.scss +3 -3
- package/v2Containers/Facebook/Facebook.style.js +1 -1
- package/v2Containers/Facebook/constants.js +0 -4
- package/v2Containers/Facebook/index.js +122 -198
- package/v2Containers/Facebook/messages.js +4 -24
- package/v2Containers/Templates/index.js +21 -37
- package/v2Containers/Templates/messages.js +1 -1
- package/v2Containers/Templates/reducer.js +4 -4
- package/v2Containers/TemplatesV2/index.js +6 -23
- package/v2Containers/TemplatesV2/messages.js +0 -4
- package/v2Containers/CapFacebookPreview/index.scss +0 -4
package/index.js
CHANGED
|
@@ -76,8 +76,8 @@ import viberSaga from './v2Containers/Viber/sagas';
|
|
|
76
76
|
import TemplatesV2 from './v2Containers/TemplatesV2/index';
|
|
77
77
|
|
|
78
78
|
import FacebookPreview from './v2Containers/CapFacebookPreview';
|
|
79
|
-
import
|
|
80
|
-
import
|
|
79
|
+
import FacebookPreviewReducer from './v2Containers/CapFacebookPreview/reducer';
|
|
80
|
+
import FacebookPreviewSaga from './v2Containers/CapFacebookPreview/sagas';
|
|
81
81
|
|
|
82
82
|
import CreativesContainer from './v2Containers/CreativesContainer';
|
|
83
83
|
import CreativesContainerReducer from './v2Containers/CreativesContainer/reducer';
|
|
@@ -105,7 +105,7 @@ const LineCreateContainer = {LineCreate, lineCreateReducer, lineCreateSaga};
|
|
|
105
105
|
const TemplatesV2Container = {TemplatesV2, templateReducer, templateSaga};
|
|
106
106
|
const FacebookContainer = {Facebook, facebookReducer, facebookSaga};
|
|
107
107
|
const ViberContainer = {Viber, viberReducer, viberSaga};
|
|
108
|
-
const FacebookPreviewContainer = { FacebookPreview,
|
|
108
|
+
const FacebookPreviewContainer = { FacebookPreview, FacebookPreviewReducer, FacebookPreviewSaga };
|
|
109
109
|
|
|
110
110
|
const GalleryContainer = {Gallery, galleryReducer, gallerySagas};
|
|
111
111
|
const FTPContainer = {FTP, FTPReducer, FTPSagas};
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@capillarytech/creatives-library",
|
|
3
3
|
"author": "meharaj",
|
|
4
|
-
"version": "7.7.
|
|
4
|
+
"version": "7.7.12",
|
|
5
5
|
"description": "Capillary creatives ui",
|
|
6
6
|
"main": "./index.js",
|
|
7
7
|
"module": "./index.es.js",
|
|
@@ -19,8 +19,6 @@
|
|
|
19
19
|
"@mailupinc/bee-plugin": "^1.2.0",
|
|
20
20
|
"babel-cli": "^6.26.0",
|
|
21
21
|
"chalk": "1.1.3",
|
|
22
|
-
"flow": "^0.2.3",
|
|
23
|
-
"git": "^0.1.5",
|
|
24
22
|
"jquery": "^3.3.1",
|
|
25
23
|
"load-script": "^1.0.0",
|
|
26
24
|
"normalizr": "^3.2.3",
|
|
@@ -30,7 +30,7 @@ import {
|
|
|
30
30
|
CAROUSEL,
|
|
31
31
|
NO_CALL_TO_ACTION,
|
|
32
32
|
} from '../../v2Containers/Facebook/Advertisement/constant';
|
|
33
|
-
|
|
33
|
+
|
|
34
34
|
|
|
35
35
|
export const CapFacebookPreview = (props) => {
|
|
36
36
|
const {
|
|
@@ -45,8 +45,6 @@ export const CapFacebookPreview = (props) => {
|
|
|
45
45
|
orgUnitFacebookPageSettingsMap = {},
|
|
46
46
|
accessToken,
|
|
47
47
|
accountId,
|
|
48
|
-
defaultGeneratePreview,
|
|
49
|
-
hideInfoText = false,
|
|
50
48
|
} = props;
|
|
51
49
|
const {
|
|
52
50
|
formatMessage,
|
|
@@ -200,7 +198,6 @@ export const CapFacebookPreview = (props) => {
|
|
|
200
198
|
ad_format: adPreviewFormat,
|
|
201
199
|
},
|
|
202
200
|
};
|
|
203
|
-
const { webSiteLink= "" } = (previewData || [] )[0] || {};
|
|
204
201
|
if (selectedAd !== CAROUSEL) {
|
|
205
202
|
const {
|
|
206
203
|
imageData = {},
|
|
@@ -275,7 +272,6 @@ export const CapFacebookPreview = (props) => {
|
|
|
275
272
|
message: primaryText,
|
|
276
273
|
child_attachments: childData,
|
|
277
274
|
multi_share_end_card: false,
|
|
278
|
-
"link":webSiteLink,
|
|
279
275
|
},
|
|
280
276
|
};
|
|
281
277
|
facebookPreviewActions.getPreview(data);
|
|
@@ -287,19 +283,22 @@ export const CapFacebookPreview = (props) => {
|
|
|
287
283
|
const r = random + 1;
|
|
288
284
|
setRandom(r);
|
|
289
285
|
};
|
|
286
|
+
|
|
290
287
|
const getIframe = (iframe) => {
|
|
291
288
|
const divTag = document.createElement('div');
|
|
292
289
|
divTag.innerHTML = iframe;
|
|
293
290
|
const src = divTag.getElementsByTagName('iframe')[0].getAttribute('src');
|
|
291
|
+
const width = divTag.getElementsByTagName('iframe')[0].getAttribute('width');
|
|
292
|
+
const height = divTag.getElementsByTagName('iframe')[0].getAttribute('height');
|
|
294
293
|
return (<>
|
|
295
294
|
<iframe
|
|
296
295
|
src={src}
|
|
297
296
|
key={random}
|
|
297
|
+
scrolling="yes"
|
|
298
298
|
style={{border: "none"}}
|
|
299
|
-
width={
|
|
300
|
-
|
|
301
|
-
|
|
302
|
-
className="cap-facebook-ad-iframe"
|
|
299
|
+
width={width}
|
|
300
|
+
height={height}
|
|
301
|
+
loading="lazy"
|
|
303
302
|
/>
|
|
304
303
|
</>);
|
|
305
304
|
};
|
|
@@ -318,9 +317,6 @@ export const CapFacebookPreview = (props) => {
|
|
|
318
317
|
|
|
319
318
|
useEffect(() => {
|
|
320
319
|
facebookPreviewActions.clearPreview();
|
|
321
|
-
if (defaultGeneratePreview) {
|
|
322
|
-
generatePreview();
|
|
323
|
-
}
|
|
324
320
|
}, []);
|
|
325
321
|
|
|
326
322
|
useEffect(() => {
|
|
@@ -339,6 +335,7 @@ export const CapFacebookPreview = (props) => {
|
|
|
339
335
|
setDisableAfterPreviewGenerate(false);
|
|
340
336
|
}
|
|
341
337
|
}, [previewIframeError]);
|
|
338
|
+
|
|
342
339
|
return (
|
|
343
340
|
<CapSpin spinning={isFetchingPreview}>
|
|
344
341
|
<div style={{display: 'inline-block'}}>
|
|
@@ -352,12 +349,12 @@ export const CapFacebookPreview = (props) => {
|
|
|
352
349
|
>
|
|
353
350
|
</CapSelect>
|
|
354
351
|
</div>
|
|
355
|
-
|
|
352
|
+
<CapLabel
|
|
356
353
|
type="label1"
|
|
357
354
|
style={{paddingBottom: 16, textAlign: 'left', width: 392}}
|
|
358
355
|
>
|
|
359
356
|
{formatMessage(messages.previewAdDesc)}
|
|
360
|
-
</CapLabel>
|
|
357
|
+
</CapLabel>
|
|
361
358
|
<div style={{marginBottom: 16}}>
|
|
362
359
|
{(disablePreviewButton || disableAfterPreviewGenerate) ?
|
|
363
360
|
<CapTooltip title={formatMessage(messages.generatePreviewDisableToolTip)}>
|
|
@@ -423,7 +420,6 @@ CapFacebookPreview.propTypes = {
|
|
|
423
420
|
orgUnitFacebookPageSettingsMap: PropTypes.object,
|
|
424
421
|
accessToken: PropTypes.string,
|
|
425
422
|
accountId: PropTypes.string,
|
|
426
|
-
hideInfoText:PropTypes.any,
|
|
427
423
|
};
|
|
428
424
|
|
|
429
425
|
const mapStateToProps = createStructuredSelector({
|
|
@@ -73,7 +73,7 @@ export default defineMessages({
|
|
|
73
73
|
},
|
|
74
74
|
instagramStandard: {
|
|
75
75
|
id: `${messagePrefix}.instagramStandard`,
|
|
76
|
-
defaultMessage: '
|
|
76
|
+
defaultMessage: 'instagram_standard',
|
|
77
77
|
},
|
|
78
78
|
instagramStory: {
|
|
79
79
|
id: `${messagePrefix}.instagramStory`,
|
|
@@ -81,7 +81,7 @@ export default defineMessages({
|
|
|
81
81
|
},
|
|
82
82
|
instagramExploreContextual: {
|
|
83
83
|
id: `${messagePrefix}.instagramExploreContextual`,
|
|
84
|
-
defaultMessage: '
|
|
84
|
+
defaultMessage: 'instagram_explore_contextual',
|
|
85
85
|
},
|
|
86
86
|
instagramExploreImmersive: {
|
|
87
87
|
id: `${messagePrefix}.instagramExploreImmersive`,
|
|
@@ -137,10 +137,6 @@ function SlideBoxContent(props) {
|
|
|
137
137
|
handleClose,
|
|
138
138
|
onFTPSubmit,
|
|
139
139
|
campaignSettings,
|
|
140
|
-
messageStrategy,
|
|
141
|
-
fbAdManager,
|
|
142
|
-
showDisabledFBInfo,
|
|
143
|
-
orgUnitId,
|
|
144
140
|
} = props;
|
|
145
141
|
const type = (messageDetails.type || '').toLowerCase(); // type is context in get tags values : outbound | dvs | referral | loyalty | coupons
|
|
146
142
|
const query = { type: !isFullMode && 'embedded', module: isFullMode ? 'default' : 'library', isEditFromCampaigns: (templateData || {}).isEditFromCampaigns};
|
|
@@ -338,9 +334,6 @@ function SlideBoxContent(props) {
|
|
|
338
334
|
slidBoxContent={slidBoxContent}
|
|
339
335
|
FTPMode="create"
|
|
340
336
|
selectedOfferDetails={selectedOfferDetails}
|
|
341
|
-
messageStrategy={messageStrategy}
|
|
342
|
-
showDisabledFBInfo={showDisabledFBInfo}
|
|
343
|
-
orgUnitId={orgUnitId}
|
|
344
337
|
/>
|
|
345
338
|
)}
|
|
346
339
|
{isPreview && (
|
|
@@ -565,10 +558,7 @@ function SlideBoxContent(props) {
|
|
|
565
558
|
isFullMode={isFullMode}
|
|
566
559
|
createNew
|
|
567
560
|
getFormSubscriptionData={getFormData}
|
|
568
|
-
|
|
569
|
-
fbAdManager={fbAdManager}
|
|
570
|
-
onSelectTemplate={onSelectTemplate}
|
|
571
|
-
orgUnitId={orgUnitId}
|
|
561
|
+
|
|
572
562
|
/>
|
|
573
563
|
)
|
|
574
564
|
}
|
|
@@ -585,7 +575,6 @@ function SlideBoxContent(props) {
|
|
|
585
575
|
id: templateData._id,
|
|
586
576
|
}}
|
|
587
577
|
getFormSubscriptionData={getFormData}
|
|
588
|
-
fbAdManager={fbAdManager}
|
|
589
578
|
/>
|
|
590
579
|
)
|
|
591
580
|
}
|
|
@@ -698,9 +687,5 @@ SlideBoxContent.propTypes = {
|
|
|
698
687
|
saveMessage: PropTypes.func,
|
|
699
688
|
selectedAccount: PropTypes.object,
|
|
700
689
|
onFTPSubmit: PropTypes.func,
|
|
701
|
-
messageStrategy: PropTypes.string,
|
|
702
|
-
fbAdManager: PropTypes.string,
|
|
703
|
-
showDisabledFBInfo: PropTypes.boolean,
|
|
704
|
-
orgUnitId: PropTypes.any,
|
|
705
690
|
};
|
|
706
691
|
export default SlideBoxContent;
|
|
@@ -25,9 +25,6 @@ import {isLoading as isLoadingSelector} from './selectors';
|
|
|
25
25
|
import messages from './messages';
|
|
26
26
|
import { MAP_TEMPLATE } from '../WeChat/Wrapper/constants';
|
|
27
27
|
import { makeSelectFetchingCmsData } from '../Email/selectors';
|
|
28
|
-
import {IMAGE, VIDEO } from '../Facebook/Advertisement/constant';
|
|
29
|
-
import { CREATIVE } from '../Facebook/constants';
|
|
30
|
-
|
|
31
28
|
|
|
32
29
|
const classPrefix = 'add-creatives-section';
|
|
33
30
|
|
|
@@ -54,6 +51,7 @@ class Creatives extends React.Component {
|
|
|
54
51
|
currentChannel: this.props.channel || 'sms',
|
|
55
52
|
weChatTemplateType: '',
|
|
56
53
|
weChatMaptemplateStep: 0,
|
|
54
|
+
|
|
57
55
|
};
|
|
58
56
|
this.creativesTemplateSteps = {
|
|
59
57
|
1: 'modeSelection',
|
|
@@ -76,12 +74,8 @@ class Creatives extends React.Component {
|
|
|
76
74
|
this.setState({templateNameExists: false});
|
|
77
75
|
}
|
|
78
76
|
|
|
79
|
-
onSelectTemplate = (template
|
|
80
|
-
|
|
81
|
-
if (fbAdManager) {
|
|
82
|
-
data.fbAdManager = fbAdManager;
|
|
83
|
-
}
|
|
84
|
-
this.setState(data);
|
|
77
|
+
onSelectTemplate = (template) => {
|
|
78
|
+
this.setState({ slidBoxContent: 'editTemplate', templateData: template });
|
|
85
79
|
};
|
|
86
80
|
onPreviewTemplate = (template) => {
|
|
87
81
|
const templateData = template;
|
|
@@ -93,12 +87,8 @@ class Creatives extends React.Component {
|
|
|
93
87
|
onEditTemplate = () => {
|
|
94
88
|
this.setState({ slidBoxContent: 'editTemplate', showSlideBox: true });
|
|
95
89
|
};
|
|
96
|
-
onCreateNew = (
|
|
97
|
-
|
|
98
|
-
if (fbAdManager) {
|
|
99
|
-
data.fbAdManager = fbAdManager;
|
|
100
|
-
}
|
|
101
|
-
this.setState(data);
|
|
90
|
+
onCreateNew = () => {
|
|
91
|
+
this.setState({ slidBoxContent: 'createTemplate', showSlideBox: true });
|
|
102
92
|
};
|
|
103
93
|
|
|
104
94
|
onShowTemplates = () => {
|
|
@@ -230,64 +220,11 @@ class Creatives extends React.Component {
|
|
|
230
220
|
break;
|
|
231
221
|
}
|
|
232
222
|
case constants.FACEBOOK: {
|
|
233
|
-
|
|
234
|
-
|
|
235
|
-
|
|
236
|
-
|
|
237
|
-
|
|
238
|
-
fbContentType,
|
|
239
|
-
} = templateData || {};
|
|
240
|
-
const fBContent = fbCreativeList;
|
|
241
|
-
const facebookCreativeList = [];
|
|
242
|
-
fBContent.forEach((obj) => {
|
|
243
|
-
const data = cloneDeep(obj);
|
|
244
|
-
const {subType, linkDescription, imageLink, websiteLink, videoId, videoName, videoUrl} = obj || {};
|
|
245
|
-
delete data.linkDescription;
|
|
246
|
-
delete data.websiteLink;
|
|
247
|
-
data.linkDesc = linkDescription;
|
|
248
|
-
data.webSiteLink = websiteLink;
|
|
249
|
-
data.type = creativeType;
|
|
250
|
-
switch (subType) {
|
|
251
|
-
case IMAGE:
|
|
252
|
-
data.imgSrc = imageLink;
|
|
253
|
-
delete data.imageLink;
|
|
254
|
-
break;
|
|
255
|
-
case VIDEO:
|
|
256
|
-
data.video = {
|
|
257
|
-
previewImageUrl: imageLink,
|
|
258
|
-
videoId,
|
|
259
|
-
videoSrc: videoUrl,
|
|
260
|
-
videoName,
|
|
261
|
-
};
|
|
262
|
-
delete data.imageLink;
|
|
263
|
-
break;
|
|
264
|
-
default:
|
|
265
|
-
break;
|
|
266
|
-
}
|
|
267
|
-
facebookCreativeList.push(data);
|
|
268
|
-
});
|
|
269
|
-
creativesTemplateData = {
|
|
270
|
-
versions: {
|
|
271
|
-
base: {
|
|
272
|
-
content: {
|
|
273
|
-
FacebookAd: {...facebookCreativeList},
|
|
274
|
-
pageOrgUnitId: this.props.orgUnitId,
|
|
275
|
-
},
|
|
276
|
-
},
|
|
277
|
-
},
|
|
278
|
-
type: constants.FACEBOOK,
|
|
279
|
-
edit: true,
|
|
280
|
-
selectedFacebookAccount,
|
|
281
|
-
fbContentType
|
|
282
|
-
};
|
|
283
|
-
} else {
|
|
284
|
-
creativesTemplateData = {
|
|
285
|
-
selectedMarketingObjective: templateData.selectedMarketingObjective,
|
|
286
|
-
edit: true,
|
|
287
|
-
type: channel,
|
|
288
|
-
fbContentType: templateData.fbContentType
|
|
289
|
-
};
|
|
290
|
-
}
|
|
223
|
+
creativesTemplateData = {
|
|
224
|
+
selectedMarketingObjective: templateData.selectedMarketingObjective,
|
|
225
|
+
edit: true,
|
|
226
|
+
type: channel,
|
|
227
|
+
};
|
|
291
228
|
break;
|
|
292
229
|
}
|
|
293
230
|
case constants.LINE: {
|
|
@@ -439,50 +376,6 @@ class Creatives extends React.Component {
|
|
|
439
376
|
};
|
|
440
377
|
}
|
|
441
378
|
break;
|
|
442
|
-
case constants.FACEBOOK: {
|
|
443
|
-
if (template.value) {
|
|
444
|
-
const FacebookAd = template?.value?.versions?.base?.content?.FacebookAd;
|
|
445
|
-
const type = FacebookAd[0].type;
|
|
446
|
-
const {accountId} = this.props.Templates.selectedFacebookAccount || template.value || {};
|
|
447
|
-
const facebookCreativeList = [];
|
|
448
|
-
const fBContent = Object.values(FacebookAd);
|
|
449
|
-
fBContent.forEach((obj) => {
|
|
450
|
-
const data = cloneDeep(obj);
|
|
451
|
-
const {subType, linkDesc, imgSrc, webSiteLink, video} = obj;
|
|
452
|
-
delete data.type;
|
|
453
|
-
delete data.linkDesc;
|
|
454
|
-
delete data.webSiteLink;
|
|
455
|
-
data.linkDescription = linkDesc;
|
|
456
|
-
data.websiteLink = webSiteLink;
|
|
457
|
-
|
|
458
|
-
switch (subType) {
|
|
459
|
-
case IMAGE:
|
|
460
|
-
data.imageLink = imgSrc;
|
|
461
|
-
delete data.imgSrc;
|
|
462
|
-
break;
|
|
463
|
-
case VIDEO:
|
|
464
|
-
data.imageLink = video.previewImageUrl;
|
|
465
|
-
data.videoId = video.videoId;
|
|
466
|
-
data.videoUrl = video.videoSrc;
|
|
467
|
-
data.videoName = video.videoName;
|
|
468
|
-
delete data.video;
|
|
469
|
-
break;
|
|
470
|
-
default:
|
|
471
|
-
break;
|
|
472
|
-
}
|
|
473
|
-
facebookCreativeList.push(data);
|
|
474
|
-
});
|
|
475
|
-
templateData = {
|
|
476
|
-
fbContentType: CREATIVE,
|
|
477
|
-
creativeType: type,
|
|
478
|
-
facebookCreativeList,
|
|
479
|
-
channel: constants.FACEBOOK,
|
|
480
|
-
accountId,
|
|
481
|
-
selectedMarketingObjective: template.value.selectedMarketingObjective,
|
|
482
|
-
};
|
|
483
|
-
}
|
|
484
|
-
}
|
|
485
|
-
break;
|
|
486
379
|
default:
|
|
487
380
|
break;
|
|
488
381
|
}
|
|
@@ -685,8 +578,8 @@ class Creatives extends React.Component {
|
|
|
685
578
|
return false;
|
|
686
579
|
}
|
|
687
580
|
shouldShowHeader = () => {
|
|
688
|
-
const {currentChannel
|
|
689
|
-
if (currentChannel
|
|
581
|
+
const {currentChannel} = this.state;
|
|
582
|
+
if (currentChannel === constants.FACEBOOK) {
|
|
690
583
|
return false;
|
|
691
584
|
}
|
|
692
585
|
return true;
|
|
@@ -729,7 +622,6 @@ class Creatives extends React.Component {
|
|
|
729
622
|
campaignSettings={this.props.Templates.campaignSettings}
|
|
730
623
|
location={this.props.location}
|
|
731
624
|
messageDetails={this.props.messageDetails}
|
|
732
|
-
showDisabledFBInfo={this.props.showDisabledFBInfo}
|
|
733
625
|
getFormData={this.getFormData}
|
|
734
626
|
onCallTaskSubmit={this.onCallTaskSubmit}
|
|
735
627
|
onCreateNew={this.onCreateNew}
|
|
@@ -745,7 +637,6 @@ class Creatives extends React.Component {
|
|
|
745
637
|
onEnterTemplateName={this.onEnterTemplateName}
|
|
746
638
|
onRemoveTemplateName={this.onRemoveTemplateName}
|
|
747
639
|
onResetStep={this.resetStep}
|
|
748
|
-
fbAdManager={this.state.fbAdManager}
|
|
749
640
|
cap={cap}
|
|
750
641
|
setIsLoadingContent={this.setIsLoadingContent}
|
|
751
642
|
onMobilepushModeChange={this.onMobilepushModeChange}
|
|
@@ -770,8 +661,6 @@ class Creatives extends React.Component {
|
|
|
770
661
|
handleClose={this.handleCloseSlideBox}
|
|
771
662
|
onFTPSubmit={getCreativesData}
|
|
772
663
|
editor={editor}
|
|
773
|
-
messageStrategy={this.props.strategy}
|
|
774
|
-
orgUnitId={this.props.orgUnitId}
|
|
775
664
|
/>
|
|
776
665
|
}
|
|
777
666
|
footer={this.shouldShowFooter() &&
|
|
@@ -824,8 +713,6 @@ Creatives.propTypes = {
|
|
|
824
713
|
selectedWeChatAccount: PropTypes.object,
|
|
825
714
|
Templates: PropTypes.object,
|
|
826
715
|
selectedAccount: PropTypes.object,
|
|
827
|
-
strategy: PropTypes.string,
|
|
828
|
-
orgUnitId: PropTypes.number,
|
|
829
716
|
};
|
|
830
717
|
const mapStatesToProps = () => createStructuredSelector({
|
|
831
718
|
isLoading: isLoadingSelector(),
|
|
@@ -84,12 +84,10 @@ export const Advertisement = (props) => {
|
|
|
84
84
|
actions,
|
|
85
85
|
fbADData = {},
|
|
86
86
|
onCreateComplete,
|
|
87
|
-
templateData
|
|
87
|
+
templateData,
|
|
88
88
|
params,
|
|
89
89
|
getFormSubscriptionData,
|
|
90
90
|
facebookTemplateData,
|
|
91
|
-
selectedMarketingObjective,
|
|
92
|
-
orgUnitId,
|
|
93
91
|
} = props;
|
|
94
92
|
const {
|
|
95
93
|
formatMessage,
|
|
@@ -132,7 +130,7 @@ export const Advertisement = (props) => {
|
|
|
132
130
|
orgUnitFacebookPageSettingsMap = {},
|
|
133
131
|
employeeAccessToken: accessToken = "",
|
|
134
132
|
accountId = "",
|
|
135
|
-
} = selectedFacebookAccount
|
|
133
|
+
} = selectedFacebookAccount;
|
|
136
134
|
const { pageAccessToken, pageId: pId } = orgUnitFacebookPageSettingsMap[pageId] || {};
|
|
137
135
|
videoData = {
|
|
138
136
|
accessToken,
|
|
@@ -162,7 +160,7 @@ export const Advertisement = (props) => {
|
|
|
162
160
|
}, [paramObj.id]);
|
|
163
161
|
|
|
164
162
|
useEffect(() => {
|
|
165
|
-
if (params
|
|
163
|
+
if ((params && params.id) || (templateData || {}).edit) {
|
|
166
164
|
const { FacebookAd = [], pageOrgUnitId: editPageId} = get(templateData, `versions.base.content`) || get(fbADData, `templateDetails.versions.base.content`) || {};
|
|
167
165
|
const editMessageTitle = (templateData || {}).name || get(fbADData, 'templateDetails.name');
|
|
168
166
|
const editFBContent = Object.values(FacebookAd);
|
|
@@ -221,7 +219,6 @@ export const Advertisement = (props) => {
|
|
|
221
219
|
}
|
|
222
220
|
}, [fbADData[`templateDetails`] || templateData]);
|
|
223
221
|
|
|
224
|
-
|
|
225
222
|
const CustomToolTip = useCallback((msg) => <CapTooltipWithInfo
|
|
226
223
|
infoIconProps={{svgProps: {width: 12, height: 12}, style: {marginLeft: 5}}}
|
|
227
224
|
title={msg}
|
|
@@ -354,7 +351,8 @@ export const Advertisement = (props) => {
|
|
|
354
351
|
}
|
|
355
352
|
messageData.push(data);
|
|
356
353
|
});
|
|
357
|
-
|
|
354
|
+
|
|
355
|
+
return {
|
|
358
356
|
versions: {
|
|
359
357
|
base: {
|
|
360
358
|
content: {
|
|
@@ -366,17 +364,12 @@ export const Advertisement = (props) => {
|
|
|
366
364
|
type: "FACEBOOK",
|
|
367
365
|
name: messageTitle,
|
|
368
366
|
};
|
|
369
|
-
if (!isFullMode) {
|
|
370
|
-
finalResponse = {...finalResponse, selectedMarketingObjective, accountId};
|
|
371
|
-
}
|
|
372
|
-
return finalResponse;
|
|
373
367
|
}, [carouselData,
|
|
374
368
|
pageId,
|
|
375
369
|
messageTitle,
|
|
376
370
|
primaryText,
|
|
377
371
|
callToAction,
|
|
378
|
-
displayLink
|
|
379
|
-
selectedMarketingObjective]);
|
|
372
|
+
displayLink]);
|
|
380
373
|
|
|
381
374
|
const onCreateFacebookAd = useCallback( () => {
|
|
382
375
|
actions.createTemplate(
|
|
@@ -452,7 +445,6 @@ export const Advertisement = (props) => {
|
|
|
452
445
|
updateMessageTitle(val);
|
|
453
446
|
}, [messageTitle]);
|
|
454
447
|
|
|
455
|
-
|
|
456
448
|
const isDisableDone = useCallback((isPreview) => {
|
|
457
449
|
let flag = false;
|
|
458
450
|
if (primaryText === "" ) {
|
|
@@ -502,7 +494,8 @@ export const Advertisement = (props) => {
|
|
|
502
494
|
selectedAd,
|
|
503
495
|
]
|
|
504
496
|
);
|
|
505
|
-
|
|
497
|
+
|
|
498
|
+
const isDisableContinue = () => messageTitle.trim() === "" || selectedAd === "";
|
|
506
499
|
|
|
507
500
|
const onClickContinue = useCallback(() => { updateStep('createFacebookAd'); }, [step]);
|
|
508
501
|
|
|
@@ -811,37 +804,20 @@ export const Advertisement = (props) => {
|
|
|
811
804
|
setPageId(value);
|
|
812
805
|
}, [pageId]);
|
|
813
806
|
|
|
814
|
-
const selectedFacebookAccount =
|
|
815
|
-
const {orgUnitFacebookPageSettingsMap = {}, employeeAccessToken: accessToken = "", accountId = "" } = selectedFacebookAccount
|
|
807
|
+
const selectedFacebookAccount = get(facebookTemplateData, 'selectedFacebookAccount', {});
|
|
808
|
+
const {orgUnitFacebookPageSettingsMap = {}, employeeAccessToken: accessToken = "", accountId = "" } = selectedFacebookAccount;
|
|
816
809
|
|
|
817
|
-
const
|
|
810
|
+
const getPageAccessOrgs = useCallback(() => {
|
|
811
|
+
const {status, data } = fbADData.orgOuData || {};
|
|
812
|
+
const pageAccessOrgsOptions = [];
|
|
818
813
|
const { proxyOrgList } = JSON.parse(window.localStorage.getItem('user'));
|
|
819
814
|
const orgId = window.localStorage.getItem('orgID');
|
|
820
815
|
const orgName = (
|
|
821
816
|
proxyOrgList.find(({ orgID }) => orgID === Number(orgId)) || {}
|
|
822
817
|
).orgName;
|
|
823
|
-
|
|
824
|
-
}
|
|
825
|
-
const getPageAccessOrgs = useCallback(() => {
|
|
826
|
-
const {status, data } = fbADData.orgOuData || {};
|
|
827
|
-
const pageAccessOrgsOptions = [];
|
|
828
|
-
const orgName = getOrgName()
|
|
829
|
-
if (!status) {
|
|
830
|
-
// !status is the case of library
|
|
831
|
-
//if org id is the parent org
|
|
832
|
-
if (orgUnitFacebookPageSettingsMap[-1] && !pageId) {
|
|
833
|
-
setPageId(-1);
|
|
834
|
-
}
|
|
835
|
-
if (orgUnitFacebookPageSettingsMap[-1]) {
|
|
836
|
-
pageAccessOrgsOptions.push({label: orgName, value: -1});
|
|
837
|
-
}
|
|
838
|
-
// if we are coming from default startegy and calling templates from facebook/index.js
|
|
839
|
-
if (!pageId && orgUnitId && orgUnitFacebookPageSettingsMap[orgUnitId]) {
|
|
840
|
-
setPageId(orgUnitId);
|
|
841
|
-
}
|
|
842
|
-
} else if (status === 'SUCCESS') {
|
|
818
|
+
if (status === 'SUCCESS') {
|
|
843
819
|
Object.keys(data).forEach((obj) => {
|
|
844
|
-
if ((orgUnitFacebookPageSettingsMap[data[obj]] || {}).pageAccessToken
|
|
820
|
+
if ((orgUnitFacebookPageSettingsMap[data[obj]] || {}).pageAccessToken) {
|
|
845
821
|
pageAccessOrgsOptions.push({label: obj, value: data[obj]});
|
|
846
822
|
}
|
|
847
823
|
});
|
|
@@ -859,12 +835,8 @@ export const Advertisement = (props) => {
|
|
|
859
835
|
|
|
860
836
|
const options = getPageAccessOrgs() || [];
|
|
861
837
|
const { data = {} } = fbADData.orgOuData || {};
|
|
862
|
-
const
|
|
863
|
-
|
|
864
|
-
if(data[selectedPageName] === -1){
|
|
865
|
-
selectedPageName = orgName;
|
|
866
|
-
}
|
|
867
|
-
return ( (step === 'modeSelection' && (isEmpty(templateData) || templateData?.mode === "create")) ?
|
|
838
|
+
const selectedPageName = Object.keys(data).find((key) => data[key] === pageId);
|
|
839
|
+
return ( (step === 'modeSelection') ?
|
|
868
840
|
( <CapSpin spinning={adSpinLoader} className="add-facebook-ad-section">
|
|
869
841
|
<div style={{ position: 'fixed', top: '25px', zIndex: 1}}>
|
|
870
842
|
<CapHeader
|
|
@@ -873,27 +845,25 @@ export const Advertisement = (props) => {
|
|
|
873
845
|
className={"cap-header-facebook-ad"}
|
|
874
846
|
/>
|
|
875
847
|
</div>
|
|
876
|
-
|
|
877
|
-
|
|
878
|
-
|
|
879
|
-
|
|
880
|
-
|
|
881
|
-
|
|
882
|
-
|
|
883
|
-
|
|
884
|
-
|
|
885
|
-
|
|
886
|
-
|
|
887
|
-
|
|
888
|
-
|
|
889
|
-
|
|
890
|
-
|
|
891
|
-
|
|
892
|
-
|
|
893
|
-
|
|
894
|
-
|
|
895
|
-
></CapSelect>
|
|
896
|
-
</>}
|
|
848
|
+
<CapInput
|
|
849
|
+
id={`fbAd_input`}
|
|
850
|
+
onChange={onTextTitleChange}
|
|
851
|
+
className="text-template-title"
|
|
852
|
+
defaultValue={messageTitle || ''}
|
|
853
|
+
value={messageTitle || ''}
|
|
854
|
+
style={{marginBottom: 27, width: '762px'}}
|
|
855
|
+
size="default"
|
|
856
|
+
label={formatMessage(messages.creativeName)}
|
|
857
|
+
/>
|
|
858
|
+
{isFullMode && <CapSelect
|
|
859
|
+
label={formatMessage(messages.facebookPage)}
|
|
860
|
+
key={"select-facebook-page"}
|
|
861
|
+
onChange={onChangeFacebookPage}
|
|
862
|
+
options={options}
|
|
863
|
+
defaultValue={(options[0] || {} ).value}
|
|
864
|
+
value={pageId || (options[0] || {} ).value}
|
|
865
|
+
style={{marginBottom: 27, width: '372px'}}
|
|
866
|
+
></CapSelect>}
|
|
897
867
|
<CapHeading
|
|
898
868
|
type="h4"
|
|
899
869
|
style={{marginBottom: 11}}
|
|
@@ -917,17 +887,8 @@ export const Advertisement = (props) => {
|
|
|
917
887
|
</FbAdFooter>
|
|
918
888
|
</CapSpin> ) : (
|
|
919
889
|
<CapSpin spinning={spinLoader}>
|
|
920
|
-
|
|
921
|
-
<
|
|
922
|
-
inline
|
|
923
|
-
title={formatMessage(messages.newFacebookCreatives)}
|
|
924
|
-
className={"cap-header-facebook-ad"}
|
|
925
|
-
/>
|
|
926
|
-
</div>}
|
|
927
|
-
<div className="add-facebook-ad-section">
|
|
928
|
-
<CapRow >
|
|
929
|
-
<CapColumn span={12}>
|
|
930
|
-
{isFullMode && <>
|
|
890
|
+
<CapRow className="add-facebook-ad-section" >
|
|
891
|
+
<div className="cap-header-facebook-ad">
|
|
931
892
|
<CapHeading
|
|
932
893
|
type="h2"
|
|
933
894
|
className="truncate-text"
|
|
@@ -945,7 +906,8 @@ export const Advertisement = (props) => {
|
|
|
945
906
|
title={<FormattedMessage {...messages.creativesTemplatesEditName}/>}
|
|
946
907
|
onClick={onClickEditName}
|
|
947
908
|
/>}
|
|
948
|
-
|
|
909
|
+
</div>
|
|
910
|
+
<CapColumn span={12}>
|
|
949
911
|
{isFullMode && <><CapHeading
|
|
950
912
|
type="h4"
|
|
951
913
|
style={{marginBottom: 4}}
|
|
@@ -996,7 +958,6 @@ export const Advertisement = (props) => {
|
|
|
996
958
|
/>
|
|
997
959
|
</CapColumn>
|
|
998
960
|
</CapRow>
|
|
999
|
-
</div>
|
|
1000
961
|
<FbAdFooter>
|
|
1001
962
|
<CapButton
|
|
1002
963
|
onClick={onDoneCallback()}
|
|
@@ -1020,8 +981,8 @@ Advertisement.propTypes = {
|
|
|
1020
981
|
facebookTemplateData: PropTypes.object,
|
|
1021
982
|
templateData: PropTypes.object,
|
|
1022
983
|
params: PropTypes.object,
|
|
1023
|
-
selectedMarketingObjective: PropTypes.any,
|
|
1024
984
|
|
|
1025
985
|
};
|
|
1026
986
|
|
|
1027
987
|
export default injectIntl(Advertisement);
|
|
988
|
+
|