import { useNavigate } from 'react-router-dom'; import { Box, Button, Card, Stack, Typography } from '@mui/material'; import { DataGrid, type GridColDef } from '@mui/x-data-grid'; import { useInvoices } from '../../../hooks/useARInvoices'; import { useBranchStore } from '../../../store/branchStore'; import { useAuth } from '../../../hooks/useAuth'; import { StatusChip } from '../../../components/common/StatusChip'; import { MoneyCell } from '../../../components/common/MoneyCell'; import type { ARInvoice } from '../../../types/api'; export function InvoicesListPage() { const navigate = useNavigate(); const selected = useBranchStore((state) => state.selected); const { data: invoices, isLoading } = useInvoices(selected); const { hasPermission } = useAuth(); const columns: GridColDef[] = [ { field: 'invoiceNumber', headerName: 'Invoice #', width: 180 }, { field: 'customer', headerName: 'Customer', flex: 1, valueGetter: (_v, row) => row.customer?.name }, { field: 'invoiceDate', headerName: 'Date', width: 120, valueFormatter: (value: string) => value?.slice(0, 10) }, { field: 'dueDate', headerName: 'Due', width: 120, valueFormatter: (value: string) => value?.slice(0, 10) }, { field: 'total', headerName: 'Total', width: 120, align: 'right', headerAlign: 'right', renderCell: (params) => , }, { field: 'balance', headerName: 'Balance', width: 120, align: 'right', headerAlign: 'right', renderCell: (params) => , }, { field: 'status', headerName: 'Status', width: 120, renderCell: (params) => }, ]; return ( Invoices {hasPermission('ar.invoice.manage') && ( )} navigate(`/ar/invoices/${params.row.id}`)} sx={{ border: 'none', '& .MuiDataGrid-row': { cursor: 'pointer' } }} initialState={{ sorting: { sortModel: [{ field: 'invoiceDate', sort: 'desc' }] } }} /> ); }