UNPKG

@shopgate/engage

Version:
4 lines 1.31 kB
import React from'react';import PropTypes from'prop-types';import{css}from'glamor';import classNames from'classnames';import{SurroundPortals,I18n,TimeBoundary}from'@shopgate/engage/components';import{isBeta,useWidgetSettings,useWidgetStyles}from'@shopgate/engage/core';import{PRODUCT_MAP_PRICE}from'@shopgate/engage/product';import{showHint}from"./helpers";import connect from"./connector";var defaultStyle=css({fontSize:'0.75rem'}).toString();/** * The Product Map Price Hint component. * @return {JSX} */var MapPriceHint=function MapPriceHint(_ref){var price=_ref.price,mapPrice=_ref.mapPrice;if(!isBeta()){return null;}var settings=useWidgetSettings('@shopgate/engage/product/MapPrice');if(!settings.showHint||!settings.hint){return null;}var styles=useWidgetStyles('@shopgate/engage/product/MapPrice');return React.createElement(SurroundPortals,{portalName:PRODUCT_MAP_PRICE},showHint(price,mapPrice)&&React.createElement(TimeBoundary,{start:new Date(mapPrice.startDate),end:new Date(mapPrice.endDate)},function(_ref2){var between=_ref2.between;return between&&React.createElement(I18n.Text,{string:settings.hint,className:classNames('engage__product__map-price-hint',defaultStyle,css(styles.hint).toString())});}));};MapPriceHint.defaultProps={mapPrice:null,price:null};export default connect(MapPriceHint);