diff --git a/src/components/SemesterAdministration/SemesterAdministration.tsx b/src/components/SemesterAdministration/SemesterAdministration.tsx index b973077c..111b947e 100644 --- a/src/components/SemesterAdministration/SemesterAdministration.tsx +++ b/src/components/SemesterAdministration/SemesterAdministration.tsx @@ -89,7 +89,7 @@ export const SemesterAdministration: FC = () => { } const [semesterFreezeError, setSemesterFreezeError] = useState() - const [seriesFreezeError, setSeriesFreezeError] = useState() + const [seriesFreezeErrors, setSeriesFreezeErrors] = useState>() const {mutate: freezeSemester} = useMutation({ mutationFn: (semester: SemesterWithProblems) => @@ -107,11 +107,11 @@ export const SemesterAdministration: FC = () => { const {mutate: freezeSeries} = useMutation({ mutationFn: (series: SeriesWithProblems) => axios.post(`/api/competition/series/${series.id}/results/freeze`), onSuccess: () => refetch(), - onError: (error: unknown) => { + onError: (error: unknown, variables: SeriesWithProblems) => { if (error instanceof AxiosError) { - setSeriesFreezeError(error.response?.data.detail) + setSeriesFreezeErrors((prev) => new Map(prev).set(variables.id, error.response?.data.detail)) } else { - setSeriesFreezeError('Nastala neznáma chyba.') + setSeriesFreezeErrors((prev) => new Map(prev).set(variables.id, 'Nastala neznáma chyba.')) } }, }) @@ -155,7 +155,9 @@ export const SemesterAdministration: FC = () => { Uzavrieť sériu )} - {seriesFreezeError && {seriesFreezeError}} + {seriesFreezeErrors?.get(series.id) && ( + {seriesFreezeErrors?.get(series.id)} + )}