import * as React from 'react'; import { ColorPaletteProp } from '@mui/joy/styles'; import Avatar from '@mui/joy/Avatar'; import Box from '@mui/joy/Box'; import Button from '@mui/joy/Button'; import Chip from '@mui/joy/Chip'; import Divider from '@mui/joy/Divider'; import FormControl from '@mui/joy/FormControl'; import FormLabel from '@mui/joy/FormLabel'; import Link from '@mui/joy/Link'; import Input from '@mui/joy/Input'; import Modal from '@mui/joy/Modal'; import ModalDialog from '@mui/joy/ModalDialog'; import ModalClose from '@mui/joy/ModalClose'; import Select from '@mui/joy/Select'; import Option from '@mui/joy/Option'; import Table from '@mui/joy/Table'; import Sheet from '@mui/joy/Sheet'; import Checkbox from '@mui/joy/Checkbox'; import IconButton, { iconButtonClasses } from '@mui/joy/IconButton'; import Typography from '@mui/joy/Typography'; import Menu from '@mui/joy/Menu'; import MenuButton from '@mui/joy/MenuButton'; import MenuItem from '@mui/joy/MenuItem'; import Dropdown from '@mui/joy/Dropdown'; import FilterAltIcon from '@mui/icons-material/FilterAlt'; import SearchIcon from '@mui/icons-material/Search'; import ArrowDropDownIcon from '@mui/icons-material/ArrowDropDown'; import CheckRoundedIcon from '@mui/icons-material/CheckRounded'; import BlockIcon from '@mui/icons-material/Block'; import AutorenewRoundedIcon from '@mui/icons-material/AutorenewRounded'; import KeyboardArrowRightIcon from '@mui/icons-material/KeyboardArrowRight'; import KeyboardArrowLeftIcon from '@mui/icons-material/KeyboardArrowLeft'; import MoreHorizRoundedIcon from '@mui/icons-material/MoreHorizRounded'; const rows = [ { id: 'INV-1234', date: 'Feb 3, 2023', status: 'Refunded', customer: { initial: 'O', name: 'Olivia Ryhe', email: 'olivia@email.com', }, }, { id: 'INV-1233', date: 'Feb 3, 2023', status: 'Paid', customer: { initial: 'S', name: 'Steve Hampton', email: 'steve.hamp@email.com', }, }, { id: 'INV-1232', date: 'Feb 3, 2023', status: 'Refunded', customer: { initial: 'C', name: 'Ciaran Murray', email: 'ciaran.murray@email.com', }, }, { id: 'INV-1231', date: 'Feb 3, 2023', status: 'Refunded', customer: { initial: 'M', name: 'Maria Macdonald', email: 'maria.mc@email.com', }, }, { id: 'INV-1230', date: 'Feb 3, 2023', status: 'Cancelled', customer: { initial: 'C', name: 'Charles Fulton', email: 'fulton@email.com', }, }, { id: 'INV-1229', date: 'Feb 3, 2023', status: 'Cancelled', customer: { initial: 'J', name: 'Jay Hooper', email: 'hooper@email.com', }, }, { id: 'INV-1228', date: 'Feb 3, 2023', status: 'Refunded', customer: { initial: 'K', name: 'Krystal Stevens', email: 'k.stevens@email.com', }, }, { id: 'INV-1227', date: 'Feb 3, 2023', status: 'Paid', customer: { initial: 'S', name: 'Sachin Flynn', email: 's.flyn@email.com', }, }, { id: 'INV-1226', date: 'Feb 3, 2023', status: 'Cancelled', customer: { initial: 'B', name: 'Bradley Rosales', email: 'brad123@email.com', }, }, { id: 'INV-1225', date: 'Feb 3, 2023', status: 'Paid', customer: { initial: 'O', name: 'Olivia Ryhe', email: 'olivia@email.com', }, }, { id: 'INV-1224', date: 'Feb 3, 2023', status: 'Cancelled', customer: { initial: 'S', name: 'Steve Hampton', email: 'steve.hamp@email.com', }, }, { id: 'INV-1223', date: 'Feb 3, 2023', status: 'Paid', customer: { initial: 'C', name: 'Ciaran Murray', email: 'ciaran.murray@email.com', }, }, { id: 'INV-1221', date: 'Feb 3, 2023', status: 'Refunded', customer: { initial: 'M', name: 'Maria Macdonald', email: 'maria.mc@email.com', }, }, { id: 'INV-1220', date: 'Feb 3, 2023', status: 'Paid', customer: { initial: 'C', name: 'Charles Fulton', email: 'fulton@email.com', }, }, { id: 'INV-1219', date: 'Feb 3, 2023', status: 'Cancelled', customer: { initial: 'J', name: 'Jay Hooper', email: 'hooper@email.com', }, }, { id: 'INV-1218', date: 'Feb 3, 2023', status: 'Cancelled', customer: { initial: 'K', name: 'Krystal Stevens', email: 'k.stevens@email.com', }, }, { id: 'INV-1217', date: 'Feb 3, 2023', status: 'Paid', customer: { initial: 'S', name: 'Sachin Flynn', email: 's.flyn@email.com', }, }, { id: 'INV-1216', date: 'Feb 3, 2023', status: 'Cancelled', customer: { initial: 'B', name: 'Bradley Rosales', email: 'brad123@email.com', }, }, ]; function descendingComparator(a: T, b: T, orderBy: keyof T) { if (b[orderBy] < a[orderBy]) { return -1; } if (b[orderBy] > a[orderBy]) { return 1; } return 0; } type Order = 'asc' | 'desc'; function getComparator( order: Order, orderBy: Key, ): ( a: { [key in Key]: number | string }, b: { [key in Key]: number | string }, ) => number { return order === 'desc' ? (a, b) => descendingComparator(a, b, orderBy) : (a, b) => -descendingComparator(a, b, orderBy); } function RowMenu() { return ( Edit Rename Move Delete ); } export default function OrderTable() { const [order, setOrder] = React.useState('desc'); const [selected, setSelected] = React.useState([]); const [open, setOpen] = React.useState(false); const renderFilters = () => ( Status Category Customer ); return ( } sx={{ flexGrow: 1 }} /> setOpen(true)} > setOpen(false)}> Filters {renderFilters()} *': { minWidth: { xs: '120px', md: '160px' }, }, }} > Search for order } /> {renderFilters()} {/* eslint-disable-next-line jsx-a11y/control-has-associated-label */} {[...rows].sort(getComparator(order, 'id')).map((row) => ( ))}
0 && selected.length !== rows.length } checked={selected.length === rows.length} onChange={(event) => { setSelected( event.target.checked ? rows.map((row) => row.id) : [], ); }} color={ selected.length > 0 || selected.length === rows.length ? 'primary' : undefined } sx={{ verticalAlign: 'text-bottom' }} /> setOrder(order === 'asc' ? 'desc' : 'asc')} endDecorator={} sx={[ { fontWeight: 'lg', '& svg': { transition: '0.2s', transform: order === 'desc' ? 'rotate(0deg)' : 'rotate(180deg)', }, }, order === 'desc' ? { '& svg': { transform: 'rotate(0deg)' } } : { '& svg': { transform: 'rotate(180deg)' } }, ]} > Invoice Date Status Customer
{ setSelected((ids) => event.target.checked ? ids.concat(row.id) : ids.filter((itemId) => itemId !== row.id), ); }} slotProps={{ checkbox: { sx: { textAlign: 'left' } } }} sx={{ verticalAlign: 'text-bottom' }} /> {row.id} {row.date} , Refunded: , Cancelled: , }[row.status] } color={ { Paid: 'success', Refunded: 'neutral', Cancelled: 'danger', }[row.status] as ColorPaletteProp } > {row.status} {row.customer.initial}
{row.customer.name} {row.customer.email}
Download
{['1', '2', '3', '…', '8', '9', '10'].map((page) => ( {page} ))}
); }