// TODO: Sorting import React, { useMemo } from "react"; import { Table as MuiTable, TableContainer as MuiTableContainer, TableContainerProps as MUITableContainerProps, TableProps as MUITableProps, } from "@mui/material"; import { TableContext } from "../../contexts/TableContext"; import TablePagination from "./TablePagination"; import { useTableSearchParams } from "./useTableSearchParams"; export interface TableProps extends React.PropsWithChildren { pagination?: boolean; defaultPage?: number; defaultRowsPerPage?: number; rowsPerPageOptions?: number[]; count: number; tableProps?: MUITableProps; tableContainerProps?: MUITableContainerProps; } export const Table: React.FC = ({ count, defaultPage, pagination, defaultRowsPerPage, rowsPerPageOptions, children, tableProps, tableContainerProps, }) => { const searchParams = useTableSearchParams({ page: defaultPage, rowsPerPage: defaultRowsPerPage, }); const contextValues = useMemo( () => ({ count, rowsPerPageOptions: rowsPerPageOptions ?? [50, 100, 200], ...searchParams, }), [count, searchParams, rowsPerPageOptions], ); return ( {children} {pagination && } ); }; export default Table;