@shopgate/engage
Version:
Shopgate's ENGAGE library.
47 lines (46 loc) • 1.14 kB
JavaScript
import React from 'react';
import PropTypes from 'prop-types';
import Item from "../Item";
import styles from "./styles";
/**
* Wrapper around the Item component to simplify item rendering based on the two different "items"
* lists within ListItemContent.
* @param {Object} props The component props
* @returns {JSX.Element}
*/
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
const ListItemWrapper = ({
listId,
product,
notes,
quantity,
addToCart,
removeItem,
items,
index
}) => /*#__PURE__*/_jsxs("div", {
children: [/*#__PURE__*/_jsx(Item, {
product: product,
notes: notes,
quantity: quantity,
listId: listId,
productId: product.id,
addToCart: e => {
e.preventDefault();
e.stopPropagation();
return addToCart(product, quantity);
},
remove: e => {
e.preventDefault();
e.stopPropagation();
removeItem(product.id);
}
}), index === items.length - 1 ? null : /*#__PURE__*/_jsx("div", {
className: styles.divider
})]
});
ListItemWrapper.defaultProps = {
notes: undefined,
quantity: 1
};
export default ListItemWrapper;