"use client"; import * as React from "react"; import Box from "@mui/material/Box"; import TableCell from "@mui/material/TableCell"; import TableRow from "@mui/material/TableRow"; import Typography from "@mui/material/Typography"; import IconButton from "@mui/material/IconButton"; import CircleIcon from "@mui/icons-material/Circle"; import Stack from "@mui/material/Stack/Stack"; import KeyboardArrowDownIcon from "@mui/icons-material/KeyboardArrowDown"; import KeyboardArrowUpIcon from "@mui/icons-material/KeyboardArrowUp"; import Grid2 from "@mui/material/Unstable_Grid2"; // Grid version 2 import { Collapse } from "@mui/material"; import { NodeStatus, NodeStatusKeys, TableData } from "@/data/nodeData"; export default function NodeRow(props: { row: TableData; selected: string | undefined; setSelected: (a: string | undefined) => void; }) { function renderStatus(status: NodeStatusKeys) { switch (status) { case NodeStatus.Online: return ( Online ); case NodeStatus.Offline: return ( Offline ); case NodeStatus.Pending: return ( Pending ); } } const { row, selected, setSelected } = props; const [open, setOpen] = React.useState(false); //const labelId = `enhanced-table-checkbox-${index}`; // Speed optimization. We compare string pointers here instead of the string content. const isSelected = selected == row.id; const handleClick = (event: React.MouseEvent, id: string) => { if (isSelected) { setSelected(undefined); } else { setSelected(id); } }; const debug = true; const debugSx = debug ? { "--Grid-borderWidth": "1px", borderTop: "var(--Grid-borderWidth) solid", borderLeft: "var(--Grid-borderWidth) solid", borderColor: "divider", "& > div": { borderRight: "var(--Grid-borderWidth) solid", borderBottom: "var(--Grid-borderWidth) solid", borderColor: "divider", }, } : {}; return ( {/* Rendered Row */} setOpen(!open)} > {open ? : } handleClick(event, row.id)} > {row.name} {row.id} handleClick(event, row.name)} > {renderStatus(row.status)} handleClick(event, row.name)} > {row.last_seen} days ago {/* Row Expansion */} Metadata Hello1 Hello2 ); }