Skip to content

Commit

Permalink
Fix entered team points when switching teams using select button
Browse files Browse the repository at this point in the history
  • Loading branch information
Morphenoed committed Dec 27, 2024
1 parent e70501a commit 224c95f
Showing 1 changed file with 11 additions and 11 deletions.
22 changes: 11 additions & 11 deletions client/src/pages/points-sheet/enter-form/EnterTeamPoints.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -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';
Expand Down Expand Up @@ -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;
}

Expand All @@ -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<unknown>, child: React.ReactNode) => {
Expand Down

0 comments on commit 224c95f

Please sign in to comment.