UNPKG

@shopgate/engage

Version:
3 lines 1.55 kB
import React,{useContext}from'react';import PropTypes from'prop-types';import CartTotalLine from'@shopgate/pwa-ui-shared/CartTotalLine';import{i18n}from'@shopgate/engage/core';import{CartContext}from"../../cart.context";import PaymentBarPromotionalText from"./PaymentBarPromotionalText";import{spacer}from"./PaymentBarContent.style";import connect from"./PaymentBarAppliedPromotions.connector";/** * @returns {JSX} */var PaymentBarAppliedPromotions=function PaymentBarAppliedPromotions(_ref){var promotions=_ref.promotions,className=_ref.className,showSeparator=_ref.showSeparator;var _useContext=useContext(CartContext),isLoading=_useContext.isLoading,currency=_useContext.currency,hasPromotionCoupons=_useContext.hasPromotionCoupons;return promotions.map(function(promotion){var discount=promotion.discount,code=promotion.code,name=promotion.name,promotionalText=promotion.promotionalText;var amount=discount.absoluteAmount;return React.createElement(CartTotalLine,{key:"promotion-".concat(code,"-").concat(amount),isDisabled:isLoading,className:className},React.createElement(CartTotalLine.Label,{label:i18n.text('cart.promotion_label',{label:name}),showSeparator:showSeparator,suffix:React.createElement(PaymentBarPromotionalText,{text:promotionalText})}),React.createElement(CartTotalLine.Amount,{amount:amount,currency:currency}),hasPromotionCoupons&&React.createElement(CartTotalLine.Spacer,{className:spacer}));});};PaymentBarAppliedPromotions.defaultProps={className:null,showSeparator:true};export default connect(PaymentBarAppliedPromotions);