diff --git a/frontend/frontend/src/pages/mainPage/MainPage.tsx b/frontend/frontend/src/pages/mainPage/MainPage.tsx index d1b0230a..4f4d5c6e 100644 --- a/frontend/frontend/src/pages/mainPage/MainPage.tsx +++ b/frontend/frontend/src/pages/mainPage/MainPage.tsx @@ -137,6 +137,10 @@ export default function MainPage() { } const doArchive = async () => { console.log('Archive clicked') + const newCourses = courses.map((course) => + course.vak_id == archiveCourseId ? archiveSingleCourse(course) : course + ) + setCourses(newCourses) try { await instance.patch(`/vakken/${archiveCourseId}/`, { gearchiveerd: true, @@ -370,3 +374,10 @@ export default function MainPage() { ) } + +function archiveSingleCourse(course: Course): Course { + return { + ...course, + gearchiveerd: true, + } +}