Skip to content

Commerce

Refund modal

The refund sheet for a transaction, rendered as a dialog on desktop and a bottom drawer on mobile, covering amount, reason, and which items lose access.
Available
Ports as-is

Examples

Rendered live from the maintained Storybook story. Lantern stores only the story id and embeds Storybook rather than duplicating the component or its demo.

Refund modal

Rendered live from Storybook

Storybook must be running for this to load — bun run start:storybook from the monorepo root, or set NEXT_PUBLIC_STORYBOOK_URL to a deployed instance.

Props

The component's public API, read from its TypeScript source. Descriptions come from TSDoc on the prop, so this table cannot drift from the component.

PropTypeDefaultDescription
open*boolean—Undocumented — add TSDoc to the prop in the library.
onOpenChange*(open: boolean) => void—Undocumented — add TSDoc to the prop in the library.
transactionNumber*string—Shown in the title as `Refund #{transactionNumber}`.
items*TransactionItem[]—Undocumented — add TSDoc to the prop in the library.
refundedByItemIndexRecord<number, number>—How much has already been refunded per item, keyed by index into `items`. An item whose whole total is here renders as fully refunded — greyed, with a tick instead of a checkbox, and excluded from the selection. Replaces the app's `useRefunds(transactionId)` subscription to the in-memory refund store, and with it the `transactionId` prop, which existed only to key that lookup.
onConfirm*(payload: RefundPayload) => void—Undocumented — add TSDoc to the prop in the library.
initialSelectedIndicesnumber[]—Overrides the initial item selection. Defaults to every refundable item.
initialAmountstring—Overrides the initial amount string. Defaults to the selected total.
initialReasonRefundReason"requested_by_customer"Preselects a reason. `"other"` reveals the internal-notes textarea.
initialNotesstring""Undocumented — add TSDoc to the prop in the library.
isMobileboolean—Overrides the measured viewport. `undefined` uses the live viewport; pass `true`/`false` to force the drawer or the dialog branch.

Reference

Transcribed from the component audit. If this disagrees with the source, the source is right.

Source
src/components/transactions/RefundModal.tsx
Portability
Copies across unchanged — only the utils import path moves.
Notes
Use when an operator needs to refund all or part of an order; the amount field tracks the selected items' total until manually edited, then splits the entered amount proportionally across selected items on submit, folding rounding drift into the last line. Fully refunded items are greyed out and excluded from selection, and only online-access items are flagged for access revocation.