mirror of
https://git.v0id.ovh/n3wt-innov/n3wt-school.git
synced 2026-01-29 07:53:23 +00:00
27 lines
818 B
JavaScript
27 lines
818 B
JavaScript
import React, { createContext, useState, useContext } from 'react';
|
|
|
|
const TeacherFormContext = createContext();
|
|
|
|
export const useTeacherForm = () => useContext(TeacherFormContext);
|
|
|
|
export const TeacherFormProvider = ({ children, initialTeacher }) => {
|
|
const [formData, setFormData] = useState(() => ({
|
|
last_name: initialTeacher.last_name || '',
|
|
first_name: initialTeacher.first_name || '',
|
|
email: initialTeacher.email || '',
|
|
specialities: initialTeacher.specialities || [],
|
|
associated_profile: initialTeacher.associated_profile || '',
|
|
droit: {
|
|
label: initialTeacher.droit?.label || '',
|
|
id: initialTeacher.droit?.id || 0
|
|
}
|
|
}));
|
|
|
|
|
|
return (
|
|
<TeacherFormContext.Provider value={{ formData, setFormData }}>
|
|
{children}
|
|
</TeacherFormContext.Provider>
|
|
);
|
|
};
|