/**
* External dependencies
*/
import { _n } 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 { useIncompatiblePaymentGatewaysNotice } from './use-incompatible-payment-gateways-notice';
import './editor.scss';
interface PaymentGatewaysNoticeProps {
toggleDismissedStatus: ( status: boolean ) => void;
block: 'woocommerce/cart' | 'woocommerce/checkout';
}
export function IncompatiblePaymentGatewaysNotice( {
toggleDismissedStatus,
block,
}: PaymentGatewaysNoticeProps ) {
const [
isVisible,
dismissNotice,
incompatiblePaymentMethods,
numberOfIncompatiblePaymentMethods,
] = useIncompatiblePaymentGatewaysNotice( block );
useEffect( () => {
toggleDismissedStatus( ! isVisible );
}, [ isVisible, toggleDismissedStatus ] );
if ( ! isVisible ) {
return null;
}
const noticeContent = createInterpolateElement(
_n(
'The following extension is incompatible with the block-based checkout. Learn more',
'The following extensions are incompatible with the block-based checkout. Learn more',
numberOfIncompatiblePaymentMethods,
'woo-gutenberg-products-block'
),
{
a: (
// Suppress the warning as this will be interpolated into the string with content.
// eslint-disable-next-line jsx-a11y/anchor-has-content
),
}
);
return (
}
/>
{ noticeContent }
{ Object.entries( incompatiblePaymentMethods ).map(
( [ id, title ] ) => (
-
{ title }
)
) }
);
}