This commit is contained in:
Luigi Teschio 2023-04-12 18:27:02 +02:00 committed by GitHub
parent 6c86d45951
commit 4d1604bdd0
1 changed files with 12 additions and 47 deletions

View File

@ -9,14 +9,11 @@ import {
import { useEffect } from '@wordpress/element';
import type { BlockAlignment } from '@wordpress/blocks';
import { useSelect } from '@wordpress/data';
import { __ } from '@wordpress/i18n';
/**
* Internal dependencies
*/
import Block from './block';
import { BLOCK_TITLE, BLOCK_ICON } from './constants';
import { ProductSelector } from '../shared/product-selector';
type UnsupportedAligments = 'wide' | 'full';
type AllowedAlignments = Exclude< BlockAlignment, UnsupportedAligments >;
@ -82,12 +79,6 @@ const PriceEdit = ( {
]
);
const showProductSelector =
! isDescendentOfQueryLoop &&
! isDescendentOfSingleProductTemplate &&
! attributes.isDescendentOfSingleProductBlock;
if ( ! showProductSelector ) {
return (
<>
<BlockControls>
@ -103,32 +94,6 @@ const PriceEdit = ( {
</div>
</>
);
}
return (
<div { ...blockProps }>
<ProductSelector
productId={ attributes.productId }
setAttributes={ setAttributes }
icon={ BLOCK_ICON }
label={ BLOCK_TITLE }
description={ __(
'Choose a product to display its price.',
'woo-gutenberg-products-block'
) }
>
<BlockControls>
<AlignmentToolbar
value={ attributes.textAlign }
onChange={ ( textAlign: AllowedAlignments ) => {
setAttributes( { textAlign } );
} }
/>
</BlockControls>
<Block { ...blockAttrs } />
</ProductSelector>
</div>
);
};
export default PriceEdit;