Skip to main content

Approvals inbox

A list of the requests that wait for a person, which updates while it is open.

PatternReadyView source
Works with
Reactshadcn/ui
Runs on sample data, with the neutral theme of shadcn/ui.

The approver's work queue inside your own product. Use it when approvers should not have to open the LumoAuth portal. Approve a request in the preview: it leaves the list.

Installation​

The command adds the file to your project, with the shadcn/ui components that it uses. Your project needs shadcn/ui.

pnpm dlx shadcn@latest add https://examples.lumoauth.dev/r/approvals-inbox.json

Usage​

Give the inbox the pending requests and two callbacks. It keeps the selection and the filter itself.

app/approvals/inbox.tsx
'use client';

import { ApprovalsInbox } from '@/components/approvals-inbox';
import { fromJitRequest } from '@/components/approval-request';

// `rows` are the rows of GET /jit/pending for the signed-in approver, from your API route.
export function Inbox({ rows, reload }: { rows: Array<Record<string, unknown>>; reload: () => Promise<void> }) {
const decide = (decision: 'approve' | 'deny') => async (id: string, note: string) => {
await fetch(`/api/approvals/${id}/${decision}`, { method: 'POST', body: JSON.stringify({ note }) });
await reload();
};

return <ApprovalsInbox requests={rows.map(fromJitRequest)} onApprove={decide('approve')} onDeny={decide('deny')} />;
}

Load the rows again after each decision. To show a new request at once, receive the jit.approval_required webhook in your backend and push it to the browser. Your API route makes the call to LumoAuth. Never call LumoAuth from the browser with a secret.

Where the data comes from​

What the pattern showsCall
The queueGET /jit/pending, or lumo.jit.listPendingRequests()
A decisionPOST /jit/approve/{id}, POST /jit/deny/{id}
A request as it arrivesThe webhook jit.approval_required
A request that another approver decidedThe webhooks jit.request.approved and jit.request.denied

States​

Runs on sample data, with the neutral theme of shadcn/ui.
  • Empty. Nothing waits for this person.
  • Error. The list could not be loaded.
  • A request disappears. When the list changes, the inbox selects the first request that is left.

Props​

PropTypeDescription
requestsrequiredApprovalRequestData[]The pending requests, newest first. The type comes from the approval request pattern.
onApprove(id: string, note: string) => void | Promise<void>Called when the person approves.
onDeny(id: string, note: string) => void | Promise<void>Called when the person denies.
loadingbooleanShows a loading line in place of the list.
errorstringShows this message in place of the list.
classNamestringClass name for the inbox.