import Link from "next/link" import { Calendar, ChevronRight } from "lucide-react" import { TournamentStatusBadge, type TournamentStatus } from "@/components/tournament-status-badge" export type Tournament = { id: string name: string status: TournamentStatus startDate?: string endDate?: string } const dateFormatter = new Intl.DateTimeFormat("no-NO", { day: "numeric", month: "short", year: "numeric", }) function formatDate(value?: string) { if (!value) return null const parsed = new Date(value) if (Number.isNaN(parsed.getTime())) return null return dateFormatter.format(parsed) } function formatDateRange(start?: string, end?: string) { const from = formatDate(start) const to = formatDate(end) if (from && to) return from === to ? from : `${from} – ${to}` return from ?? to ?? null } export function TournamentCard({ tournament, orgId, }: { tournament: Tournament // Satt (dashbordet, innlogget) -> lenker til den innloggede detaljsiden. // Utelatt (klubb-landingsside, offentlig) -> lenker til den offentlige // /t/{id}-ruten i stedet. Samme kort, to kontekster. orgId?: string }) { const dateRange = formatDateRange(tournament.startDate, tournament.endDate) const href = orgId ? `/tournaments/${tournament.id}?org=${orgId}&name=${encodeURIComponent(tournament.name)}` : `/t/${tournament.id}` return (