"use client"; import type { ExploreResponse, FacilityStatus } from "@dci/core"; import { BarList, ColumnChart } from "@/components/ui/charts"; import { HonestEmpty } from "@/components/intelligence/shared"; import { fmtInt, fmtMw } from "@/lib/format"; import { STATUS_SHORT } from "@/lib/labels"; /** byStatus / byCountry / byYear charts over the whole filtered set (not the current page). */ export function ExploreCharts({ charts, entity, countryHrefBase }: { charts: ExploreResponse["charts"]; entity: "facilities" | "projects"; /** href prefix the iso2 is appended to (function props cannot cross the RSC boundary) */ countryHrefBase: string }) { const countryHref = (iso2: string) => `${countryHrefBase}${encodeURIComponent(iso2)}`; const byStatus = charts.byStatus.map((s) => ({ label: STATUS_SHORT[s.key as FacilityStatus] ?? s.key, value: s.count, secondary: s.mw })); const byYear = charts.byYear.filter((y) => y.year >= 1990 && y.year <= 2100).map((y) => ({ label: String(y.year), value: y.count, secondary: y.mw })); const byCountry = charts.byCountry.slice(0, 15); const mwTotal = charts.byStatus.reduce((a, s) => a + (s.mw ?? 0), 0); return (
Records without a published date are not charted.