Expense approval policy fields
The fields of an expense approval policy: name, priority and active; conditions (an amount range in a currency, spend categories, merchants, cards, people, receipt and business or personal spend); the action as three described choices; up to five approvers for Require approval; and the rule read back in plain words. Controlled, so the policy dialog and the policy document review share it.
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
Ready to connect to Dolfin. Loads data through SDK hooks, with appearance and behaviour you can customise. Requires DolfinProvider.
Installation
Needs the Dolfin registry token. The CLI copies the source into your app.
bunx --bun shadcn@4.23.0 add @dolfin/expenses-approval-policy-fieldsAlso installs: field, input, select, switch, base-page, ap-bills-filters, ap-bill-lines-editor, ap-submit-review-dialog, ui-expenses-approval-policy-fields.
Usage
import { ExpensePolicyFields } from "@/components/dolfin/expenses/expense-policy-fields";
// Place it anywhere inside your <DolfinProvider>.
<ExpensePolicyFields draft={draft} onChange={handleChange} referenceData={referenceData} />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
| Prop | Type | Description |
|---|---|---|
draft required | ExpensePolicyDraft | |
onChange required | (next: ExpensePolicyDraft) => void | |
referenceData required | ExpensePolicyReferenceData | Category, merchant, card and member names, from `useExpensePolicyReferenceData`. |
members | readonly { id: string; label: string; }[] | Your members for the people and approver pickers (`id` and the name to show). Given, they are not fetched. |
currencies | readonly { id?: string; code: string; name: string; symbol: string; decimalPlaces?: number | string; }[] | Your currencies for the currency picker. Given, the list is not fetched. |
disabled | boolean | |
hideActive | boolean | Hide the active switch, e.g. when confirming a document (confirmed policies start active). |
hideCards | boolean | Hide the card and people pickers, e.g. for document proposals, which never name cards or people. |
className | string |
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.
useExpensePolicyFormatuseMessagesFiles
Written to your app by the install command:
components/dolfin/expenses/expense-policy-fields.tsx211 lines