import InfiniteScroll from "@Front/Components/Elements/InfiniteScroll"; import Table from "@mui/material/Table"; import TableBody from "@mui/material/TableBody"; import TableCell from "@mui/material/TableCell"; import TableContainer from "@mui/material/TableContainer"; import TableHead from "@mui/material/TableHead"; import TableRow from "@mui/material/TableRow"; import Typography, { ETypo, ETypoColor } from "../../Typography"; import classes from "./classes.module.scss"; import { SxProps, Theme } from "@mui/material"; export type IRowProps = { key: string } & Record; content: React.ReactNode }>; type IRow = { key?: string; content: Record; }; type IProps = { header: readonly IHead[]; rows: IRowProps[]; onNext?: ((release: () => void, reset?: () => void) => Promise | void) | null; }; export type IHead = { key: string; title?: string; }; type CellContent = { key: string; value: React.ReactNode | { sx: SxProps; content: React.ReactNode }; }; export default function MuiTable(props: IProps) { const rows: IRow[] = props.rows.map((rowProps) => { const row: IRow = { key: rowProps.key, content: {}, }; props.header.forEach((column) => { const cellContent: CellContent = { key: column.key + rowProps.key, value: rowProps[column.key], }; row.content[column.key] = cellContent; }); return row; }); return ( {props.header.map((column) => ( {column.title && ( {column.title} {/* */} )} ))} {rows.map((row) => { return ( {Object.values(row.content).map((cell) => ( {cell.value && typeof cell.value === "object" && "content" in cell.value ? cell.value.content : cell.value} ))} ); })}
); function getCellValueStyle(value: React.ReactNode | { sx: SxProps; content: React.ReactNode }) { if (typeof value === "object" && value !== null && "sx" in value) { return value.sx; } return {}; } }