UNPKG

@shopgate/engage

Version:
8 lines 1.48 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} */var CharacteristicsButton=function CharacteristicsButton(_ref){var _variant$stock,_variant$stock2;var isBackInStockEnabled=_ref.isBackInStockEnabled,subscription=_ref.subscription,variant=_ref.variant;var productIsNotAVariant=!variant;var featureIsNotEnabled=!isBackInStockEnabled;var productIsNotAvailable=(variant===null||variant===void 0?void 0:(_variant$stock=variant.stock)===null||_variant$stock===void 0?void 0:_variant$stock.quantity)===0&&(variant===null||variant===void 0?void 0:(_variant$stock2=variant.stock)===null||_variant$stock2===void 0?void 0:_variant$stock2.ignoreQuantity)===false;if(productIsNotAVariant||featureIsNotEnabled||!productIsNotAvailable)return null;return React.createElement(BackInStockButton,{subscription:subscription,stopPropagation:true,productId:variant.id,alignRight:true});};CharacteristicsButton.defaultProps={variant:{},subscription:null};export default withCurrentProduct(connect(CharacteristicsButton));