UNPKG

@shopgate/engage

Version:
58 lines (57 loc) 2.17 kB
import React, { Fragment } from 'react'; import PropTypes from 'prop-types'; import { Grid, Price, PriceStriked } from '@shopgate/engage/components'; import { PriceInfo } from '@shopgate/engage/product/components'; import { withPriceCalculation } from '@shopgate/engage/product/hocs'; import styles from "./style"; /** * The ProductGridPrice component is supposed to be used to display prices at product grids. It * renders a row with the current price and a strike price when present. As same as the price info. * @param {Object} product A product entity. * @return {JSX.Element} */ import { jsx as _jsx, jsxs as _jsxs, Fragment as _Fragment } from "react/jsx-runtime"; const ProductGridPrice = ({ product }) => { const { price } = product; return /*#__PURE__*/_jsxs(_Fragment, { children: [/*#__PURE__*/_jsxs(Grid, { className: `${styles.priceWrapper} engage__product__product-grid-price`, wrap: true, children: [/*#__PURE__*/_jsx(Grid.Item, { grow: 1, children: /*#__PURE__*/_jsx(Price, { currency: price.currency, discounted: !!price.discount, unitPrice: price.unitPrice, unitPriceMin: price.unitPriceMin, unitPriceMax: price.unitPriceMax }) }), price.msrp > 0 && price.unitPrice !== price.msrp && /*#__PURE__*/_jsx(Grid.Item, { children: /*#__PURE__*/_jsx(PriceStriked, { className: styles.strikedPrice, value: price.msrp, currency: price.currency }) }), !price.msrp && price.unitPriceStriked > 0 && price.unitPrice !== price.unitPriceStriked && /*#__PURE__*/_jsx(Grid.Item, { children: /*#__PURE__*/_jsx(PriceStriked, { className: styles.strikedPrice, value: price.unitPriceStriked, currency: price.currency }) })] }), /*#__PURE__*/_jsx(PriceInfo, { product: product, className: styles.basicPrice, wrapper: children => /*#__PURE__*/_jsx(Grid, { children: /*#__PURE__*/_jsx(Grid.Item, { children: children }) }) })] }); }; export default withPriceCalculation(ProductGridPrice);