Refactor the Overview tab > Features > Buttons

This commit is contained in:
Daniel Dudzic 2025-01-02 13:55:32 +01:00
parent 7a223de4a7
commit e4e95de5f6
No known key found for this signature in database
GPG key ID: 31B40D33E3465483
15 changed files with 602 additions and 239 deletions

View file

@ -0,0 +1,51 @@
import { __ } from '@wordpress/i18n';
import ModalPayPal from './ModalPayPal';
import ModalFastlane from './ModalFastlane';
import ModalAcdc from './ModalAcdc';
import { useActiveModal } from '../../../../data/common/hooks';
export const MODAL_CONFIG = {
paypal: {
component: ModalPayPal,
icon: 'payment-method-paypal-big',
title: __( 'PayPal', 'woocommerce-paypal-payments' ),
},
fastlane: {
component: ModalFastlane,
icon: 'payment-method-fastlane-big',
title: __( 'Fastlane by PayPal', 'woocommerce-paypal-payments' ),
size: 'small',
},
advanced_credit_and_debit_card_payments: {
component: ModalAcdc,
icon: 'payment-method-cards-big',
title: __(
'Advanced Credit and Debit Card Payments',
'woocommerce-paypal-payments'
),
},
};
const Modal = () => {
const { activeModal, setActiveModal } = useActiveModal();
const handleCloseModal = () => {
setActiveModal( '' );
};
if ( ! activeModal || ! MODAL_CONFIG[ activeModal ] ) {
return null;
}
const { component: ModalComponent, ...modalProps } =
MODAL_CONFIG[ activeModal ];
return (
<ModalComponent
setModalIsVisible={ handleCloseModal }
{ ...modalProps }
/>
);
};
export default Modal;