UNPKG

@shopgate/engage

Version:
4 lines 1.77 kB
import React,{useMemo}from'react';import PropTypes from'prop-types';import{i18n}from"../../../core/helpers/i18n";import CheckoutConfirmationSection from"./CheckoutConfirmationSection";/** * CheckoutConfirmationShippedTo component * @returns {JSX} */var CheckoutConfirmationShippedTo=function CheckoutConfirmationShippedTo(_ref){var order=_ref.order,className=_ref.className;var content=useMemo(function(){var _orderSegment$selecte,_orderSegment$selecte2;var shipping=order.addressSequences.find(function(address){return address.type==='shipping';});if(!shipping){return null;}var firstName=shipping.firstName,lastName=shipping.lastName,address1=shipping.address1,city=shipping.city,region=shipping.region,postalCode=shipping.postalCode,orderSegment=shipping.orderSegment;var shippingMethodServiceLevel=orderSegment===null||orderSegment===void 0?void 0:(_orderSegment$selecte=orderSegment.selectedShippingMethod)===null||_orderSegment$selecte===void 0?void 0:(_orderSegment$selecte2=_orderSegment$selecte.serviceLevel)===null||_orderSegment$selecte2===void 0?void 0:_orderSegment$selecte2.name;var address=["".concat(firstName," ").concat(lastName),"".concat(address1||''),"".concat(city?"".concat(city,","):''," ").concat(city&&region?region:''," ").concat(postalCode||'')].filter(Boolean).join('\n');return[{label:i18n.text('checkout.success.address'),text:address}].concat(shippingMethodServiceLevel?{label:i18n.text('checkout.success.shipping_method'),text:shippingMethodServiceLevel}:[]);},[order]);if(!content){return null;}return React.createElement(CheckoutConfirmationSection,{title:"checkout.success.shipped_to",content:content,className:className});};CheckoutConfirmationShippedTo.defaultProps={className:null};export default CheckoutConfirmationShippedTo;