Files
lokiloto/components/lottery-row.tsx
T
Nazim KriandClaude Sonnet 5 c3a0a7b765 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>
2026-10-30 09:02:26 -04:00

88 lines
2.5 KiB
TypeScript

import { NumberSequence } from "@/components/number-sequence"
import { FollowButton } from "@/components/follow-button"
import type { LotteryFeedEntry } from "@/lib/lokilab-feed"
export function LotteryRow({
entry,
country,
isFollowing,
isAuthenticated,
}: {
entry: LotteryFeedEntry
country: string
isFollowing: boolean
isAuthenticated: boolean
}) {
const { lifetime, lastDraw } = entry
const resultSet = new Set(lastDraw?.result ?? [])
return (
<div className="grid grid-cols-[28px_160px_1fr_1fr_72px_120px] items-center gap-3 border-b border-border/60 px-3 py-3 text-sm last:border-b-0 hover:bg-panel-hover/40">
<div>
{lastDraw && (
<FollowButton
lotteryId={entry.id}
country={country}
targetDrawDate={lastDraw.date}
initialFollowing={isFollowing}
isAuthenticated={isAuthenticated}
/>
)}
</div>
<div className="min-w-0">
<p className="truncate font-semibold leading-tight" title={entry.name}>
{entry.name}
</p>
{lastDraw && (
<p className="text-xs text-muted-foreground">{formatDate(lastDraw.date)}</p>
)}
</div>
<div>{lastDraw ? <NumberSequence numbers={lastDraw.result} /> : <Dash />}</div>
<div>
{lastDraw?.pick ? (
<NumberSequence numbers={lastDraw.pick} hitSet={resultSet} />
) : (
<span className="text-xs text-muted-foreground">Aucun choix pour ce tirage</span>
)}
</div>
<div className="text-right tabular-nums">
{lastDraw?.pick ? (
<span className={lastDraw.won ? "font-semibold text-success" : "text-foreground"}>
{lastDraw.matched} / {lastDraw.result.length}
</span>
) : (
<Dash />
)}
</div>
<div className="text-right">
{lifetime.picksTracked > 0 ? (
<>
<span className="font-semibold tabular-nums">
{(lifetime.winRate * 100).toFixed(0)}%
</span>
<span className="ml-1 text-xs text-muted-foreground">
sur {lifetime.picksTracked} grilles
</span>
</>
) : (
<span className="text-xs text-muted-foreground">Nouveau</span>
)}
</div>
</div>
)
}
function Dash() {
return <span className="text-muted-foreground">—</span>
}
function formatDate(iso: string): string {
const d = new Date(iso + "T00:00:00")
return d.toLocaleDateString("fr-CA", { day: "numeric", month: "short" })
}