import type { FacilitySummary } from "@dci/core"; import { FacilityTable, type FacilityTableProps } from "@/components/facility-table"; import { Pagination } from "@/components/ui/pagination"; /** * Facilities block of operator / country / metro pages: table + `?fPage=` pager (50 per page, sorted by MW server-side). * `hrefFor` must preserve the other query params of the page. */ export function PagedFacilities({ items, total, page, perPage = 50, hrefFor, columns, emptyTitle, emptyDescription }: { items: FacilitySummary[]; total: number; page: number; perPage?: number; hrefFor: (page: number) => string; columns?: FacilityTableProps["columns"]; emptyTitle?: string; emptyDescription?: string }) { return (
); } /** Parse `?fPage=` (1-based, integer). */ export function parseFPage(v: string | string[] | undefined): number { const s = Array.isArray(v) ? v[0] : v; const n = Number(s); return Number.isFinite(n) && n > 1 ? Math.floor(n) : 1; } /** Build `?fPage=N#facilities`, keeping other params. */ export function fPageHref(base: string, params: Record, page: number, anchor = "facilities"): string { const sp = new URLSearchParams(); for (const [k, v] of Object.entries(params)) { if (k === "fPage" || v === undefined) continue; sp.set(k, Array.isArray(v) ? v[0] ?? "" : v); } if (page > 1) sp.set("fPage", String(page)); const qs = sp.toString(); return `${base}${qs ? `?${qs}` : ""}${anchor ? `#${anchor}` : ""}`; }