feat: add benchmark submission page and button

This commit is contained in:
2026-04-26 10:30:22 -05:00
parent 206103d79c
commit 945c8d18f6
2 changed files with 91 additions and 0 deletions
+13
View File
@@ -11,7 +11,10 @@ import {
ClockIcon, ClockIcon,
SparklesIcon, SparklesIcon,
DatabaseIcon, DatabaseIcon,
Plus,
} from "lucide-react" } from "lucide-react"
import Link from "next/link"
import { useSession } from "@/lib/auth-client"
import { FaSteam } from "react-icons/fa" import { FaSteam } from "react-icons/fa"
import { motion } from "motion/react" import { motion } from "motion/react"
@@ -181,6 +184,7 @@ export function GamePageClient({
presets, presets,
gameId, gameId,
}: Props) { }: Props) {
const { data: session } = useSession()
const [imgError, setImgError] = useState(false) const [imgError, setImgError] = useState(false)
const [stats, setStats] = useState<StatsResponse | null>(null) const [stats, setStats] = useState<StatsResponse | null>(null)
const [selectedDevices, setSelectedDevices] = useState<string[]>([]) const [selectedDevices, setSelectedDevices] = useState<string[]>([])
@@ -360,6 +364,15 @@ export function GamePageClient({
</span> </span>
)} )}
<BookmarkButton gameId={game.id} /> <BookmarkButton gameId={game.id} />
{session && (
<Link
href={`/game/${game.id}/submit`}
className="inline-flex items-center gap-2 px-4 py-2 rounded-lg bg-primary text-white text-sm font-semibold hover:bg-primary/90 transition-colors"
>
<Plus className="h-4 w-4" />
Add Benchmark
</Link>
)}
</div> </div>
{/* External links */} {/* External links */}
+78
View File
@@ -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 (
<div className="max-w-2xl mx-auto px-4 py-8">
<div className="mb-8">
<h1 className="text-2xl font-bold mb-2">Submit Benchmark</h1>
<p className="text-sm text-text/60">
Submit performance data for <span className="text-text font-medium">{game.title}</span>
</p>
</div>
<GameEntryWizard
gameId={game.id}
gameVersionId={version.id}
/>
</div>
)
}