@shopgate/engage
Version:
Shopgate's ENGAGE library.
5 lines • 1.98 kB
JavaScript
import React,{Fragment}from'react';import{CART_PATH}from'@shopgate/pwa-common-commerce/cart/constants';import CardListItem from'@shopgate/pwa-ui-shared/CardList/components/Item';import{MessageBar,ResponsiveContainer}from'@shopgate/engage/components';import{getPageSettings}from'@shopgate/engage/core/config';import{messagesContainerCard,messagesCard,messagesContainerLine,messagesLine}from"./CartItem.style";import{CartItemProductLayout}from"./CartItemProductLayout";import{CartItemProductLayoutWide}from"./CartItemProductLayoutWide";import{noGap}from"./CartItemProduct.style";import{useCartItemProduct}from"./CartItem.hooks";import CartItemSubstitution from"./CartItemSubstitution";var messageStyles={card:{container:messagesContainerCard,message:messagesCard},line:{container:messagesContainerLine,message:messagesLine}};/**
* The CartProduct component.
* @param {Object} props The component props.
* @returns {JSX}
*/var CartItemProduct=function CartItemProduct(){var _useCartItemProduct=useCartItemProduct(),messages=_useCartItemProduct.messages,cartItemRef=_useCartItemProduct.cartItemRef,isEditable=_useCartItemProduct.isEditable;var _getPageSettings=getPageSettings(CART_PATH),_getPageSettings$cart=_getPageSettings.cartItemsDisplay,cartItemsDisplay=_getPageSettings$cart===void 0?'line':_getPageSettings$cart;return React.createElement(CardListItem,{className:cartItemsDisplay==='card'?noGap:null},React.createElement("div",{ref:cartItemRef,"data-test-id":"cartItem"},React.createElement(ResponsiveContainer,{appAlways:true,breakpoint:"<=xs"},React.createElement(Fragment,null,messages.length>0&&React.createElement(MessageBar,{messages:messages,classNames:messageStyles[cartItemsDisplay]}),React.createElement(CartItemProductLayout,null))),React.createElement(ResponsiveContainer,{webOnly:true,breakpoint:">xs"},React.createElement(CartItemProductLayoutWide,null)),React.createElement(CartItemSubstitution,{editable:isEditable})));};export default CartItemProduct;