export const dynamic = 'force-dynamic'; import { pb, type Diplomatenkennzeichen } from "@/lib/pb"; export const metadata = { title: "Diplomatenkennzeichen" }; const COUNTRY_NAMES: Record = { germany: "Deutschland", austria: "Österreich", switzerland: "Schweiz", luxembourg: "Luxemburg", }; const COUNTRY_FLAGS: Record = { germany: "🇩🇪", austria: "🇦🇹", switzerland: "🇨🇭", luxembourg: "🇱🇺", }; const TYPE_LABELS: Record = { embassy: "Botschaft", consulate: "Konsulat", io: "Intern. Organisation", }; const TYPE_COLORS: Record = { embassy: "bg-blue-50 text-blue-800 border-blue-200", consulate: "bg-amber-50 text-amber-800 border-amber-200", io: "bg-emerald-50 text-emerald-800 border-emerald-200", }; interface Props { searchParams: { land?: string } } async function getData(baseCountry: string) { try { // Ohne sort um 400 zu vermeiden, sortieren wir client-side return pb.collection("diplomatenkennzeichen").getFullList({ filter: `base_country="${baseCountry}"`, }); } catch { return []; } } async function getAvailableCountries(): Promise { try { const all = await pb.collection("diplomatenkennzeichen").getFullList({ fields: "base_country", }); return [...new Set(all.map((i: any) => i.base_country).filter(Boolean))].sort() as string[]; } catch { return ["germany"]; } } function sortByCode(a: Diplomatenkennzeichen, b: Diplomatenkennzeichen) { const parseCode = (c: string) => { const m = c.match(/^(?:0-)?(\d+)$/); return m ? parseInt(m[1]) : -1; }; const na = parseCode(a.code); const nb = parseCode(b.code); if (na >= 0 && nb >= 0) return na - nb; if (na >= 0) return -1; if (nb >= 0) return 1; return a.code.localeCompare(b.code); } export default async function DiplomatenPage({ searchParams }: Props) { const countries = await getAvailableCountries(); const activeLand = searchParams.land ?? countries[0] ?? "germany"; const rawItems = await getData(activeLand); const items = [...rawItems].sort(sortByCode); const grouped = items.reduce>((acc, item) => { const t = item.type ?? "embassy"; if (!acc[t]) acc[t] = []; acc[t].push(item); return acc; }, {}); return (
Datenbank

Diplomatenkennzeichen

Sonderkennzeichen für Botschaften, Konsulate und internationale Organisationen.

{/* Länder-Tabs */}
{Object.entries(TYPE_LABELS).map(([key, label]) => ( {label}: {grouped[key]?.length ?? 0} ))} — {items.length} Einträge gesamt
{items.length === 0 ? (
Keine Daten für dieses Land.
) : ( Object.entries(TYPE_LABELS).map(([type, typeLabel]) => { const entries = grouped[type]; if (!entries?.length) return null; return (

{typeLabel} {entries.length} Einträge

{entries.map((d) => ( ))}
Kürzel Land / Organisation Stadt Bemerkung
{d.code}
{d.country}
{d.organisation &&
{d.organisation}
}
{d.city} {d.note}
); }) )}

Daten unvollständig oder fehlerhaft?

git.denode.eu/denode/plates →
); }