dolfindevelopers

Expense approval policies list

ComponentExpensesSDK + UI

Expense approval policies in priority order: priority, name with its version and the policy document clause it came from, conditions in words with the merchants, cards and people it applies to, the outcome with who approves, and an active switch. Edit and Delete row actions with a confirmation, and the fall-through rule under the table. Read-only without the manageExpensePolicies permission. Takes columns and rowActions. Pass policies (with loading, error and the callbacks you want) to render your own list without a request.

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/expenses-approval-policies-list

Also installs: alert-dialog, badge, button, popover, switch, base-data-table, base-info-hint, base-states, base-status-badge, ui-expenses-approval-policies-list.

Usage

screen.tsx
import { ExpensePoliciesList } from "@/components/dolfin/expenses/expense-policies-list";

// Place it anywhere inside your <DolfinProvider>.
<ExpensePoliciesList />

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
policiesreadonly { id: string; name: string; version: number | string; priorityOrder: number | string; active: boolean; amountGte?: null | number | …Your policies, in priority order: rendered as given and nothing is fetched. Read when omitted.
loadingboolean
errorError
onRetry() => void
onEdit(policy: ExpensePolicy) => voidOpens the policy form for a row; without it there is no Edit action.
onCreate() => voidShows "New policy" in the empty state.
onDelete(policy: ExpensePolicy) => voidDeletes a policy after the confirm dialog; without it there is no Delete action. Wired to the SDK by id.
onToggleActive(policy: ExpensePolicy, active: boolean) => voidTurns a policy on or off; without it the switch is read-only. Wired to the SDK by id.
pendingIdstringThe policy a change is running for.
referenceDataExpensePolicyReferenceDataNames for categories, merchants, cards and people; read here (or short ids with your data) when not passed.
columnsExpensePolicyColumnsProp
columnOrderreadonly string[]
columnVisibilityReadonly<Record<string, boolean>>
rowActionsExpensePolicyRowActionsPropPass `[]` for none.
emptyStatestring | number | bigint | boolean | React.ReactElement<unknown, string | React.JSXElementConstructor<any>> | Iterable<ReactNode> | React.Re…Replaces the empty state.
hideFallThroughbooleanHides the note under the table on what happens when no policy matches.
classNamestring

Customisation

Without editing the source, you can change:

Class names
className
Messages
expenses.approvalPolicies

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.

useExpensePoliciesuseExpensePolicyFormatuseExpensePolicyMutationsuseExpensePolicyReferenceDatauseMessagesusePermissions

Files

Written to your app by the install command:

  • components/dolfin/expenses/expense-policies-list.tsx 267 lines
  • components/dolfin/expenses/expense-policy-columns.tsx 251 lines