import Link from "next/link"; import { toFaDigits } from "@/lib/format"; import { ChevronLeft, ChevronRight } from "../icons"; // Simple numbered pager. `buildHref` turns a page number into the URL for // that page — callers own how query params are preserved (search, filters). export default function Pagination({ page, pageSize, total, buildHref, }: { page: number; pageSize: number; total: number; buildHref: (page: number) => string; }) { const pageCount = Math.max(1, Math.ceil(total / pageSize)); if (pageCount <= 1) return null; // A short window around the current page, plus first/last, keeps the // control usable even with a few hundred pages. const pages = new Set([1, pageCount, page - 1, page, page + 1].filter((p) => p >= 1 && p <= pageCount)); const sorted = [...pages].sort((a, b) => a - b); const linkClass = (active: boolean) => `flex h-9 min-w-9 items-center justify-center rounded-lg px-2 text-[13px] transition ${ active ? "bg-brand text-white" : "border border-line text-ink-soft hover:border-brand hover:text-brand" }`; return ( ); }