Skip to content

Commit

Permalink
Merge branch 'merge_problems_fix' of https://github.com/SELab-2/UGent-4
Browse files Browse the repository at this point in the history
… into merge_problems_fix
  • Loading branch information
sPAICEcake committed May 21, 2024
2 parents 8a7c18f + d890836 commit 2ec6f9c
Show file tree
Hide file tree
Showing 3 changed files with 40 additions and 2 deletions.
1 change: 1 addition & 0 deletions frontend/frontend/src/i18n/en.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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
1 change: 1 addition & 0 deletions frontend/frontend/src/i18n/nl.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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
40 changes: 38 additions & 2 deletions frontend/frontend/src/pages/subjectsPage/AddChangeSubjectPage.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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)
}
Expand Down Expand Up @@ -492,6 +504,10 @@ export function AddChangeSubjectPage() {
}
}

const handleCancel = (): void => {
navigate('/')
}

useEffect(() => {
async function fetchUser() {
setUserLoading(true)
Expand Down Expand Up @@ -661,15 +677,17 @@ export function AddChangeSubjectPage() {
<SecondaryButton
/* This is the large save button on the top of the page */
onClick={() =>
navigate(`/`)
setCancelConfirmation(true)
}
>
{t('cancel')}
</SecondaryButton>

<Button
/* This is the large save button on the top of the page */
onClick={handleSave}
onClick={() =>
setSaveConfirmation(true)
}
>
{t('save')}
</Button>
Expand Down Expand Up @@ -780,6 +798,24 @@ export function AddChangeSubjectPage() {
</Box>
</Stack>
</Stack>
{/* Confirmation popup for saving course */}
<WarningPopup
title={t('save_course_warning')}
content={t('visible_for_everyone')}
buttonName={t('confirm')}
open={saveConfirmation}
handleClose={closeSaveConfirmation}
doAction={handleSave}
/>
{/* Confirmation popup for canceling changes*/}
<WarningPopup
title={t('undo_changes_warning')}
content={t('cant_be_undone')}
buttonName={t('confirm')}
open={cancelConfirmation}
handleClose={closeCancel}
doAction={handleCancel}
/>
</Stack>
</>
) : (
Expand Down

0 comments on commit 2ec6f9c

Please sign in to comment.