UNPKG

@shopgate/engage

Version:
6 lines 1.47 kB
import React from'react';import PropTypes from'prop-types';import{connect}from'react-redux';import{css}from'glamor';import{makeIsProductOnSpecificFavoriteList}from'@shopgate/pwa-common-commerce/favorites/selectors';import{i18n}from'@shopgate/engage/core';import{getWishlistItemQuantityEnabled}from"../../../core/selectors/shopSettings";/** * @returns {Object} */var makeMapStateToProps=function makeMapStateToProps(){var getIsOnList=makeIsProductOnSpecificFavoriteList(function(_,props){return props.productId;},function(_,props){return props.listId;});return function(state,props){return{isOnList:getIsOnList(state,props),wishlistItemQuantityEnabled:getWishlistItemQuantityEnabled(state)};};};var styles={remove:css({color:'var(--color-state-alert)'}).toString(),add:css({color:'var(--color-state-ok)',whiteSpace:'noWrap'}).toString()};/** * @param {Object} props Props. * @returns {JSX.Element} */var ListChooserItem=function ListChooserItem(_ref){var isOnList=_ref.isOnList,wishlistItemQuantityEnabled=_ref.wishlistItemQuantityEnabled;if(wishlistItemQuantityEnabled&&isOnList){return React.createElement("span",{className:styles.add},i18n.text('favorites.list_chooser.add_more'));}if(isOnList){return React.createElement("span",{className:styles.remove},i18n.text('favorites.list_chooser.remove'));}return React.createElement("span",{className:styles.add},i18n.text('favorites.list_chooser.add'));};export default connect(makeMapStateToProps)(ListChooserItem);