import { format } from 'date-fns'; // @mui import Link from '@mui/material/Link'; import Button from '@mui/material/Button'; import Avatar from '@mui/material/Avatar'; import Divider from '@mui/material/Divider'; import MenuItem from '@mui/material/MenuItem'; import TableRow from '@mui/material/TableRow'; import TableCell from '@mui/material/TableCell'; import IconButton from '@mui/material/IconButton'; import Typography from '@mui/material/Typography'; import ListItemText from '@mui/material/ListItemText'; // hooks import { useBoolean } from 'src/hooks/use-boolean'; // utils import { fNumber } from 'src/utils/format-number'; // types import { Invoice } from 'src/schemas'; // components import Label from 'src/components/label'; import Iconify from 'src/components/iconify'; import { ConfirmDialog } from 'src/components/custom-dialog'; import CustomPopover, { usePopover } from 'src/components/custom-popover'; // ---------------------------------------------------------------------- type Props = { row: Invoice; selected: boolean; onSelectRow: VoidFunction; onViewRow: VoidFunction; onEditRow: VoidFunction; onCopyRow: VoidFunction; onDeleteRow: () => Promise; onSendRow: VoidFunction; onToggleCompose: VoidFunction; }; export default function InvoiceTableRow({ row, selected, onSelectRow, onViewRow, onEditRow, onCopyRow, onDeleteRow, onSendRow, onToggleCompose, }: Props) { const { sent, invoiceNumber, issueDate, dueDate, status, invoiceTo, currency, totalAmount, month, } = row; console.log(issueDate); const confirmSend = useBoolean(); const confirmDelete = useBoolean(); const popover = usePopover(); return ( <> {/* */} {invoiceTo.name.charAt(0).toUpperCase()} {invoiceTo.name} } secondary={ {invoiceNumber} } /> {fNumber(totalAmount)} {currency} {month} {sent} { onCopyRow(); popover.onClose(); }} > Copy { onViewRow(); popover.onClose(); }} > View { onEditRow(); popover.onClose(); }} disabled={status === 'processing'} > Edit { popover.onClose(); onToggleCompose(); }} sx={{ color: 'info.main' }} disabled={status === 'processing' || status === 'paid'} > Send { confirmDelete.onTrue(); popover.onClose(); }} disabled={status === 'processing'} sx={{ color: 'error.main' }} > Delete { onSendRow(); confirmSend.onFalse(); }} > Send } /> { await onDeleteRow(); confirmDelete.onToggle(); }} > Delete } /> ); }