mirror of
https://git.v0id.ovh/n3wt-innov/n3wt-school.git
synced 2026-01-29 07:53:23 +00:00
feat: Ajout de la fratrie [#27]
This commit is contained in:
@ -7,6 +7,7 @@ import logger from '@/utils/logger';
|
||||
import SectionHeader from '@/components/SectionHeader';
|
||||
import { User } from 'lucide-react';
|
||||
import FileUpload from '@/components/FileUpload';
|
||||
import { BASE_URL } from '@/utils/Url';
|
||||
|
||||
const levels = [
|
||||
{ value: '1', label: 'TPS - Très Petite Section' },
|
||||
@ -25,6 +26,7 @@ export default function StudentInfoForm({
|
||||
formData,
|
||||
setFormData,
|
||||
setGuardians,
|
||||
setSiblings,
|
||||
errors,
|
||||
setIsPageValid,
|
||||
hasInteracted,
|
||||
@ -37,9 +39,11 @@ export default function StudentInfoForm({
|
||||
fetchRegisterForm(studentId).then((data) => {
|
||||
logger.debug(data);
|
||||
|
||||
const photoPath = data?.student?.photo || null;
|
||||
|
||||
setFormData({
|
||||
id: data?.student?.id || '',
|
||||
photo: data?.student?.photo || null,
|
||||
photo: photoPath,
|
||||
last_name: data?.student?.last_name || '',
|
||||
first_name: data?.student?.first_name || '',
|
||||
address: data?.student?.address || '',
|
||||
@ -56,7 +60,29 @@ export default function StudentInfoForm({
|
||||
totalRegistrationFees: data?.totalRegistrationFees,
|
||||
totalTuitionFees: data?.totalTuitionFees,
|
||||
});
|
||||
|
||||
setGuardians(data?.student?.guardians || []);
|
||||
setSiblings(data?.student?.siblings || []);
|
||||
|
||||
// Convertir la photo en fichier binaire si elle est un chemin ou une URL
|
||||
if (photoPath && typeof photoPath === 'string') {
|
||||
fetch(`${BASE_URL}${photoPath}`)
|
||||
.then((response) => {
|
||||
if (!response.ok) {
|
||||
throw new Error('Erreur lors de la récupération de la photo.');
|
||||
}
|
||||
return response.blob();
|
||||
})
|
||||
.then((blob) => {
|
||||
const file = new File([blob], photoPath.split('/').pop(), {
|
||||
type: blob.type,
|
||||
});
|
||||
handlePhotoUpload(file); // Utiliser handlePhotoUpload pour valoriser la photo
|
||||
})
|
||||
.catch((error) => {
|
||||
logger.error('Erreur lors de la conversion de la photo :', error);
|
||||
});
|
||||
}
|
||||
});
|
||||
|
||||
setIsLoading(false);
|
||||
|
||||
Reference in New Issue
Block a user