2022-10-11 15:46:59 +00:00
|
|
|
/* eslint-disable @wordpress/no-unsafe-wp-apis */
|
|
|
|
/**
|
|
|
|
* External dependencies
|
|
|
|
*/
|
|
|
|
import classnames from 'classnames';
|
|
|
|
import { useBlockProps } from '@wordpress/block-editor';
|
|
|
|
import { innerBlockAreas } from '@woocommerce/blocks-checkout';
|
|
|
|
import { useSelect } from '@wordpress/data';
|
|
|
|
import { CHECKOUT_STORE_KEY } from '@woocommerce/block-data';
|
2022-12-09 09:50:08 +00:00
|
|
|
import { LOCAL_PICKUP_ENABLED } from '@woocommerce/block-settings';
|
2022-10-11 15:46:59 +00:00
|
|
|
|
|
|
|
/**
|
|
|
|
* Internal dependencies
|
|
|
|
*/
|
|
|
|
import {
|
|
|
|
FormStepBlock,
|
|
|
|
AdditionalFields,
|
|
|
|
AdditionalFieldsContent,
|
|
|
|
} from '../../form-step';
|
|
|
|
import Block from './block';
|
|
|
|
|
|
|
|
export const Edit = ( {
|
|
|
|
attributes,
|
|
|
|
setAttributes,
|
|
|
|
}: {
|
|
|
|
attributes: {
|
|
|
|
title: string;
|
|
|
|
description: string;
|
|
|
|
showStepNumber: boolean;
|
|
|
|
className: string;
|
|
|
|
};
|
|
|
|
setAttributes: ( attributes: Record< string, unknown > ) => void;
|
|
|
|
} ): JSX.Element | null => {
|
|
|
|
const { prefersCollection } = useSelect( ( select ) => {
|
|
|
|
const checkoutStore = select( CHECKOUT_STORE_KEY );
|
|
|
|
return {
|
|
|
|
prefersCollection: checkoutStore.prefersCollection(),
|
|
|
|
};
|
|
|
|
} );
|
|
|
|
const { className } = attributes;
|
|
|
|
|
2022-12-09 09:50:08 +00:00
|
|
|
if ( ! prefersCollection || ! LOCAL_PICKUP_ENABLED ) {
|
2022-10-11 15:46:59 +00:00
|
|
|
return null;
|
|
|
|
}
|
|
|
|
|
|
|
|
return (
|
|
|
|
<FormStepBlock
|
|
|
|
attributes={ attributes }
|
|
|
|
setAttributes={ setAttributes }
|
|
|
|
className={ classnames(
|
2022-10-20 10:48:46 +00:00
|
|
|
'wc-block-checkout__shipping-method',
|
2022-10-11 15:46:59 +00:00
|
|
|
className
|
|
|
|
) }
|
|
|
|
>
|
|
|
|
<Block />
|
|
|
|
<AdditionalFields block={ innerBlockAreas.PICKUP_LOCATION } />
|
|
|
|
</FormStepBlock>
|
|
|
|
);
|
|
|
|
};
|
|
|
|
|
|
|
|
export const Save = (): JSX.Element => {
|
|
|
|
return (
|
|
|
|
<div { ...useBlockProps.save() }>
|
|
|
|
<AdditionalFieldsContent />
|
|
|
|
</div>
|
|
|
|
);
|
|
|
|
};
|