Create customer dialog
Add a customer in a dialog, optionally prefilled. Checks the fields before saving, shows the API's field errors beside their fields, and refreshes customer lists, pickers and invoices afterwards. A fields prop and a request hook let the host add its own settings.
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-create-customer-dialogAlso installs: button, dialog, base-theme, ar-customer-form, ui-ar-create-customer-dialog.
Usage
import { ArCreateCustomerDialog } from "@/components/dolfin/ar/create-customer-dialog";
// Place it anywhere inside your <DolfinProvider>.
<ArCreateCustomerDialog 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 | (customer: Customer) => void | After the customer was created; the dialog has closed. |
initialValues | Partial<CustomerFormValue> | Prefill (e.g. a name typed into a picker). Applied each time the dialog opens. |
transformRequest | (body: CreateCustomerRequest) => CreateCustomerRequest | Adjust the request before it is sent, e.g. to add the values of your `fields`. |
onSubmit | (body: CreateCustomerRequest) => Promise<Customer | void> | void | Saves the customer 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. |
countries | readonly CodeOption[] | The countries to offer (ISO code and name), instead of loading them. |
fields | string | number | bigint | boolean | React.ReactElement<unknown, string | React.JSXElementConstructor<any>> | Iterable<ReactNode> | React.Re… | Extra fields after the address (e.g. e-invoicing or WhatsApp settings); 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… | |
hideAddress | boolean | |
className | string |
Customisation
Without editing the source, you can change:
- Class names
className- Messages
ar.customers
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.
useCustomerMutationsuseMessagesFiles
Written to your app by the install command:
components/dolfin/ar/create-customer-dialog.tsx138 lines