@shopgate/engage
Version:
Shopgate's ENGAGE library.
8 lines • 822 B
JavaScript
import{isBetween}from'@shopgate/pwa-common/helpers/date';/**
* Decide is map price hint should be shown for exact product
* @param {Object} productPrice product.price object
* @param {Object} mapPrice product.price.mapPricing
* @returns {boolean}
*/export var showHint=function showHint(productPrice,mapPrice){var _ref=productPrice||{},_ref$unitPrice=_ref.unitPrice,unitPrice=_ref$unitPrice===void 0?0:_ref$unitPrice;var _ref2=mapPrice||{},_ref2$price=_ref2.price,price=_ref2$price===void 0?0:_ref2$price,startDate=_ref2.startDate,endDate=_ref2.endDate;// MAP price is active and higher than the actual price
if(!price||price<=unitPrice){return false;}var start=new Date(startDate);var end=new Date(endDate);if(!start.getDate()||!end.getDate()){// dates invalid
return false;}return isBetween(new Date(),start,end);};