@shopgate/engage
Version:
Shopgate's ENGAGE library.
4 lines • 1.85 kB
JavaScript
import React,{useMemo}from'react';import{css}from'glamor';import{i18n}from'@shopgate/engage/core';import TimeIcon from'@shopgate/pwa-ui-shared/icons/TimeIcon';import moment from'moment';import Section from"./CheckoutSection";import{useCheckoutContext}from"../../hooks/common";var styles={root:css({padding:16,paddingTop:0,display:'flex',flexDirection:'column',flex:'0 0 auto'}).toString(),card:css({marginTop:8}).toString(),time:css({marginBottom:4,display:'flex',flexDirection:'row',alignItems:'center'}).toString(),timeText:css({marginLeft:8})};/**
* Billing
* @returns {JSX}
*/var Billing=function Billing(){var _useCheckoutContext=useCheckoutContext(),taxLines=_useCheckoutContext.taxLines,fulfillmentSlot=_useCheckoutContext.fulfillmentSlot;var content=useMemo(function(){return taxLines.filter(function(t){return t.visible;}).map(function(t){var text=null;if(t.value!==null){if(t.type==='shippingTotal'&&t.value===0){text=i18n.text('shipping.free_short');}else{text=i18n.price(t.value,t.currencyCode,2);}}return{label:t.label===null?i18n.text("checkout.summary.".concat(t.type)):t.label,text:text,info:t.info||null,messages:t.messages||null};});},[taxLines]);return React.createElement("div",{className:styles.root},React.createElement(Section,{className:styles.card,title:"checkout.summary.headline",content:content},fulfillmentSlot?React.createElement("div",{className:styles.time},React.createElement(TimeIcon,{size:20}),React.createElement("span",{className:styles.timeText},moment(fulfillmentSlot===null||fulfillmentSlot===void 0?void 0:fulfillmentSlot.date,'YYYY-MM-DD').format('ll'),' ',moment(fulfillmentSlot===null||fulfillmentSlot===void 0?void 0:fulfillmentSlot.from,'HH:mm').format('LT'),' - ',moment(fulfillmentSlot===null||fulfillmentSlot===void 0?void 0:fulfillmentSlot.to,'HH:mm').format('LT'))):null));};export default Billing;