dolfindevelopers

Expense approval policy form dialog

DialogExpensesSDK + UI

Creates or edits an expense approval policy: the policy fields with Save, validated as the API validates, in a dialog titled with the version being edited (every save is a new version). Also ships ExpensePolicyForm for use on a page. Driven by useExpensePolicyMutations.

Dialog: a modal you open from your own screen. You control when it opens with its props. 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-form-dialog

Also installs: button, dialog, expenses-approval-policy-fields, ui-expenses-approval-policy-form-dialog.

Usage

screen.tsx
import { ExpensePolicyFormDialog } from "@/components/dolfin/expenses/expense-policy-form-dialog";

// Place it anywhere inside your <DolfinProvider>.
<ExpensePolicyFormDialog open={open} onOpenChange={handleOpenChange} />

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
open requiredboolean
onOpenChange required(open: boolean) => void
policy{ id: string; name: string; version: number | string; priorityOrder: number | string; active: boolean; amountGte?: null | number | string; a…The policy to edit; without one the dialog creates a policy.
defaultPrioritynumberPriority for a new policy; defaults to after the last existing one.
referenceDataExpensePolicyReferenceData
onSaved(policy: ExpensePolicy) => void
classNamestring
onSubmit(request: ExpensePolicyRequest, draft: ExpensePolicyDraft) => voidSave it yourself: called with the request once the draft passes the API's checks. Nothing is sent then.
submittingboolean
currenciesreadonly { id?: string; code: string; name: string; symbol: string; decimalPlaces?: number | string; }[]Your currencies for the currency picker. Given, the list is not fetched.
onChange(draft: ExpensePolicyDraft) => void
valuesExpensePolicyDraftControlled draft; the form keeps its own when omitted.
errorErrorWhy the last save failed: shown in words under the form.
membersreadonly { id: string; label: string; }[]Your members for the people and approver pickers. Given, they are not fetched.

Customisation

Without editing the source, you can change:

Class names
className
Messages
core.errorsexpenses.approvalPolicies

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

Hooks

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

useExpensePoliciesuseExpensePolicyFormatuseExpensePolicyMutationsuseExpensePolicyReferenceDatauseMessages

Files

Written to your app by the install command:

  • components/dolfin/expenses/expense-policy-form-dialog.tsx 276 lines