From 224c95fb7e41432d2edc15371723378200bb9b0d Mon Sep 17 00:00:00 2001 From: Mykhailo Date: Fri, 27 Dec 2024 18:11:33 +0100 Subject: [PATCH] Fix entered team points when switching teams using select button --- .../enter-form/EnterTeamPoints.tsx | 22 +++++++++---------- 1 file changed, 11 insertions(+), 11 deletions(-) diff --git a/client/src/pages/points-sheet/enter-form/EnterTeamPoints.tsx b/client/src/pages/points-sheet/enter-form/EnterTeamPoints.tsx index 98df9a96c..31cd5977b 100644 --- a/client/src/pages/points-sheet/enter-form/EnterTeamPoints.tsx +++ b/client/src/pages/points-sheet/enter-form/EnterTeamPoints.tsx @@ -10,7 +10,7 @@ import { import { useCustomSnackbar } from '../../../hooks/snackbar/useCustomSnackbar'; import { GradingList } from '../../../model/GradingList'; import { Team } from '../../../model/Team'; -import { ROUTES, useTutorialRoutes } from '../../../routes/Routing.routes'; +import { useTutorialRoutes } from '../../../routes/Routing.routes'; import { PointsFormSubmitCallback } from './components/EnterPointsForm.helpers'; import EnterPoints from './EnterPoints'; import { convertFormStateToGradingDTO } from './EnterPoints.helpers'; @@ -43,19 +43,10 @@ function EnterTeamPoints(): JSX.Element { setTeams(response); }) .catch(() => setError('Teams konnten nicht abgerufen werden.')); - - if (sheetId) { - getGradingsOfTutorial(sheetId, tutorialId) - .then((response) => setGradings(response)) - .catch(() => { - setError('Bewertungen konnten nicht abgerufen werden.'); - setGradings(new GradingList([])); - }); - } }, [tutorialId, sheetId, setError]); useEffect(() => { - if (!teamId) { + if (!teamId || !tutorialId) { return; } @@ -64,6 +55,15 @@ function EnterTeamPoints(): JSX.Element { if (newSelectedTeam) { setSelectedTeam(newSelectedTeam); } + + if (sheetId) { + getGradingsOfTutorial(sheetId, tutorialId) + .then((response) => setGradings(response)) + .catch(() => { + setError('Bewertungen konnten nicht abgerufen werden.'); + setGradings(new GradingList([])); + }); + } }, [teams, teamId]); const handleTeamChange = (event: SelectChangeEvent, child: React.ReactNode) => {