safe data access, add default empty view

This commit is contained in:
Alex Holliday committed 2025-01-03 11:17:55 -08:00
1 parent c192d7024e
commit c6ef46133c
1 file changed
+2 -2
+2 -2
View File
@@ -32,7 +32,7 @@ import { useTheme } from "@emotion/react";
* @returns {JSX.Element} The rendered table component. * @returns {JSX.Element} The rendered table component.
*/ */
const DataTable = ({ headers, data, config }) => { const DataTable = ({ headers, data, config = { emptyView: "No data" } }) => {
const theme = useTheme(); const theme = useTheme();
if ((headers?.length ?? 0) === 0) { if ((headers?.length ?? 0) === 0) {
@@ -58,7 +58,7 @@ const DataTable = ({ headers, data, config }) => {
</TableRow> </TableRow>
</TableHead> </TableHead>
<TableBody> <TableBody>
{data.length === 0 ? ( {(data?.length ?? 0 === 0) ? (
<TableRow> <TableRow>
<TableCell <TableCell
colSpan={headers.length} colSpan={headers.length}