@shopgate/engage
Version:
Shopgate's ENGAGE library.
4 lines • 1.45 kB
JavaScript
import*as React from'react';import{SurroundPortals}from'@shopgate/engage/components';import{CART_PAYMENT_BAR_TOTALS_TAX,getTaxLine}from'@shopgate/pwa-common-commerce/cart';import CartTotalLine from'@shopgate/pwa-ui-shared/CartTotalLine';import{CartContext}from"../../cart.context";import{spacer}from"./PaymentBarContent.style";import connect from"./PaymentBarTax.connector";/**
* The Tax component.
* @returns {JSX}
*/function PaymentBarTax(_ref){var taxData=_ref.taxData,showSeparator=_ref.showSeparator,className=_ref.className;var _React$useContext=React.useContext(CartContext),currency=_React$useContext.currency,isLoading=_React$useContext.isLoading,config=_React$useContext.config,hasPromotionCoupons=_React$useContext.hasPromotionCoupons;if(!taxData){return null;}var taxLine=getTaxLine(config,taxData);if(!taxLine){return null;}return React.createElement(SurroundPortals,{portalName:CART_PAYMENT_BAR_TOTALS_TAX},React.createElement(CartTotalLine,{isDisabled:isLoading,type:"tax",className:className},React.createElement(CartTotalLine.Label,{label:taxLine.label,showSeparator:showSeparator}),React.createElement(CartTotalLine.Amount,{amount:taxLine.amount,currency:currency}),React.createElement(CartTotalLine.Hint,{hint:taxLine.hint}),hasPromotionCoupons&&React.createElement(CartTotalLine.Spacer,{className:spacer})));}PaymentBarTax.defaultProps={taxData:null,className:null,showSeparator:true};export default connect(PaymentBarTax);