/** * External dependencies */ import { useRef } from '@wordpress/element'; import { useSelect } from '@wordpress/data'; import { __ } from '@wordpress/i18n'; import { InspectorControls, useBlockProps, RichText, } from '@wordpress/block-editor'; import PageSelector from '@woocommerce/editor-components/page-selector'; import { PanelBody, ToggleControl } from '@wordpress/components'; import { CHECKOUT_PAGE_ID } from '@woocommerce/block-settings'; import { getSetting } from '@woocommerce/settings'; import { ReturnToCartButton } from '@woocommerce/base-components/cart-checkout'; import Button from '@woocommerce/base-components/button'; import Noninteractive from '@woocommerce/base-components/noninteractive'; /** * Internal dependencies */ import { defaultPlaceOrderButtonLabel } from './constants'; export const Edit = ( { attributes, setAttributes, }: { attributes: { showReturnToCart: boolean; cartPageId: number; placeOrderButtonLabel: string; }; setAttributes: ( attributes: Record< string, unknown > ) => void; } ): JSX.Element => { const blockProps = useBlockProps(); const { cartPageId = 0, showReturnToCart = true, placeOrderButtonLabel, } = attributes; const { current: savedCartPageId } = useRef( cartPageId ); const currentPostId = useSelect( ( select ) => { if ( ! savedCartPageId ) { const store = select( 'core/editor' ); return store.getCurrentPostId(); } return savedCartPageId; }, [ savedCartPageId ] ); return (