Skip to content

Commit

Permalink
Leve/hotfix/19 02 release testing (#940)
Browse files Browse the repository at this point in the history
* fix edits by release testing

* rr view edits
  • Loading branch information
levenecav authored Feb 19, 2019
1 parent 0a3da8d commit 074b1e5
Show file tree
Hide file tree
Showing 2 changed files with 40 additions and 15 deletions.
20 changes: 19 additions & 1 deletion src/pages/Store/Product/Product.js
Original file line number Diff line number Diff line change
Expand Up @@ -569,11 +569,29 @@ class Product extends Component<PropsType, StateType> {
{this.makeTabs(longDescription)}
</MediaQuery>
</div>
{/*
<MediaQuery minWidth={992}>
<div styleName="rrBlock">
<RRElement productId={productVariant.rawId} dataVendor="brand" />
</div>
</MediaQuery>
*/}
</Col>
</Row>
</div>
{/*
<MediaQuery maxWidth={991}>
<div styleName="rrBlock">
<RRElement productId={productVariant.rawId} dataVendor="brand" fullWidth />
</div>
</MediaQuery>
*/}
<div styleName="rrBlock">
<RRElement productId={productVariant.rawId} fullWidth />
<RRElement
productId={productVariant.rawId}
title="Similar goods"
fullWidth
/>
</div>
</div>
</ProductContext.Provider>
Expand Down
35 changes: 21 additions & 14 deletions src/pages/Store/Product/RRElement/index.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
// @flow strict

import React, { Component } from 'react';
import { map, isEmpty, dissoc, take, filter, isNil } from 'ramda';
import { map, isEmpty, dissoc, take, filter, isNil, assoc } from 'ramda';
import { Environment } from 'relay-runtime';
import classNames from 'classnames';
// $FlowIgnore
Expand Down Expand Up @@ -59,6 +59,8 @@ type PropsType = {
productId: number,
fullWidth?: boolean,
environment: Environment,
dataVendor?: string,
title?: string,
};

class RRElement extends Component<PropsType, StateType> {
Expand All @@ -72,22 +74,25 @@ class RRElement extends Component<PropsType, StateType> {

componentDidMount() {
this.isMount = true;
const { productId } = this.props;
const { productId, dataVendor } = this.props;
let params = {
itemIds: `${productId}`,
format: 'json',
};

if (dataVendor === 'brand') {
params = assoc('vendor', 'brand', params);
}

axios
.get(
'https://api.retailrocket.net/api/2.0/recommendation/alternative/5ba8ba0797a5281c5c422860',
{
params: {
itemIds: `${productId}`,
format: 'json',
},
},
{ params },
)
.then(({ data }) => {
if (data && !isEmpty(data)) {
const ids = map(item => item.ItemId, data);
this.fetchData(take(4, ids));
this.fetchData(ids);
}
return true;
})
Expand Down Expand Up @@ -123,7 +128,7 @@ class RRElement extends Component<PropsType, StateType> {
},
};
// $FlowIgnore
}, filter(item => !isNil(item.baseProduct), products)),
}, take(4, filter(item => !isNil(item.baseProduct), products))),
});
return true;
})
Expand All @@ -134,16 +139,18 @@ class RRElement extends Component<PropsType, StateType> {
};

render() {
const { fullWidth } = this.props;
const { fullWidth, title } = this.props;
const { items } = this.state;
if (isEmpty(items)) {
return null;
}
return (
<div styleName="container">
<div styleName="title">
<strong>Similar goods</strong>
</div>
{!isNil(title) && (
<div styleName="title">
<strong>Similar goods</strong>
</div>
)}
<div styleName={classNames('items', { fullWidth })}>
{map(
item => (
Expand Down

0 comments on commit 074b1e5

Please sign in to comment.