@shopgate/engage
Version:
Shopgate's ENGAGE library.
3 lines • 1.67 kB
JavaScript
import*as React from'react';import{SurroundPortals}from'@shopgate/engage/components';import{CART_PAYMENT_BAR_TOTALS_SHIPPING,getShippingLine}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"./PaymentBarShippingCost.connector";/**
* @returns {JSX}
*/function PaymentBarShippingCost(_ref){var shippingCost=_ref.shippingCost,showSeparator=_ref.showSeparator,className=_ref.className;var _React$useContext=React.useContext(CartContext),currency=_React$useContext.currency,isLoading=_React$useContext.isLoading,isUserLoggedIn=_React$useContext.isUserLoggedIn,config=_React$useContext.config,hasPromotionCoupons=_React$useContext.hasPromotionCoupons;var shippingLine=React.useMemo(function(){return getShippingLine(config,isUserLoggedIn,shippingCost);},[config,isUserLoggedIn,shippingCost]);return React.createElement(SurroundPortals,{portalName:CART_PAYMENT_BAR_TOTALS_SHIPPING},shippingLine&&React.createElement(CartTotalLine,{isDisabled:isLoading,type:"shipping",className:className},React.createElement(CartTotalLine.Label,{label:shippingLine.label,showSeparator:showSeparator!==null?showSeparator:!!shippingLine.amount}),React.createElement(CartTotalLine.Amount,{amount:shippingLine.amount,currency:currency}),React.createElement(CartTotalLine.Hint,{hint:shippingLine.hint}),hasPromotionCoupons&&React.createElement(CartTotalLine.Spacer,{className:spacer})));}PaymentBarShippingCost.defaultProps={className:null,showSeparator:true,shippingCost:null};export default connect(PaymentBarShippingCost);