Replaces the left sidebar with a header dropdown (flag + name), like 1xbet's region picker. The shown country resolves as: saved choice (cookie, then the member's profile so it follows them across devices), else Cloudflare's CF-IPCountry (Canada maps to Québec), else Québec. favoriteCountry becomes nullable so geo-detection isn't overridden by a default nobody chose. Emoji flags render as letters on Windows, so flags are now SVGs in /public/flags; country names are in French. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
65 lines
2.6 KiB
TypeScript
65 lines
2.6 KiB
TypeScript
import type { Metadata } from "next"
|
|
import { redirect } from "next/navigation"
|
|
import { getCurrentMember } from "@/lib/member-auth"
|
|
import { listFollowedPicks } from "@/lib/follows"
|
|
import { countryTheme } from "@/lib/countries"
|
|
import { AppHeader } from "@/components/app-header"
|
|
import { NicknameForm } from "@/components/nickname-form"
|
|
import { Badge } from "@/components/ui/badge"
|
|
import { Flag } from "@/components/flag"
|
|
|
|
export const metadata: Metadata = { title: "Mon profil — LokiLoto" }
|
|
export const instant = false
|
|
|
|
export default async function ProfilePage() {
|
|
const member = await getCurrentMember()
|
|
if (!member) redirect("/connexion?next=/profil")
|
|
|
|
const follows = await listFollowedPicks(member.id)
|
|
|
|
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">Mon profil</h1>
|
|
<p className="mt-1 text-sm text-muted-foreground">{member.email}</p>
|
|
|
|
<div className="mt-6 rounded-md border border-border/60 bg-panel p-4">
|
|
<h2 className="mb-2 text-sm font-semibold">Pseudo public</h2>
|
|
<p className="mb-3 text-xs text-muted-foreground">
|
|
Affiché au classement à la place de votre nom. Requis pour apparaître publiquement.
|
|
</p>
|
|
<NicknameForm currentNickname={member.publicNickname} />
|
|
</div>
|
|
|
|
<div className="mt-6">
|
|
<h2 className="mb-2 text-sm font-semibold">
|
|
Pronostics suivis <Badge variant="secondary">{follows.length}</Badge>
|
|
</h2>
|
|
{follows.length === 0 ? (
|
|
<p className="text-sm text-muted-foreground">
|
|
Vous ne suivez aucun pronostic de Loki pour l'instant. Suivez-en un depuis la page
|
|
des résultats pour apparaître au classement.
|
|
</p>
|
|
) : (
|
|
<div className="divide-y divide-border rounded-md border border-border/60 bg-panel">
|
|
{follows.map((f) => {
|
|
const theme = countryTheme(f.country)
|
|
return (
|
|
<div key={f.id} className="flex items-center justify-between px-4 py-2.5 text-sm">
|
|
<span className="flex items-center gap-2">
|
|
<Flag code={theme.code} />
|
|
{f.lotteryId}
|
|
</span>
|
|
<span className="text-xs text-muted-foreground">{f.targetDrawDate}</span>
|
|
</div>
|
|
)
|
|
})}
|
|
</div>
|
|
)}
|
|
</div>
|
|
</div>
|
|
</main>
|
|
)
|
|
}
|