The approval flow
An approval flow moves a record from draft to submitted to approved or rejected, and the same rule is asked twice: by the screen, to show the decision card, and by the api, before it saves. In Meadowstack the decision is an `ApprovalPanel` card at the top of the side column, nobody approves their own record, a rejection always has a written reason and every move writes a history entry.
By Bohuslav PoláčekChecked
const decision =
request.status === "submitted" ? (
<ApprovalPanel
canDecide={can("request.approve", request)}
decidedBy={
mine ? "You can't approve your own request. An approver or admin decides." : "An approver or admin decides."
}
onApprove={() => move("approve")}
onReject={(reason) => move("reject", reason)}
copy={approvalCopy}
>
<p className="text-xl font-semibold text-fg tabular">{formatMoney(request.amount)}</p>
<p className="text-xs text-fg-muted">
incl. VAT, needed by <span className="tabular">{formatDate(request.neededBy)}</span>
</p>
</ApprovalPanel>The flow, step by step
The starter's purchase requests, with its three sample people: Leah Morgan (member), Marcus Webb (approver) and Hannah Brooks (admin).
- Draft. Leah writes a request. A draft is private to her and the admins: to anyone else the api answers "not found", the way row-level security hides a row.
- Submit. She presses "Submit for approval". The status turns to "Waiting for approval", the history gains "Submitted for approval" with her name, and the toast offers Undo. While it waits she may withdraw it to a draft. She never sees an Approve button on it.
- Decide. Marcus opens the request beside the list. The decision card sits at the top of the side column (first on a phone) with the amount it decides on. Approve asks once more, so a stray click decides nothing. Reject opens a dialog that does not send without a reason.
- The answer. Status, card and history change at once, before the server answers, through the same
applyMove()andmoveEvent()the api runs. If the api refuses, a toast says why and the screen swaps back to what is stored. The toast's Undo reopens the request, and only the person who decided may do that. - Rejected, then fixed. Leah reads "Rejected by Marcus Webb" with his reason, edits the request and submits it again. The history keeps both rounds.
- Many at once. In the list, the selection bar approves only the rows this person may approve and says how many: "Approve 2 of 5". The api moves all of them or none.
The rules and where each one is enforced
| Rule | Where it is enforced |
|---|---|
| Nobody approves their own record, an admin included | one line in domain/permissions.ts (request.status === "submitted" && !mine), asked by the card through can() and by the api before it saves; unit test "keeps four eyes", e2e "nobody approves their own request, an approver included" |
| A rejection has a written reason | the card's reject dialog does not send an empty one, and the api refuses it too ("Write why the request is rejected."); api test "asks for a reason before a rejection, and keeps it in the history" |
| Approving asks once | ApprovalPanel confirms before it calls onApprove |
| People who cannot decide read who does | with canDecide false the card shows the decidedBy sentence in place of the buttons, never a disabled button |
| Every move writes a history entry | moveEvent() in domain/workflow.ts, written by the api with the move; in the Supabase example a trigger writes it in the same transaction |
| Only the decider undoes a decision | request.reopen in domain/permissions.ts (decidedById === person.id); unit test "lets only the decider undo a decision" |
| A bulk approve says how many rows it applies to | the selection bar counts the rows can("request.approve", row) allows; api test "moves all or nothing" |
| The detail offers approve and reject | contract.ts declares approval: true, and e2e/contract.spec.ts looks for both actions |
The kit-approval skill builds this flow for a new entity with every rule above, and docs/recipes/approval.md is the checklist it works through.
What AI coding tools build instead
- An Approve button anyone can press. The page hides it from members, the endpoint accepts it from anyone who sends the request. Here the page and the api ask the same
canFor(), and the api tests run against the simulated adapter and the HTTP one alike. - Four eyes written in a component.
if (request.requesterId !== user.id)holds until the bulk bar, the bell or a second screen offers the same action and forgets it. The rule is one line indomain/permissions.ts. - A disabled Approve button with no reason. The author stares at grey. The card says who decides instead.
- Reject without a reason, or a reason field the api never checks. The person who has to fix the request learns nothing, and neither does the history.
- A coloured banner across the page for a routine step, so every waiting request looks like an alarm. The decision is a white card with the half-filled status glyph.
- A status change without a history entry, from an update that only sets
status. Nobody can tell who approved what, or when. - Only one person may decide. With four eyes, that person's own requests then wait for ever. Give the deciding role to two people.
Where to see it
- Order record: Reject and Approve on a card at the top of the side column.
- Proof approval: a customer approves or returns a print proof, and the reason is a comment pinned on the artwork (
onRejectInPlace). - Time-off approval: a leave request decided by someone other than the person taking the leave.
- Quote form: a quote approved by someone other than its author.
- The kit's ApprovalPanel, the audit trail every move writes and the permissions the card asks.
Example apps with a decision card
| Example app | Modules that render it |
|---|---|
| An app for a packaging and print company | Jobs, Print file editor, Quotes |
| An app for a studio or agency | Capacity |
| An app for a sports club | Coaching |
| An app for a construction company | Crews, Drawings |
| An app for an accounting office | Invoicing |
| An app for restaurants and venues | Shifts, People |
Five moves in one table
export type Move = "submit" | "withdraw" | "approve" | "reject" | "reopen";
const moves: Record<Move, { to: RequestStatus; event: RequestEventType; action: Action }> = {
submit: { to: "submitted", event: "submitted", action: "request.submit" },
withdraw: { to: "draft", event: "withdrawn", action: "request.withdraw" },
approve: { to: "approved", event: "approved", action: "request.approve" },
reject: { to: "rejected", event: "rejected", action: "request.reject" },
reopen: { to: "submitted", event: "reopened", action: "request.reopen" },
};Questions
Can an admin approve their own request?
No. Four eyes holds for every role: approving and rejecting need a submitted request that someone else wrote. An app where only one person decides gives the deciding role to a second person, or that person's own requests wait for ever.
Why does a rejection need a reason when an approval does not?
A rejection sends work back to someone who has to fix it, and the reason is the only thing that says what to fix. It stays in the history with the decision. An approval moves the record on, so one confirmation against a stray click is enough.
What does the author see while the request waits?
The status Waiting for approval, a sentence that says who decides, and the choice to withdraw the request to a draft. There is no Approve button for them to wonder about.
How is an approval made by mistake undone?
Undo in the toast after the decision reopens the request and writes Decision undone in the history. The permission behind it, request.reopen, lets only the person who decided do it.
Where does the rule live once the app has a real database?
In the database as well as in the screens. The starter's Supabase example writes the same rules as row-level security policies and a function that moves several requests all or nothing, and the screens keep asking the rules in domain/permissions.ts, so nothing on them changes.
Related
- A time-off request waiting for a decisionScreens
- A driver record that says what expires nextScreens
- A lot record that traces one step back and one step forwardScreens
- A month close that knows what each step waits forScreens
- A site diary day, prefilled and signed by the right personScreens
- An order record with its decisionScreens
Two ways
Build it yourself, or have it built
Build it yourself
Build your app on the framework
Get the codebase these apps stand on and build yours with Claude Code, Cursor or Codex.
One payment, lifetime updates
Get the frameworkHave it built
Have us build your app
Tell us how your team works. We plan the app with you and build it on the same framework at a fixed price.
After launch, Care keeps it improving, from €99 a month.
from €1,990
Describe your app