dolfindevelopers

Expense approval policy fields

ComponentExpensesSDK + UI

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

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-approval-policy-fields

Also installs: field, input, select, switch, base-page, ap-bills-filters, ap-bill-lines-editor, ap-submit-review-dialog, ui-expenses-approval-policy-fields.

Usage

screen.tsx
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

PropTypeDescription
draft requiredExpensePolicyDraft
onChange required(next: ExpensePolicyDraft) => void
referenceData requiredExpensePolicyReferenceDataCategory, merchant, card and member names, from `useExpensePolicyReferenceData`.
membersreadonly { id: string; label: string; }[]Your members for the people and approver pickers (`id` and the name to show). Given, they are not fetched.
currenciesreadonly { id?: string; code: string; name: string; symbol: string; decimalPlaces?: number | string; }[]Your currencies for the currency picker. Given, the list is not fetched.
disabledboolean
hideActivebooleanHide the active switch, e.g. when confirming a document (confirmed policies start active).
hideCardsbooleanHide the card and people pickers, e.g. for document proposals, which never name cards or people.
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.

useExpensePolicyFormatuseMessages

Files

Written to your app by the install command:

  • components/dolfin/expenses/expense-policy-fields.tsx 211 lines