shoc-frontend-new/src/app/(protected)/dashboard/_components/dispatcher-table-pager.tsx
Codex Review Integration 0279cfac64 feat(dashboard): paginate dispatcher tables and fix Aveta drilldown
Workload and Performance page server-side at 10 rows and now return Page,
PageSize, and TotalDispatchers on dev (backend#126/#127), so wire the pager
that SH-346 and SH-347 require: getWorkload/getPerformance send a 1-based
`page` and parse the paging envelope, the hooks and query keys carry the page,
and each dispatcher table renders a 10-row pager. Page state is per-table and
resets on a range change so switching range never lands on an out-of-range
empty page that reads as a false "no dispatchers" state.

Drop `docs=No` from the Aveta Pending drilldown. `docs` filters on
completion-document status, not the Aveta clearance document the tile counts
(SH-294 / backend#138), so it narrowed to the wrong rows. The board has no
missing-Aveta-document filter, so the drilldown is now the Aveta-required work
in the two-day open window — a deliberate superset of the count.
2026-09-17 00:36:55 -03:00

40 lines
908 B
TypeScript

import { Box, Pagination } from "@mui/material";
interface DispatcherTablePagerProps {
page: number;
pageSize: number;
totalDispatchers: number;
onPageChange: (page: number) => void;
label: string;
}
/**
* 10-row pager for the dispatcher tables (SH-346/SH-347). Renders nothing until
* there is more than one page, so single-page tables are unchanged.
*/
export function DispatcherTablePager({
page,
pageSize,
totalDispatchers,
onPageChange,
label,
}: DispatcherTablePagerProps) {
const pageCount = pageSize > 0 ? Math.ceil(totalDispatchers / pageSize) : 1;
if (pageCount <= 1) {
return null;
}
return (
<Box className="mt-3 flex justify-end">
<Pagination
size="small"
color="primary"
count={pageCount}
page={page}
onChange={(_event, value) => onPageChange(value)}
aria-label={label}
/>
</Box>
);
}