Table of Contents

**@arolariu/website**


@arolariu/website / lib/actions/invoices/fetchInvoices / default

Function: default()

default(_void?): ServerActionOutputType

Defined in: lib/actions/invoices/fetchInvoices.ts:78

Fetches all invoices accessible to the authenticated user.

Parameters

_void?

Readonly<{ }>

Reserved parameter for future filter/pagination options

Returns

ServerActionOutputType

Promise resolving to ServerActionResult with Invoice array or error

Remarks

Execution Context: Server-side only (Next.js server action).

Authentication: Automatically fetches JWT from Clerk auth service.

Data Returned:

  • Array of full invoice aggregates
  • Includes both owned and shared invoices
  • Excludes soft-deleted invoices

Performance:

  • Returns complete entities; use with caution for large datasets
  • Consider client-side caching via Zustand store
  • Includes 30-second timeout for network resilience

Side Effects: Emits OpenTelemetry spans for tracing.

Example

import fetchInvoices from "@/lib/actions/invoices/fetchInvoices";

const invoices = await fetchInvoices();

// Display invoice count
console.log(`Found ${invoices.length} invoices`);

// Filter important invoices
const important = invoices.filter(inv =>
  inv.additionalMetadata?.isImportant === "true"
);

See

  • fetchInvoice for fetching a specific invoice
  • useInvoicesStore for client-side state management