"use client"; import { useState, useEffect } from "react"; import { fetchInvoices, type InvoiceRow, type InvoiceListFilter } from "@/lib/supabase/invoicing-actions"; import InvoicesShell from "../invoices/InvoicesShell"; import PageSkeleton from "./PageSkeleton"; export default function InvoicesPage() { const [invoices, setInvoices] = useState(null); const [loading, setLoading] = useState(true); const [error, setError] = useState(null); useEffect(() => { let cancelled = false; fetchInvoices("all") .then((data) => { if (!cancelled) setInvoices(data); }) .catch(() => { if (!cancelled) setError("Failed to load invoices"); }) .finally(() => { if (!cancelled) setLoading(false); }); return () => { cancelled = true; }; }, []); if (loading) return ; if (error) { return (
{error}
); } if (!invoices) return null; return ; }