Create supplier dialog
Add a supplier by hand in a dialog, optionally prefilled (e.g. from a bill). Checks the fields before saving, shows the API's field errors beside their fields, and refreshes supplier lists, pickers and bills afterwards.
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-create-supplier-dialogAlso installs: button, dialog, base-theme, ap-supplier-form, ui-ap-create-supplier-dialog.
Usage
import { ApCreateSupplierDialog } from "@/components/dolfin/ap/create-supplier-dialog";
// Place it anywhere inside your <DolfinProvider>.
<ApCreateSupplierDialog 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 | (supplier: Supplier) => void | After the supplier was created; the dialog has closed. |
onSubmit | (values: SupplierFormValue) => void | Promise<unknown> | Saves the supplier yourself: called with the validated form instead of creating it through the API. Resolve to close the dialog; reject (or set `error`) to keep it open. |
submitting | boolean | Your save is running. |
error | Error | Why your save failed, shown above the button. |
initialValues | SupplierFormPrefill | Prefill (e.g. the supplier details read off a bill). Applied each time the dialog opens. |
title | string | number | bigint | boolean | React.ReactElement<unknown, string | React.JSXElementConstructor<any>> | Iterable<ReactNode> | React.Re… | |
description | string | number | bigint | boolean | React.ReactElement<unknown, string | React.JSXElementConstructor<any>> | Iterable<ReactNode> | React.Re… | |
hideAddress | boolean | |
hideBankDetails | boolean | |
countries | readonly CodeOption[] | Your countries and currencies for the pickers. Given, those lists are not fetched. |
currencies | readonly { id?: string; code: string; name: string; symbol: string; decimalPlaces?: number | string; }[] | |
bankProfiles | Readonly<Record<string, { countryCode: string; countryName: string; defaultCurrencies: string[]; accountHolderName: components["schemas"]["B… | Your bank profiles by country code. Given, or with your `countries`, no bank profile is fetched. |
className | string |
Customisation
Without editing the source, you can change:
- Class names
className- Messages
ap.supplierscore.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.
useMessagesuseSupplierMutationsFiles
Written to your app by the install command:
components/dolfin/ap/create-supplier-dialog.tsx165 lines