File size: 1,907 Bytes
1e92f2d |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 |
import React from 'react';
import MuiTable from '@mui/material/Table';
import TablePagination from './TablePagination';
import { makeStyles } from 'tss-react/mui';
import PropTypes from 'prop-types';
const useStyles = makeStyles({ name: 'MUIDataTableFooter' })(() => ({
root: {
'@media print': {
display: 'none',
},
},
}));
const TableFooter = ({ options, rowCount, page, rowsPerPage, changeRowsPerPage, changePage }) => {
const { classes } = useStyles();
const { customFooter, pagination = true } = options;
if (customFooter) {
return (
<MuiTable className={classes.root}>
{options.customFooter(
rowCount,
page,
rowsPerPage,
changeRowsPerPage,
changePage,
options.textLabels.pagination,
)}
</MuiTable>
);
}
if (pagination) {
return (
<MuiTable className={classes.root}>
<TablePagination
count={rowCount}
page={page}
rowsPerPage={rowsPerPage}
changeRowsPerPage={changeRowsPerPage}
changePage={changePage}
component={'div'}
options={options}
/>
</MuiTable>
);
}
return null;
};
TableFooter.propTypes = {
/** Total number of table rows */
rowCount: PropTypes.number.isRequired,
/** Options used to describe table */
options: PropTypes.shape({
customFooter: PropTypes.func,
pagination: PropTypes.bool,
textLabels: PropTypes.shape({
pagination: PropTypes.object,
}),
}),
/** Current page index */
page: PropTypes.number.isRequired,
/** Total number allowed of rows per page */
rowsPerPage: PropTypes.number.isRequired,
/** Callback to trigger rows per page change */
changeRowsPerPage: PropTypes.func.isRequired,
/** Callback to trigger page change */
changePage: PropTypes.func.isRequired,
};
export default TableFooter;
|