fix pagination
This commit is contained in:
@@ -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"
|
||||
|
||||
Reference in New Issue
Block a user