woocommerce/plugins/woocommerce-blocks/assets/js/blocks/order-confirmation/downloads-wrapper/edit.tsx

55 lines
1.0 KiB
TypeScript

/**
* External dependencies
*/
import { useBlockProps, InnerBlocks } from '@wordpress/block-editor';
import { getSetting } from '@woocommerce/settings';
const Edit = ( {
attributes,
setAttributes,
}: {
attributes: {
heading: string;
};
setAttributes: ( attributes: Record< string, unknown > ) => void;
} ) => {
const blockProps = useBlockProps();
const hasDownloadableProducts = getSetting(
'storeHasDownloadableProducts'
);
if ( ! hasDownloadableProducts ) {
return null;
}
return (
<div { ...blockProps }>
<InnerBlocks
allowedBlocks={ [ 'core/heading' ] }
template={ [
[
'core/heading',
{
level: 3,
style: { typography: { fontSize: '24px' } },
content: attributes.heading || '',
onChangeContent: ( value: string ) =>
setAttributes( { heading: value } ),
},
],
[
'woocommerce/order-confirmation-downloads',
{
lock: {
remove: true,
},
},
],
] }
/>
</div>
);
};
export default Edit;