import * as React from "react"
import Box from "@mui/material/Box"
import Collapse from "@mui/material/Collapse"
import IconButton from "@mui/material/IconButton"
import Table from "@mui/material/Table"
import TableBody from "@mui/material/TableBody"
import TableCell, { tableCellClasses } from "@mui/material/TableCell"
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 { PrettyPrintJson } from "utils"
import { useTheme } from "@mui/system"
function Row({ keyName, obj }: any) {
const [showCopy, setShowCopy] = React.useState(false)
const [clipboardCopy, setclipboardCopy] = React.useState(false)
const [open, setOpen] = React.useState(false)
const theme = useTheme()
let value = ""
let valueType = "string"
if (typeof obj === "string") {
value = obj
} else {
valueType = "object"
}
console.log(obj, keyName, 11111111111111111111111111)
return (
*": { borderBottom: "unset" } }}>
{/* Row Data */}
setOpen(!open)}
>
{open ? ⬆️ : ⬇️}
{keyName}
{valueType}
{value}
{value.length}
setShowCopy(true)}
onMouseLeave={() => {
setShowCopy(false)
setclipboardCopy(false)
}}
sx={{
background: theme.palette.zesty.zestyDarkBlue,
color: theme.palette.zesty.zestyGreen,
position: "relative",
}}
>
{clipboardCopy && ✅ Copied to clidboard!}
{showCopy && 📜 Copy!}
{/* Expanded Data */}
{PrettyPrintJson({ data: obj })}
)
}
export default function CollapsibleTable({ data = {} }: any) {
return (
{/* HEaders */}
Field Name
Type
Content Example
Content Length
Access Example
{/* Table Row main */}
{Object.keys(data)?.map((keyName: any) => (
))}
)
}