import React, { useEffect } from 'react'; import SelectChoice from '@/components/SelectChoice'; export default function PaymentMethodSelector({ formData, setFormData, registrationPaymentModes, tuitionPaymentModes, errors, setIsPageValid, }) { useEffect(() => { const isValid = !Object.keys(formData).some( (field) => getLocalError(field) !== '' ); setIsPageValid(isValid); }, [formData, setIsPageValid]); const paymentModesOptions = [ { id: 1, name: 'Prélèvement SEPA' }, { id: 2, name: 'Virement' }, { id: 3, name: 'Chèque' }, { id: 4, name: 'Espèce' }, ]; const getError = (field) => { return errors?.student?.[field]?.[0]; }; const getLocalError = (field) => { if ( // Student Form (field === 'registration_payment' && (!formData.registration_payment || String(formData.registration_payment).trim() === '')) || (field === 'tuition_payment' && (!formData.tuition_payment || String(formData.tuition_payment).trim() === '')) ) { return 'Champs requis'; } return ''; }; const onChange = (field, value) => { setFormData((prev) => ({ ...prev, [field]: value })); }; return ( <>
Montant :{' '} {formData.totalRegistrationFees} €
Montant :{' '} {formData.totalTuitionFees} €