Press n or j to go to the next uncovered block, b, p or k for the previous block.
| 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 | /* eslint-disable react-hooks/exhaustive-deps */ import { Paper, TableContainer, TablePagination } from "@mui/material"; import { useState, useEffect } from "react"; import React from "react"; import usePagination from "../hooks/common/usePagination"; const rowsPerPageOptions = [2, 5, 10, 25, 100]; interface PaginatedTableProps { renderTable: React.ComponentType<any>; data: any[]; total: number; tableContainerStyles?: object; params?: any; onSortChange?: (params: any) => void; } const PaginatedTable: React.FC<PaginatedTableProps> = ({ renderTable: RenderTableComponent, data, total, tableContainerStyles = {}, params = {}, onSortChange, }) => { const { page, limit, handleChangePage, handleChangeRowsPerPage } = usePagination(); const [rows, setRows] = useState(data); const [totalRows, setTotalRows] = useState(total); useEffect(() => { setRows(data); setTotalRows(total); }, [data, total]); return ( <> <TableContainer component={Paper} className="!shadow-none !border" sx={tableContainerStyles}> <RenderTableComponent data={rows} onSortChange={onSortChange} params={params} /> </TableContainer> {limit ? ( <TablePagination component="div" rowsPerPageOptions={rowsPerPageOptions} count={totalRows} rowsPerPage={limit} page={page} onPageChange={handleChangePage} onRowsPerPageChange={handleChangeRowsPerPage} /> ) : null} </> ); }; export default PaginatedTable; |