Skip to content

Commit d432184

Browse files
committed
Add event link to individual game page
1 parent 8c53a22 commit d432184

1 file changed

Lines changed: 25 additions & 3 deletions

File tree

client/src/pages/games/[id].tsx

Lines changed: 25 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@ import { SocialIcon } from "react-social-icons";
55

66
import { GameEmbed } from "@/components/ui/GameEmbed";
77
import { ItchEmbed } from "@/components/ui/ItchEmbed";
8+
import { useEvents } from "@/hooks/useEvents";
89
import { useGame } from "@/hooks/useGames";
910

1011
export default function IndividualGamePage() {
@@ -17,6 +18,7 @@ export default function IndividualGamePage() {
1718
error,
1819
isError,
1920
} = useGame(router.isReady ? id : undefined);
21+
const { data: eventsData } = useEvents({});
2022

2123
if (isPending) {
2224
return (
@@ -55,6 +57,15 @@ export default function IndividualGamePage() {
5557
const gameEmbedID = game.itchGameEmbedID;
5658
const gameWidth = game.itchGameWidth;
5759
const gameHeight = game.itchGameHeight;
60+
const eventID = game.event;
61+
let eventName = "";
62+
if (eventID && eventsData && Array.isArray(eventsData.items)) {
63+
const eventObj = eventsData.items.find((e) => e.id === eventID);
64+
eventName = eventObj ? eventObj.name : "";
65+
}
66+
67+
console.log("eventID:", eventID);
68+
console.log("eventsData:", eventsData);
5869

5970
const completionLabels: Record<number, string> = {
6071
1: "WIP",
@@ -65,8 +76,6 @@ export default function IndividualGamePage() {
6576

6677
const devStage = completionLabels[game.completion] ?? "Stage Unknown";
6778

68-
// TODO ADD EVENT
69-
const event = "Game Jam November 2025";
7079
// TODO ADD ARTIMAGES
7180
const artImages: { src: string; alt: string }[] = [];
7281
// const artImages = [
@@ -173,7 +182,20 @@ export default function IndividualGamePage() {
173182
<td className="py-1 pr-2 text-muted-foreground sm:py-2">
174183
Event
175184
</td>
176-
<td className="py-1 text-right sm:py-2">{event}</td>
185+
<td className="py-1 text-right sm:py-2">
186+
{eventID && eventName ? (
187+
<a
188+
href={`/events/${eventID}`}
189+
className="text-primary hover:underline"
190+
>
191+
{eventName}
192+
</a>
193+
) : (
194+
<span className="text-muted-foreground">
195+
No upcoming event
196+
</span>
197+
)}
198+
</td>
177199
</tr>
178200
</tbody>
179201
</table>

0 commit comments

Comments
 (0)