Create tax rate dialog
Add a custom tax rate (code, name, 0 to 100%) in a dialog. Checks the fields before saving, shows the API's errors (such as a code already in use), and refreshes the tax rates list and every tax rate picker.
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-tax-rate-dialogAlso installs: button, dialog, base-theme, ar-tax-rate-form, ui-ar-create-tax-rate-dialog.
Usage
import { ArCreateTaxRateDialog } from "@/components/dolfin/ar/create-tax-rate-dialog";
// Place it anywhere inside your <DolfinProvider>.
<ArCreateTaxRateDialog 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 | (taxRate: TaxRate) => void | After the rate was created; the dialog has closed. |
initialValues | Partial<TaxRateFormValue> | Prefill. Applied each time the dialog opens. |
onSubmit | (body: CreateTaxRateRequest) => Promise<TaxRate | 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. |
children | string | number | bigint | boolean | React.ReactElement<unknown, string | React.JSXElementConstructor<any>> | Iterable<ReactNode> | React.Re… | Extra fields after the rate. |
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.taxRates
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.
useMessagesuseTaxRateMutationsFiles
Written to your app by the install command:
components/dolfin/ar/create-tax-rate-dialog.tsx122 lines