Skip to content

Commit

Permalink
SemesterAdmin removed semester freezing.
Browse files Browse the repository at this point in the history
Semester freezes automatically when all series are frozen.
  • Loading branch information
michalmasrna1 committed Nov 24, 2024
1 parent 3034a7b commit 28f1de3
Showing 1 changed file with 1 addition and 22 deletions.
23 changes: 1 addition & 22 deletions src/components/SemesterAdministration/SemesterAdministration.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -88,22 +88,8 @@ export const SemesterAdministration: FC = () => {
)
}

const [semesterFreezeError, setSemesterFreezeError] = useState<string>()
const [seriesFreezeErrors, setSeriesFreezeErrors] = useState<Map<number, string>>()

const {mutate: freezeSemester} = useMutation({
mutationFn: (semester: SemesterWithProblems) =>
axios.post(`/api/competition/semester/${semester.id}/results/freeze`),
onSuccess: () => refetch(),
onError: (error: unknown) => {
if (error instanceof AxiosError) {
setSemesterFreezeError(error.response?.data.detail)
} else {
setSemesterFreezeError('Nastala neznáma chyba.')
}
},
})

const {mutate: freezeSeries} = useMutation({
mutationFn: (series: SeriesWithProblems) => axios.post(`/api/competition/series/${series.id}/results/freeze`),
onSuccess: () => refetch(),
Expand Down Expand Up @@ -135,14 +121,7 @@ export const SemesterAdministration: FC = () => {
<>
<Stack alignItems="start" direction="row" spacing={2}>
<Typography variant="h2">Semester</Typography>
{semester.complete ? (
<Typography variant="body1">Semester je uzavretý</Typography>
) : (
<Button variant="button2" onClick={() => freezeSemester(semester)}>
Uzavrieť semester
</Button>
)}
{semesterFreezeError && <Typography variant="body1">{semesterFreezeError}</Typography>}
{semester.complete && <Typography variant="body1">Semester je uzavretý</Typography>}
</Stack>
{semester.series_set.map((series) => (
<Stack key={series.id} gap={1} mt={5}>
Expand Down

0 comments on commit 28f1de3

Please sign in to comment.