Further simplified
This commit is contained in:
1 parent
cc9c439c8d
commit
e0d3dd0331
1 file changed
+16
-35
@@ -77,13 +77,9 @@ const BasicTable = ({ data, paginated }) => {
|
|||||||
setPage(0); // Reset to first page after changing rows per page
|
setPage(0); // Reset to first page after changing rows per page
|
||||||
};
|
};
|
||||||
|
|
||||||
let paginatedData = [];
|
let displayData = paginated
|
||||||
if (paginated) {
|
? data.rows.slice(page * rowsPerPage, page * rowsPerPage + rowsPerPage)
|
||||||
paginatedData = data.rows.slice(
|
: data.rows;
|
||||||
page * rowsPerPage,
|
|
||||||
page * rowsPerPage + rowsPerPage
|
|
||||||
);
|
|
||||||
}
|
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<>
|
<>
|
||||||
@@ -97,34 +93,19 @@ const BasicTable = ({ data, paginated }) => {
|
|||||||
</TableRow>
|
</TableRow>
|
||||||
</TableHead>
|
</TableHead>
|
||||||
<TableBody>
|
<TableBody>
|
||||||
{paginated === false &&
|
{displayData.map((row) => {
|
||||||
data.rows.map((row) => {
|
return (
|
||||||
return (
|
<TableRow
|
||||||
<TableRow
|
sx={{ cursor: row.handleClick ? "pointer" : "default" }}
|
||||||
sx={{ cursor: row.handleClick ? "pointer" : "default" }}
|
key={row.id}
|
||||||
key={row.id}
|
onClick={row.handleClick ? row.handleClick : null}
|
||||||
onClick={row.handleClick ? row.handleClick : null}
|
>
|
||||||
>
|
{row.data.map((cell) => {
|
||||||
{row.data.map((cell) => {
|
return <TableCell key={cell.id}>{cell.data}</TableCell>;
|
||||||
return <TableCell key={cell.id}>{cell.data}</TableCell>;
|
})}
|
||||||
})}
|
</TableRow>
|
||||||
</TableRow>
|
);
|
||||||
);
|
})}
|
||||||
})}
|
|
||||||
{paginated === true &&
|
|
||||||
paginatedData.map((row) => {
|
|
||||||
return (
|
|
||||||
<TableRow
|
|
||||||
sx={{ cursor: row.handleClick ? "pointer" : "default" }}
|
|
||||||
key={row.id}
|
|
||||||
onClick={row.handleClick ? row.handleClick : null}
|
|
||||||
>
|
|
||||||
{row.data.map((cell) => {
|
|
||||||
return <TableCell key={cell.id}>{cell.data}</TableCell>;
|
|
||||||
})}
|
|
||||||
</TableRow>
|
|
||||||
);
|
|
||||||
})}
|
|
||||||
</TableBody>
|
</TableBody>
|
||||||
</Table>
|
</Table>
|
||||||
</TableContainer>
|
</TableContainer>
|
||||||
|
|||||||
Reference in new issue
Block a user