mirror of
https://git.v0id.ovh/n3wt-innov/n3wt-school.git
synced 2026-01-28 23:43:22 +00:00
refactor: Création de nouveaux composants / update formulaire de
création de classe (#2)
This commit is contained in:
22
Front-End/src/context/TeacherFormContext.js
Normal file
22
Front-End/src/context/TeacherFormContext.js
Normal file
@ -0,0 +1,22 @@
|
||||
import React, { createContext, useState, useContext } from 'react';
|
||||
|
||||
const TeacherFormContext = createContext();
|
||||
|
||||
export const useTeacherForm = () => useContext(TeacherFormContext);
|
||||
|
||||
export const TeacherFormProvider = ({ children, initialTeacher }) => {
|
||||
const [formData, setFormData] = useState(() => ({
|
||||
nom: initialTeacher.nom || '',
|
||||
prenom: initialTeacher.prenom || '',
|
||||
mail: initialTeacher.mail || '',
|
||||
specialites_ids: initialTeacher.specialites_ids || [],
|
||||
profilAssocie_id: initialTeacher.profilAssocie_id || '',
|
||||
droit: initialTeacher.droit || 0
|
||||
}));
|
||||
|
||||
return (
|
||||
<TeacherFormContext.Provider value={{ formData, setFormData }}>
|
||||
{children}
|
||||
</TeacherFormContext.Provider>
|
||||
);
|
||||
};
|
||||
Reference in New Issue
Block a user