Remove old tables

This commit is contained in:
Alex Holliday committed 2024-07-16 15:00:30 -07:00
1 parent 9e0c80f650
commit 10de2caa2e
3 files changed
+110 -146

No files matched your search

Whitespace-only changes.
-114
View File
@@ -1,114 +0,0 @@
import React from 'react';
import PropTypes from 'prop-types';
import { styled, useTheme } from '@mui/material/styles';
import Table from '@mui/material/Table';
import TableBody from '@mui/material/TableBody';
import TableCell, { tableCellClasses } from '@mui/material/TableCell';
import TableContainer from '@mui/material/TableContainer';
import TableHead from '@mui/material/TableHead';
import TableRow from '@mui/material/TableRow';
import Paper from '@mui/material/Paper';
import Box from '@mui/material/Box';
import Pagination from '../../Components/Pagination';
const StyledTableCell = styled(TableCell)(({ theme }) => ({
[`&.${tableCellClasses.head}`]: {
backgroundColor: theme.palette.action.hover,
color: theme.palette.common.black,
},
[`&.${tableCellClasses.body}`]: {
fontSize: 14,
},
}));
const StyledTableRow = styled(TableRow)(({ theme }) => ({
'&:nth-of-type(odd)': {
backgroundColor: theme.palette.action.hover,
},
'&:nth-of-type(even)': {
backgroundColor: theme.palette.common.white,
},
'&:last-child td, &:last-child th': {
border: 0,
},
}));
const itemsPerPage = 5; // Number of items per page
export default function StatusTable({ data, columns }) {
const theme = useTheme();
const [currentPage, setCurrentPage] = React.useState(1);
const onPageChange = (page) => {
setCurrentPage(page);
};
// Calculate total pages based on data length and items per page
const totalPages = Math.ceil(data.length / itemsPerPage);
// Slice data based on current page and items per page
const paginatedData = data.slice((currentPage - 1) * itemsPerPage, currentPage * itemsPerPage);
return (
<Box
sx={{
marginTop: theme.spacing(4),
marginX: 'auto',
width: '80%',
paddingX: theme.spacing(6),
[theme.breakpoints.down('md')]: {
width: '100%',
},
}}
>
<TableContainer component={Paper}>
<Table sx={{ minWidth: 700 }} aria-label="customized table">
<TableHead>
<TableRow>
{columns.map((column, index) => (
<StyledTableCell key={index} align={column.align || 'left'}>
{column.header}
</StyledTableCell>
))}
</TableRow>
</TableHead>
<TableBody>
{paginatedData.map((row, rowIndex) => (
<StyledTableRow key={rowIndex}>
{columns.map((column, colIndex) => (
<StyledTableCell key={colIndex} align={column.align || 'left'}>
{column.id === 'name' ? (
<div style={row.name.props.customStyles}>
{row.name}
</div>
) : (
row[column.id]
)}
</StyledTableCell>
))}
</StyledTableRow>
))}
</TableBody>
</Table>
</TableContainer>
{totalPages > 1 && (
<Pagination
page={currentPage}
count={totalPages}
onPageChange={onPageChange}
/>
)}
</Box>
);
}
StatusTable.propTypes = {
data: PropTypes.arrayOf(PropTypes.object).isRequired,
columns: PropTypes.arrayOf(
PropTypes.shape({
id: PropTypes.string.isRequired,
header: PropTypes.node.isRequired,
align: PropTypes.oneOf(['left', 'right', 'center']),
})
).isRequired,
};