dolfindevelopers

Invoice preview

ComponentReceivablesSDK + UI

The invoice as the customer sees it: its PDF, the email a draft's send would deliver, and the pay page once issued, as tabs; tabs that do not apply yet stay disabled with the reason.

Component: A piece you place inside your own screens: a table, a form, a card or a dialog. You decide the layout around it. 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-invoice-pdf-preview

Also installs: tabs, base-document-viewer, base-info-hint, base-states, ui-ar-invoice-pdf-preview.

Usage

screen.tsx
import { InvoicePdfPreview } from "@/components/dolfin/ar/invoice-pdf-preview";

// Place it anywhere inside your <DolfinProvider>.
<InvoicePdfPreview />

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
invoiceIdstringLoads the invoice, its PDF and (for a draft, once its tab opens) the email a send would deliver.
invoice{ id?: string; organisationId?: string; customerId?: string; documentNumber?: null | string; currency: string; issueDate?: string; dueDate?:…Your own invoice: the preview then makes no request.
pdfUrlstringThe PDF to show (an object URL or a link).
loadingbooleanThe PDF is still being made.
errorError
onRetry() => void
email{ subject: string; previewText: string; greetingLine: string; openingBodyMarkdown: string; openingBodyHtml: string; htmlBody: string; textBo…Shows the Email tab with this email (a draft's send would deliver it).
emailLoadingboolean
emailErrorError
onEmailRetry() => void
emailDisabledReasonstringShows the Email tab disabled, with why beside it.
pdfOnlybooleanHides the email and pay page tabs, leaving the PDF alone.
classNamestring

Customisation

Without editing the source, you can change:

Class names
className
Messages
ar.invoice.previewbase.documentViewerbase.infoHint.moreAboutbase.states.retrycore.errors

Or edit the installed file directly: it is your code. See theming for colours and fonts.

Hooks

The SDK hooks this component uses. Use them directly from @dolfinai/react to build your own version.

useInvoiceuseInvoiceEmailPreviewuseInvoicePdfuseInvoiceSettingsuseMessages

Files

Written to your app by the install command:

  • components/dolfin/ar/invoice-pdf-preview.tsx 105 lines