Supplier credit notes table
Supplier credit notes with supplier, number and reason, amount, available credit, status and created date. Status tabs, a supplier filter with that supplier's available credit, cursor pagination, rows that link to the note and an Issue row action on drafts. Takes columns, rowActions and initial filters.
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/ap-supplier-credit-notes-tableAlso installs: select, tabs, ap-supplier-credit-parts, base-data-table, base-states, base-money, ui-ap-supplier-credit-notes-table.
Usage
import { SupplierCreditNotesTable } from "@/components/dolfin/ap/supplier-credit-notes-table";
// Place it anywhere inside your <DolfinProvider>.
<SupplierCreditNotesTable />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 |
|---|---|---|
filters | SupplierCreditNoteFilters | Initial filters when the table fetches: a status, a supplier, a currency. A changed `supplierId` re-applies. |
pageSize | number | |
onSupplierFilterChange | (supplierId: string | null) => void | |
hideToolbar | boolean | Hide the status tabs and supplier filter (shown only when the table fetches). |
hideSupplierFilter | boolean | |
hideBalances | boolean | Hide the "Available from" balance shown while one supplier is filtered. |
toolbarActions | string | number | bigint | boolean | React.ReactElement<unknown, string | React.JSXElementConstructor<any>> | Iterable<ReactNode> | React.Re… | Extra controls at the end of the toolbar. |
creditNotes | readonly { id?: string; organisationId?: string; supplierId?: string; documentNumber?: null | string; amount?: number | string; netAmount?: … | The rows to show. Passing them (or `loading` / `error`) fetches nothing; rows still link to the note. |
loading | boolean | |
error | Error | |
onRetry | () => void | |
page | number | 1-based page shown; the pager shows with `onPageChange`. |
hasNextPage | boolean | |
onPageChange | (page: number) => void | |
supplierNames | Readonly<Record<string, string>> | Supplier names by id, for the supplier column (e.g. `useSupplierCreditNotes().supplierNamesRecord`). |
balances | readonly { currency: string; available?: number | string; }[] | Credit available from the supplier in view, shown above the table. |
status | "Draft" | "Issued" | "PartiallyApplied" | "Applied" | The status or supplier the rows are filtered by, for the empty state's words. |
supplierId | string | |
filtered | boolean | A search hides every row, so the empty state says nothing matches. |
onIssue | (note: SupplierCreditNote) => void | Shows Issue on drafts. Wired for you when the table fetches. |
pendingId | string | The row an action is running on. |
columns | SupplierCreditNoteColumnsProp | |
columnOrder | readonly string[] | |
columnVisibility | Readonly<Record<string, boolean>> | |
rowActions | SupplierCreditNoteRowActionsProp | Replace or extend the row menu (Issue when `onIssue` is given). Pass `[]` for none. |
onRowClick | (note: SupplierCreditNote) => void | |
getRowRoute | (note: SupplierCreditNote) => DolfinRoute | null | Where a row links to when there is no `onRowClick`; the credit note by default (`null` for a plain row). |
emptyState | string | number | bigint | boolean | React.ReactElement<unknown, string | React.JSXElementConstructor<any>> | Iterable<ReactNode> | React.Re… | |
emptyAction | string | number | bigint | boolean | React.ReactElement<unknown, string | React.JSXElementConstructor<any>> | Iterable<ReactNode> | React.Re… | Shown in the default empty state when nothing is filtered (e.g. a "New credit note" button). |
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). |
onRowHover | (row: { id?: string; organisationId?: string; supplierId?: string; documentNumber?: null | string; amount?: number | string; netAmount?: num… | 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
ap.supplierCreditNotes
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.
useDolfinLocaleuseMessagesuseSupplierCreditNoteMutationsuseSupplierCreditNotesFiles
Written to your app by the install command:
components/dolfin/ap/supplier-credit-notes-table.tsx353 linescomponents/dolfin/ap/supplier-credit-notes-toolbar.tsx59 lines