2021-08-25 15:42:55 +00:00
|
|
|
/**
|
|
|
|
* External dependencies
|
|
|
|
*/
|
2022-03-09 09:13:52 +00:00
|
|
|
import { InspectorControls, useBlockProps } from '@wordpress/block-editor';
|
2021-08-25 15:42:55 +00:00
|
|
|
import type { ReactElement } from 'react';
|
2021-10-29 02:35:17 +00:00
|
|
|
import { formatPrice } from '@woocommerce/price-format';
|
2021-10-21 09:07:20 +00:00
|
|
|
import { CartCheckoutCompatibilityNotice } from '@woocommerce/editor-components/compatibility-notices';
|
2022-03-09 09:13:52 +00:00
|
|
|
import { PanelBody, ExternalLink } from '@wordpress/components';
|
2021-12-14 00:54:23 +00:00
|
|
|
import { getSetting } from '@woocommerce/settings';
|
2021-11-17 15:39:07 +00:00
|
|
|
import { __ } from '@wordpress/i18n';
|
2021-12-07 14:29:56 +00:00
|
|
|
import Noninteractive from '@woocommerce/base-components/noninteractive';
|
2021-08-25 15:42:55 +00:00
|
|
|
|
2021-10-29 02:35:17 +00:00
|
|
|
/**
|
|
|
|
* Internal dependencies
|
|
|
|
*/
|
|
|
|
import QuantityBadge from './quantity-badge';
|
|
|
|
|
2022-03-09 09:13:52 +00:00
|
|
|
const MiniCartBlock = (): ReactElement => {
|
2021-08-25 15:42:55 +00:00
|
|
|
const blockProps = useBlockProps( {
|
2022-03-09 09:13:52 +00:00
|
|
|
className: `wc-block-mini-cart`,
|
2021-11-17 15:39:07 +00:00
|
|
|
} );
|
|
|
|
|
2021-12-14 00:54:23 +00:00
|
|
|
const templatePartEditUri = getSetting(
|
|
|
|
'templatePartEditUri',
|
|
|
|
''
|
|
|
|
) as string;
|
2021-11-30 09:42:07 +00:00
|
|
|
|
2021-08-25 15:42:55 +00:00
|
|
|
const productCount = 0;
|
2021-10-29 02:35:17 +00:00
|
|
|
const productTotal = 0;
|
2021-08-25 15:42:55 +00:00
|
|
|
|
|
|
|
return (
|
|
|
|
<div { ...blockProps }>
|
2021-11-17 15:39:07 +00:00
|
|
|
<InspectorControls>
|
2021-12-14 00:54:23 +00:00
|
|
|
{ templatePartEditUri && (
|
|
|
|
<PanelBody
|
|
|
|
title={ __(
|
|
|
|
'Template Editor',
|
|
|
|
'woo-gutenberg-products-block'
|
|
|
|
) }
|
|
|
|
>
|
|
|
|
<ExternalLink href={ templatePartEditUri }>
|
|
|
|
{ __(
|
|
|
|
'Edit template part',
|
2021-11-30 09:42:07 +00:00
|
|
|
'woo-gutenberg-products-block'
|
|
|
|
) }
|
2021-12-14 00:54:23 +00:00
|
|
|
</ExternalLink>
|
|
|
|
</PanelBody>
|
|
|
|
) }
|
2021-11-17 15:39:07 +00:00
|
|
|
</InspectorControls>
|
2021-12-07 14:29:56 +00:00
|
|
|
<Noninteractive>
|
2022-03-09 09:13:52 +00:00
|
|
|
<button className="wc-block-mini-cart__button">
|
2021-12-07 14:29:56 +00:00
|
|
|
<span className="wc-block-mini-cart__amount">
|
|
|
|
{ formatPrice( productTotal ) }
|
|
|
|
</span>
|
2022-03-09 09:13:52 +00:00
|
|
|
<QuantityBadge count={ productCount } />
|
2021-12-07 14:29:56 +00:00
|
|
|
</button>
|
|
|
|
</Noninteractive>
|
2021-10-21 09:07:20 +00:00
|
|
|
<CartCheckoutCompatibilityNotice blockName="mini-cart" />
|
2021-08-25 15:42:55 +00:00
|
|
|
</div>
|
|
|
|
);
|
|
|
|
};
|
|
|
|
|
|
|
|
export default MiniCartBlock;
|