pagination error fixed

This commit is contained in:
suryacp23 2026-07-20 10:27:45 +05:30
parent 569fdc5125
commit cd4de05a68

View File

@ -14,7 +14,6 @@ export interface PaginationProps {
/** Pager: "Showing ab of N" + Prev/Next. Renders nothing when the set fits on
* one page. Shared by the record-view tables. */
export function Pagination({ page, pageSize, total, onPage, onPageSizeChange }: PaginationProps) {
if (total <= 0) return null;
const totalPages = Math.max(1, Math.ceil(total / pageSize));
const safePage = Math.min(Math.max(page, 1), totalPages);
const start = (safePage - 1) * pageSize;
@ -25,6 +24,8 @@ export function Pagination({ page, pageSize, total, onPage, onPageSizeChange }:
setJumpPage(safePage.toString());
}, [safePage]);
if (total <= 0) return null;
const handlePageChange = (newPage: number) => {
onPage(newPage);
window.scrollTo({ top: 0, behavior: 'smooth' });