dolfindevelopers

Approval policy form

ComponentPayablesSDK + UI

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

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/ap-approval-policy-form

Also 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

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

PropTypeDescription
policyApprovalPolicyThe policy to edit; without one the form creates a policy.
defaultPrioritynumberPriority 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.
submittingbooleanYour save is running.
supplierOptionsreadonly { value: string; label: string; }[]Suppliers for the "Applies to" picker. Given, nothing is fetched.
approverOptionsreadonly { id: string; label: string; }[]Members for the approvers picker. Given, nothing is fetched.
currenciesreadonly { 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() => voidShows a Cancel button.
childrenstring | 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.
classNamestring

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.

useApprovalPolicyFormatuseApprovalPolicyMutationsuseMessages

Files

Written to your app by the install command:

  • components/dolfin/ap/approval-policy-form.tsx 190 lines