Receipt upload
A drop zone for receipts: drop PDFs or photos, or click to browse. Up to ten at once, uploaded one at a time with progress; files that are not PDFs or images are skipped and reported. Dolfin reads each receipt, then pairs it with its card transaction.
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
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/expenses-receipt-uploadAlso installs: progress, base-theme, ui-expenses-receipt-upload.
Usage
import { ReceiptUploadDropzone } from "@/components/dolfin/expenses/receipt-upload";
// Place it anywhere inside your <DolfinProvider>.
<ReceiptUploadDropzone />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 |
|---|---|---|
onUpload | (files: File[]) => void | Handle the dropped files yourself: nothing is uploaded by the zone then. Pair it with `uploading`, `progress` and `error`. |
uploading | boolean | |
progress | { done: number; total: number; } | Files done out of the batch, while `uploading`. |
error | Error | |
onUploaded | (batch: ReceiptUploadBatch) => void | After every batch that uploaded at least one receipt. |
notify | boolean | Report the result through the provider's `notify`. Defaults to true. |
inputRef | ((instance: HTMLInputElement | null) => void | (() => VoidOrUndefinedOnly) | React.DO_NOT_USE_OR_YOU_WILL_BE_FIRED_CALLBACK_REF_RETURN_VALUE… | The file input, so another control (an Upload button) can open the picker. |
children | string | number | bigint | boolean | React.ReactElement<unknown, string | React.JSXElementConstructor<any>> | Iterable<ReactNode> | React.Re… | Replaces the idle content ("Drop receipts here, or click to browse"). |
className | string |
Customisation
Without editing the source, you can change:
- Class names
className- Messages
core.errorsexpenses.receipts.upload
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.
useMessagesuseNotifyuseReceiptUploadFiles
Written to your app by the install command:
components/dolfin/expenses/receipt-upload.tsx95 lines