/** * External dependencies */ import { useRef } from '@wordpress/element'; import { useSelect } from '@wordpress/data'; import { __ } from '@wordpress/i18n'; import { InspectorControls, useBlockProps } from '@wordpress/block-editor'; import PageSelector from '@woocommerce/editor-components/page-selector'; import { CART_PAGE_ID } from '@woocommerce/block-settings'; import Noninteractive from '@woocommerce/base-components/noninteractive'; /** * Internal dependencies */ import Block from './block'; export const Edit = ( { attributes, setAttributes, }: { attributes: { checkoutPageId: number; className: string; }; setAttributes: ( attributes: Record< string, unknown > ) => void; } ): JSX.Element => { const blockProps = useBlockProps(); const { checkoutPageId = 0, className } = attributes; const { current: savedCheckoutPageId } = useRef( checkoutPageId ); const currentPostId = useSelect( ( select ) => { if ( ! savedCheckoutPageId ) { const store = select( 'core/editor' ); return store.getCurrentPostId(); } return savedCheckoutPageId; }, [ savedCheckoutPageId ] ); return (