dolfindevelopers

Approval policy form dialog

DialogPayablesSDK + UI

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

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-dialog

Also installs: dialog, ap-approval-policy-form, ui-ap-approval-policy-form-dialog.

Usage

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

PropTypeDescription
open requiredboolean
onOpenChange required(open: boolean) => void
policyApprovalPolicyThe policy to edit; without one the dialog creates a policy.
defaultPrioritynumberPriority for a new policy; defaults to after the last existing one.
onSaved(policy: ApprovalPolicy) => void
classNamestring
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.

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.

useApprovalPoliciesuseMessages

Files

Written to your app by the install command:

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