From b1f828fcc9519a821e4d6829e333006def173aab Mon Sep 17 00:00:00 2001 From: rissois <44072214+rissois@users.noreply.github.com> Date: Thu, 26 Sep 2024 07:23:10 -0700 Subject: [PATCH] Analyze votes redirects to most recent content --- react-ui/src/pages/analyzeVotes/AnalyzeVotes.jsx | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/react-ui/src/pages/analyzeVotes/AnalyzeVotes.jsx b/react-ui/src/pages/analyzeVotes/AnalyzeVotes.jsx index 7edf574..415b298 100644 --- a/react-ui/src/pages/analyzeVotes/AnalyzeVotes.jsx +++ b/react-ui/src/pages/analyzeVotes/AnalyzeVotes.jsx @@ -84,7 +84,7 @@ function AnalyzeVotes() { const contestId = useContestId(); const { data: contests } = useSwrContests(); const contest = useMemo( - () => contests.find((c) => c.id === contestId) || contests[0], + () => contests.find((c) => c.id === contestId), [contests, contestId], ); const navigate = useNavigate(); @@ -100,6 +100,10 @@ function AnalyzeVotes() { const [user1, setUser1] = useState(''); const [user2, setUser2] = useState(''); + if (!contestId && contests[0]?.id) { + navigate(`/mod/analyze/${contests[0].id}`, { replace: true }); + } + const numberOfEntries = Object.keys(entryAvg).length; const usernames = useMemo(() => userAvg.map((ua) => ua.username), [userAvg]); const formattedContest = (name, date) => `${name} (${format(parseISO(date), 'MMM yy')})`;