From c668c6ce44b63733763d6c6bb3edfd531eb7b2de Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?S=C3=A1muel=20Fekete?= Date: Sun, 29 Dec 2024 20:19:56 +0100 Subject: [PATCH] fix weight page redirect --- .../src/pages/seasons/WeightAdjustment.page.tsx | 13 ++++++++++++- 1 file changed, 12 insertions(+), 1 deletion(-) diff --git a/packages/client/src/pages/seasons/WeightAdjustment.page.tsx b/packages/client/src/pages/seasons/WeightAdjustment.page.tsx index f2aed5b..b8f138d 100644 --- a/packages/client/src/pages/seasons/WeightAdjustment.page.tsx +++ b/packages/client/src/pages/seasons/WeightAdjustment.page.tsx @@ -2,8 +2,11 @@ import { Alert, AlertDescription, AlertIcon, Button, Heading, HStack, SimpleGrid import { useMemo } from 'react' import { FaEdit, FaMedal, FaRedoAlt } from 'react-icons/fa' import { useNavigate, useParams } from 'react-router-dom' +import { useAuthContext } from 'src/api/contexts/useAuthContext' import { useFetchSeasonWeights } from 'src/api/hooks/seasonHooks' import { LoadingSpinner } from 'src/components/commons/LoadingSpinner' +import { LoginNavigate } from 'src/components/commons/LoginNavigate' +import { NavigateWithError } from 'src/components/commons/NavigateWithError' import { criterionWeightReducer } from 'src/util/criterionWeightHelper' import { PATHS } from 'src/util/paths' import { CategoryWeights } from './components/CategoryWeights' @@ -11,8 +14,9 @@ import { SourceSeasonSelectorModal } from './components/SourceSeasonSelectorModa export const WeightAdjustmentPage = () => { const { seasonId } = useParams() - const { isLoading, data } = useFetchSeasonWeights(seasonId) + const { isLoading, data, error } = useFetchSeasonWeights(seasonId) const nav = useNavigate() + const { isLoggedIn } = useAuthContext() const totalWeightSum = useMemo(() => { if (!data) return 0 @@ -28,6 +32,13 @@ export const WeightAdjustmentPage = () => { }, 0) }, [data]) + if (!isLoggedIn) { + return + } + if (error) { + return + } + if (isLoading || !data) return return (