import { IconButtonMiniLink } from "@/components/IconButtonMini"; import { IoTicketOutline } from "react-icons/io5"; export type ConcertData = { _id: string; title?: string; subtitle?: string; date: string; time: string; locationName?: string; city?: string; country?: string; artists?: { _id: string; name?: string; slug?: string }[]; ticketUrl?: string; }; function formatConcertDate(dateString: string) { return new Intl.DateTimeFormat("en-GB", { day: "numeric", month: "short", year: "numeric", }).format(new Date(dateString + "T00:00:00")); } function getCountryCode(code?: string): string | undefined { if (!code) return undefined; return code.toUpperCase(); } /** City + country code, e.g. "Utrecht (NL)" */ function formatCityCountry(city?: string, country?: string): string | undefined { const code = getCountryCode(country); if (city && code) return `${city} (${code})`; if (city) return city; if (code) return `(${code})`; return undefined; } export function getDisplayTitle(concert: ConcertData): string { if (concert.title) return concert.title; if (concert.artists?.length) { return concert.artists .map((a) => a.name) .filter(Boolean) .join(", "); } return "Concert"; } export function ConcertRow({ concert, past, }: { concert: ConcertData; past?: boolean; }) { const displayTitle = getDisplayTitle(concert); const cityCountry = formatCityCountry(concert.city, concert.country); return (