/** * External dependencies */ import { __ } from '@wordpress/i18n'; import { useBlockProps } from '@wordpress/block-editor'; import { Placeholder, Button } from 'wordpress-components'; import { useExpressPaymentMethods } from '@woocommerce/base-context/hooks'; import { Icon, payment } from '@wordpress/icons'; import { ADMIN_URL } from '@woocommerce/settings'; import classnames from 'classnames'; /** * Internal dependencies */ import Block from './block'; import './editor.scss'; /** * Renders a placeholder in the editor. */ const NoExpressPaymentMethodsPlaceholder = () => { return ( } label={ __( 'Express Checkout', 'woo-gutenberg-products-block' ) } className="wp-block-woocommerce-checkout-express-payment-block-placeholder" > { __( "Your store doesn't have any Payment Methods that support the Express Checkout Block. If they are added, they will be shown here.", 'woo-gutenberg-products-block' ) } ); }; export const Edit = ( { attributes, }: { attributes: { className: string }; } ): JSX.Element | null => { const { paymentMethods, isInitialized } = useExpressPaymentMethods(); const hasExpressPaymentMethods = Object.keys( paymentMethods ).length > 0; const blockProps = useBlockProps( { className: classnames( { 'wp-block-woocommerce-cart-express-payment-block--has-express-payment-methods': hasExpressPaymentMethods, } ), } ); const { className } = attributes; if ( ! isInitialized ) { return null; } return (
{ hasExpressPaymentMethods ? ( ) : ( ) }
); }; export const Save = (): JSX.Element => { return
; };