dolfindevelopers

Category mapping tables

ComponentExpensesSDK + UI

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

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-mcc-mappings-table

Also 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

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

PropTypeDescription
mappingsreadonly { mcc: string; label: string; source: string; ledgerAccountId?: null | string; ledgerAccountName?: null | string; ledgerAccountCode…Every category with its account.
columnsMccMappingColumnsProp
rowActionsMccMappingRowActionsPropNone by default.
searchstringNarrows the list by category, code or account (by id), and names the no-match empty state.
loadingbooleanWith the data prop (`categories` or `mappings`), `loading` or `error`: the table renders what you pass and fetches nothing.
errorError
onRetry() => void
columnOrderreadonly string[]
columnVisibilityReadonly<Record<string, boolean>>
emptyStatestring | number | bigint | boolean | React.ReactElement<unknown, string | React.JSXElementConstructor<any>> | Iterable<ReactNode> | React.Re…Replaces the default empty state.
classNamestring
variantDataTableVariant
classNamesDataTableClassNames
pagerbooleanShow 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).
accountsreadonly MccLedgerAccount[]The accounts to offer; the organisation's spend accounts when omitted.
onAccountChange(mcc: string, ledgerAccountId: string) => voidMaps a category to an account. Without it the account column is read-only.
pendingIdstringThe category (MCC code) a save is running for: its picker waits.
onCreateAccount(mcc: string) => voidOpen 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.

useMccMappingMutationsuseMccMappingsuseMessages

Files

Written to your app by the install command:

  • components/dolfin/expenses/mcc-mappings-table.tsx 261 lines
  • components/dolfin/expenses/mcc-mapping-columns.tsx 272 lines