Added styled pagination controls

This commit is contained in:
Alex Holliday committed 2024-08-09 10:01:28 -07:00
1 parent 7888a11bfe
commit 01c6026dd2
1 file changed
+71 -45
@@ -8,8 +8,13 @@ import {
TableBody, TableBody,
TableFooter, TableFooter,
TablePagination, TablePagination,
Pagination,
PaginationItem,
} from "@mui/material"; } from "@mui/material";
import ArrowBackRoundedIcon from "@mui/icons-material/ArrowBackRounded";
import ArrowForwardRoundedIcon from "@mui/icons-material/ArrowForwardRounded";
import { useState, useEffect } from "react"; import { useState, useEffect } from "react";
import { useSelector } from "react-redux"; import { useSelector } from "react-redux";
import axiosInstance from "../../../Utils/axiosConfig"; import axiosInstance from "../../../Utils/axiosConfig";
@@ -68,52 +73,73 @@ const IncidentTable = ({ monitorId, filter }) => {
}); });
}; };
return ( let paginationComponent = <></>;
<TableContainer> if (checksCount > paginationController.rowsPerPage) {
<Table> paginationComponent = (
<TableHead> <Pagination
<TableRow> count={Math.ceil(checksCount / paginationController.rowsPerPage)}
<TableCell>Monitor Name</TableCell> page={paginationController.page + 1}
<TableCell>Status</TableCell> onChange={handlePageChange}
<TableCell>Date & Time</TableCell> shape="rounded"
<TableCell>Message</TableCell> renderItem={(item) => (
</TableRow> <PaginationItem
</TableHead> slots={{
<TableBody> previous: ArrowBackRoundedIcon,
{checks.map((check) => { next: ArrowForwardRoundedIcon,
const status = check.status === true ? "up" : "down"; }}
{...item}
sx={{
"&:focus": {
outline: "none",
},
"& .MuiTouchRipple-root": {
pointerEvents: "none",
display: "none",
},
}}
/>
)}
/>
);
}
return ( return (
<TableRow key={check._id}> <>
<TableCell> <TableContainer>
<StatusLabel <Table>
status={status} <TableHead>
text={status} <TableRow>
customStyles={{ textTransform: "capitalize" }} <TableCell>Monitor Name</TableCell>
/> <TableCell>Status</TableCell>
</TableCell> <TableCell>Date & Time</TableCell>
<TableCell> <TableCell>Message</TableCell>
{new Date(check.createdAt).toLocaleString()} </TableRow>
</TableCell> </TableHead>
<TableCell>{check.statusCode}</TableCell> <TableBody>
</TableRow> {checks.map((check) => {
); const status = check.status === true ? "up" : "down";
})}
</TableBody> return (
<TableFooter> <TableRow key={check._id}>
<TableRow> <TableCell>
<TablePagination <StatusLabel
rowsPerPageOptions={[5, 10, 25]} status={status}
onPageChange={handlePageChange} text={status}
page={paginationController.page} customStyles={{ textTransform: "capitalize" }}
count={checksCount} />
rowsPerPage={paginationController.rowsPerPage} </TableCell>
onRowsPerPageChange={handleChangeRowsPerPage} <TableCell>
/> {new Date(check.createdAt).toLocaleString()}
</TableRow> </TableCell>
</TableFooter> <TableCell>{check.statusCode}</TableCell>
</Table> </TableRow>
</TableContainer> );
})}
</TableBody>
</Table>
</TableContainer>
{paginationComponent}
</>
); );
}; };