dolfindevelopers

Expense policy documents

ComponentExpensesSDK + UI

Upload the written expense policy (PDF, Word .docx or text, by drop or browse) and see every version: its status while it is read into proposed policies (polling until done, or showing it as taking longer than usual with Check again once it stalls), how many policies and unenforceable clauses it yielded, and Review, View or Retry. Also ships the document status badge. Driven by useExpensePolicyDocuments. Pass documents (with loading, error, onUpload and onRetryDocument) to render your own list without a request.

Component: A piece you place inside your own screens: a table, a form, a card or a dialog. You decide the layout around it. Pages vs components

Choose your integration

Ready to connect to Dolfin. Loads data through SDK hooks, with appearance and behaviour you can customise. Requires DolfinProvider.

Loading preview…

Installation

Needs the Dolfin registry token. The CLI copies the source into your app.

Terminal
bunx --bun shadcn@4.23.0 add @dolfin/expenses-policy-documents-panel

Also installs: button, card, base-theme, base-data-table, base-info-hint, base-states, base-status-badge, ui-expenses-policy-documents-panel, ui-base-data-table.

Usage

screen.tsx
import { ExpensePolicyDocumentsPanel } from "@/components/dolfin/expenses/policy-documents-panel";

// Place it anywhere inside your <DolfinProvider>.
<ExpensePolicyDocumentsPanel />

Renders inside DolfinProvider (set it up once). By default it loads its own data through the SDK. Supplied-data examples show how to override that behavior.

API reference

PropTypeDescription
documentsreadonly { id: string; version: number | string; fileName: string; contentType: string; sizeBytes?: number | string; pageCount?: null | numb…Your documents, newest first: rendered as given and nothing is fetched. Read when omitted.
loadingboolean
errorError
onRetry() => void
onUpload(file: File) => voidShows the drop zone; called with the one file dropped or picked. Wired to the SDK by default.
uploadingboolean
onRetryDocument(documentId: string) => voidShows Retry on a document that failed to read. Wired to the SDK by default.
pendingIdstringThe document a retry is running for: its Retry waits.
columnsreadonly Column[] | ((defaults: Column[]) => readonly Column[])Replaces the default columns (version, file, status, found, uploaded).
classNamestring

Customisation

Without editing the source, you can change:

Class names
className
Messages
expenses.approvalPolicies

Or edit the installed file directly: it is your code. See theming for colours and fonts.

Hooks

The SDK hooks this component uses. Use them directly from @dolfinai/react to build your own version.

useDolfinLocaleuseExpensePolicyDocumentMutationsuseExpensePolicyDocumentsuseExpensePolicyFormatuseMessagesuseNotify

Files

Written to your app by the install command:

  • components/dolfin/expenses/policy-documents-panel.tsx 346 lines