UNPKG

@shopgate/engage

Version:
36 lines (35 loc) 1.3 kB
import React from 'react'; import PropTypes from 'prop-types'; import { BackInStockButton } from '@shopgate/engage/back-in-stock/components'; import { withCurrentProduct } from '@shopgate/engage/core'; import connect from "./connector"; /** * The CharacteristicsButton component. * @param {Object} props The component props. * @param {boolean} props.isBackInStockEnabled Whether the back in stock feature is enabled * @param {Object} props.variant The variant for this entry * @param {Object} props.subscription The subscription * @return {JSX} */ import { jsx as _jsx } from "react/jsx-runtime"; const CharacteristicsButton = ({ isBackInStockEnabled, subscription, variant }) => { const productIsNotAVariant = !variant; const featureIsNotEnabled = !isBackInStockEnabled; const productIsNotAvailable = variant?.stock?.quantity === 0 && variant?.stock?.ignoreQuantity === false; if (productIsNotAVariant || featureIsNotEnabled || !productIsNotAvailable) return null; return /*#__PURE__*/_jsx(BackInStockButton, { subscription: subscription, stopPropagation: true, productId: variant.id, alignRight: true }); }; CharacteristicsButton.defaultProps = { variant: {}, subscription: null }; export default withCurrentProduct(connect(CharacteristicsButton));