import * as React from 'react'; import IconButton from '@mui/joy/IconButton'; import Table from '@mui/joy/Table'; import Typography from '@mui/joy/Typography'; import Sheet from '@mui/joy/Sheet'; import KeyboardArrowDownIcon from '@mui/icons-material/KeyboardArrowDown'; import KeyboardArrowUpIcon from '@mui/icons-material/KeyboardArrowUp'; 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; initialOpen?: boolean }) { const { row } = props; const [open, setOpen] = React.useState(props.initialOpen || false); return ( setOpen(!open)} > {open ? : } {row.name} {row.calories} {row.fat} {row.carbs} {row.protein} {open && ( History thead > tr > th:nth-child(n + 3), & > tbody > tr > td:nth-child(n + 3)': { textAlign: 'right' }, '--TableCell-paddingX': '0.5rem', }} > {row.history.map((historyRow) => ( ))}
Date Customer Amount Total price ($)
{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 TableCollapsibleRow() { return ( thead > tr > th:nth-child(n + 3), & > tbody > tr > td:nth-child(n + 3)': { textAlign: 'right' }, '& > tbody > tr:nth-child(odd) > td, & > tbody > tr:nth-child(odd) > th[scope="row"]': { borderBottom: 0, }, }} > {rows.map((row, index) => ( ))}
Dessert (100g serving) Calories Fat (g) Carbs (g) Protein (g)
); }