refactor(client): extract useClientPagination hook and clean up Select prop

- Replace duplicated page/rowsPerPage state in Team, Notifications and Status Pages tables with a shared useClientPagination hook
- Drop unused placeholderColor prop from Select; placeholder always uses secondary text
- Restore LAYOUT.MD constant for the account menu item gap
This commit is contained in:
gorkem-bwl committed 2026-04-26 00:22:14 -04:00
1 parent 25735df0c6
commit 897204ead3
6 files changed
+57 -109

No files matched your search

@@ -4,9 +4,9 @@ import Typography from "@mui/material/Typography";
import { Table, type Header, ValueLabel } from "@/Components/design-elements";
import { Pagination } from "@/Components/design-elements/Table";
import { ActionsMenu, type ActionMenuItem } from "@/Components/actions-menu";
import { useClientPagination } from "@/Hooks/useClientPagination";
import { ExternalLink } from "lucide-react";
import { useState } from "react";
import { useTranslation } from "react-i18next";
import { useTheme } from "@mui/material/styles";
import { useNavigate } from "react-router-dom";
@@ -25,8 +25,7 @@ export const StatusPagesTable = ({
const { t } = useTranslation();
const theme = useTheme();
const navigate = useNavigate();
const [page, setPage] = useState(0);
const [rowsPerPage, setRowsPerPage] = useState(10);
const { pagedRows, paginationProps } = useClientPagination(data);
const getActions = (row: StatusPage): ActionMenuItem[] => {
return [
@@ -133,41 +132,15 @@ export const StatusPagesTable = ({
navigate(`/status/${statusPage.url}`);
};
const handlePageChange = (
_e: React.MouseEvent<HTMLButtonElement> | null,
newPage: number
) => {
setPage(newPage);
};
const handleRowsPerPageChange = (
e: React.ChangeEvent<HTMLTextAreaElement | HTMLInputElement>
) => {
setPage(0);
setRowsPerPage(Number(e.target.value));
};
const pagedData = data.slice(page * rowsPerPage, page * rowsPerPage + rowsPerPage);
return (
<Box>
<Table
headers={getHeaders()}
data={pagedData}
data={pagedRows}
onRowClick={handleRowClick}
emptyViewText={t("common.table.empty")}
/>
{data.length > 0 && (
<Pagination
component="div"
count={data.length}
page={page}
rowsPerPage={rowsPerPage}
onPageChange={handlePageChange}
onRowsPerPageChange={handleRowsPerPageChange}
itemsOnPage={pagedData.length}
/>
)}
{data.length > 0 && <Pagination {...paginationProps} />}
</Box>
);
};