mirror of
https://git.v0id.ovh/n3wt-innov/n3wt-school.git
synced 2026-01-29 07:53:23 +00:00
refactor: refactoring du FRONT page subscribe
This commit is contained in:
@ -4,10 +4,10 @@ import { School, Calendar } from 'lucide-react';
|
||||
import TabsStructure from '@/components/Structure/Configuration/TabsStructure';
|
||||
import ScheduleManagement from '@/components/Structure/Planning/ScheduleManagement'
|
||||
import StructureManagement from '@/components/Structure/Configuration/StructureManagement'
|
||||
import { BK_GESTIONENSEIGNANTS_SPECIALITES_URL,
|
||||
BK_GESTIONENSEIGNANTS_CLASSES_URL,
|
||||
BK_GESTIONENSEIGNANTS_TEACHERS_URL,
|
||||
BK_GESTIONENSEIGNANTS_PLANNINGS_URL } from '@/utils/Url';
|
||||
import { BE_SCHOOL_SPECIALITIES_URL,
|
||||
BE_SCHOOL_SCHOOLCLASSES_URL,
|
||||
BE_SCHOOL_TEACHERS_URL,
|
||||
BE_SCHOOL_PLANNINGS_URL } from '@/utils/Url';
|
||||
import DjangoCSRFToken from '@/components/DjangoCSRFToken'
|
||||
import useCsrfToken from '@/hooks/useCsrfToken';
|
||||
import { ClassesProvider } from '@/context/ClassesContext';
|
||||
@ -34,13 +34,13 @@ export default function Page() {
|
||||
|
||||
// Fetch data for classes
|
||||
fetchClasses();
|
||||
|
||||
|
||||
// Fetch data for schedules
|
||||
fetchSchedules();
|
||||
}, []);
|
||||
|
||||
const fetchSpecialities = () => {
|
||||
fetch(`${BK_GESTIONENSEIGNANTS_SPECIALITES_URL}`)
|
||||
fetch(`${BE_SCHOOL_SPECIALITIES_URL}`)
|
||||
.then(response => response.json())
|
||||
.then(data => {
|
||||
setSpecialities(data);
|
||||
@ -51,7 +51,7 @@ export default function Page() {
|
||||
};
|
||||
|
||||
const fetchTeachers = () => {
|
||||
fetch(`${BK_GESTIONENSEIGNANTS_TEACHERS_URL}`)
|
||||
fetch(`${BE_SCHOOL_TEACHERS_URL}`)
|
||||
.then(response => response.json())
|
||||
.then(data => {
|
||||
setTeachers(data);
|
||||
@ -62,7 +62,7 @@ export default function Page() {
|
||||
};
|
||||
|
||||
const fetchClasses = () => {
|
||||
fetch(`${BK_GESTIONENSEIGNANTS_CLASSES_URL}`)
|
||||
fetch(`${BE_SCHOOL_SCHOOLCLASSES_URL}`)
|
||||
.then(response => response.json())
|
||||
.then(data => {
|
||||
setClasses(data);
|
||||
@ -73,7 +73,7 @@ export default function Page() {
|
||||
};
|
||||
|
||||
const fetchSchedules = () => {
|
||||
fetch(`${BK_GESTIONENSEIGNANTS_PLANNINGS_URL}`)
|
||||
fetch(`${BE_SCHOOL_PLANNINGS_URL}`)
|
||||
.then(response => response.json())
|
||||
.then(data => {
|
||||
setSchedules(data);
|
||||
@ -141,13 +141,13 @@ export default function Page() {
|
||||
console.error('Erreur :', error);
|
||||
});
|
||||
};
|
||||
|
||||
|
||||
|
||||
const handleDelete = (url, id, setDatas) => {
|
||||
fetch(`${url}/${id}`, {
|
||||
method:'DELETE',
|
||||
headers: {
|
||||
'Content-Type':'application/json',
|
||||
'Content-Type':'application/json',
|
||||
'X-CSRFToken': csrfToken
|
||||
},
|
||||
credentials: 'include'
|
||||
@ -172,12 +172,12 @@ export default function Page() {
|
||||
|
||||
{activeTab === 'Configuration' && (
|
||||
<>
|
||||
<StructureManagement
|
||||
<StructureManagement
|
||||
specialities={specialities}
|
||||
setSpecialities={setSpecialities}
|
||||
teachers={teachers}
|
||||
setTeachers={setTeachers}
|
||||
classes={classes}
|
||||
classes={classes}
|
||||
setClasses={setClasses}
|
||||
handleCreate={handleCreate}
|
||||
handleEdit={handleEdit}
|
||||
@ -190,7 +190,7 @@ export default function Page() {
|
||||
<ScheduleManagement
|
||||
handleUpdatePlanning={handleUpdatePlanning}
|
||||
classes={classes}
|
||||
/>
|
||||
/>
|
||||
</ClassesProvider>
|
||||
)}
|
||||
</div>
|
||||
|
||||
Reference in New Issue
Block a user