ApprovalQueue
The records of the ambient <List> as a queue, one card per record with an Approve and a Reject. The queue fetches nothing: it reads the ambient <List>, so filter that list on the pending status, and a decided row leaves once the update's refetch lands. Approve is <DualApprovalButton>, with required approvals of 1 by default. Reject opens a form that asks for a reason and, on Confirm reject, writes the rejected status, the reason and the signed-in user; it needs edit access on the resource and an identity. A record already in the rejected status shows Rejected in place of both buttons. The rules are in the UI only, so the server has to enforce who may approve or reject.
Installation
pnpm dlx shadcn@latest add @chelone/approval-queueThe records of the ambient <List> as a queue, one card per record with an Approve and a Reject. The queue fetches nothing: it reads the ambient <List>, so filter that list on the pending status, and a decided row leaves once the update's refetch lands. Approve is <DualApprovalButton>, with required approvals of 1 by default. Reject opens a form that asks for a reason and, on Confirm reject, writes the rejected status, the reason and the signed-in user; it needs edit access on the resource and an identity. A record already in the rejected status shows Rejected in place of both buttons. The rules are in the UI only, so the server has to enforce who may approve or reject.
Props
| Prop | Type | Default | Description |
|---|---|---|---|
| approvedValue | string | — | Status written once approvals reach `required`. Default `"approved"`. |
| approverSource | keyof TRecord & string | — | Record field holding the approver ids, a top-level key. Default `"approvers"`. |
| className | string | — | |
| mutationMode | MutationMode | — | Default `"pessimistic"`; `"undoable"` shows an Undo notification. |
| noteSource | string | — | Record field the reason is written to. Default `"rejectionNote"`. |
| pendingValue | string | — | Status written while approvals are short of `required`. Default `"pending"`. |
| rejectedBySource | string | — | Record field the rejecter's id is written to. Default `"rejectedBy"`. |
| rejectedValue | string | — | Status written on rejection. Default `"rejected"`. |
| required | number | — | Approvals needed. Default 1. |
| requireReason | boolean | — | Refuse a rejection until a reason is typed. Default `false`. |
| rowExtra | (record: TRecord) => ReactNode | — | Renders extra content in each row; the row's record is the ambient record. |
| statusSource | keyof TRecord & string | — | Record field the status is written to and read from. Default `"status"`. |
| subtitleSource | SourceProp<TRecord> | — | The field shown as a second line when its value is not empty. |
| titleSource | SourceProp<TRecord> | — | The field shown as the row title; the record representation when it is null or undefined. |