"use client"; import { useState } from "react"; import { useRouter } from "next/navigation"; import { ArrowRight, Timer, ZoomIn } from "lucide-react"; import { difficulties, type Difficulty } from "@/shared/protocol"; export async function api>( path: string, body?: unknown, method = body ? "POST" : "GET", ): Promise { const res = await fetch("/api/v1/" + path, { method, headers: body ? { "Content-Type": "application/json" } : undefined, body: body ? JSON.stringify(body) : undefined, }); const data = await res.json(); if (!res.ok) throw new Error(data.error || "Request failed"); return data; } export function StartGame({ datasetId }: { datasetId: string }) { const [difficulty, setDifficulty] = useState("normal"), [loading, setLoading] = useState(false), [error, setError] = useState(""); const router = useRouter(); async function start() { setLoading(true); setError(""); try { const session = await api<{ id: string }>("sessions", { datasetId, difficulty, }); router.push("/play/" + session.id); } catch (e) { setError((e as Error).message); setLoading(false); } } return (
YOUR EXPEDITION

Choose your challenge.

{Object.entries(difficulties).map(([key, value]) => ( ))}

5 rounds · 25,000 possible points · No movement

{error && (

{error}

)}
); }