fix pagination

This commit is contained in:
smanylov
2026-05-06 19:12:37 +07:00
parent 8a72dbaf68
commit 84b07af246
2 changed files with 10 additions and 3 deletions
@@ -32,7 +32,7 @@ export function TrackingHistoryView() {
const tableData = apiResponse?.history || [];
const totalItems = apiResponse?.history.length || 0;
const totalPages = Math.ceil(totalItems / pagination.pageSize);
const totalPages = apiResponse?.totalPages || 0;
const viewport = useViewport();
@@ -244,6 +244,12 @@ export function TrackingHistoryView() {
getPaginationRowModel: getPaginationRowModel(),
});
useEffect(() => {
if (tableData.length === 0 && pagination.pageIndex > 0 && totalPages > 0) {
setPagination(prev => ({ ...prev, pageIndex: Math.max(0, totalPages - 1) }));
}
}, [tableData, pagination.pageIndex, totalPages]);
return (
<div
className="block-wrapper"