/** URL state of the project tracker — shared by the server page and the client filter bar (no "use client" here). */ export const PROJECT_VIEWS = ["table", "map", "timeline", "kanban"] as const; export type ProjectView = (typeof PROJECT_VIEWS)[number]; export interface ProjectQuery { view?: ProjectView; status?: string; country?: string; operator?: string; min_mw?: number; ai?: boolean; /** project class (NEW_BUILD, EXPANSION, …), comma list */ project_class?: string; expected_from?: number; expected_to?: number; q?: string; sort?: "updated" | "mw" | "announced" | "opening"; order?: "asc" | "desc"; page?: number; } export const PROJECT_SORTS: Array<{ v: NonNullable; label: string }> = [ { v: "updated", label: "Last update" }, { v: "mw", label: "Planned MW" }, { v: "announced", label: "Announced" }, { v: "opening", label: "Expected opening" }, ]; /** Physical project classes (may create or move a project); associated classes are events, never projects. */ export const PROJECT_CLASS_OPTIONS: Array<{ v: string; label: string }> = [ { v: "NEW_BUILD", label: "New build" }, { v: "EXPANSION", label: "Expansion" }, { v: "CONSTRUCTION_START", label: "Construction start" }, { v: "PERMIT", label: "Permit" }, { v: "LAND_ACQUISITION", label: "Land acquisition" }, { v: "GRID_CONNECTION", label: "Grid connection" }, ]; export function projectQueryString(q: ProjectQuery): string { const p = new URLSearchParams(); if (q.view && q.view !== "table") p.set("view", q.view); if (q.q) p.set("q", q.q); if (q.status) p.set("status", q.status); if (q.country) p.set("country", q.country); if (q.operator) p.set("operator", q.operator); if (q.min_mw) p.set("min_mw", String(q.min_mw)); if (q.ai) p.set("ai", "1"); if (q.project_class) p.set("class", q.project_class); if (q.expected_from) p.set("expected_from", String(q.expected_from)); if (q.expected_to) p.set("expected_to", String(q.expected_to)); if (q.sort && q.sort !== "updated") p.set("sort", q.sort); if (q.order) p.set("order", q.order); if (q.page && q.page > 1) p.set("page", String(q.page)); return p.toString(); }