Purchase order form dialog
Raise or edit a purchase order in a dialog: PO number, supplier, currency, dates, external reference and lines (description, SKU, quantity, unit, unit price) with each line's net and the total. Checks the fields before saving, offers to replace the lines of an order whose PO number is taken, and refreshes order lists, bill matches and the overview afterwards. A new order can be seeded with initial values (currency, supplier, lines). Also ships NewPurchaseOrderButton and EditPurchaseOrderButton.
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/ap-purchase-order-form-dialogAlso installs: button, dialog, input, base-theme, base-money, ap-purchase-order-form-parts, ui-ap-purchase-order-form-dialog.
Usage
import { PurchaseOrderFormDialog } from "@/components/dolfin/ap/purchase-order-form-dialog";
// Place it anywhere inside your <DolfinProvider>.
<PurchaseOrderFormDialog 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 | |
purchaseOrder | { id?: string; organisationId?: string; supplierId?: null | string; externalRef?: null | string; poNumber: string; currency: string; status?… | The order to edit; omit (or pass null) to raise a new one. |
initialValues | PurchaseOrderFormInitialValues | Seeds a new order, e.g. `{ currency: "EUR" }` or a supplier; ignored when editing. Read when the dialog opens. Without a currency here, a new order starts in the provider's `defaultCurrency`, else GBP. |
onSaved | (purchaseOrder: PurchaseOrder) => void | After a save; the dialog has closed. |
onSubmit | (value: PurchaseOrderFormValue) => void | Promise<unknown> | Saves the order yourself: called with the validated form instead of saving through the API. Resolve to close the dialog; reject (or set `error`) to keep it open. |
submitting | boolean | Your save is running. |
error | Error | Why your save failed. |
supplierOptions | readonly { id: string; name: string; }[] | Suppliers to pick from (with `onSubmit`). Given, the picker fetches nothing. |
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
ap.orderscore.errors
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.
useDolfinDefaultCurrencyuseMessagesusePurchaseOrderMutationsFiles
Written to your app by the install command:
components/dolfin/ap/purchase-order-form-dialog.tsx334 linescomponents/dolfin/ap/purchase-order-form-saver.tsx69 lines