From d4321840b850923ceb31afbaf8648bb2a2203459 Mon Sep 17 00:00:00 2001 From: Canaan Guo Date: Sat, 21 Feb 2026 06:17:51 +0000 Subject: [PATCH 1/3] Add event link to individual game page --- client/src/pages/games/[id].tsx | 28 +++++++++++++++++++++++++--- 1 file changed, 25 insertions(+), 3 deletions(-) diff --git a/client/src/pages/games/[id].tsx b/client/src/pages/games/[id].tsx index 5c11078..16eae68 100644 --- a/client/src/pages/games/[id].tsx +++ b/client/src/pages/games/[id].tsx @@ -5,6 +5,7 @@ import { SocialIcon } from "react-social-icons"; import { GameEmbed } from "@/components/ui/GameEmbed"; import { ItchEmbed } from "@/components/ui/ItchEmbed"; +import { useEvents } from "@/hooks/useEvents"; import { useGame } from "@/hooks/useGames"; export default function IndividualGamePage() { @@ -17,6 +18,7 @@ export default function IndividualGamePage() { error, isError, } = useGame(router.isReady ? id : undefined); + const { data: eventsData } = useEvents({}); if (isPending) { return ( @@ -55,6 +57,15 @@ export default function IndividualGamePage() { const gameEmbedID = game.itchGameEmbedID; const gameWidth = game.itchGameWidth; const gameHeight = game.itchGameHeight; + const eventID = game.event; + let eventName = ""; + if (eventID && eventsData && Array.isArray(eventsData.items)) { + const eventObj = eventsData.items.find((e) => e.id === eventID); + eventName = eventObj ? eventObj.name : ""; + } + + console.log("eventID:", eventID); + console.log("eventsData:", eventsData); const completionLabels: Record = { 1: "WIP", @@ -65,8 +76,6 @@ export default function IndividualGamePage() { const devStage = completionLabels[game.completion] ?? "Stage Unknown"; - // TODO ADD EVENT - const event = "Game Jam November 2025"; // TODO ADD ARTIMAGES const artImages: { src: string; alt: string }[] = []; // const artImages = [ @@ -173,7 +182,20 @@ export default function IndividualGamePage() { Event - {event} + + {eventID && eventName ? ( + + {eventName} + + ) : ( + + No upcoming event + + )} + From 1245a376a438bb73bad9cc09b5da2256e0e14275 Mon Sep 17 00:00:00 2001 From: Canaan Guo Date: Sat, 21 Feb 2026 06:30:44 +0000 Subject: [PATCH 2/3] Fix wrong hook and use useEvent instead --- client/src/pages/games/[id].tsx | 17 ++++++----------- 1 file changed, 6 insertions(+), 11 deletions(-) diff --git a/client/src/pages/games/[id].tsx b/client/src/pages/games/[id].tsx index 16eae68..b22dd7d 100644 --- a/client/src/pages/games/[id].tsx +++ b/client/src/pages/games/[id].tsx @@ -5,7 +5,7 @@ import { SocialIcon } from "react-social-icons"; import { GameEmbed } from "@/components/ui/GameEmbed"; import { ItchEmbed } from "@/components/ui/ItchEmbed"; -import { useEvents } from "@/hooks/useEvents"; +import { useEvent } from "@/hooks/useEvent"; import { useGame } from "@/hooks/useGames"; export default function IndividualGamePage() { @@ -18,7 +18,9 @@ export default function IndividualGamePage() { error, isError, } = useGame(router.isReady ? id : undefined); - const { data: eventsData } = useEvents({}); + const { data: eventData } = useEvent( + game?.event ? String(game.event) : undefined, + ); if (isPending) { return ( @@ -58,14 +60,7 @@ export default function IndividualGamePage() { const gameWidth = game.itchGameWidth; const gameHeight = game.itchGameHeight; const eventID = game.event; - let eventName = ""; - if (eventID && eventsData && Array.isArray(eventsData.items)) { - const eventObj = eventsData.items.find((e) => e.id === eventID); - eventName = eventObj ? eventObj.name : ""; - } - - console.log("eventID:", eventID); - console.log("eventsData:", eventsData); + const eventName = eventData?.name || ""; const completionLabels: Record = { 1: "WIP", @@ -192,7 +187,7 @@ export default function IndividualGamePage() { ) : ( - No upcoming event + No past/upcoming event )} From d2c4f0cfec27ad8bc0ad1f8cf564fd83d0743dc2 Mon Sep 17 00:00:00 2001 From: Canaan Guo Date: Sat, 21 Feb 2026 06:39:53 +0000 Subject: [PATCH 3/3] Fix the bug that unpublished event would leak through /event/{id} --- server/game_dev/views.py | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/server/game_dev/views.py b/server/game_dev/views.py index 086119c..751d4a4 100644 --- a/server/game_dev/views.py +++ b/server/game_dev/views.py @@ -60,7 +60,16 @@ class EventDetailAPIView(generics.RetrieveAPIView): lookup_url_kwarg = "id" def get_queryset(self): - return Event.objects.filter(id=self.kwargs["id"]) + now = timezone.now().date() + return Event.objects.filter(id=self.kwargs["id"], publicationDate__lte=now) + + def get_object(self): + queryset = self.get_queryset() + try: + return queryset.get() + except Event.DoesNotExist: + from rest_framework.exceptions import NotFound + raise NotFound(detail="The event is not yet published by admin or does not exist.") class GameshowcaseAPIView(APIView):