Create supplier credit note dialog
Records credit a supplier owes you as a draft: a searchable supplier picker (or a fixed supplier), gross amount, currency and an optional reason. Also ships SupplierCreditSupplierPicker.
Dialog: a modal you open from your own screen. You control when it opens with its props. 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-new-supplier-credit-note-dialogAlso installs: button, command, dialog, input, label, popover, select, base-states, ui-ap-new-supplier-credit-note-dialog.
Usage
import { NewSupplierCreditNoteDialog } from "@/components/dolfin/ap/new-supplier-credit-note-dialog";
// Place it anywhere inside your <DolfinProvider>.
<NewSupplierCreditNoteDialog open={open} onOpenChange={handleOpenChange} />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 |
|---|---|---|
open required | boolean | |
onOpenChange required | (open: boolean) => void | |
onCreated | (note: SupplierCreditNote) => void | Called with the new draft after the dialog closes. |
onSubmit | (draft: NewSupplierCreditNoteDraft) => void | Promise<unknown> | Records the draft yourself: called with the validated values instead of creating it through the API. Resolve to close the dialog; reject (or set `error`) to keep it open. |
submitting | boolean | |
error | Error | Why your save failed (a `DolfinError` reads as the API's message). |
suppliers | readonly SupplierChoice[] | Suppliers to pick from (with `onSubmit`). Given, the picker fetches nothing. |
fixedSupplierId | string | Pre-selects and locks the supplier (hides the picker). |
currencies | readonly string[] | Currencies to offer; GBP, USD and EUR by default. |
defaultCurrency | string | |
className | string |
Customisation
Without editing the source, you can change:
- Class names
className- Messages
ap.supplierCreditNotes.newDialogcore.errors
Or edit the installed file directly: it is your code. See theming for colours and fonts.
Hooks
The SDK hooks this dialog uses. Use them directly from @dolfinai/react to build your own version.
useMessagesuseSupplierCreditNoteMutationsuseSupplierCreditSupplierSearchFiles
Written to your app by the install command:
components/dolfin/ap/new-supplier-credit-note-dialog.tsx272 lines