dolfindevelopers

Edit product dialog

DialogReceivablesSDK + UI

Edit a product's name, description, unit price, currency and type in a dialog. Carries over the fields the form does not show (the income ledger account), shows the API's field errors beside their fields, and refreshes the catalogue, the product page and open pickers.

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-edit-product-dialog

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

Usage

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

// Place it anywhere inside your <DolfinProvider>.
<ArEditProductDialog product={product} 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
product required{ id?: string; organisationId?: string; name: string; description?: null | string; unitPrice?: number | string; currency: string; type?: com…The product to edit; the form reloads when the dialog opens or another product is passed.
open requiredboolean
onOpenChange required(open: boolean) => void
onUpdated(product: Product) => voidAfter the product was saved; the dialog has closed.
transformRequest(body: UpdateProductRequest) => UpdateProductRequestAdjust the request before it is sent. The income ledger account is carried over unless this changes it.
onSubmit(body: UpdateProductRequest) => 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.
submitDisabledReasonstringWhy the product can't be saved (e.g. the role may not manage products); disables Save.
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 when accounting sync is on); 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.

useMessagesuseProductMutations

Files

Written to your app by the install command:

  • components/dolfin/ar/edit-product-dialog.tsx 133 lines