SPB Git forge
38commits 1branches 0releases
338.7 MBsize
maindefault branch
5 h agolast push
HTML 53.9% TypeScript 44.5% JavaScript 0.6% SQL 0.5%
2.1 KB · 56 lines typescript
Raw Blame History
1/** URL state of the project tracker — shared by the server page and the client filter bar (no "use client" here). */2export const PROJECT_VIEWS = ["table", "map", "timeline", "kanban"] as const;3export type ProjectView = (typeof PROJECT_VIEWS)[number];45export interface ProjectQuery {6  view?: ProjectView;7  status?: string;8  country?: string;9  operator?: string;10  min_mw?: number;11  ai?: boolean;12  /** project class (NEW_BUILD, EXPANSION, …), comma list */13  project_class?: string;14  expected_from?: number;15  expected_to?: number;16  q?: string;17  sort?: "updated" | "mw" | "announced" | "opening";18  order?: "asc" | "desc";19  page?: number;20}2122export const PROJECT_SORTS: Array<{ v: NonNullable<ProjectQuery["sort"]>; label: string }> = [23  { v: "updated", label: "Last update" },24  { v: "mw", label: "Planned MW" },25  { v: "announced", label: "Announced" },26  { v: "opening", label: "Expected opening" },27];2829/** Physical project classes (may create or move a project); associated classes are events, never projects. */30export const PROJECT_CLASS_OPTIONS: Array<{ v: string; label: string }> = [31  { v: "NEW_BUILD", label: "New build" },32  { v: "EXPANSION", label: "Expansion" },33  { v: "CONSTRUCTION_START", label: "Construction start" },34  { v: "PERMIT", label: "Permit" },35  { v: "LAND_ACQUISITION", label: "Land acquisition" },36  { v: "GRID_CONNECTION", label: "Grid connection" },37];3839export function projectQueryString(q: ProjectQuery): string {40  const p = new URLSearchParams();41  if (q.view && q.view !== "table") p.set("view", q.view);42  if (q.q) p.set("q", q.q);43  if (q.status) p.set("status", q.status);44  if (q.country) p.set("country", q.country);45  if (q.operator) p.set("operator", q.operator);46  if (q.min_mw) p.set("min_mw", String(q.min_mw));47  if (q.ai) p.set("ai", "1");48  if (q.project_class) p.set("class", q.project_class);49  if (q.expected_from) p.set("expected_from", String(q.expected_from));50  if (q.expected_to) p.set("expected_to", String(q.expected_to));51  if (q.sort && q.sort !== "updated") p.set("sort", q.sort);52  if (q.order) p.set("order", q.order);53  if (q.page && q.page > 1) p.set("page", String(q.page));54  return p.toString();55}56