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