Category account picker
Picks the account a merchant category, expense or card codes to, from the organisation's spend accounts (or accounts you pass), with Create an account as the last option: it opens the create dialog and picks the new account, or calls your own handler. Loading, busy and needs-attention looks.
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-category-account-pickerAlso installs: select, expenses-category-account-dialog, base-theme, ui-expenses-category-account-picker.
Usage
import { CategoryAccountPicker } from "@/components/dolfin/expenses/category-account-picker";
// Place it anywhere inside your <DolfinProvider>.
<CategoryAccountPicker onChange={handleChange} />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 |
|---|---|---|
onChange required | (ledgerAccountId: string) => void | |
value | string | The chosen account id. |
valueLabel | string | Shown when `value` is not among the accounts (e.g. an account since deactivated). |
accounts | readonly MccLedgerAccount[] | The accounts to offer; the organisation's spend accounts by default. |
label | string | Names what the picker is for, for screen readers ("Account for Restaurants"). |
blocking | boolean | Outlines the picker as the thing holding spend back (an unmapped category). |
disabled | boolean | |
submitting | boolean | A save for this choice is running. |
allowCreate | boolean | Offer "Create an account..." last. With `onCreate` the host opens its own dialog; otherwise the picker opens the create dialog itself and picks the new account. Pass `false` to hide it. Defaults to true. |
onCreate | () => void | |
createPurpose | CategoryAccountPurpose | What the new account is for, which sets the dialog's copy. Defaults to "expense". |
className | string |
Customisation
Without editing the source, you can change:
- Class names
className- Messages
expenses.merchants.account
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.
useMccAccountsuseMessagesFiles
Written to your app by the install command:
components/dolfin/expenses/category-account-picker.tsx98 lines