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:
Nazim Kri
2026-10-30 09:02:26 -04:00
co-authored by Claude Sonnet 5
parent fc69d4a668
commit c3a0a7b765
36 changed files with 2419 additions and 27 deletions
+53
View File
@@ -0,0 +1,53 @@
"use client"
import { useState, useTransition } from "react"
import { useRouter } from "next/navigation"
import { Star } from "lucide-react"
import { toggleFollowAction } from "@/app/actions"
import { cn } from "@/lib/utils"
export function FollowButton({
lotteryId,
country,
targetDrawDate,
initialFollowing,
isAuthenticated,
}: {
lotteryId: string
country: string
targetDrawDate: string
initialFollowing: boolean
isAuthenticated: boolean
}) {
const [following, setFollowing] = useState(initialFollowing)
const [pending, startTransition] = useTransition()
const router = useRouter()
function handleClick() {
if (!isAuthenticated) {
router.push(`/connexion?next=${encodeURIComponent(window.location.pathname + window.location.search)}`)
return
}
const next = !following
setFollowing(next)
startTransition(async () => {
const res = await toggleFollowAction(lotteryId, country, targetDrawDate, following)
if (!res.ok) setFollowing(!next)
})
}
return (
<button
type="button"
onClick={handleClick}
disabled={pending}
title={following ? "Ne plus suivre" : "Suivre ce pronostic"}
className={cn(
"flex h-6 w-6 shrink-0 items-center justify-center rounded transition-colors",
following ? "text-accent" : "text-muted-foreground hover:text-foreground"
)}
>
<Star className="h-4 w-4" fill={following ? "currentColor" : "none"} />
</button>
)
}