dolfindevelopers

Create product dialog

DialogReceivablesSDK + UI

Add a product or service in a dialog, starting in the organisation's default currency (or a given one, optionally locked, e.g. an invoice's). Checks the fields before saving, shows the API's field errors beside their fields, and refreshes the catalogue and open product pickers 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/ar-create-product-dialog

Also installs: button, dialog, base-theme, ar-product-form, ui-ar-create-product-dialog.

Usage

screen.tsx
import { ArCreateProductDialog } from "@/components/dolfin/ar/create-product-dialog";

// Place it anywhere inside your <DolfinProvider>.
<ArCreateProductDialog 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(product: Product) => voidAfter the product was created; the dialog has closed.
defaultCurrencystringPre-selected currency (e.g. the invoice's); takes priority over the organisation's default.
lockCurrencybooleanKeep the currency fixed at `defaultCurrency` (a product made for an invoice must match it).
initialValuesPartial<ProductFormValue>Prefill (e.g. a name typed into a picker). Applied each time the dialog opens.
transformRequest(body: CreateProductRequest) => CreateProductRequestAdjust the request before it is sent, e.g. to add the values of your `fields`.
onSubmit(body: CreateProductRequest) => Promise<Product | void> | voidSaves it yourself instead of the SDK. The dialog closes once it resolves and shows the error in place if it rejects.
submittingbooleanYour own save is running.
currenciesreadonly { id?: string; code: string; name: string; symbol: string; decimalPlaces?: number | string; }[]The currencies to offer, instead of loading them.
fieldsstring | number | bigint | boolean | React.ReactElement<unknown, string | React.JSXElementConstructor<any>> | Iterable<ReactNode> | React.Re…Extra fields after the type (e.g. an income account); pair with `transformRequest`.
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…
classNamestring

Customisation

Without editing the source, you can change:

Class names
className
Messages
ar.products

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.

useMessagesuseProductCurrenciesuseProductMutations

Files

Written to your app by the install command:

  • components/dolfin/ar/create-product-dialog.tsx 160 lines