import React from 'react'; import { makeStyles } from '@material-ui/core/styles'; import Box from '@material-ui/core/Box'; import Collapse from '@material-ui/core/Collapse'; import IconButton from '@material-ui/core/IconButton'; import Table from '@material-ui/core/Table'; import TableBody from '@material-ui/core/TableBody'; import TableCell from '@material-ui/core/TableCell'; import TableContainer from '@material-ui/core/TableContainer'; import TableHead from '@material-ui/core/TableHead'; import TableRow from '@material-ui/core/TableRow'; import Typography from '@material-ui/core/Typography'; import Paper from '@material-ui/core/Paper'; import KeyboardArrowDownIcon from '@material-ui/icons/KeyboardArrowDown'; import KeyboardArrowUpIcon from '@material-ui/icons/KeyboardArrowUp'; const useRowStyles = makeStyles({ root: { '& > *': { borderBottom: 'unset', }, }, }); function createData( name: string, calories: number, fat: number, carbs: number, protein: number, price: number, ) { return { name, calories, fat, carbs, protein, price, history: [ { date: '2020-01-05', customerId: '11091700', amount: 3 }, { date: '2020-01-02', customerId: 'Anonymous', amount: 1 }, ], }; } function Row(props: { row: ReturnType }) { const { row } = props; const [open, setOpen] = React.useState(false); const classes = useRowStyles(); return ( setOpen(!open)}> {open ? : } {row.name} {row.calories} {row.fat} {row.carbs} {row.protein} History Date Customer Amount Total price ($) {row.history.map((historyRow) => ( {historyRow.date} {historyRow.customerId} {historyRow.amount} {Math.round(historyRow.amount * row.price * 100) / 100} ))}
); } const rows = [ createData('Frozen yoghurt', 159, 6.0, 24, 4.0, 3.99), createData('Ice cream sandwich', 237, 9.0, 37, 4.3, 4.99), createData('Eclair', 262, 16.0, 24, 6.0, 3.79), createData('Cupcake', 305, 3.7, 67, 4.3, 2.5), createData('Gingerbread', 356, 16.0, 49, 3.9, 1.5), ]; export default function CollapsibleTable() { return ( Dessert (100g serving) Calories Fat (g) Carbs (g) Protein (g) {rows.map((row) => ( ))}
); }