@shopgate/engage
Version:
Shopgate's ENGAGE library.
5 lines • 1.43 kB
JavaScript
import React from'react';import PropTypes from'prop-types';import{i18n}from'@shopgate/engage/core';import{BOPIS,ROPIS}from'@shopgate/engage/locations';import connect from"./CartItemSubstitution.connector";import{useCartItem}from"./CartItem.hooks";import Substitution,{SubstitutionWrapper}from"../Substitution";import{root}from"./CartItemSubstitution.style";/**
* Renders the cart reservation card label.
* @param {Object} props The component props.
* @returns {JSX}
*/var CartItemSubstitution=function CartItemSubstitution(_ref){var setSubstitutionAllowed=_ref.setSubstitutionAllowed,editable=_ref.editable;var _useCartItem=useCartItem(),_useCartItem$cartItem=_useCartItem.cartItem,_useCartItem$cartItem2=_useCartItem$cartItem===void 0?{}:_useCartItem$cartItem,id=_useCartItem$cartItem2.id,substitutionAllowed=_useCartItem$cartItem2.substitutionAllowed,fulfillment=_useCartItem$cartItem2.fulfillment;if(![ROPIS,BOPIS].includes((fulfillment===null||fulfillment===void 0?void 0:fulfillment.method)||[])){return null;}return React.createElement(SubstitutionWrapper,null,React.createElement(Substitution,{className:root,id:"substitution-".concat(id),label:i18n.text('cart.allow_substitution'),checked:substitutionAllowed,onChange:function onChange(){return setSubstitutionAllowed(id,!substitutionAllowed);},disabled:!editable}));};CartItemSubstitution.defaultProps={editable:false};export default connect(CartItemSubstitution);