Skip to content
This repository has been archived by the owner on Feb 23, 2024. It is now read-only.

Commit

Permalink
update PR to recent changes
Browse files Browse the repository at this point in the history
  • Loading branch information
senadir committed Nov 14, 2023
1 parent aa3a7f9 commit 6c58eeb
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 10 deletions.
9 changes: 5 additions & 4 deletions assets/js/blocks/checkout/address-card/index.tsx
Expand Up @@ -7,6 +7,7 @@ import type {
CartShippingAddress,
CartBillingAddress,
} from '@woocommerce/types';
import { AddressFields, AddressField } from '@woocommerce/settings';

/**
* Internal dependencies
Expand All @@ -17,12 +18,12 @@ const AddressCard = ( {
address,
onEdit,
target,
showPhoneField,
fieldConfig,
}: {
address: CartShippingAddress | CartBillingAddress;
onEdit: () => void;
target: string;
showPhoneField: boolean;
fieldConfig: Record< keyof AddressFields, Partial< AddressField > >;
} ): JSX.Element | null => {
return (
<div className="wc-block-components-address-card">
Expand All @@ -33,7 +34,7 @@ const AddressCard = ( {
<div className="wc-block-components-address-card__address-section">
{ [
address.address_1,
address.address_2,
! fieldConfig.address_2.hidden && address.address_2,
address.city,
address.state,
address.postcode,
Expand All @@ -46,7 +47,7 @@ const AddressCard = ( {
<span key={ `address-` + index }>{ field }</span>
) ) }
</div>
{ address.phone && showPhoneField ? (
{ address.phone && ! fieldConfig.phone.hidden ? (
<div
key={ `address-phone` }
className="wc-block-components-address-card__address-section"
Expand Down
Expand Up @@ -90,10 +90,10 @@ const CustomerAddress = ( {
onEdit={ () => {
setEditing( true );
} }
showPhoneField={ showPhoneField }
fieldConfig={ addressFieldsConfig }
/>
),
[ billingAddress, showPhoneField ]
[ billingAddress, addressFieldsConfig ]
);

const renderAddressFormComponent = useCallback(
Expand All @@ -113,9 +113,7 @@ const CustomerAddress = ( {
addressFieldKeys,
addressFieldsConfig,
billingAddress,
dispatchCheckoutEvent,
onChangeAddress,
useBillingAsShipping,
]
);

Expand Down
Expand Up @@ -67,7 +67,6 @@ const CustomerAddress = ( {
const addressFieldKeys = Object.keys(
defaultAddressFields
) as ( keyof AddressFields )[];

const onChangeAddress = useCallback(
( values: Partial< ShippingAddress > ) => {
setShippingAddress( values );
Expand All @@ -93,9 +92,10 @@ const CustomerAddress = ( {
onEdit={ () => {
setEditing( true );
} }
fieldConfig={ addressFieldsConfig }
/>
),
[ shippingAddress ]
[ shippingAddress, addressFieldsConfig ]
);

const renderAddressFormComponent = useCallback(
Expand Down

0 comments on commit 6c58eeb

Please sign in to comment.