/** * External dependencies */ import { __, sprintf } from '@wordpress/i18n'; import { Notice, ExternalLink } from '@wordpress/components'; import { createInterpolateElement, useEffect } from '@wordpress/element'; import { Alert } from '@woocommerce/icons'; import { Icon } from '@wordpress/icons'; /** * Internal dependencies */ import { useCombinedIncompatibilityNotice } from './use-combined-incompatibility-notice'; import './editor.scss'; interface ExtensionNoticeProps { toggleDismissedStatus: ( status: boolean ) => void; block: 'woocommerce/cart' | 'woocommerce/checkout'; } export function IncompatibleExtensionsNotice( { toggleDismissedStatus, block, }: ExtensionNoticeProps ) { const [ isVisible, dismissNotice, incompatiblePaymentMethods, numberOfIncompatiblePaymentMethods, ] = useCombinedIncompatibilityNotice( block ); useEffect( () => { toggleDismissedStatus( ! isVisible ); }, [ isVisible, toggleDismissedStatus ] ); if ( ! isVisible ) { return null; } // console.log( incompatiblePaymentMethods ); const noticeContent = ( <> { numberOfIncompatiblePaymentMethods > 1 ? createInterpolateElement( __( 'The following extensions may be incompatible with the block-based checkout. Learn more', 'woo-gutenberg-products-block' ), { a: ( ), } ) : createInterpolateElement( sprintf( // translators: %s is the name of the extension that is incompatible with the block-based checkout. __( '%s may be incompatible with the block-based checkout. Learn more', 'woo-gutenberg-products-block' ), Object.values( incompatiblePaymentMethods )[ 0 ] ), { strong: , a: ( ), } ) } > ); return ( } /> { noticeContent } { numberOfIncompatiblePaymentMethods > 1 && ( { Object.entries( incompatiblePaymentMethods ).map( ( [ id, title ] ) => ( { title } ) ) } ) } ); }
{ noticeContent }