@get-asset/react
Global Receipts Config
Drop-in styled receipt-request setting: the rule's title and copy, one threshold row per country, and a Save that commits the lot. Each row is the same styled AssetReceiptsThreshold body, so a row looks and behaves identically whether it stands alone or sits in this list. The tenant's configs are read and written for you: GET /v0/tenant/rules/receipts fills the rows, and Save PATCHes the whole set back and reseeds the rows from the response, which puts the button to sleep again. onSaveSuccess / onSaveError tell you how it went — for a toast — and onSave takes the request over entirely.
Built on the headless GlobalReceiptsConfig compound from @get-asset/sdk.
Preview
Loading preview…
API reference
Root props
| Prop | Type | Default | Description |
|---|---|---|---|
titlerequired | string | — | The card's label, e.g. "Auto-request Receipts". Renders as a heading in sentence case. |
subtitlerequired | string | — | The muted line explaining what the rule does. |
note | string | — | A second muted line for who the setting applies to, e.g. "This is the default for your businesses." Optional — nothing renders without it. |
thresholds | GlobalReceiptsConfigThreshold[] | — | Override the fetched configs, skipping the request entirely — for tests, stories, or a host that already holds the setting. One row per entry: { id, title, subtitle, currency, amount, enabled }. |
state | "loading" | "error" | "empty" | — | Force a state, skipping the request — tests/stories. |
saveError | Error | — | Force the save-error message — tests/stories. A real one only appears after a failed write, which needs an edit and a press to reach. |
emptyMessage | string | — | Override the copy shown when no country has a threshold configured. Defaults to “No receipt thresholds set yet. Configured countries will appear here.” |
onSave | (thresholds: GlobalReceiptsConfigThreshold[]) => void | Promise<void> | — | Own the write: called with the whole edited set instead of the built-in PATCH. Return a promise and the card stays in its saving state until it settles, and shows the save-error message if it rejects. |
onSaveSuccess | (thresholds: GlobalReceiptsConfigThreshold[]) => void | — | Called after a save succeeds, with the rows as saved — the server-confirmed set when the card wrote, the submitted set when onSave did. |
onSaveError | (error: Error) => void | — | Called when a save fails, with the same error the card shows beside Save. Use it for a toast, or leave the inline message to do the talking. |
saving | boolean | — | Force the saving state — tests/stories. Otherwise it follows the write in flight: the rows go inert and Save stops responding. |
disabled | boolean | — | Make the whole card inert (e.g. the viewer can't change the setting). |
editable | boolean | — | Whether the setting can be changed here. Defaults to true; pass false and the controls go inert and Save isn't rendered at all. Different from disabled, which keeps the button on screen but unpressable — that says “not now”, this says “not here”. |
saveLabel | string | — | Override the copy on the save button. Defaults to "Save". |
className | string | — | Forwarded to the card. |
States
Loading preview…
Loading preview…
Loading preview…
Loading preview…
Loading preview…
Loading preview…
Loading preview…
Loading preview…
Behavior notes
- One row per country in the payload. The response carries the setting only (
is_enabled,threshold_amount), so each row's label, explanation and currency come from the SDK's country map — Canada in CAD, the United States in USD. A country the tenant hasn't configured gets no row. - The rows edit a draft, not the server: a row commit (blur, Enter, a switch flip) moves the draft, and only Save writes — the whole set, in one PATCH. Save is inert while the configs load, while the read is failing, and until something actually differs.
- A failed write keeps the draft and says so in a quiet line beside Save — the same surface
AssetTransactionMatchuses for a failed action — so a retry costs no retyping. A failed read replaces the rows instead: different problem, different surface. - Save compares values rather than counting edits, so a threshold typed away from 30 and back to 30 leaves nothing to save and the button goes inert again.
- A row paints exactly like a standalone
AssetReceiptsThreshold— same recessed--asset-surfacerow, same--asset-cardfield. This card adds layout around the rows, not colour of its own, so retheming a token moves both the same way. - Below ~420px of row width each row changes shape: its switch comes up beside the title, with the subtitle and the threshold field full width underneath. The rows measure themselves, not the viewport, so the card reflows correctly in a narrow column on a wide page.