/** * External dependencies */ import { InspectorControls, useBlockProps } from '@wordpress/block-editor'; import { formatPrice } from '@woocommerce/price-format'; import { PanelBody, ExternalLink, ToggleControl, BaseControl, __experimentalToggleGroupControlOption as ToggleGroupControlOption, __experimentalToggleGroupControl as ToggleGroupControl, } from '@wordpress/components'; import { getSetting } from '@woocommerce/settings'; import { __ } from '@wordpress/i18n'; import Noninteractive from '@woocommerce/base-components/noninteractive'; import type { ReactElement } from 'react'; import { useSelect } from '@wordpress/data'; /** * Internal dependencies */ import QuantityBadge from './quantity-badge'; import './editor.scss'; interface Attributes { addToCartBehaviour: string; hasHiddenPrice: boolean; cartAndCheckoutRenderStyle: boolean; } interface Props { attributes: Attributes; setAttributes: ( attributes: Record< string, unknown > ) => void; } const Edit = ( { attributes, setAttributes }: Props ): ReactElement => { const { addToCartBehaviour, hasHiddenPrice, cartAndCheckoutRenderStyle } = attributes; const blockProps = useBlockProps( { className: `wc-block-mini-cart`, } ); const isSiteEditor = useSelect( 'core/edit-site' ) !== undefined; const templatePartEditUri = getSetting( 'templatePartEditUri', '' ) as string; const productCount = 0; const productTotal = 0; return (
setAttributes( { hasHiddenPrice: ! hasHiddenPrice, } ) } /> { isSiteEditor && ( { setAttributes( { cartAndCheckoutRenderStyle: value, } ); } } help={ __( 'Select how the Mini-Cart behaves in the Cart and Checkout pages. This might affect the header layout.', 'woo-gutenberg-products-block' ) } > ) } { templatePartEditUri && ( <>

{ __( 'When opened, the Mini-Cart drawer gives shoppers quick access to view their selected products and checkout.', 'woo-gutenberg-products-block' ) }

{ __( 'Edit Mini-Cart Drawer template', 'woo-gutenberg-products-block' ) }

) } { setAttributes( { addToCartBehaviour: value ? 'open_drawer' : 'none', } ); } } help={ __( 'Toggle to open the Mini-Cart drawer when a shopper adds a product to their cart.', 'woo-gutenberg-products-block' ) } checked={ addToCartBehaviour === 'open_drawer' } />
); }; export default Edit;