Add member accounts, follow-based leaderboard, and dedicated Postgres
Members register via email+password (scrypt) or Google OAuth — same signed-cookie + scrypt pattern as LokiLab (lib/auth.ts, member-password.ts, member-auth.ts, google-oauth.ts), own AUTH_SECRET and own OAuth client, own dedicated Postgres database (lokiloto-db on Coolify), fully isolated from LokiLab's own DB and auth. Leaderboard tracks who follows Loki's picks most accurately — members star a pick from the results panel (FollowButton), resolution reuses LokiLab's own lastDraw.won, no money or pooled play involved anywhere. Leaderboard page renders a horizontal bar chart (recharts) plus a ranked list. Profile page: public nickname (required to appear on the leaderboard), list of followed picks. Header now carries nav + a user menu (avatar dropdown when signed in, "Connexion" button otherwise). Dockerfile runs prisma migrate deploy at container start via docker-entrypoint.sh, same pattern as LokiLab. Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
This commit is contained in:
co-authored by
Claude Sonnet 5
parent
fc69d4a668
commit
c3a0a7b765
@@ -0,0 +1,59 @@
|
||||
import type { Metadata } from "next"
|
||||
import { leaderboard } from "@/lib/follows"
|
||||
import { AppHeader } from "@/components/app-header"
|
||||
import { LeaderboardChart } from "@/components/leaderboard-chart"
|
||||
import { Avatar, AvatarFallback, AvatarImage } from "@/components/ui/avatar"
|
||||
import { Trophy } from "lucide-react"
|
||||
|
||||
export const metadata: Metadata = { title: "Classement — LokiLoto" }
|
||||
export const instant = false
|
||||
|
||||
export default async function LeaderboardPage() {
|
||||
const standings = await leaderboard(20)
|
||||
|
||||
return (
|
||||
<main className="flex flex-1 flex-col">
|
||||
<AppHeader />
|
||||
<div className="mx-auto w-full max-w-3xl flex-1 px-4 py-6 sm:px-6">
|
||||
<h1 className="text-2xl font-bold tracking-tight">Classement</h1>
|
||||
<p className="mt-1 text-sm text-muted-foreground">
|
||||
Les membres qui suivent le plus fidèlement les choix de Loki — aucun argent réel en jeu,
|
||||
seulement le taux de réussite des pronostics suivis.
|
||||
</p>
|
||||
|
||||
{standings.length === 0 ? (
|
||||
<p className="mt-8 text-sm text-muted-foreground">
|
||||
Personne n'a encore suivi de pronostic. Le classement apparaîtra dès les premiers
|
||||
tirages résolus.
|
||||
</p>
|
||||
) : (
|
||||
<>
|
||||
<div className="mt-6 rounded-md border border-border/60 bg-panel p-4">
|
||||
<LeaderboardChart standings={standings} />
|
||||
</div>
|
||||
|
||||
<div className="mt-4 divide-y divide-border rounded-md border border-border/60 bg-panel">
|
||||
{standings.map((s, i) => (
|
||||
<div key={s.userId} className="flex items-center gap-3 px-4 py-2.5 text-sm">
|
||||
<span className="w-5 shrink-0 text-center text-xs text-muted-foreground tabular-nums">
|
||||
{i + 1}
|
||||
</span>
|
||||
<Avatar className="h-7 w-7 shrink-0">
|
||||
<AvatarImage src={s.avatarUrl ?? undefined} alt="" />
|
||||
<AvatarFallback>{s.displayName.charAt(0).toUpperCase()}</AvatarFallback>
|
||||
</Avatar>
|
||||
<span className="flex-1 font-medium">{s.displayName}</span>
|
||||
{i === 0 && <Trophy className="h-4 w-4 text-accent" />}
|
||||
<span className="text-xs text-muted-foreground">{s.followed} suivis</span>
|
||||
<span className="w-12 text-right font-semibold tabular-nums">
|
||||
{(s.winRate * 100).toFixed(0)}%
|
||||
</span>
|
||||
</div>
|
||||
))}
|
||||
</div>
|
||||
</>
|
||||
)}
|
||||
</div>
|
||||
</main>
|
||||
)
|
||||
}
|
||||
Reference in New Issue
Block a user