Keeps only countries with archived results (Québec, France, US, Spain, Portugal). The landing gets motion and a real structure: staggered fade-in hero with a floating Loki, twinkling stars, a shimmering gold CTA and counters that tick up (draws archived, lotteries, countries); draw cards in place of the table, with lottery balls dropping in and a lift-on-hover; a three-step "Comment ça marche"; and a site-wide footer with links, covered countries, responsible-play note and 18+ notice. All motion is disabled under prefers-reduced-motion. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
109 lines
4.0 KiB
TypeScript
109 lines
4.0 KiB
TypeScript
import { Suspense } from "react"
|
|
import { COUNTRIES, countryTheme } from "@/lib/countries"
|
|
import { getArmyFeed } from "@/lib/lokilab-feed"
|
|
import { getCurrentMember } from "@/lib/member-auth"
|
|
import { listFollowedPicks } from "@/lib/follows"
|
|
import { resolveCountry } from "@/lib/country-pref"
|
|
import { AppHeader } from "@/components/app-header"
|
|
import { LotteryStrip } from "@/components/lottery-strip"
|
|
import { Hero } from "@/components/hero"
|
|
import { LotteryCard } from "@/components/lottery-card"
|
|
import { HowItWorks } from "@/components/how-it-works"
|
|
import { SideRail } from "@/components/side-rail"
|
|
import { Flag } from "@/components/flag"
|
|
import { Skeleton } from "@/components/ui/skeleton"
|
|
|
|
export const instant = false
|
|
|
|
export default function Home() {
|
|
return (
|
|
<main className="flex flex-1 flex-col">
|
|
<AppHeader />
|
|
<Suspense fallback={<HomeSkeleton />}>
|
|
<HomeContent />
|
|
</Suspense>
|
|
</main>
|
|
)
|
|
}
|
|
|
|
async function HomeContent() {
|
|
const [feed, member] = await Promise.all([getArmyFeed(), getCurrentMember()])
|
|
const activeCode = await resolveCountry(member)
|
|
const theme = countryTheme(activeCode)
|
|
const lotteries = feed.lotteries.filter((l) => l.country === activeCode)
|
|
const globalWins = feed.lotteries.reduce((sum, l) => sum + l.lifetime.wins, 0)
|
|
|
|
// EuroMillions is listed once per country; count each game's archive once.
|
|
const uniqueGames = new Map(feed.lotteries.map((l) => [l.id, l]))
|
|
const archived = [...uniqueGames.values()].reduce((sum, l) => sum + (l.totalDraws ?? l.recentDraws.length), 0)
|
|
|
|
const follows = member ? await listFollowedPicks(member.id) : []
|
|
const followedKeys = new Set(follows.map((f) => `${f.lotteryId}:${f.targetDrawDate}`))
|
|
|
|
return (
|
|
<>
|
|
<LotteryStrip lotteries={lotteries} />
|
|
<Hero
|
|
isAuthenticated={!!member}
|
|
draws={archived}
|
|
lotteries={uniqueGames.size}
|
|
countries={COUNTRIES.length}
|
|
/>
|
|
|
|
<div
|
|
style={{ "--accent": theme.accent, "--accent-soft": theme.accentSoft } as React.CSSProperties}
|
|
className="mx-auto grid w-full max-w-6xl flex-1 grid-cols-1 gap-6 px-4 py-8 sm:px-6 lg:grid-cols-[1fr_300px]"
|
|
>
|
|
<div className="min-w-0 space-y-6">
|
|
<section id="tirages" aria-labelledby="tirages-title" className="scroll-mt-28">
|
|
<div className="mb-4 flex flex-wrap items-end justify-between gap-2">
|
|
<h2 id="tirages-title" className="flex items-center gap-2.5 font-display text-2xl">
|
|
<Flag code={theme.code} className="h-[18px] w-[27px]" />
|
|
Derniers tirages — {theme.name}
|
|
</h2>
|
|
<p className="text-xs text-muted-foreground">Changez de pays en haut à droite</p>
|
|
</div>
|
|
|
|
{lotteries.length > 0 ? (
|
|
<div className="grid gap-4 sm:grid-cols-2">
|
|
{lotteries.map((entry, i) => (
|
|
<LotteryCard
|
|
key={entry.id}
|
|
entry={entry}
|
|
index={i}
|
|
country={activeCode}
|
|
isAuthenticated={!!member}
|
|
isFollowing={entry.lastDraw ? followedKeys.has(`${entry.id}:${entry.lastDraw.date}`) : false}
|
|
/>
|
|
))}
|
|
</div>
|
|
) : (
|
|
<p className="rounded-xl border border-dashed border-border py-14 text-center text-sm text-muted-foreground">
|
|
Aucune loterie pour {theme.name} pour le moment.
|
|
</p>
|
|
)}
|
|
</section>
|
|
|
|
<HowItWorks />
|
|
</div>
|
|
|
|
<Suspense fallback={<Skeleton className="h-72 w-full" />}>
|
|
<SideRail armyTotal={feed.army.total} globalWins={globalWins} />
|
|
</Suspense>
|
|
</div>
|
|
</>
|
|
)
|
|
}
|
|
|
|
function HomeSkeleton() {
|
|
return (
|
|
<div className="mx-auto w-full max-w-6xl space-y-4 px-4 py-6 sm:px-6">
|
|
<Skeleton className="h-[420px] w-full" />
|
|
<div className="grid gap-4 sm:grid-cols-2">
|
|
<Skeleton className="h-52" />
|
|
<Skeleton className="h-52" />
|
|
</div>
|
|
</div>
|
|
)
|
|
}
|