Approval policy form
Creates or edits a bill approval policy: name, priority and active; conditions (an amount range in a currency, specific suppliers, supplier standing); the action as three described choices; up to five approvers for review policies; and the rule read back in plain words. Validated as the API validates before saving. Driven by useApprovalPolicyMutations.
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/ap-approval-policy-formAlso installs: button, field, input, select, switch, base-page, ap-bills-filters, ap-bill-lines-editor, ap-submit-review-dialog, ui-ap-approval-policy-form.
Usage
import { ApprovalPolicyForm } from "@/components/dolfin/ap/approval-policy-form";
// Place it anywhere inside your <DolfinProvider>.
<ApprovalPolicyForm />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 |
|---|---|---|
policy | ApprovalPolicy | The policy to edit; without one the form creates a policy. |
defaultPriority | number | Priority for a new policy, e.g. `useApprovalPolicies().nextPriority`. |
onSaved | (policy: ApprovalPolicy) => void | |
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. |
onCancel | () => void | Shows a Cancel button. |
children | string | number | bigint | boolean | React.ReactElement<unknown, string | React.JSXElementConstructor<any>> | Iterable<ReactNode> | React.Re… | Extra fields under the rule, e.g. your own policy metadata. |
className | string |
Customisation
Without editing the source, you can change:
- Class names
className- Messages
ap.approvalPoliciescore.errors
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.
useApprovalPolicyFormatuseApprovalPolicyMutationsuseMessagesFiles
Written to your app by the install command:
components/dolfin/ap/approval-policy-form.tsx190 lines