From 945c8d18f64ef05fc6e2e553510dd23592d4dbfd Mon Sep 17 00:00:00 2001 From: Adrian Bonpin Date: Sun, 26 Apr 2026 10:30:22 -0500 Subject: [PATCH] feat: add benchmark submission page and button --- app/game/[id]/game-page-client.tsx | 13 +++++ app/game/[id]/submit/page.tsx | 78 ++++++++++++++++++++++++++++++ 2 files changed, 91 insertions(+) create mode 100644 app/game/[id]/submit/page.tsx diff --git a/app/game/[id]/game-page-client.tsx b/app/game/[id]/game-page-client.tsx index 7bf0d1b..6626c9d 100644 --- a/app/game/[id]/game-page-client.tsx +++ b/app/game/[id]/game-page-client.tsx @@ -11,7 +11,10 @@ import { ClockIcon, SparklesIcon, DatabaseIcon, + Plus, } from "lucide-react" +import Link from "next/link" +import { useSession } from "@/lib/auth-client" import { FaSteam } from "react-icons/fa" import { motion } from "motion/react" @@ -181,6 +184,7 @@ export function GamePageClient({ presets, gameId, }: Props) { + const { data: session } = useSession() const [imgError, setImgError] = useState(false) const [stats, setStats] = useState(null) const [selectedDevices, setSelectedDevices] = useState([]) @@ -360,6 +364,15 @@ export function GamePageClient({ )} + {session && ( + + + Add Benchmark + + )} {/* External links */} diff --git a/app/game/[id]/submit/page.tsx b/app/game/[id]/submit/page.tsx new file mode 100644 index 0000000..fe1b40f --- /dev/null +++ b/app/game/[id]/submit/page.tsx @@ -0,0 +1,78 @@ +import { notFound } from "next/navigation" +import { db } from "@/lib/db/index" +import { games, gameVersions } from "@/lib/db/schema" +import { eq, sql } from "drizzle-orm" +import { GameEntryWizard } from "@/components/wizard/game-entry-wizard" + +export const metadata = { + title: "Submit Benchmark", +} + +export default async function SubmitBenchmarkPage({ + params, +}: { + params: Promise<{ id: string }> +}) { + const { id } = await params + + // Resolve game + const isNumeric = /^\d+$/.test(id) + let game + + if (isNumeric) { + const rows = await db + .select() + .from(games) + .where(eq(games.steamAppId, Number(id))) + .limit(1) + game = rows[0] + } else { + const rows = await db + .select() + .from(games) + .where(eq(games.id, id)) + .limit(1) + game = rows[0] + } + + if (!game) { + notFound() + } + + // Get or create the latest game version + let [version] = await db + .select() + .from(gameVersions) + .where( + eq(gameVersions.gameId, game.id), + ) + .orderBy(sql`${gameVersions.createdAt} DESC`) + .limit(1) + + // Create a default version if none exists + if (!version) { + [version] = await db + .insert(gameVersions) + .values({ + gameId: game.id, + isLatest: true, + }) + .returning() + } + + return ( +
+
+

Submit Benchmark

+

+ Submit performance data for {game.title} +

+
+ + +
+ ) +}