Bill edit form
A bill's header fields for review: a supplier picker (searched on the server, or your own `suppliers` list with no request) with the extraction's suggestion one click away, currency, invoice and PO numbers, payment terms, dates, the supplier's details as printed, amounts and payment details. Changed fields are marked and the API's field errors show in place. A controlled form (`values`, `onChange`, `errors`), driven by useBillDraft.
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-bill-edit-formAlso installs: button, calendar, card, command, field, input, popover, base-theme, ap-bill-lines-editor, ui-ap-bill-edit-form.
Usage
import { BillEditForm } from "@/components/dolfin/ap/bill-edit-form";
// Place it anywhere inside your <DolfinProvider>.
<BillEditForm values={values} 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 |
|---|---|---|
values required | BillDraft | The draft to edit, e.g. `useBillDraft(billId).draft`. A controlled form: every change goes to `onChange`. |
onChange required | (next: BillDraft) => void | |
errors | Partial<Record<BillDraftPath, string>> | Messages by field (`invoiceNumber`, `dueDate`, ...). |
dirtyFields | readonly string[] | Paths changed since the bill was read, ringed (`useBillDraft(billId).dirtyFields`). |
bill | { id?: string; organisationId?: string; state?: components["schemas"]["BillState"]; source?: components["schemas"]["BillSource"]; eInvoiceId… | The bill the draft came from: its supplier and the extraction's suggestion. |
suggestedSupplier | BillSupplierSuggestion | The extraction's suggested supplier, offered while another is picked. |
onCreateSupplier | () => void | Offers "New Supplier" in the supplier picker; open your create-supplier dialog from here. |
onSupplierClick | (supplierId: string) => void | Makes the suggested supplier's name a link (for example to the supplier page). |
suppliers | readonly BillSupplierOption[] | Your suppliers for the supplier picker. Given, the picker filters these as the reviewer types and the form makes no supplier request (an unknown supplier id shows as itself until you name it in this list). |
onSupplierSearch | (query: string) => void | With `suppliers`: the picker's search as typed, debounced 400ms, so you can load more. |
currencies | readonly { id?: string; code: string; name: string; symbol: string; decimalPlaces?: number | string; }[] | Your currencies for the currency picker. Given, the list is not fetched. |
hideSections | BillEditSection[] | Sections to leave out (for hosts that edit supplier or payment details elsewhere). |
children | string | number | bigint | boolean | React.ReactElement<unknown, string | React.JSXElementConstructor<any>> | Iterable<ReactNode> | React.Re… | Extra cards after the built-in ones. |
className | string | On the form's wrapper. |
classNames | BillEditFormClassNames |
Customisation
Without editing the source, you can change:
- Class names
classNameclassNames.cardclassNames.cardHeaderclassNames.cardTitleclassNames.cardContent- Messages
ap.billDraftbase.states.retry
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.
useBillSupplieruseBillSupplierOptionsuseDolfinLocaleuseMessagesFiles
Written to your app by the install command:
components/dolfin/ap/bill-edit-form.tsx180 linescomponents/dolfin/ap/bill-edit-fields.tsx165 lines