@shopgate/engage
Version:
Shopgate's ENGAGE library.
4 lines • 2.04 kB
JavaScript
import React,{useMemo}from'react';import PropTypes from'prop-types';import{css}from'glamor';import TimeIcon from'@shopgate/pwa-ui-shared/icons/TimeIcon';import moment from'moment';import{i18n}from"../../../core/helpers/i18n";import CheckoutConfirmationSection from"./CheckoutConfirmationSection";import{getCheckoutTaxLinesFromOrder}from"../../helpers";var styles={time:css({marginBottom:4,display:'flex',flexDirection:'row',alignItems:'center'}).toString(),timeText:css({marginLeft:8})};/**
* CheckoutConfirmationOrderSummary component
* @returns {JSX}
*/var CheckoutConfirmationOrderSummary=function CheckoutConfirmationOrderSummary(_ref){var _order$lineItems$;var order=_ref.order,className=_ref.className;var content=useMemo(function(){return getCheckoutTaxLinesFromOrder(order).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};});},[order]);var fulfillmentSlot=order===null||order===void 0?void 0:(_order$lineItems$=order.lineItems[0])===null||_order$lineItems$===void 0?void 0:_order$lineItems$.fulfillmentSlot;return React.createElement(CheckoutConfirmationSection,{title:"checkout.success.order_summary",content:content,isSummary:true,className:className},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);};CheckoutConfirmationOrderSummary.defaultProps={className:null};export default CheckoutConfirmationOrderSummary;