Files
lokiloto/components/lottery-row.tsx
T
Nazim KriandClaude Opus 5.5 302915d888 Show international lotteries with their bonus balls
LokiLab's feed now carries US, French and EuroMillions results with a
bonus array (Powerball, N° Chance, étoiles). Bonus balls render after a
"+" in gold; the lottery strip gets icons for the new games.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-10-31 10:59:56 -04:00

93 lines
2.7 KiB
TypeScript

import Link from "next/link"
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">
<Link
href={`/loterie/${entry.id}`}
className="block truncate font-semibold leading-tight hover:text-accent hover:underline"
title={entry.name}
>
{entry.name}
</Link>
{lastDraw && (
<p className="text-xs text-muted-foreground">{formatDate(lastDraw.date)}</p>
)}
</div>
<div>{lastDraw ? <NumberSequence numbers={lastDraw.result} bonus={lastDraw.bonus} bonusLabel={entry.bonusLabel} /> : <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" })
}