@capillarytech/creatives-library 7.6.4 → 7.6.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.
Binary file
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@capillarytech/creatives-library",
3
3
  "author": "meharaj",
4
- "version": "7.6.4",
4
+ "version": "7.6.6",
5
5
  "description": "Capillary creatives ui",
6
6
  "main": "./index.js",
7
7
  "module": "./index.es.js",
@@ -563,6 +563,7 @@ function SlideBoxContent(props) {
563
563
  getFormSubscriptionData={getFormData}
564
564
  messageStrategy={messageStrategy}
565
565
  fbAdManger={fbAdManger}
566
+ onSelectTemplate={onSelectTemplate}
566
567
  />
567
568
  )
568
569
  }
@@ -579,6 +580,7 @@ function SlideBoxContent(props) {
579
580
  id: templateData._id,
580
581
  }}
581
582
  getFormSubscriptionData={getFormData}
583
+ fbAdManger={fbAdManger}
582
584
  />
583
585
  )
584
586
  }
@@ -73,8 +73,12 @@ class Creatives extends React.Component {
73
73
  this.setState({templateNameExists: false});
74
74
  }
75
75
 
76
- onSelectTemplate = (template) => {
77
- this.setState({ slidBoxContent: 'editTemplate', templateData: template });
76
+ onSelectTemplate = (template, fbAdManger) => {
77
+ if (fbAdManger) {
78
+ this.setState({ slidBoxContent: 'editTemplate', templateData: template, fbAdManger});
79
+ } else {
80
+ this.setState({ slidBoxContent: 'editTemplate', templateData: template });
81
+ }
78
82
  };
79
83
  onPreviewTemplate = (template) => {
80
84
  const templateData = template;
@@ -379,6 +383,49 @@ class Creatives extends React.Component {
379
383
  };
380
384
  }
381
385
  break;
386
+ case constants.FACEBOOK: {
387
+ if (template.value) {
388
+ const FacebookAd = template.value.versions.base.content.FacebookAd;
389
+ const type = FacebookAd[0].type;
390
+ const {accountId, orgUnitFacebookPageSettingsMap = {}} = this.props.Templates.selectedFacebookAccount;
391
+ const facebookCreativeList = [];
392
+ const fBContent = Object.values(FacebookAd);
393
+ fBContent.forEach((obj) => {
394
+ const data = cloneDeep(obj);
395
+ const {subType, linkDesc, imgSrc, webSiteLink} = obj;
396
+ delete data.type;
397
+ delete data.linkDesc;
398
+ delete data.webSiteLink;
399
+ data.linkDescription = linkDesc;
400
+ data.websiteLink = webSiteLink;
401
+
402
+ switch (subType) {
403
+ case "IMAGE":
404
+ data.imageLink = imgSrc;
405
+ delete data.imgSrc;
406
+ break;
407
+ case "VIDEO":
408
+ data.imageLink = "www.kuch_bhi_link.com";
409
+ data.videoId = "123";
410
+ break;
411
+ case "CAROUSEL":
412
+ break;
413
+ default:
414
+ break;
415
+ }
416
+ facebookCreativeList.push(data);
417
+ });
418
+ templateData = {
419
+ fbContentType: "CREATIVE",
420
+ creativeType: type,
421
+ facebookCreativeList,
422
+ channel: "FACEBOOK",
423
+ accountId,
424
+ selectedMarketingObjective: template.value.selectedMarketingObjective,
425
+ };
426
+ }
427
+ }
428
+ break;
382
429
  default:
383
430
  break;
384
431
  }
@@ -581,8 +628,8 @@ class Creatives extends React.Component {
581
628
  return false;
582
629
  }
