Add empty message to BasicTable component
This commit is contained in:
1 parent
4ff4c95951
commit
1e6b339483
1 file changed
+13
-2
@@ -115,7 +115,7 @@ TablePaginationActions.propTypes = {
|
|||||||
* @param {boolean} [props.paginated=false] - Flag to enable pagination.
|
* @param {boolean} [props.paginated=false] - Flag to enable pagination.
|
||||||
* @param {boolean} [props.reversed=false] - Flag to enable reverse order.
|
* @param {boolean} [props.reversed=false] - Flag to enable reverse order.
|
||||||
* @param {number} props.rowsPerPage- Number of rows per page (table).
|
* @param {number} props.rowsPerPage- Number of rows per page (table).
|
||||||
*
|
* @param {string} props.emptyMessage - Message to display when there is no data.
|
||||||
* @example
|
* @example
|
||||||
* const data = {
|
* const data = {
|
||||||
* cols: [
|
* cols: [
|
||||||
@@ -149,7 +149,7 @@ TablePaginationActions.propTypes = {
|
|||||||
* <BasicTable data={data} rows={rows} paginated={true} />
|
* <BasicTable data={data} rows={rows} paginated={true} />
|
||||||
*/
|
*/
|
||||||
|
|
||||||
const BasicTable = ({ data, paginated, reversed, table }) => {
|
const BasicTable = ({ data, paginated, reversed, table, emptyMessage = "No data" }) => {
|
||||||
const DEFAULT_ROWS_PER_PAGE = 5;
|
const DEFAULT_ROWS_PER_PAGE = 5;
|
||||||
const theme = useTheme();
|
const theme = useTheme();
|
||||||
const dispatch = useDispatch();
|
const dispatch = useDispatch();
|
||||||
@@ -228,6 +228,16 @@ const BasicTable = ({ data, paginated, reversed, table }) => {
|
|||||||
</TableRow>
|
</TableRow>
|
||||||
);
|
);
|
||||||
})}
|
})}
|
||||||
|
{displayData.length === 0 && (
|
||||||
|
<TableRow>
|
||||||
|
<TableCell
|
||||||
|
sx={{ textAlign: "center" }}
|
||||||
|
colSpan={data.cols.length}
|
||||||
|
>
|
||||||
|
{emptyMessage}
|
||||||
|
</TableCell>
|
||||||
|
</TableRow>
|
||||||
|
)}
|
||||||
</TableBody>
|
</TableBody>
|
||||||
</Table>
|
</Table>
|
||||||
</TableContainer>
|
</TableContainer>
|
||||||
@@ -317,6 +327,7 @@ BasicTable.propTypes = {
|
|||||||
reversed: PropTypes.bool,
|
reversed: PropTypes.bool,
|
||||||
rowPerPage: PropTypes.number,
|
rowPerPage: PropTypes.number,
|
||||||
table: PropTypes.string,
|
table: PropTypes.string,
|
||||||
|
emptyMessage: PropTypes.string,
|
||||||
};
|
};
|
||||||
|
|
||||||
export default BasicTable;
|
export default BasicTable;
|
||||||
Reference in new issue
Block a user