Expense approval policies list
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
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/expenses-approval-policies-listAlso installs: alert-dialog, badge, button, popover, switch, base-data-table, base-info-hint, base-states, base-status-badge, ui-expenses-approval-policies-list.
Usage
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
| Prop | Type | Description |
|---|---|---|
policies | readonly { 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. |
loading | boolean | |
error | Error | |
onRetry | () => void | |
onEdit | (policy: ExpensePolicy) => void | Opens the policy form for a row; without it there is no Edit action. |
onCreate | () => void | Shows "New policy" in the empty state. |
onDelete | (policy: ExpensePolicy) => void | Deletes a policy after the confirm dialog; without it there is no Delete action. Wired to the SDK by id. |
onToggleActive | (policy: ExpensePolicy, active: boolean) => void | Turns a policy on or off; without it the switch is read-only. Wired to the SDK by id. |
pendingId | string | The policy a change is running for. |
referenceData | ExpensePolicyReferenceData | Names for categories, merchants, cards and people; read here (or short ids with your data) when not passed. |
columns | ExpensePolicyColumnsProp | |
columnOrder | readonly string[] | |
columnVisibility | Readonly<Record<string, boolean>> | |
rowActions | ExpensePolicyRowActionsProp | Pass `[]` for none. |
emptyState | string | number | bigint | boolean | React.ReactElement<unknown, string | React.JSXElementConstructor<any>> | Iterable<ReactNode> | React.Re… | Replaces the empty state. |
hideFallThrough | boolean | Hides the note under the table on what happens when no policy matches. |
className | string |
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.
useExpensePoliciesuseExpensePolicyFormatuseExpensePolicyMutationsuseExpensePolicyReferenceDatauseMessagesusePermissionsFiles
Written to your app by the install command:
components/dolfin/expenses/expense-policies-list.tsx267 linescomponents/dolfin/expenses/expense-policy-columns.tsx251 lines