pagination fixed
This commit is contained in:
parent
bd71b0ae3f
commit
9ee67313f5
@ -18,20 +18,25 @@ export function Pagination({ page, pageSize, total, onPage }: PaginationProps) {
|
|||||||
const safePage = Math.min(Math.max(page, 1), totalPages);
|
const safePage = Math.min(Math.max(page, 1), totalPages);
|
||||||
const start = (safePage - 1) * pageSize;
|
const start = (safePage - 1) * pageSize;
|
||||||
|
|
||||||
|
const handlePageChange = (newPage: number) => {
|
||||||
|
onPage(newPage);
|
||||||
|
window.scrollTo({ top: 0, behavior: 'smooth' });
|
||||||
|
};
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<div className="flex items-center justify-between gap-3 border-t border-border-subtle px-[18px] py-3">
|
<div className="flex items-center justify-between gap-3 border-t border-border-subtle px-[18px] pt-4 pb-24">
|
||||||
<span className="text-xs text-faint">
|
<span className="text-xs text-faint">
|
||||||
Showing {start + 1}–{Math.min(start + pageSize, total)} of {total}
|
Showing {start + 1}–{Math.min(start + pageSize, total)} of {total}
|
||||||
</span>
|
</span>
|
||||||
<div className="flex items-center gap-2">
|
<div className="flex items-center gap-2">
|
||||||
<Button variant="secondary" size="sm" disabled={safePage <= 1} onClick={() => onPage(safePage - 1)}>
|
<Button variant="secondary" size="sm" disabled={safePage <= 1} onClick={() => handlePageChange(safePage - 1)}>
|
||||||
<ChevronLeft size={15} />
|
<ChevronLeft size={15} />
|
||||||
Prev
|
Prev
|
||||||
</Button>
|
</Button>
|
||||||
<span className="px-1 text-xs font-medium text-muted nums">
|
<span className="px-1 text-xs font-medium text-muted nums">
|
||||||
{safePage} / {totalPages}
|
{safePage} / {totalPages}
|
||||||
</span>
|
</span>
|
||||||
<Button variant="secondary" size="sm" disabled={safePage >= totalPages} onClick={() => onPage(safePage + 1)}>
|
<Button variant="secondary" size="sm" disabled={safePage >= totalPages} onClick={() => handlePageChange(safePage + 1)}>
|
||||||
Next
|
Next
|
||||||
<ChevronRight size={15} />
|
<ChevronRight size={15} />
|
||||||
</Button>
|
</Button>
|
||||||
|
|||||||
@ -54,7 +54,7 @@ export function RecordView({
|
|||||||
rvUid,
|
rvUid,
|
||||||
title = 'Records',
|
title = 'Records',
|
||||||
columns,
|
columns,
|
||||||
pageSize = 50,
|
pageSize = 20,
|
||||||
onRowClick,
|
onRowClick,
|
||||||
rowKey,
|
rowKey,
|
||||||
headerActions,
|
headerActions,
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user