import { Box, Grid } from "@chakra-ui/layout"; import { useMediaQuery } from "@chakra-ui/media-query"; import { Table, TableCaption, Tbody, Td, Tfoot, Th, Thead, Tr, } from "@chakra-ui/table"; import React, { Fragment } from "react"; import OutlinedBox from "./OutlinedBox"; export default function NewTable({ caption, headers, data, smallAtPx, }: { caption?: string; headers: { name: string; dataKey: string; }[]; data: (Record & { id: number })[]; smallAtPx?: string; }) { const [isSmall] = useMediaQuery( smallAtPx ? `(max-width: ${smallAtPx}px)` : "(max-width: 600px)" ); if (isSmall) { return ( <> {data.map((row) => { return ( {headers.map(({ name, dataKey }) => { return ( {name} {row[dataKey]} ); })} ); })} ); } return ( {caption && {caption}} {headers.map(({ name }) => ( ))} {data.map((row) => { return ( {headers.map(({ dataKey }) => { return ; })} ); })} {headers.map(({ name }) => ( ))}
{name}
{row[dataKey]}
{name}
); }