fix(e2e): resilient auth helper — handle zustand hydration delay, flexible selectors, longer timeout; add isError to invoices
This commit is contained in:
@@ -38,7 +38,7 @@ export default function InvoicesPage() {
|
||||
const [selected, setSelected] = useState<Invoice | null>(null);
|
||||
const [payForm, setPayForm] = useState({ amount: "", channel: "CASH", referenceNumber: "", notes: "" });
|
||||
|
||||
const { data, isLoading, refetch } = useQuery<InvoicesResponse>({
|
||||
const { data, isLoading, isError, refetch } = useQuery<InvoicesResponse>({
|
||||
queryKey: ["invoices", search, statusFilter, page],
|
||||
queryFn: async () => {
|
||||
const params = new URLSearchParams({ page: String(page), limit: "20" });
|
||||
@@ -116,6 +116,8 @@ export default function InvoicesPage() {
|
||||
Array.from({ length: 8 }).map((_, i) => (
|
||||
<TableRow key={i}><Td colSpan={8}><div className="h-4 bg-gray-100 rounded animate-pulse" /></Td></TableRow>
|
||||
))
|
||||
) : isError ? (
|
||||
<TableRow><Td colSpan={8}><p className="text-center py-6 text-red-400 text-sm">Failed to load invoices. <button onClick={() => refetch()} className="underline">Retry</button></p></Td></TableRow>
|
||||
) : invoices.length === 0 ? (
|
||||
<EmptyState colSpan={8} message="No invoices found" icon={<FileText size={24} />} />
|
||||
) : invoices.map(inv => (
|
||||
|
||||
Reference in New Issue
Block a user