import PropTypes from "prop-types"; import { useTheme } from "@emotion/react"; import { Stack, TablePagination, Typography } from "@mui/material"; import { TablePaginationActions } from "./Actions"; import SelectorVertical from "../../../assets/icons/selector-vertical.svg?react"; Pagination.propTypes = { paginationLabel: PropTypes.string, // Label for the pagination. itemCount: PropTypes.number, // Total number of items for pagination. page: PropTypes.number, // Current page index. rowsPerPage: PropTypes.number, // Number of rows displayed per page. handleChangePage: PropTypes.func.isRequired, // Function to handle page changes. handleChangeRowsPerPage: PropTypes.func, // Function to handle changes in rows per page. }; const ROWS_PER_PAGE_OPTIONS = [5, 10, 15, 25]; // Determine whether pagination buttons should be shown const shouldShowPaginationButtons = (itemCount, rowsPerPage) => { return Math.ceil(itemCount / rowsPerPage) > 1; }; // Empty action component for pagination (no-op component) const EmptyPaginationActions = () =>
; /** * Pagination component for table navigation with customized styling and behavior. * * @param {object} props - Component properties. * @param {string} props.paginationLabel - Label for the pagination. * @param {number} props.monitorCount - Total number of monitors to paginate. * @param {number} props.page - Current page index (0-based). * @param {number} props.rowsPerPage - Number of rows to display per page. * @param {function} props.handleChangePage - Callback for handling page changes. * @param {function} props.handleChangeRowsPerPage - Callback for handling changes to rows per page. * @returns {JSX.Element} The Pagination component. */ function Pagination({ paginationLabel, itemCount = 0, page = 0, rowsPerPage = 5, handleChangePage, handleChangeRowsPerPage, }) { const theme = useTheme(); const start = page * rowsPerPage + 1; const end = Math.min(page * rowsPerPage + rowsPerPage, itemCount); const range = `${start} - ${end}`; const showPaginationButtons = shouldShowPaginationButtons(itemCount, rowsPerPage); return (