Skip to content

Commit

Permalink
DCN-112 - Add promo product for Magento integration
Browse files Browse the repository at this point in the history
  • Loading branch information
hejtmii committed Mar 21, 2019
1 parent 1257368 commit ef2de5a
Show file tree
Hide file tree
Showing 7 changed files with 68 additions and 39 deletions.
56 changes: 20 additions & 36 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand Down
2 changes: 1 addition & 1 deletion src/Client.js
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
39 changes: 39 additions & 0 deletions src/Components/MagentoProductPromo.js
Original file line number Diff line number Diff line change
@@ -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;
3 changes: 3 additions & 0 deletions src/Models/article.js
Original file line number Diff line number Diff line change
Expand Up @@ -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';
}
Expand Down
2 changes: 2 additions & 0 deletions src/Pages/Article.js
Original file line number Diff line number Diff line change
Expand Up @@ -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 => {
Expand Down Expand Up @@ -124,6 +125,7 @@ class Article extends Component {
</div>
</div>
<div className="row">{bodyCopyElement}</div>
<MagentoProductPromo product={article.promoForMagentoProduct} />
</article>
</div>
);
Expand Down
3 changes: 2 additions & 1 deletion src/Stores/Article.js
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
Expand Down

0 comments on commit ef2de5a

Please sign in to comment.