2021-09-21 10:18:27 +00:00
|
|
|
/**
|
|
|
|
* External dependencies
|
|
|
|
*/
|
|
|
|
import { useBlockProps, InnerBlocks } from '@wordpress/block-editor';
|
|
|
|
import { Sidebar } from '@woocommerce/base-components/sidebar-layout';
|
|
|
|
import { innerBlockAreas } from '@woocommerce/blocks-checkout';
|
2021-10-15 09:48:57 +00:00
|
|
|
import type { TemplateArray } from '@wordpress/blocks';
|
2021-09-21 10:18:27 +00:00
|
|
|
|
|
|
|
/**
|
|
|
|
* Internal dependencies
|
|
|
|
*/
|
|
|
|
import './style.scss';
|
2022-04-05 10:14:32 +00:00
|
|
|
import {
|
|
|
|
useForcedLayout,
|
|
|
|
getAllowedBlocks,
|
2022-04-07 13:47:58 +00:00
|
|
|
} from '../../../cart-checkout-shared';
|
2021-09-21 10:18:27 +00:00
|
|
|
|
|
|
|
export const Edit = ( { clientId }: { clientId: string } ): JSX.Element => {
|
2021-10-25 15:31:22 +00:00
|
|
|
const blockProps = useBlockProps( { className: 'wc-block-cart__sidebar' } );
|
2021-09-21 10:18:27 +00:00
|
|
|
const allowedBlocks = getAllowedBlocks( innerBlockAreas.CART_TOTALS );
|
2021-10-15 09:48:57 +00:00
|
|
|
const defaultTemplate = [
|
|
|
|
[ 'woocommerce/cart-order-summary-block', {}, [] ],
|
|
|
|
[ 'woocommerce/cart-express-payment-block', {}, [] ],
|
|
|
|
[ 'woocommerce/proceed-to-checkout-block', {}, [] ],
|
2021-10-19 11:23:33 +00:00
|
|
|
[ 'woocommerce/cart-accepted-payment-methods-block', {}, [] ],
|
2021-10-15 09:48:57 +00:00
|
|
|
] as TemplateArray;
|
2021-09-21 10:18:27 +00:00
|
|
|
|
|
|
|
useForcedLayout( {
|
|
|
|
clientId,
|
2021-10-15 09:48:57 +00:00
|
|
|
registeredBlocks: allowedBlocks,
|
|
|
|
defaultTemplate,
|
2021-09-21 10:18:27 +00:00
|
|
|
} );
|
|
|
|
|
|
|
|
return (
|
2021-10-25 15:31:22 +00:00
|
|
|
<Sidebar { ...blockProps }>
|
|
|
|
<InnerBlocks
|
|
|
|
allowedBlocks={ allowedBlocks }
|
|
|
|
template={ defaultTemplate }
|
|
|
|
templateLock={ false }
|
|
|
|
renderAppender={ InnerBlocks.ButtonBlockAppender }
|
|
|
|
/>
|
2021-09-21 10:18:27 +00:00
|
|
|
</Sidebar>
|
|
|
|
);
|
|
|
|
};
|
|
|
|
|
|
|
|
export const Save = (): JSX.Element => {
|
|
|
|
return (
|
|
|
|
<div { ...useBlockProps.save() }>
|
|
|
|
<InnerBlocks.Content />
|
|
|
|
</div>
|
|
|
|
);
|
|
|
|
};
|