@shopgate/engage
Version:
Shopgate's ENGAGE library.
62 lines (61 loc) • 1.56 kB
JavaScript
import React, { useMemo } from 'react';
import PropTypes from 'prop-types';
import { i18n } from "../../../core/helpers/i18n";
import CheckoutConfirmationSection from "./CheckoutConfirmationSection";
/**
* CheckoutConfirmationPickUpContact component
* @returns {JSX}
*/
import { jsx as _jsx } from "react/jsx-runtime";
const CheckoutConfirmationPickUpContact = ({
order,
className
}) => {
const content = useMemo(() => {
const pickup = order.addressSequences.find(address => address.type === 'pickup');
if (!pickup) {
return null;
}
const {
firstName,
lastName,
phone,
mobile,
emailAddress
} = pickup;
const entries = [{
label: i18n.text('checkout.success.name'),
text: `${firstName} ${lastName}`
}];
if (emailAddress) {
entries.push({
label: i18n.text('checkout.success.email_address'),
text: emailAddress
});
}
if (mobile) {
entries.push({
label: i18n.text('checkout.success.phone_number'),
text: mobile
});
} else if (phone) {
entries.push({
label: i18n.text('checkout.success.phone_number'),
text: phone
});
}
return entries;
}, [order]);
if (!content) {
return null;
}
return /*#__PURE__*/_jsx(CheckoutConfirmationSection, {
title: "checkout.success.pick_up_contact",
content: content,
className: className
});
};
CheckoutConfirmationPickUpContact.defaultProps = {
className: null
};
export default CheckoutConfirmationPickUpContact;