Approval policy form dialog
The approval policy form in a dialog, titled for a new or an existing policy. A new policy starts after the last one in the evaluation order. Closes once saved.
Dialog: a modal you open from your own screen. You control when it opens with its props. 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/ap-approval-policy-form-dialogAlso installs: dialog, ap-approval-policy-form, ui-ap-approval-policy-form-dialog.
Usage
import { ApprovalPolicyFormDialog } from "@/components/dolfin/ap/approval-policy-form-dialog";
// Place it anywhere inside your <DolfinProvider>.
<ApprovalPolicyFormDialog 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
| Prop | Type | Description |
|---|---|---|
open required | boolean | |
onOpenChange required | (open: boolean) => void | |
policy | ApprovalPolicy | The policy to edit; without one the dialog creates a policy. |
defaultPriority | number | Priority for a new policy; defaults to after the last existing one. |
onSaved | (policy: ApprovalPolicy) => void | |
className | string | |
onSubmit | (request: ApprovalPolicyRequest, policyId: string | null) => void | Promise<unknown> | Saves the policy yourself: called with the validated request (and the policy id when editing) instead of saving through the API. Reject with an Error to show its message. |
submitting | boolean | Your save is running. |
supplierOptions | readonly { value: string; label: string; }[] | Suppliers for the "Applies to" picker. Given, nothing is fetched. |
approverOptions | readonly { id: string; label: string; }[] | Members for the approvers picker. Given, nothing is fetched. |
currencies | readonly { id?: string; code: string; name: string; symbol: string; decimalPlaces?: number | string; }[] | The currencies for the amount range. Given, nothing is fetched; left out, they are read once the picker opens. |
Customisation
Without editing the source, you can change:
- Class names
className- Messages
ap.approvalPolicies.form
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.
useApprovalPoliciesuseMessagesFiles
Written to your app by the install command:
components/dolfin/ap/approval-policy-form-dialog.tsx80 lines