initial commit of the paytime session frontend

This commit is contained in:
jenz
2026-08-22 14:53:27 +02:00
parent 4ad037bd13
commit 9e8e8378a2
43 changed files with 2936 additions and 0 deletions
@@ -0,0 +1,54 @@
import Link from 'next/link';
import { notFound } from 'next/navigation';
import { getMapPeriods } from '@/lib/queries';
import { diffMinutes } from '@/lib/dates';
import { formatMinutes } from '@/lib/steam';
export default async function MapPeriodsPage({
params,
}: {
params: Promise<{ mapname: string }>;
}) {
const { mapname: rawMapname } = await params;
const mapName = decodeURIComponent(rawMapname);
const periods = await getMapPeriods(mapName);
if (periods.length === 0) {
notFound();
}
return (
<div className="space-y-6">
<Link href="/maps" className="text-sm text-ink-muted hover:text-accent transition-colors">
Back to maps
</Link>
<div>
<h1 className="text-2xl text-ink mb-1">{mapName}</h1>
<p className="text-sm text-ink-muted">
Played {periods.length} time{periods.length === 1 ? '' : 's'}.
</p>
</div>
<div className="panel divide-y divide-base-border">
{periods.map((p) => (
<Link
key={p.map_id}
href={`/maps/period/${p.map_id}`}
className="flex items-center justify-between px-4 py-3 hover:bg-base transition-colors"
>
<div>
<div className="text-ink text-sm">
{new Date(p.map_start_dt.replace(' ', 'T')).toLocaleString()}
</div>
{!p.map_end_dt && <div className="text-xs text-accent">currently running</div>}
</div>
<div className="mono text-ink-faint text-sm">
{p.map_end_dt ? formatMinutes(diffMinutes(p.map_start_dt, p.map_end_dt)) : '—'}
</div>
</Link>
))}
</div>
</div>
);
}