583
630
  shouldShowHeader = () => {
584
- const {currentChannel} = this.state;
585
- if (currentChannel === constants.FACEBOOK) {
631
+ const {currentChannel, slidBoxContent} = this.state;
632
+ if (currentChannel.toUpperCase() === constants.FACEBOOK && slidBoxContent === 'createTemplate') {
586
633
  return false;
587
634
  }
588
635
  return true;
@@ -3,6 +3,8 @@ import React, { useState, useEffect, useCallback} from "react";
3
3
  import { injectIntl, FormattedMessage, intlShape } from 'react-intl';
4
4
  import { isUrl } from '../../Line/Container/Wrapper/utils';
5
5
  import get from 'lodash/get';
6
+ import isEmpty from 'lodash/isEmpty';
7
+
6
8
  import {
7
9
  CapInput,
8
10
  CapRadioCard,
@@ -86,6 +88,7 @@ export const Advertisement = (props) => {
86
88
  params,
87
89
  getFormSubscriptionData,
88
90
  facebookTemplateData,
91
+ selectedMarketingObjective,
89
92
  } = props;
90
93
  const {
91
94
  formatMessage,
@@ -349,8 +352,7 @@ export const Advertisement = (props) => {
349
352
  }
350
353
  messageData.push(data);
351
354
  });
352
-
353
- return {
355
+ let finalResponse = {
354
356
  versions: {
355
357
  base: {
356
358
  content: {
@@ -362,12 +364,17 @@ export const Advertisement = (props) => {
362
364
  type: "FACEBOOK",
363
365
  name: messageTitle,
364
366
  };
367
+ if (!isFullMode) {
368
+ finalResponse = {...finalResponse, selectedMarketingObjective};
369
+ }
370
+ return finalResponse;
365
371
  }, [carouselData,
366
372
  pageId,
367
373
  messageTitle,
368
374
  primaryText,
369
375
  callToAction,
370
- displayLink]);
376
+ displayLink,
377
+ selectedMarketingObjective]);
371
378
 
372
379
  const onCreateFacebookAd = useCallback( () => {
373
380
  actions.createTemplate(
@@ -829,7 +836,7 @@ export const Advertisement = (props) => {
829
836
  const options = getPageAccessOrgs() || [];
830
837
  const { data = {} } = fbADData.orgOuData || {};
831
838
  const selectedPageName = Object.keys(data).find((key) => data[key] === pageId);
832
- return ( (step === 'modeSelection') ?
839
+ return ( (step === 'modeSelection' && isEmpty(templateData)) ?
833
840
  ( <CapSpin spinning={adSpinLoader} className="add-facebook-ad-section">
834
841
  <div style={{ position: 'fixed', top: '25px', zIndex: 1}}>
835
842
  <CapHeader
@@ -974,6 +981,7 @@ Advertisement.propTypes = {
974
981
  facebookTemplateData: PropTypes.object,
975
982
  templateData: PropTypes.object,
976
983
  params: PropTypes.object,
984
+ selectedMarketingObjective: PropTypes.any,
977
985
 
978
986
  };
979
987
 
@@ -194,6 +194,7 @@ const Facebook = (props) => {
194
194
  onSelectTemplate,
195
195
  createNew,
196
196
  fbAdManger,
197
+ getFormSubscriptionData,
197
198
  } = props;
198
199
  const {
199
200
  selectedMarketingObjective: fbMarketingObjectiveValue = VALUE_REACH,
@@ -347,7 +348,7 @@ const Facebook = (props) => {
347
348
  <div className="ad-section">
348
349
  <CapHeading type="h4" style={{marginBottom: 17}}>
349
350
  <FormattedMessage
350
- {...messages.adManagerHeading}
351
+ {...messages.adManagerHeading}
351
352
  />
352
353
  </CapHeading>
353
354
  <CapRadioGroup
@@ -359,14 +360,14 @@ const Facebook = (props) => {
359
360
  />
360
361
  {adManager === AD_MANAGER ? <>
361
362
  <div className="account-section-container">
362
- <CapLabel type="label1">
363
- <FormattedMessage {...messages.fbAdsDescription} />
364
- </CapLabel>
365
- </div>
363
+ <CapLabel type="label1">
364
+ <FormattedMessage {...messages.fbAdsDescription} />
365
+ </CapLabel>
366
+ </div>
366
367
 
367
368
 
368
369
  <CapRow span={12} type="flex">
369
- <CapColumn span={6}>
370
+ <CapColumn span={6}>
370
371
  <CapCustomCard
371
372
  type="Facebook"
372
373
  FBDynamicComponent={() => (
@@ -378,7 +379,7 @@ const Facebook = (props) => {
378
379
  )}
379
380
  />
380
381
  </CapColumn>
381
- <CapColumn span={16}>
382
+ <CapColumn span={16}>
382
383
  <ul className="parameter-list">
383
384
  {adSetParameters.map((parameter, index) => (
384
385
  <li key={parameter} className="parameter-list-item">
@@ -392,7 +393,7 @@ const Facebook = (props) => {
392
393
  ))}
393
394
  </ul>
394
395
  </CapColumn>
395
- </CapRow></> : <CapLabel type="label1"><FormattedMessage {...messages.capAdManagerHeading}/></CapLabel>}
396
+ </CapRow></> : <CapLabel type="label1"><FormattedMessage {...messages.capAdManagerHeading}/></CapLabel>}
396
397
 
397
398
  </div>
398
399
  </div>
@@ -406,7 +407,7 @@ const Facebook = (props) => {
406
407
  </div>
407
408
  ) :
408
409
  <div style={{height: '1200px'}}>
409
- <Advertisement
410
+ <Advertisement
410
411
  isFullMode={isFullMode}
411
412
  actions={facebookActions}
412
413
  fbADData={fbADData}
@@ -415,8 +416,10 @@ const Facebook = (props) => {
415
416
  params={params}
416
417
  facebookTemplateData={facebookTemplateData}
417
418
  messageStrategy={messageStrategy}
419
+ getFormSubscriptionData={getFormSubscriptionData}
420
+ selectedMarketingObjective={selectedMarketingObjective}
418
421
  />
419
- </div>
422
+ </div>
420
423
  );
421
424
  };
422
425
 
@@ -435,11 +438,11 @@ Facebook.propTypes = {
435
438
  onCreateComplete: PropTypes.func,
436
439
  facebookTemplateData: PropTypes.object,
437
440
  messageStrategy: PropTypes.string,
441
+ getFormSubscriptionData: PropTypes.func,
438
442
  };
439
443
 
440
444
  Facebook.defaultProps = {
441
445
  marketingObjectiveList: [""],
442
-
443
446
  };
444
447
 
445
448
  const mapStateToProps = createStructuredSelector({
@@ -1143,7 +1143,7 @@ export class Templates extends React.Component { // eslint-disable-line react/pr
1143
1143
  if (this.isEnabledInLibraryModule("callCreateFromProps")) {
1144
1144
  if (this.props.fbAdManger === "CREATIVE") {
1145
1145
  this.props.createNew(this.props.fbAdManger);
1146
- } else{
1146
+ } else {
1147
1147
  this.props.createNew();
1148
1148
  }
1149
1149
  } else if (ev.key && (ev.key.toLowerCase() === "text" || ev.key.toLowerCase() === "image")) {
@@ -1416,7 +1416,7 @@ export class Templates extends React.Component { // eslint-disable-line react/pr
1416
1416
  }
1417
1417
  }
1418
1418
  if (this.isEnabledInLibraryModule("callSelectFromProps")) {
1419
- this.props.onSelectTemplate(id);
1419
+ this.props.onSelectTemplate(this.selectTemplate(id), this.props.fbAdManger);
1420
1420
  } else {
1421
1421
  if (this.state.channel.toLowerCase() === 'ebill') {
1422
1422
  pathName = `/ebill/edit/${id}`;
@@ -1428,6 +1428,9 @@ export class Templates extends React.Component { // eslint-disable-line react/pr
1428
1428
  }
1429
1429
  }
1430
1430
 
1431
+ selectTemplate = (id) => find(this.props.TemplatesList, {_id: id})
1432
+
1433
+
1431
1434
  handlePreviewClick(template, modeType) {
1432
1435
  this.togglePreview();
1433
1436
  const templateInfo = cloneDeep(template);
@@ -208,7 +208,7 @@ export class TemplatesV2 extends React.Component { // eslint-disable-line react/
208
208
  router={this.props.router}
209
209
  isFullMode={this.props.isFullMode}
210
210
  createNew={this.props.createNew}
211
- onSelectTemplate={(id) => this.props.onSelectTemplate(this.selectTemplate(id))}
211
+ onSelectTemplate={this.props.onSelectTemplate}
212
212
  renderNewCardGrid={this.getTemplateDataForGrid}
213
213
  handlePeviewTemplate={this.props.handlePeviewTemplate}
214
214
  messageStrategy={this.props.messageStrategy}