import SettingsBlock from '../SettingsBlock'; import PaymentMethodItemBlock from './PaymentMethodItemBlock'; import { PaymentHooks } from '../../../data'; // TODO: This is not a reusable component, as it's connected to the Redux store. const PaymentMethodsBlock = ( { paymentMethods = [], onTriggerModal } ) => { const { changePaymentSettings } = PaymentHooks.useStore(); const handleSelect = ( methodId, isSelected ) => changePaymentSettings( methodId, { enabled: isSelected, } ); if ( ! paymentMethods.length ) { return null; } return ( { paymentMethods // Remove empty/invalid payment method entries. .filter( ( m ) => m.id ) .map( ( paymentMethod ) => ( handleSelect( paymentMethod.id, checked ) } onTriggerModal={ () => onTriggerModal?.( paymentMethod.id ) } /> ) ) } ); }; export default PaymentMethodsBlock;