import { isDarkTheme } from '../../lib/themeUpdater' import { Table as ResponsiveTable, Thead, Tbody, Tr, Th, Td, } from 'react-super-responsive-table' import 'react-super-responsive-table/dist/SuperResponsiveTableStyle.css' import { PencilSimple, Plus, Trash } from 'phosphor-react' import { Box, SpanBox, VStack } from './LayoutPrimitives' import { styled } from '../tokens/stitches.config' import { StyledText } from './StyledText' import { InfoLink } from './InfoLink' import { Button } from './Button' import { IconButton } from './Button' interface TableProps { heading: string infoLink?: string onAdd?: () => void headers: string[] rows: Map> onDelete?: (id: string) => void onEdit?: (obj: any) => void } const HeaderWrapper = styled(Box, { width: '100%', '@md': { display: 'block', }, }) const StyledTable = styled(ResponsiveTable, { margin: ' 0 auto', border: '0.5px solid $grayBgActive', backgroundColor: '$graySolid', borderCollapse: 'collapse', borderRadius: '5px', width: '100%', mt: '$3', '&:hover': { border: '0.5px solid #FFD234', }, }) const TableBody = styled(Tbody, { backgroundColor: '$grayBg', }) const TableRow = styled(Tr, { border: '0 !important', borderTop: '0.5px solid $grayBgActive !important', }) export function Table(props: TableProps): JSX.Element { const iconColor = isDarkTheme() ? '#D8D7D5' : '#5F5E58' return ( {props.heading} {props.infoLink && } {props.onAdd && ( )} {props.headers.map((header: string, index: number) => ( {header} ))} {Array.from(props.rows.keys()).map((key, index) => ( {Object.values(props.rows.get(key) || {}).map((cell, index) => ( {cell} ))} {props.onDelete && ( { props.onDelete && props.onDelete(key) }} > )} {props.onEdit && ( { props.onEdit && props.onEdit({ ...props.rows.get(key), id: key }) }} > )} ))} ) }