2026-08-25 07:51:38 +02:00
|
|
|
import Link from "next/link";
|
|
|
|
|
import { Button } from "@/components/ui/button";
|
|
|
|
|
import { Card, CardContent, CardHeader, CardTitle } from "@/components/ui/card";
|
2026-08-25 16:43:28 +02:00
|
|
|
import { BrandMark } from "@/components/layout/BrandMark";
|
2026-08-30 20:39:43 +02:00
|
|
|
import { SessionsTable } from "@/components/sessions/SessionsTable";
|
2026-08-27 21:38:51 +02:00
|
|
|
import { listSessions } from "@/lib/db/queries/sessions";
|
2026-08-25 07:51:38 +02:00
|
|
|
import { getSessionsSummary } from "@/lib/db/queries/stats";
|
|
|
|
|
|
|
|
|
|
// Always reflects live DB state for an authenticated, single-tenant app -
|
|
|
|
|
// never worth prerendering (and the DB file doesn't exist at build time).
|
|
|
|
|
export const dynamic = "force-dynamic";
|
|
|
|
|
|
|
|
|
|
export default async function DashboardPage() {
|
2026-08-27 21:38:51 +02:00
|
|
|
const [sessions, summary] = await Promise.all([listSessions(), getSessionsSummary()]);
|
2026-08-25 07:51:38 +02:00
|
|
|
|
|
|
|
|
const recentSessions = [...sessions].reverse().slice(0, 5);
|
|
|
|
|
|
|
|
|
|
return (
|
|
|
|
|
<div className="flex flex-col gap-8">
|
|
|
|
|
<Card className="bp-glass overflow-hidden">
|
|
|
|
|
<CardContent className="flex flex-col items-start gap-4 py-8">
|
2026-08-26 18:47:30 +02:00
|
|
|
<BrandMark size={48} animated className="rounded-[9px]" />
|
|
|
|
|
<h1 className="font-heading text-3xl font-semibold">Welcome back</h1>
|
2026-08-25 07:51:38 +02:00
|
|
|
<p className="max-w-xl text-sm text-muted-foreground">
|
2026-08-27 21:38:51 +02:00
|
|
|
Scan for nearby devices, take control, and replay completed sessions later - all running
|
2026-08-25 07:51:38 +02:00
|
|
|
directly from your browser over Web Bluetooth.
|
|
|
|
|
</p>
|
|
|
|
|
<Button asChild size="lg">
|
|
|
|
|
<Link href="/control">Start a session</Link>
|
|
|
|
|
</Button>
|
|
|
|
|
</CardContent>
|
|
|
|
|
</Card>
|
|
|
|
|
|
|
|
|
|
<div className="grid gap-4 sm:grid-cols-3">
|
|
|
|
|
<Card className="bp-glass">
|
|
|
|
|
<CardHeader>
|
|
|
|
|
<CardTitle className="text-sm text-muted-foreground">Completed sessions</CardTitle>
|
|
|
|
|
</CardHeader>
|
2026-08-25 16:43:28 +02:00
|
|
|
<CardContent className="bp-readout text-3xl">{summary.count}</CardContent>
|
2026-08-25 07:51:38 +02:00
|
|
|
</Card>
|
|
|
|
|
<Card className="bp-glass">
|
|
|
|
|
<CardHeader>
|
|
|
|
|
<CardTitle className="text-sm text-muted-foreground">Total play time</CardTitle>
|
|
|
|
|
</CardHeader>
|
2026-08-25 16:43:28 +02:00
|
|
|
<CardContent className="bp-readout text-3xl">
|
2026-08-25 07:51:38 +02:00
|
|
|
{(summary.totalDurationMs / 3_600_000).toFixed(1)}h
|
|
|
|
|
</CardContent>
|
|
|
|
|
</Card>
|
|
|
|
|
<Card className="bp-glass">
|
|
|
|
|
<CardHeader>
|
2026-08-27 21:38:51 +02:00
|
|
|
<CardTitle className="text-sm text-muted-foreground">Replays</CardTitle>
|
2026-08-25 07:51:38 +02:00
|
|
|
</CardHeader>
|
2026-08-27 21:38:51 +02:00
|
|
|
<CardContent className="bp-readout text-3xl">{summary.totalReplays}</CardContent>
|
2026-08-25 07:51:38 +02:00
|
|
|
</Card>
|
|
|
|
|
</div>
|
|
|
|
|
|
2026-08-27 21:38:51 +02:00
|
|
|
<Card className="bp-glass">
|
|
|
|
|
<CardHeader>
|
2026-08-30 20:39:43 +02:00
|
|
|
<CardTitle className="text-base">Recent sessions</CardTitle>
|
2026-08-27 21:38:51 +02:00
|
|
|
</CardHeader>
|
2026-08-30 20:39:43 +02:00
|
|
|
<CardContent className="flex flex-col gap-3">
|
|
|
|
|
<SessionsTable sessions={recentSessions} />
|
2026-08-27 21:38:51 +02:00
|
|
|
</CardContent>
|
|
|
|
|
</Card>
|
2026-08-25 07:51:38 +02:00
|
|
|
</div>
|
|
|
|
|
);
|
|
|
|
|
}
|