import { useEffect, useState } from 'react'; import { Table, TableHead, TableBody, TableRow, TableCell, Button, } from '@mui/material'; import OpenInNew from '@mui/icons-material/OpenInNew'; import { PageContent } from 'component/common/PageContent/PageContent'; import { PageHeader } from 'component/common/PageHeader/PageHeader'; import { ConditionallyRender } from 'component/common/ConditionallyRender/ConditionallyRender'; import { formatApiPath } from 'utils/formatPath'; import useInvoices from 'hooks/api/getters/useInvoices/useInvoices'; import type { IInvoice } from 'interfaces/invoice'; import { useLocationSettings } from 'hooks/useLocationSettings'; import { formatDateYMD } from 'utils/formatDate'; const PORTAL_URL = formatApiPath('api/admin/invoices/portal'); const InvoiceList = () => { const { refetchInvoices, invoices } = useInvoices(); const [isLoaded, setLoaded] = useState(false); const { locationSettings } = useLocationSettings(); useEffect(() => { refetchInvoices(); setLoaded(true); // eslint-disable-next-line react-hooks/exhaustive-deps }, []); return ( 0} show={ } > Billing portal } /> } >
Amount Status Due date PDF Link {invoices.map((item: IInvoice) => ( {item.amountFormatted} {item.status} {item.dueDate && formatDateYMD( item.dueDate, locationSettings.locale, )} PDF Payment link ))}
} elseShow={ {isLoaded && 'No invoices to show.'} } /> ); }; export default InvoiceList;