"use client"; import { X, ExternalLink, Clock, Zap, MapPin, Building2, Truck } from "lucide-react"; import type { ChargeFeature, EnrichedConnector, EnrichedLocation } from "@/types/charging"; import { formatConnectorStandard, formatPowerType, statusColorClass, statusLabel } from "@/lib/connectorLabels"; import UsageChart from "@/components/UsageChart"; const fmtPrice = (v: number) => v.toLocaleString("nl-NL", { style: "currency", currency: "EUR", minimumFractionDigits: 2, maximumFractionDigits: 3 }); // Prefer the price baked by the pipeline; fall back to a best-effort parse of the // raw tariff (for data generated before the price field existed). function connectorPriceKwh(c: EnrichedConnector): number | null { if (typeof c.priceKwh === "number") return c.priceKwh; for (const t of c.tariffs ?? []) { for (const el of t.elements ?? []) { const energy = el.price_components?.find((pc) => pc.type === "ENERGY"); if (energy && typeof energy.price === "number") return energy.price; } } return null; } interface Props { selected: ChargeFeature | null; detail: EnrichedLocation | null; loading: boolean; slug?: string; // gemeente slug for usage history (undefined / 'nederland' = no chart) onClose: () => void; onJumpToGemeente?: () => void; } export default function LocationDetailPanel({ selected, detail, loading, slug, onClose, onJumpToGemeente }: Props) { if (!selected) return null; const p = selected.properties; const isFreight = p.layer === "freight"; return (
{isFreight ? : } {isFreight ? "Vracht" : "Personenauto"} {p.isMegawatt && ( Megawatt )}

{p.name}

{p.address && (
{p.address} {p.city ? `, ${p.city}` : ""}
)}
{/* Operator */}

Exploitant

{p.operatorName || "Onbekend"}
{detail?.operatorWebsite && ( {detail.operatorWebsite} )}
Bron: {p.source.toUpperCase()}
{/* Usage over time (gemeente view only; per-gemeente snapshot history) */} {slug && slug !== "nederland" && } {loading && (
Details laden…
)} {!loading && detail && ( <> {/* General */}

Gegevens

{detail.twentyFourSeven ? "Ja" : "Nee"} {detail.maxPowerKw > 0 && {detail.maxPowerKw} kW} {detail.parkingType && ( {detail.parkingType.replace(/_/g, " ")} )} {detail.ocpiId} {new Date(detail.lastUpdated).toLocaleString("nl-NL")}
{/* EVSEs */} {detail.evses.length > 0 && (

Laadpunten ({detail.evses.length})

{detail.evses.map((evse) => (
{evse.evse_id} {statusLabel(evse.status)}
{evse.connectors.length > 0 && (
{evse.connectors.map((c) => (
{formatConnectorStandard(c.standard)} {c.format}
{formatPowerType(c.power_type)} {c.max_electric_power ? ( {(c.max_electric_power / 1000).toFixed(1)} kW ) : null}
{(() => { const price = connectorPriceKwh(c); if (price === null) return null; return (
Tarief: {fmtPrice(price)} / kWh {typeof c.priceVat === "number" ? ` (excl. ${c.priceVat}% btw)` : ""}
); })()}
))}
)}
))}
)} )} {!loading && !detail && (

Geen gedetailleerde informatie geladen voor deze locatie {p.maxPowerKw > 0 ? ` (max. ${p.maxPowerKw} kW).` : "."}

{onJumpToGemeente && ( )}
)}
); } function Row({ label, children }: { label: string; children: React.ReactNode }) { return (
{label}: {children}
); }