import React, { useEffect } from 'react'; import SelectChoice from '@/components/SelectChoice'; import RadioList from '@/components/RadioList'; export default function PaymentMethodSelector({ formData, setFormData, registrationPaymentModes, tuitionPaymentModes, registrationPaymentPlans, tuitionPaymentPlans, errors, setIsPageValid, }) { useEffect(() => { const isValid = !Object.keys(formData).some( (field) => getLocalError(field) !== '' ); setIsPageValid(isValid); console.log('formdata : ', formData); }, [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 paymentPlansOptions = [ { id: 1, name: '1 fois' }, { id: 3, name: '3 fois' }, { id: 10, name: '10 fois' }, { id: 12, name: '12 fois' }, ]; const getError = (field) => { return errors?.student?.[field]?.[0]; }; const getLocalError = (field) => { if ( (field === 'registration_payment' && (!formData.registration_payment || String(formData.registration_payment).trim() === '')) || (field === 'tuition_payment' && (!formData.tuition_payment || String(formData.tuition_payment).trim() === '')) || (field === 'registration_payment_plan' && (!formData.registration_payment_plan || String(formData.registration_payment_plan).trim() === '')) || (field === 'tuition_payment_plan' && (!formData.tuition_payment_plan || String(formData.tuition_payment_plan).trim() === '')) ) { return 'Champs requis'; } return ''; }; const onChange = (field, value) => { setFormData((prev) => ({ ...prev, [field]: value })); }; return ( <> {/* Frais d'inscription */}
Montant :{' '} {formData.totalRegistrationFees} €
Montant :{' '} {formData.totalTuitionFees} €