2023-03-08 09:51:59 +00:00
|
|
|
/**
|
|
|
|
* External dependencies
|
|
|
|
*/
|
2023-03-09 21:11:25 +00:00
|
|
|
import {
|
|
|
|
__experimentalEditor as Editor,
|
2023-05-16 10:41:26 +00:00
|
|
|
__experimentalInitBlocks as initBlocks,
|
2023-03-10 20:21:22 +00:00
|
|
|
ProductEditorSettings,
|
2023-04-13 15:45:50 +00:00
|
|
|
productApiFetchMiddleware,
|
2023-03-09 21:11:25 +00:00
|
|
|
} from '@woocommerce/product-editor';
|
|
|
|
import { Spinner } from '@wordpress/components';
|
2023-05-16 10:41:26 +00:00
|
|
|
import { useEffect } from '@wordpress/element';
|
2023-03-09 21:11:25 +00:00
|
|
|
import { useParams } from 'react-router-dom';
|
2023-03-08 09:51:59 +00:00
|
|
|
|
|
|
|
/**
|
|
|
|
* Internal dependencies
|
|
|
|
*/
|
2023-03-22 07:48:55 +00:00
|
|
|
import { useProductEntityRecord } from './hooks/use-product-entity-record';
|
2023-03-22 10:30:06 +00:00
|
|
|
import './fills/product-block-editor-fills';
|
2023-05-18 08:25:36 +00:00
|
|
|
import './product-page.scss';
|
2023-03-08 09:51:59 +00:00
|
|
|
|
2023-03-10 20:21:22 +00:00
|
|
|
declare const productBlockEditorSettings: ProductEditorSettings;
|
|
|
|
|
2023-04-13 15:45:50 +00:00
|
|
|
productApiFetchMiddleware();
|
|
|
|
|
2023-03-22 07:48:55 +00:00
|
|
|
export default function ProductPage() {
|
|
|
|
const { productId } = useParams();
|
|
|
|
|
|
|
|
const product = useProductEntityRecord( productId );
|
|
|
|
|
2023-05-16 10:41:26 +00:00
|
|
|
useEffect( () => {
|
|
|
|
return initBlocks();
|
|
|
|
}, [] );
|
|
|
|
|
2023-03-15 16:44:05 +00:00
|
|
|
if ( ! product?.id ) {
|
2023-03-09 21:11:25 +00:00
|
|
|
return <Spinner />;
|
|
|
|
}
|
|
|
|
|
2023-03-10 20:21:22 +00:00
|
|
|
return (
|
|
|
|
<Editor
|
|
|
|
product={ product }
|
|
|
|
settings={ productBlockEditorSettings || {} }
|
|
|
|
/>
|
|
|
|
);
|
2023-03-08 09:51:59 +00:00
|
|
|
}
|