mirror of
https://git.v0id.ovh/n3wt-innov/n3wt-school.git
synced 2026-01-29 07:53:23 +00:00
refactor: Partie FRONT / School
This commit is contained in:
@ -11,6 +11,7 @@ import { BE_SCHOOL_SPECIALITIES_URL,
|
||||
import DjangoCSRFToken from '@/components/DjangoCSRFToken'
|
||||
import useCsrfToken from '@/hooks/useCsrfToken';
|
||||
import { ClassesProvider } from '@/context/ClassesContext';
|
||||
import { fetchSpecialities, fetchTeachers, fetchClasses, fetchSchedules } from '@/app/lib/schoolAction';
|
||||
|
||||
export default function Page() {
|
||||
const [specialities, setSpecialities] = useState([]);
|
||||
@ -27,21 +28,20 @@ export default function Page() {
|
||||
|
||||
useEffect(() => {
|
||||
// Fetch data for specialities
|
||||
fetchSpecialities();
|
||||
handleSpecialities();
|
||||
|
||||
// Fetch data for teachers
|
||||
fetchTeachers();
|
||||
handleTeachers();
|
||||
|
||||
// Fetch data for classes
|
||||
fetchClasses();
|
||||
handleClasses();
|
||||
|
||||
// Fetch data for schedules
|
||||
fetchSchedules();
|
||||
handleSchedules();
|
||||
}, []);
|
||||
|
||||
const fetchSpecialities = () => {
|
||||
fetch(`${BE_SCHOOL_SPECIALITIES_URL}`)
|
||||
.then(response => response.json())
|
||||
const handleSpecialities = () => {
|
||||
fetchSpecialities()
|
||||
.then(data => {
|
||||
setSpecialities(data);
|
||||
})
|
||||
@ -50,9 +50,8 @@ export default function Page() {
|
||||
});
|
||||
};
|
||||
|
||||
const fetchTeachers = () => {
|
||||
fetch(`${BE_SCHOOL_TEACHERS_URL}`)
|
||||
.then(response => response.json())
|
||||
const handleTeachers = () => {
|
||||
fetchTeachers()
|
||||
.then(data => {
|
||||
setTeachers(data);
|
||||
})
|
||||
@ -61,9 +60,8 @@ export default function Page() {
|
||||
});
|
||||
};
|
||||
|
||||
const fetchClasses = () => {
|
||||
fetch(`${BE_SCHOOL_SCHOOLCLASSES_URL}`)
|
||||
.then(response => response.json())
|
||||
const handleClasses = () => {
|
||||
fetchClasses()
|
||||
.then(data => {
|
||||
setClasses(data);
|
||||
})
|
||||
@ -72,9 +70,8 @@ export default function Page() {
|
||||
});
|
||||
};
|
||||
|
||||
const fetchSchedules = () => {
|
||||
fetch(`${BE_SCHOOL_PLANNINGS_URL}`)
|
||||
.then(response => response.json())
|
||||
const handleSchedules = () => {
|
||||
fetchSchedules()
|
||||
.then(data => {
|
||||
setSchedules(data);
|
||||
})
|
||||
@ -142,7 +139,6 @@ export default function Page() {
|
||||
});
|
||||
};
|
||||
|
||||
|
||||
const handleDelete = (url, id, setDatas) => {
|
||||
fetch(`${url}/${id}`, {
|
||||
method:'DELETE',
|
||||
|
||||
@ -1,9 +1,26 @@
|
||||
import {
|
||||
BE_SCHOOL_SCHOOLCLASSES_URL
|
||||
BE_SCHOOL_SPECIALITIES_URL,
|
||||
BE_SCHOOL_TEACHERS_URL,
|
||||
BE_SCHOOL_SCHOOLCLASSES_URL,
|
||||
BE_SCHOOL_PLANNINGS_URL
|
||||
} from '@/utils/Url';
|
||||
|
||||
export const fetchClasses = () => {
|
||||
return fetch(`${BE_SCHOOL_SCHOOLCLASSES_URL}`)
|
||||
.then(response => response.json())
|
||||
export const fetchSpecialities = () => {
|
||||
return fetch(`${BE_SCHOOL_SPECIALITIES_URL}`)
|
||||
.then(response => response.json())
|
||||
};
|
||||
|
||||
};
|
||||
export const fetchTeachers = () => {
|
||||
return fetch(`${BE_SCHOOL_TEACHERS_URL}`)
|
||||
.then(response => response.json())
|
||||
};
|
||||
|
||||
export const fetchClasses = () => {
|
||||
return fetch(`${BE_SCHOOL_SCHOOLCLASSES_URL}`)
|
||||
.then(response => response.json())
|
||||
};
|
||||
|
||||
export const fetchSchedules = () => {
|
||||
return fetch(`${BE_SCHOOL_PLANNINGS_URL}`)
|
||||
.then(response => response.json())
|
||||
};
|
||||
Reference in New Issue
Block a user