From ab937f276e24378dcdfb6f6359d780b1a2c48645 Mon Sep 17 00:00:00 2001 From: Eivind Dalholt Date: Tue, 12 Sep 2023 16:16:35 +0200 Subject: [PATCH] fix: 404 page if slug is invalid --- frontend/src/pages/AssemblyPage.tsx | 13 +++++++++++-- 1 file changed, 11 insertions(+), 2 deletions(-) diff --git a/frontend/src/pages/AssemblyPage.tsx b/frontend/src/pages/AssemblyPage.tsx index c8a33f6..d50abe8 100644 --- a/frontend/src/pages/AssemblyPage.tsx +++ b/frontend/src/pages/AssemblyPage.tsx @@ -11,11 +11,13 @@ import Arrow from "../assets/Arrow.svg"; import { getCurrentVotationByGroup } from "../services/votation"; import { LimitedVoteType } from "../types/votes"; import { getUserData } from "../services/organizer"; +import { NotFound } from "./NotFound"; export function AssemblyLobby() { let navigate = useNavigate(); const { groupSlug } = useParams() as { groupSlug: string }; const [groupName, setGroupName] = useState(undefined); + const [groupNotFound, setGroupNotFound] = useState(false); const [kickedOut, setKickedOut] = useState(false); const [activeVotation, setActiveVotation] = useState(false); @@ -54,6 +56,10 @@ export function AssemblyLobby() { setGroupName(group.groupName); } }); + + if (!userData.groups.some((group) => group.groupSlug == groupSlug)) { + setGroupNotFound(true); + } }; getGroupName(); isCheckedIn(); @@ -95,7 +101,10 @@ export function AssemblyLobby() { navigate("/start"); } - return ( + return groupNotFound ? ( + // Render 404 not found component if group is not found + + ) : ( <> {!checkedIn && ( ) : ( <> - Check-in for {groupName} + {groupName && Check-in for {groupName}} )}