diff --git a/Client/src/Components/Table/index.jsx b/Client/src/Components/Table/index.jsx index 1edbc3386..361d32762 100644 --- a/Client/src/Components/Table/index.jsx +++ b/Client/src/Components/Table/index.jsx @@ -35,7 +35,7 @@ import { useTheme } from "@emotion/react"; const DataTable = ({ headers, data, config }) => { const theme = useTheme(); - if ((headers?.length ?? 0) === 0 || (data?.length ?? 0) === 0) { + if ((headers?.length ?? 0) === 0) { return "No data"; } @@ -58,26 +58,37 @@ const DataTable = ({ headers, data, config }) => { - {data.map((row) => { - return ( - config?.onRowClick(row)} + {data.length === 0 ? ( + + - {headers.map((header, index) => { - return ( - - {header.render(row)} - - ); - })} - - ); - })} + {config.emptyView} + + + ) : ( + data.map((row) => { + return ( + config?.onRowClick(row)} + > + {headers.map((header, index) => { + return ( + + {header.render(row)} + + ); + })} + + ); + }) + )} @@ -96,6 +107,7 @@ DataTable.propTypes = { config: PropTypes.shape({ onRowClick: PropTypes.func.isRequired, rowSX: PropTypes.object, + emptyView: PropTypes.node, }), };