Category mapping tables
Merchant category (MCC) mapping tables. Needs mapping: the categories spend is waiting on, with transactions, the amount waiting and its share, and an account picker outlined as needing attention. All categories: each category with where its account comes from (yours, platform default, Dolfin default, unmapped, explained by a hint), whether its VAT is reclaimable and an account picker. Saving re-codes waiting spend. Loading, empty, no-match and error states; takes columns and row actions. Pass rows (with loading, error, accounts and onAccountChange) to render your own data 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-mcc-mappings-tableAlso installs: expenses-category-account-picker, base-data-table, base-info-hint, base-money, base-states, base-status-badge, base-theme, ui-expenses-mcc-mappings-table.
Usage
import { MccMappingsTable } from "@/components/dolfin/expenses/mcc-mappings-table";
// Place it anywhere inside your <DolfinProvider>.
<MccMappingsTable />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 |
|---|---|---|
mappings | readonly { mcc: string; label: string; source: string; ledgerAccountId?: null | string; ledgerAccountName?: null | string; ledgerAccountCode… | Every category with its account. |
columns | MccMappingColumnsProp | |
rowActions | MccMappingRowActionsProp | None by default. |
search | string | Narrows the list by category, code or account (by id), and names the no-match empty state. |
loading | boolean | With the data prop (`categories` or `mappings`), `loading` or `error`: the table renders what you pass and fetches nothing. |
error | Error | |
onRetry | () => void | |
columnOrder | readonly string[] | |
columnVisibility | Readonly<Record<string, boolean>> | |
emptyState | string | number | bigint | boolean | React.ReactElement<unknown, string | React.JSXElementConstructor<any>> | Iterable<ReactNode> | React.Re… | Replaces the default empty state. |
className | string | |
variant | DataTableVariant | |
classNames | DataTableClassNames | |
pager | boolean | Show the built-in previous / next pager when there is more than one page. Default true; pass false when you draw your own pager from the list's pagination (the table still dims while a page loads). |
accounts | readonly MccLedgerAccount[] | The accounts to offer; the organisation's spend accounts when omitted. |
onAccountChange | (mcc: string, ledgerAccountId: string) => void | Maps a category to an account. Without it the account column is read-only. |
pendingId | string | The category (MCC code) a save is running for: its picker waits. |
onCreateAccount | (mcc: string) => void | Open your own "Create an account" dialog for a category; the picker's own dialog by default. |
onRowHover | (row: { mcc: string; label: string; source: string; ledgerAccountId?: null | string; ledgerAccountName?: null | string; ledgerAccountCode?: … | Called with the row the pointer moves onto, and with `null` when the pointer leaves the rows (e.g. to highlight the row's point in a chart next to the table). Moving between rows reports the new row without a `null` first. |
Customisation
Without editing the source, you can change:
- Class names
classNameclassNames.frameclassNames.headerclassNames.headerCellclassNames.rowclassNames.cellclassNames.pager- Messages
expenses.merchants
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.
useMccMappingMutationsuseMccMappingsuseMessagesFiles
Written to your app by the install command:
components/dolfin/expenses/mcc-mappings-table.tsx261 linescomponents/dolfin/expenses/mcc-mapping-columns.tsx272 lines