2022-08-12 14:23:08 +00:00
/ * *
* External dependencies
* /
import { Notice , ExternalLink } from '@wordpress/components' ;
import { createInterpolateElement } from '@wordpress/element' ;
import { __ } from '@wordpress/i18n' ;
2022-08-29 08:35:05 +00:00
import classnames from 'classnames' ;
2022-08-12 14:23:08 +00:00
/ * *
* Internal dependencies
* /
import './editor.scss' ;
import { useCompatibilityNotice } from './use-compatibility-notice' ;
2024-01-05 03:47:34 +00:00
import { SwitchToClassicShortcodeButton } from '../switch-to-classic-shortcode-button' ;
interface CartCheckoutSidebarCompatibilityNoticeProps {
block : 'cart' | 'checkout' ;
clientId : string ;
}
2022-08-12 14:23:08 +00:00
export const CartCheckoutSidebarCompatibilityNotice = ( {
block ,
2024-01-05 03:47:34 +00:00
clientId ,
} : CartCheckoutSidebarCompatibilityNoticeProps ) = > {
2022-08-12 14:23:08 +00:00
const [ isVisible , dismissNotice ] = useCompatibilityNotice ( block ) ;
2024-01-05 03:47:34 +00:00
if ( ! isVisible ) {
return null ;
}
2022-08-12 14:23:08 +00:00
const noticeText = createInterpolateElement (
__ (
2024-01-05 03:47:34 +00:00
"Some extensions don't yet support this block, which may impact the shopper experience. To make sure this feature is right for your store, <a>review the list of compatible extensions</a>." ,
2023-12-12 22:12:36 +00:00
'woocommerce'
2022-08-12 14:23:08 +00:00
) ,
{
a : (
// Suppress the warning as this <a> will be interpolated into the string with content.
// eslint-disable-next-line jsx-a11y/anchor-has-content
2023-12-29 15:28:11 +00:00
< ExternalLink href = "https://woo.com/document/cart-checkout-blocks-status/#section-10" / >
2022-08-12 14:23:08 +00:00
) ,
}
) ;
return (
2022-08-29 08:35:05 +00:00
< Notice
onRemove = { dismissNotice }
className = { classnames ( [
'wc-blocks-sidebar-compatibility-notice' ,
{ 'is-hidden' : ! isVisible } ,
] ) }
2022-08-12 14:23:08 +00:00
>
2022-08-29 08:35:05 +00:00
{ noticeText }
2024-01-05 03:47:34 +00:00
< SwitchToClassicShortcodeButton
block = { ` woocommerce/ ${ block } ` }
clientId = { clientId }
type = { 'generic' }
/ >
2022-08-29 08:35:05 +00:00
< / Notice >
2022-08-12 14:23:08 +00:00
) ;
} ;