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,84 @@
import Link from 'next/link';
import { notFound } from 'next/navigation';
import { getPlayersByCountry } from '@/lib/queries';
import { countryCodeToFlag, countryCodeToName, formatMinutes } from '@/lib/steam';
export default async function CountryPlayersPage({
params,
searchParams,
}: {
params: Promise<{ code: string }>;
searchParams: Promise<{ sort?: string }>;
}) {
const { code: rawCode } = await params;
const code = decodeURIComponent(rawCode).toUpperCase();
const { sort: rawSort } = await searchParams;
const sort = rawSort === 'playtime' ? 'playtime' : 'recent';
const players = await getPlayersByCountry(code, sort);
if (players.length === 0) {
notFound();
}
return (
<div className="space-y-6">
<Link href="/countries" className="text-sm text-ink-muted hover:text-accent transition-colors">
All countries
</Link>
<div className="flex flex-wrap items-end justify-between gap-4">
<div>
<h1 className="text-2xl text-ink mb-1 flex items-center gap-2">
<span aria-hidden>{countryCodeToFlag(code)}</span>
{countryCodeToName(code)}
</h1>
<p className="text-sm text-ink-muted">
{players.length} player{players.length === 1 ? '' : 's'}
</p>
</div>
<div className="flex gap-2 text-sm">
<Link
href={`/countries/${encodeURIComponent(code)}?sort=recent`}
className={`px-3 py-1.5 rounded border transition-colors ${
sort === 'recent'
? 'border-accent/50 text-accent bg-accent-dim/20'
: 'border-base-border text-ink-muted hover:text-ink'
}`}
>
Most recently played
</Link>
<Link
href={`/countries/${encodeURIComponent(code)}?sort=playtime`}
className={`px-3 py-1.5 rounded border transition-colors ${
sort === 'playtime'
? 'border-accent/50 text-accent bg-accent-dim/20'
: 'border-base-border text-ink-muted hover:text-ink'
}`}
>
Highest playtime
</Link>
</div>
</div>
<div className="panel divide-y divide-base-border">
{players.map((p) => (
<Link
key={p.steamid}
href={`/players/${encodeURIComponent(p.steamid)}`}
className="flex items-center justify-between px-4 py-3 hover:bg-base transition-colors"
>
<div className="text-ink text-sm">{p.current_name}</div>
<div className="flex items-center gap-4 text-xs">
<span className="text-ink-faint mono">{p.steamid}</span>
<span className="text-ink-muted mono w-16 text-right">
{formatMinutes(p.total_minutes)}
</span>
</div>
</Link>
))}
</div>
</div>
);
}