/** * External dependencies */ import { __ } from '@wordpress/i18n'; import { ALLOWED_COUNTRIES } from '@woocommerce/block-settings'; import type { CartShippingAddress, CartBillingAddress, } from '@woocommerce/types'; import { AddressFields, AddressField } from '@woocommerce/settings'; /** * Internal dependencies */ import './style.scss'; const AddressCard = ( { address, onEdit, target, fieldConfig, }: { address: CartShippingAddress | CartBillingAddress; onEdit: () => void; target: string; fieldConfig: Record< keyof AddressFields, Partial< AddressField > >; } ): JSX.Element | null => { return (
{ address.first_name + ' ' + address.last_name }
{ [ address.address_1, ! fieldConfig.address_2.hidden && address.address_2, address.city, address.state, address.postcode, ALLOWED_COUNTRIES[ address.country ] ? ALLOWED_COUNTRIES[ address.country ] : address.country, ] .filter( ( field ) => !! field ) .map( ( field, index ) => ( { field } ) ) }
{ address.phone && ! fieldConfig.phone.hidden ? (
{ address.phone }
) : ( '' ) }
{ onEdit && ( { onEdit(); e.preventDefault(); } } > { __( 'Edit', 'woo-gutenberg-products-block' ) } ) }
); }; export default AddressCard;