mirror of
https://github.com/woocommerce/woocommerce-paypal-payments.git
synced 2025-09-06 10:55:00 +08:00
Add Billing Details updating when a new card gets selected
This commit is contained in:
parent
861034855e
commit
24a481bdeb
12 changed files with 399 additions and 152 deletions
|
@ -0,0 +1,68 @@
|
|||
import { __ } from '@wordpress/i18n';
|
||||
|
||||
const AddressCard = ( { address, onEdit, isExpanded } ) => {
|
||||
const formatAddress = ( addressData ) => {
|
||||
const {
|
||||
first_name,
|
||||
last_name,
|
||||
company,
|
||||
address_1,
|
||||
address_2,
|
||||
city,
|
||||
state,
|
||||
postcode,
|
||||
country,
|
||||
} = addressData;
|
||||
const formattedAddress = [
|
||||
`${ first_name } ${ last_name }`,
|
||||
company,
|
||||
address_1,
|
||||
address_2,
|
||||
city,
|
||||
state,
|
||||
postcode,
|
||||
country,
|
||||
].filter( Boolean );
|
||||
|
||||
return formattedAddress;
|
||||
};
|
||||
|
||||
const formattedAddress = formatAddress( address );
|
||||
|
||||
return (
|
||||
<div className="wc-block-components-axo-address-card">
|
||||
<address>
|
||||
{ formattedAddress.map( ( line, index ) => (
|
||||
<span
|
||||
key={ index }
|
||||
className="wc-block-components-axo-address-card__address-section"
|
||||
>
|
||||
{ line }
|
||||
</span>
|
||||
) ) }
|
||||
{ address.phone && (
|
||||
<div className="wc-block-components-axo-address-card__address-section">
|
||||
{ address.phone }
|
||||
</div>
|
||||
) }
|
||||
</address>
|
||||
{ onEdit && (
|
||||
<button
|
||||
className="wc-block-components-axo-address-card__edit"
|
||||
aria-controls="shipping"
|
||||
aria-expanded={ isExpanded }
|
||||
aria-label={ __( 'Edit shipping address', 'woocommerce' ) }
|
||||
onClick={ ( e ) => {
|
||||
e.preventDefault();
|
||||
onEdit();
|
||||
} }
|
||||
type="button"
|
||||
>
|
||||
{ __( 'Edit', 'woocommerce' ) }
|
||||
</button>
|
||||
) }
|
||||
</div>
|
||||
);
|
||||
};
|
||||
|
||||
export default AddressCard;
|
Loading…
Add table
Add a link
Reference in a new issue