generated from Luis/nextjs-python-web-template
ran format command
This commit is contained in:
@@ -1,27 +1,29 @@
|
||||
import React from "react";
|
||||
import Table from '@mui/material/Table';
|
||||
import TableBody from '@mui/material/TableBody';
|
||||
import TableContainer from '@mui/material/TableContainer';
|
||||
import TableHead from '@mui/material/TableHead';
|
||||
import TableRow from '@mui/material/TableRow';
|
||||
import Paper from '@mui/material/Paper';
|
||||
import Table from "@mui/material/Table";
|
||||
import TableBody from "@mui/material/TableBody";
|
||||
import TableContainer from "@mui/material/TableContainer";
|
||||
import TableHead from "@mui/material/TableHead";
|
||||
import TableRow from "@mui/material/TableRow";
|
||||
import Paper from "@mui/material/Paper";
|
||||
|
||||
import { NoDataOverlay } from "@/components/noDataOverlay";
|
||||
import { StyledTableCell, StyledTableRow } from "./style";
|
||||
import { ICustomTable, CustomTableConfiguration } from "@/types";
|
||||
|
||||
const CustomTable = ({ configuration, data }: ICustomTable) => {
|
||||
|
||||
// display empty icon in case there is no data
|
||||
if (!data || data.length === 0)
|
||||
return <NoDataOverlay label="No Activity yet" />
|
||||
|
||||
const renderTableCell = (value: any, cellKey: string, render?: (param: any) => void | undefined) => {
|
||||
return <NoDataOverlay label="No Activity yet" />;
|
||||
|
||||
const renderTableCell = (
|
||||
value: any,
|
||||
cellKey: string,
|
||||
render?: (param: any) => void | undefined,
|
||||
) => {
|
||||
let renderedValue = value;
|
||||
|
||||
// cover use case if the data is an array
|
||||
if (Array.isArray(value)) renderedValue = value.join(', ')
|
||||
if (Array.isArray(value)) renderedValue = value.join(", ");
|
||||
|
||||
// cover use case if we want to render a component
|
||||
if (render) renderedValue = render(value);
|
||||
@@ -31,8 +33,7 @@ const CustomTable = ({ configuration, data }: ICustomTable) => {
|
||||
{renderedValue}
|
||||
</StyledTableCell>
|
||||
);
|
||||
|
||||
}
|
||||
};
|
||||
|
||||
return (
|
||||
<TableContainer component={Paper}>
|
||||
@@ -40,9 +41,7 @@ const CustomTable = ({ configuration, data }: ICustomTable) => {
|
||||
<TableHead>
|
||||
<TableRow>
|
||||
{configuration.map((header: CustomTableConfiguration) => (
|
||||
<StyledTableCell key={header.key}>
|
||||
{header.label}
|
||||
</StyledTableCell>
|
||||
<StyledTableCell key={header.key}>{header.label}</StyledTableCell>
|
||||
))}
|
||||
</TableRow>
|
||||
</TableHead>
|
||||
@@ -60,7 +59,7 @@ const CustomTable = ({ configuration, data }: ICustomTable) => {
|
||||
</TableBody>
|
||||
</Table>
|
||||
</TableContainer>
|
||||
)
|
||||
}
|
||||
);
|
||||
};
|
||||
|
||||
export default CustomTable;
|
||||
export default CustomTable;
|
||||
|
||||
Reference in New Issue
Block a user