@get-asset/react

Receipts Config

Drop-in styled receipt-request setting for one business: the threshold row and a Save that commits it. The row is the same styled AssetReceiptsThreshold body used everywhere else, so it looks and behaves identically standalone, here, or inside the tenant-wide AssetGlobalReceiptsConfig. The business's own rule is read and written for you; a business that has never had one requests no receipts, so the row reads off at 0 until something is saved.

Preview

Loading preview…

API reference

Root props

PropTypeDefaultDescription
titlerequiredstringThe row's label, e.g. "Auto-request Receipts".
subtitlerequiredstringThe muted line under the label explaining what the threshold does.
currencystringISO-4217 code the threshold is denominated in. Resolved from the business's own country when omitted.
settingReceiptsConfigSettingOverride the fetched rule, skipping the request: { amount, enabled }. For tests, stories, or a host that already holds the setting.
state"loading" | "error" | "not-configured"Force a state, skipping the request — tests/stories.
saveErrorErrorForce the save-error message — tests/stories.
onSave(setting: ReceiptsConfigSetting) => void | Promise<void>Own the write: called with the edited rule instead of the built-in PATCH. Return a promise and the card stays in its saving state until it settles.
onSaveSuccess(setting: ReceiptsConfigSetting) => voidCalled after a save succeeds, with the rule as saved.
onSaveError(error: Error) => voidCalled when a save fails, with the same error the card shows beside Save.
savingbooleanForce the saving state — tests/stories. Otherwise it follows the write.
disabledbooleanMake the whole card inert (e.g. the viewer can't change the setting).
editablebooleanWhether 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”.
saveLabelstringOverride the copy on the save button. Defaults to "Save".
classNamestringForwarded to the card.

States

DefaultThe business's own rule. Save wakes up once something differs.

Loading preview…

Never setNo config row for this business, so no receipts are requested: the row reads off at 0. The first change is what creates a rule of its own.

Loading preview…

LoadingReading the business's rule.

Loading preview…

ErrorThe read failed: Try Again refetches.

Loading preview…

Save failedThe write was rejected: the row and the edit survive, and a quiet line beside Save says so.

Loading preview…

Behavior notes

  • The row edits a draft, not the server: a commit (blur, Enter, a switch flip) moves the draft, and only Save writes — both fields at once, so the control the user didn't touch can't fall to a default.
  • A business that has never had a rule saved requests no receipts, so the row reads off at 0 — the rule in force, not a placeholder. Save behaves the same either way, waiting for a change, and the first one writes the rule. ReceiptsConfig.NotConfigured is there if you want to mark that it was never set.
  • A failed write keeps the draft and says so beside Save; a failed read replaces the row instead. Different problem, different surface.
  • Below ~420px of row width the row changes shape — switch beside the title, subtitle and field full width underneath — exactly as it does standalone.