import Link from "next/link"; // Shared by the employee list and the audit log, which both used to render // one link per page: 54 of them for ~800 employees, and an unbounded number // for the audit log, all in a single overflowing row. This shows the first // and last page plus a window around the current one, with the gaps elided. const WINDOW = 2; function pageItems(current: number, total: number): number[] { const pages = new Set([1, total]); for (let p = current - WINDOW; p <= current + WINDOW; p++) { if (p >= 1 && p <= total) pages.add(p); } return [...pages].sort((a, b) => a - b); } type PaginationProps = { page: number; totalPages: number; hrefFor: (page: number) => string; /** Screen-reader name, e.g. "Mitarbeiter:innen" — several lists per app. */ label: string; }; export function Pagination({ page, totalPages, hrefFor, label }: PaginationProps) { if (totalPages <= 1) return null; const current = Math.min(Math.max(1, page), totalPages); const items = pageItems(current, totalPages); return ( ); }