From d8908369614a7e0d975c8392882c73e24974a151 Mon Sep 17 00:00:00 2001 From: Gus Vanpoucke <159711661+gusvanpoucke@users.noreply.github.com> Date: Tue, 21 May 2024 20:23:27 +0200 Subject: [PATCH] popups voor cancel en save op addchangesubjectpage --- frontend/frontend/src/i18n/en.ts | 1 + frontend/frontend/src/i18n/nl.ts | 1 + .../subjectsPage/AddChangeSubjectPage.tsx | 40 ++++++++++++++++++- 3 files changed, 40 insertions(+), 2 deletions(-) diff --git a/frontend/frontend/src/i18n/en.ts b/frontend/frontend/src/i18n/en.ts index a6e00270..4140b168 100644 --- a/frontend/frontend/src/i18n/en.ts +++ b/frontend/frontend/src/i18n/en.ts @@ -125,6 +125,7 @@ const english = { cant_add_users_twice: 'You cannot add users to a subject twice', this_user_doesnt_exist: 'This user does not exist', status: 'Status', + save_course_warning: 'Save Course?', } export default english diff --git a/frontend/frontend/src/i18n/nl.ts b/frontend/frontend/src/i18n/nl.ts index 04fa8eb9..c958ada2 100644 --- a/frontend/frontend/src/i18n/nl.ts +++ b/frontend/frontend/src/i18n/nl.ts @@ -125,6 +125,7 @@ const dutch = { cant_add_users_twice: 'Je kan gebruikers geen twee keer toevoegen', this_user_doesnt_exist: 'Deze gebruiker bestaat niet', status: 'Status', + save_course_warning: 'Vak Opslaan?', } export default dutch diff --git a/frontend/frontend/src/pages/subjectsPage/AddChangeSubjectPage.tsx b/frontend/frontend/src/pages/subjectsPage/AddChangeSubjectPage.tsx index a43f97ae..5efe5e63 100644 --- a/frontend/frontend/src/pages/subjectsPage/AddChangeSubjectPage.tsx +++ b/frontend/frontend/src/pages/subjectsPage/AddChangeSubjectPage.tsx @@ -28,6 +28,7 @@ import ClearIcon from '@mui/icons-material/Clear' import Dialog from '@mui/material/Dialog' import instance from '../../axiosConfig.ts' import Papa, { ParseResult } from 'papaparse' +import WarningPopup from '../../components/WarningPopup.tsx' export interface User { user: number @@ -248,6 +249,17 @@ export function AddChangeSubjectPage() { const [loading, setLoading] = useState(false) const [userLoading, setUserLoading] = useState(true) + const [saveConfirmation, setSaveConfirmation] = useState(false) + const [cancelConfirmation, setCancelConfirmation] = useState(false) + + const closeSaveConfirmation = () => { + setSaveConfirmation(false) + } + + const closeCancel = () => { + setCancelConfirmation(false) + } + const handleCloseStudent = (): void => { setOpenStudent(false) } @@ -492,6 +504,10 @@ export function AddChangeSubjectPage() { } } + const handleCancel = (): void => { + navigate('/') + } + useEffect(() => { async function fetchUser() { setUserLoading(true) @@ -661,7 +677,7 @@ export function AddChangeSubjectPage() { - navigate(`/`) + setCancelConfirmation(true) } > {t('cancel')} @@ -669,7 +685,9 @@ export function AddChangeSubjectPage() { @@ -780,6 +798,24 @@ export function AddChangeSubjectPage() { + {/* Confirmation popup for saving course */} + + {/* Confirmation popup for canceling changes*/} + ) : (