2023-10-09 11:49:09 +00:00
|
|
|
/**
|
|
|
|
* External dependencies
|
|
|
|
*/
|
2024-05-31 03:49:36 +00:00
|
|
|
import clsx from 'clsx';
|
2023-10-10 21:07:58 +00:00
|
|
|
|
2023-10-09 11:49:09 +00:00
|
|
|
/**
|
|
|
|
* Internal dependencies
|
|
|
|
*/
|
|
|
|
import './style.scss';
|
|
|
|
|
2023-10-10 21:07:58 +00:00
|
|
|
/**
|
|
|
|
* Wrapper for address fields which handles the edit/preview transition. Form fields are always rendered so that
|
|
|
|
* validation can occur.
|
|
|
|
*/
|
2023-10-09 11:49:09 +00:00
|
|
|
export const AddressWrapper = ( {
|
|
|
|
isEditing = false,
|
|
|
|
addressCard,
|
|
|
|
addressForm,
|
|
|
|
}: {
|
|
|
|
isEditing: boolean;
|
|
|
|
addressCard: () => JSX.Element;
|
|
|
|
addressForm: () => JSX.Element;
|
|
|
|
} ): JSX.Element | null => {
|
2024-05-31 03:49:36 +00:00
|
|
|
const wrapperClasses = clsx(
|
2023-10-10 21:07:58 +00:00
|
|
|
'wc-block-components-address-address-wrapper',
|
|
|
|
{
|
|
|
|
'is-editing': isEditing,
|
|
|
|
}
|
|
|
|
);
|
|
|
|
|
2023-10-09 11:49:09 +00:00
|
|
|
return (
|
2023-10-10 21:07:58 +00:00
|
|
|
<div className={ wrapperClasses }>
|
|
|
|
<div className="wc-block-components-address-card-wrapper">
|
|
|
|
{ addressCard() }
|
|
|
|
</div>
|
|
|
|
<div className="wc-block-components-address-form-wrapper">
|
|
|
|
{ addressForm() }
|
|
|
|
</div>
|
|
|
|
</div>
|
2023-10-09 11:49:09 +00:00
|
|
|
);
|
|
|
|
};
|
|
|
|
|
|
|
|
export default AddressWrapper;
|