-
Notifications
You must be signed in to change notification settings - Fork 7
/
index.jsx
55 lines (51 loc) · 1.35 KB
/
index.jsx
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
import React from 'react';
import PropTypes from 'prop-types';
import pure from 'recompose/pure';
import { Link } from '@shopgate/engage/components';
import { bin2hex } from '@shopgate/engage/core';
import { ITEM_PATH } from '@shopgate/engage/product';
import ItemImage from './components/ItemImage';
import ItemDiscount from './components/ItemDiscount';
import ItemFavoritesButton from './components/ItemFavoritesButton';
import ItemDetails from './components/ItemDetails';
import styles from './style';
/**
* The Product Grid Item component.
* @param {Object} props The component props.
* @return {JSX}
*/
const Item = ({ product, display }) => (
<Link
tagName="a"
href={`${ITEM_PATH}/${bin2hex(product.id)}`}
className={styles}
state={{ title: product.name }}
>
<ItemImage
productId={product.id}
name={product.name}
imageUrl={product.featuredImageUrl}
/>
<ItemDiscount
productId={product.id}
discount={product.price.discount || null}
/>
<ItemFavoritesButton
productId={product.id}
/>
<ItemDetails
productId={product.id}
name={product.name}
price={product.price}
display={display}
/>
</Link>
);
Item.propTypes = {
product: PropTypes.shape().isRequired,
display: PropTypes.shape(),
};
Item.defaultProps = {
display: null,
};
export default pure(Item);