Skip to content
Permalink
Browse files

DCN-112 - Add promo product for Magento integration

  • Loading branch information...
kenticomartinh committed Mar 21, 2019
1 parent 1257368 commit ef2de5ad5798a82d6c909e3154b5cdbb9582db79
Showing with 68 additions and 39 deletions.
  1. +20 −36 package-lock.json
  2. +1 −1 package.json
  3. +1 −1 src/Client.js
  4. +39 −0 src/Components/MagentoProductPromo.js
  5. +3 −0 src/Models/article.js
  6. +2 −0 src/Pages/Article.js
  7. +2 −1 src/Stores/Article.js

Some generated files are not rendered by default. Learn more.

@@ -15,7 +15,7 @@
"@chevtek/react-spinners": "^1.0.5",
"google-maps-react": "^2.0.2",
"immutable": "^3.8.2",
"kentico-cloud-delivery": "^5.1.0",
"kentico-cloud-delivery": "^5.7.2",
"lodash": "^4.17.11",
"qs": "^6.5.2",
"react": "^16.4.2",
@@ -22,7 +22,7 @@ import { HostedVideo } from './Models/hosted_video';
import { Office } from './Models/office';
import { Tweet } from './Models/tweet';

const projectId = '';
const projectId = '471f9f4c-4f97-009b-a0b8-79db2558e63f';
const previewApiKey = '';

// configure type resolvers
@@ -0,0 +1,39 @@
import React from 'react';

const MagentoProductPromo = props => {
const value =
props.product && props.product.value && JSON.parse(props.product.value);

if (!value) {
return null;
}

const imageLink = value.previewUrl ? (
<img alt={value.title} src={value.previewUrl} title={value.title} />
) : (
<div style={{ height: '257.15px' }} className="placeholder-tile-image">
{this.props.t('noTeaserValue')}
</div>
);

const storeFrontUrl = `https://demo1-m2.mage.direct/${value.urlKey}.html`;

return (
<div className="row">
<h2>Featured product</h2>
<div className="col-md-6 col-lg-4">
<div className="product-tile">
<h1 className="product-heading">{value.title}</h1>
<figure className="product-tile-image">{imageLink}</figure>
<div className="product-tile-info">
<a className="btn btn-secondary" href={storeFrontUrl}>
See more details
</a>
</div>
</div>
</div>
</div>
);
};

export default MagentoProductPromo;
@@ -50,6 +50,9 @@ export class Article extends ContentItem {
if (fieldName === 'metadata__og_image') {
return 'metadataOgImage';
}
if (fieldName === 'promo_for_magento_product') {
return 'promoForMagentoProduct';
}
if (fieldName === 'related_articles') {
return 'relatedArticles';
}
@@ -5,6 +5,7 @@ import { ArticleStore } from '../Stores/Article';
import RichTextElement from '../Components/RichTextElement';
import { dateFormats } from '../Utilities/LanguageCodes';
import Metadata from '../Components/Metadata';
import MagentoProductPromo from '../Components/MagentoProductPromo';
import { translate } from 'react-translate';

let getState = props => {
@@ -124,6 +125,7 @@ class Article extends Component {
</div>
</div>
<div className="row">{bodyCopyElement}</div>
<MagentoProductPromo product={article.promoForMagentoProduct} />
</article>
</div>
);
@@ -49,7 +49,8 @@ class Article {
'metadata__twitter_site',
'metadata__twitter_creator',
'metadata__twitter_description',
'metadata__twitter_image'
'metadata__twitter_image',
'promo_for_magento_product'
]);

if (language) {

0 comments on commit ef2de5a

Please sign in to comment.
You can’t perform that action at this time.