import { ToggleControl, Icon, Button } from '@wordpress/components'; import { cog } from '@wordpress/icons'; import { useEffect } from '@wordpress/element'; import { useActiveHighlight } from '../../../data/common/hooks'; import SettingsBlock from '../SettingsBlock'; import PaymentMethodIcon from '../PaymentMethodIcon'; const PaymentMethodItemBlock = ( { paymentMethod, onTriggerModal, onSelect, isSelected, } ) => { const { activeHighlight, setActiveHighlight } = useActiveHighlight(); const isHighlighted = activeHighlight === paymentMethod.id; // Reset the active highlight after 2 seconds useEffect( () => { if ( isHighlighted ) { const timer = setTimeout( () => { setActiveHighlight( null ); }, 2000 ); return () => clearTimeout( timer ); } }, [ isHighlighted, setActiveHighlight ] ); return (
{ paymentMethod?.icon && ( ) } { paymentMethod.itemTitle }

{ paymentMethod.itemDescription }

{ paymentMethod?.fields && onTriggerModal && ( ) }
); }; export default PaymentMethodItemBlock;