Edit product dialog
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
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/ar-edit-product-dialogAlso installs: button, dialog, base-theme, ar-product-form, ui-ar-edit-product-dialog.
Usage
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
| Prop | Type | Description |
|---|---|---|
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 required | boolean | |
onOpenChange required | (open: boolean) => void | |
onUpdated | (product: Product) => void | After the product was saved; the dialog has closed. |
transformRequest | (body: UpdateProductRequest) => UpdateProductRequest | Adjust the request before it is sent. The income ledger account is carried over unless this changes it. |
onSubmit | (body: UpdateProductRequest) => Promise<Product | void> | void | Saves it yourself instead of the SDK. The dialog closes once it resolves and shows the error in place if it rejects. |
submitting | boolean | Your own save is running. |
submitDisabledReason | string | Why the product can't be saved (e.g. the role may not manage products); disables Save. |
currencies | readonly { id?: string; code: string; name: string; symbol: string; decimalPlaces?: number | string; }[] | The currencies to offer, instead of loading them. |
fields | string | 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`. |
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… | |
className | string |
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.
useMessagesuseProductMutationsFiles
Written to your app by the install command:
components/dolfin/ar/edit-product-dialog.tsx133 lines