"use client"; import Link from "next/link"; type PaginationProps = { page: number; pageSize: number; total: number; basePath: string; }; function pageHref(basePath: string, page: number) { if (page <= 1) return basePath; return `${basePath}?page=${page}`; } export function Pagination({ page, pageSize, total, basePath, }: PaginationProps) { const totalPages = Math.max(1, Math.ceil(total / pageSize)); if (totalPages <= 1) return null; const windowSize = 5; let start = Math.max(1, page - Math.floor(windowSize / 2)); const end = Math.min(totalPages, start + windowSize - 1); start = Math.max(1, end - windowSize + 1); const pages = Array.from({ length: end - start + 1 }, (_, i) => start + i); const scrollTop = () => { window.scrollTo({ top: 0, behavior: "smooth" }); }; return ( ); }