@shopgate/engage
Version:
Shopgate's ENGAGE library.
51 lines (50 loc) • 1.54 kB
JavaScript
import React, { useMemo } from 'react';
import PropTypes from 'prop-types';
import { i18n } from "../../../core/helpers/i18n";
import CheckoutConfirmationSection from "./CheckoutConfirmationSection";
/**
* CheckoutConfirmationShippedTo component
* @returns {JSX}
*/
import { jsx as _jsx } from "react/jsx-runtime";
const CheckoutConfirmationShippedTo = ({
order,
className
}) => {
const content = useMemo(() => {
const shipping = order.addressSequences.find(address => address.type === 'shipping');
if (!shipping) {
return null;
}
const {
firstName,
lastName,
address1,
city,
region,
postalCode,
orderSegment
} = shipping;
const shippingMethodServiceLevel = orderSegment?.selectedShippingMethod?.serviceLevel?.name;
const address = [`${firstName} ${lastName}`, `${address1 || ''}`, `${city ? `${city},` : ''} ${city && region ? region : ''} ${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 /*#__PURE__*/_jsx(CheckoutConfirmationSection, {
title: "checkout.success.shipped_to",
content: content,
className: className
});
};
CheckoutConfirmationShippedTo.defaultProps = {
className: null
};
export default CheckoutConfirmationShippedTo;