"use client"; import type { MapPoint, MapResponse, ProjectSummary } from "@dci/core"; import dynamic from "next/dynamic"; import Link from "next/link"; import { useCallback, useState } from "react"; import { StatusBadge } from "@/components/ui/badge"; import { Button } from "@/components/ui/button"; import { Skeleton } from "@/components/ui/skeleton"; import { fmtInt, fmtMw } from "@/lib/format"; import { PRECISION_LABEL } from "@/lib/labels"; import { routes } from "@/lib/routes"; const MapCanvas = dynamic(() => import("@/components/map/map-canvas").then((m) => m.MapCanvas), { ssr: false, loading: () => }); /** * Projects MAP view: the shared canvas in `layer=projects` mode (square stage-coloured markers, hollow ring for * city-level points). Projects without published coordinates cannot be drawn — the caption says how many are missing * instead of guessing a location. */ export function ProjectsMapView({ items, total, projectStatus }: { items: ProjectSummary[]; total: number; projectStatus?: string }) { const [data, setData] = useState(null); const [sel, setSel] = useState(null); const onData = useCallback((r: MapResponse | null) => setData(r), []); const located = items.filter((p) => p.lat !== null && p.lng !== null).length; return (
{sel && (
{sel.n} {sel.mw != null ? `≈ ${fmtMw(sel.mw)}` : "—"} {PRECISION_LABEL[sel.p]}
)}

{data ? <>{fmtInt(data.total)} located {data.total === 1 ? "project" : "projects"} drawn : "Loading…"} · {fmtInt(located)} of the {fmtInt(items.length)} projects on this page have published coordinates{total > items.length ? ` (${fmtInt(total)} match in total)` : ""}. Square markers are coloured by stage; a hollow ring means a city-level location, never a site.{" "} Open in the full map

); }