dolfindevelopers

Create supplier dialog

DialogPayablesSDK + UI

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

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/ap-create-supplier-dialog

Also installs: button, dialog, base-theme, ap-supplier-form, ui-ap-create-supplier-dialog.

Usage

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

PropTypeDescription
open requiredboolean
onOpenChange required(open: boolean) => void
onCreated(supplier: Supplier) => voidAfter 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.
submittingbooleanYour save is running.
errorErrorWhy your save failed, shown above the button.
initialValuesSupplierFormPrefillPrefill (e.g. the supplier details read off a bill). Applied each time the dialog opens.
titlestring | number | bigint | boolean | React.ReactElement<unknown, string | React.JSXElementConstructor<any>> | Iterable<ReactNode> | React.Re…
descriptionstring | number | bigint | boolean | React.ReactElement<unknown, string | React.JSXElementConstructor<any>> | Iterable<ReactNode> | React.Re…
hideAddressboolean
hideBankDetailsboolean
countriesreadonly CodeOption[]Your countries and currencies for the pickers. Given, those lists are not fetched.
currenciesreadonly { id?: string; code: string; name: string; symbol: string; decimalPlaces?: number | string; }[]
bankProfilesReadonly<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.
classNamestring

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.

useMessagesuseSupplierMutations

Files

Written to your app by the install command:

  • components/dolfin/ap/create-supplier-dialog.tsx 165 lines