/** * External dependencies */ import { __ } from '@wordpress/i18n'; import { Disabled, PanelBody } from '@wordpress/components'; import { InspectorControls } from '@wordpress/block-editor'; import ServerSideRender from '@wordpress/server-side-render'; import GridContentControl from '@woocommerce/editor-components/grid-content-control'; import GridLayoutControl from '@woocommerce/editor-components/grid-layout-control'; import ProductCategoryControl from '@woocommerce/editor-components/product-category-control'; import ProductStockControl from '@woocommerce/editor-components/product-stock-control'; import { gridBlockPreview } from '@woocommerce/resource-previews'; import { getSetting } from '@woocommerce/settings'; /** * Internal dependencies */ import { Props } from './types'; /** * Component to handle edit mode of "Top Rated Products". */ export const ProductTopRatedBlock = ( { attributes, name, setAttributes, }: Props ): JSX.Element => { const { categories, catOperator, columns, contentVisibility, rows, alignButtons, stockStatus, isPreview, } = attributes; const getInspectorControls = () => { return ( setAttributes( { contentVisibility: value } ) } /> { const ids = value.map( ( { id } ) => id ); setAttributes( { categories: ids } ); } } operator={ catOperator } onOperatorChange={ ( value = 'any' ) => setAttributes( { catOperator: value } ) } /> ); }; if ( isPreview ) { return gridBlockPreview; } return ( <> { getInspectorControls() } ); }; export default ProductTopRatedBlock;