'use client'; import { useEffect, useState } from 'react'; import { Card, CardContent } from '@/components/ui/card'; import { InvoiceTable } from '@/components/invoices/invoice-table'; import { FileText } from 'lucide-react'; import type { InvoiceEntry } from '@/types/invoices'; function InvoiceSkeleton() { return (
{[...Array(5)].map((_, i) => (
))}
); } export default function InvoicesPage() { const [invoices, setInvoices] = useState(null); const [error, setError] = useState(null); const [accessDenied, setAccessDenied] = useState(false); useEffect(() => { fetch('/api/invoices') .then((res) => { if (res.status === 403) { setAccessDenied(true); return []; } if (!res.ok) throw new Error(`HTTP ${res.status}`); return res.json(); }) .then((json) => { if (!accessDenied) setInvoices(json); }) .catch((err) => setError(err.message)); // eslint-disable-next-line react-hooks/exhaustive-deps }, []); if (accessDenied) { return (

Invoices

Invoice access is not available

Your company does not have invoice viewing enabled. Please contact Vorteq support if you need access to invoices.

); } return (

Invoices

{error ? ( Failed to load invoices: {error} ) : invoices === null ? ( ) : ( )}
); }