import { Header, Footer } from "@/components/Shell"; import { SignIn } from "@/components/SignIn"; import { Dashboard } from "@/components/Dashboard"; import { admin, user, required } from "@/lib/supabase"; import Link from "next/link"; import { accountProfile } from "@/lib/profile"; export const dynamic = "force-dynamic"; export default async function DashboardPage() { const account = await user(); const profile = account ? await accountProfile(account) : null; const history = account ? required( await admin() .from("game_sessions") .select("id,difficulty,created_at,current_round") .eq("owner_id", account.id) .order("created_at", { ascending: false }) .limit(20), ) : []; return ( <> {account ? ( <> THE CARTOGRAPHER’S DESK My expedition. Welcome back, {profile?.display_name}. {history.length > 0 && ( Recent journeys {history.map((s) => ( {new Date(s.created_at).toLocaleDateString("en-GB")} ·{" "} {s.difficulty} · {s.current_round}/5 rounds = 5 ? "results" : "play"}/${s.id}`} > Open → ))} )} > ) : ( )} > ); }
Welcome back, {profile?.display_name}.