Skip to Content

Detail pages

A detail page shows one record (a summary in the header, approval progress, details, history) and only the buttons the signed-in role can use in the current status.

This is where decisions happen. An approver opens a request, reads the amount and the reason, and clicks Approve or Reject. The creator opens the same page but sees Cancel request. The example follows the detail page of the Duyệt mua sắm (purchase approval) template (templates/purchase-requests/).

Detail page + approvalDetail page: PageContainer (breadcrumb, tag, summary, key numbers) + progress Steps + info + Timeline + decision buttons fixed at the bottom.
example.manh.run · sample dataOpen in editor ↗
The example runs when you scroll to it

File tree

The page and its APIs share the [id:int] folder. Each status change is its own API.

app/requests/[id:int]/ ├── page.tsx /requests/12 detail page ├── get.ts GET /requests/12 api.requests.detail(id) ├── patch.ts PATCH /requests/12 api.requests.update(id, body) ├── approve/post.ts POST …/approve api.requests.approve(id, { note }) ├── reject/post.ts POST …/reject api.requests.reject(id, { note }) └── cancel/post.ts POST …/cancel api.requests.cancel(id, {})

Page layout

The page follows the Ant Design Pro profile/advanced layout:

PageContainer ├── header title · status Tag · status buttons (extra) ├── content 3–4 key facts (ProDescriptions) ├── extraContent the one number that matters (the amount) ├── ProCard "Progress" → Steps ├── Alert outcome: approved / rejected + note ├── Row gutter={[16, 16]} │ ├── Col lg={15} ProCard "Details" → ProDescriptions │ └── Col lg={9} ActivityLog "History"

Load the record and handle “not found”

Load with useRequest and refreshDeps: [id]. When the record doesn’t exist or the user can’t see it, show a Result inside PageContainer with a button back to the list.

app/requests/[id:int]/page.tsx
const { id } = useParams(); const api = useApiClient(); const { data: r, loading, error, refresh, mutate } = useRequest(async () => (await api.requests.detail(id!)) as RequestDetail, { refreshDeps: [id] }); const breadcrumb = { items: [{ title: <a onClick={() => nav("/requests")}>Requests</a> }, { title: `#${id}` }] }; if (loading && !r) return <PageContainer header={{ breadcrumb }} loading />; if (error || !r) return ( <PageContainer header={{ breadcrumb }}> <ProCard> <Result status="404" title="Request not found" subTitle="The request doesn't exist, or you don't have permission to view it." extra={<Button type="primary" onClick={() => nav("/requests")}>Back to list</Button>} /> </ProCard> </PageContainer> );

Header: status, summary, key number

Put the status in tags, the key facts in content, and the amount in extraContent. The approver can decide without scrolling.

app/requests/[id:int]/page.tsx
<PageContainer header={{ title: r.title, breadcrumb, tags: <Tag color={STATUS_COLOR[r.status]}>{STATUS_ENUM[r.status].text}</Tag>, extra: actions, }} content={ <ProDescriptions column={{ xs: 1, sm: 2, lg: 4 }} dataSource={r}> <ProDescriptions.Item label="Created by">{r.creatorName}</ProDescriptions.Item> <ProDescriptions.Item label="Category">{CATEGORY[r.category]}</ProDescriptions.Item> <ProDescriptions.Item label="Needed by"> <Typography.Text type={isLate(r) ? "danger" : undefined}>{vnDate(r.neededBy)}</Typography.Text> </ProDescriptions.Item> <ProDescriptions.Item label="ID">#{r.id}</ProDescriptions.Item> </ProDescriptions> } extraContent={<Statistic title="Requested amount" value={vnd(r.amount)} />} > {/* progress, details, history */} </PageContainer>

Progress with Steps

Derive the steps from the status. The waiting step is the next decision; a rejected request gets status="error".

app/requests/[id:int]/page.tsx
const decided = r.status === "approved" || r.status === "rejected"; const steps = [ { title: "Submitted", content: `${r.creatorName} · ${vnDateTime(r.createdAt)}` }, r.status === "cancelled" ? { title: "Cancelled", content: "Cancelled by the creator before approval" } : decided ? { title: r.status === "approved" ? "Approved" : "Rejected", content: `${r.deciderName} · ${vnDateTime(r.decidedAt)}` } : { title: "Manager approval", content: r.neededBy ? `Needed by ${vnDate(r.neededBy)}` : "Waiting" }, ]; <ProCard title="Progress" headerBordered> <Steps current={r.status === "pending" ? 1 : 2} status={r.status === "rejected" ? "error" : r.status === "cancelled" ? "wait" : r.status === "approved" ? "finish" : "process"} items={steps} /> </ProCard> {r.status === "rejected" && ( <Alert type="error" showIcon title={`Rejected by ${r.deciderName}`} description={`Reason: ${r.decisionNote}`} /> )}

Details and history

Details use a two-column ProDescriptions. History uses ActivityLog from manh/shell: each entry shows who, what, the note and when, and a status move reads “Pending → Approved”.

app/requests/[id:int]/page.tsx
<Row gutter={[16, 16]}> <Col xs={24} lg={15}> <ProCard title="Details" headerBordered style={{ height: "100%" }}> <ProDescriptions column={{ xs: 1, sm: 2 }} dataSource={r}> <ProDescriptions.Item label="Created">{vnDateTime(r.createdAt)}</ProDescriptions.Item> <ProDescriptions.Item label="Approver">{r.deciderName ?? "—"}</ProDescriptions.Item> <ProDescriptions.Item label="Decision note" span={2}>{r.decisionNote || "—"}</ProDescriptions.Item> </ProDescriptions> </ProCard> </Col> <Col xs={24} lg={9}> <ActivityLog title="History" items={r.events} statusLabels={RequestStatus} /> </Col> </Row>

Each item of items looks like { id, at, actorName, body?, fromStatus?, toStatus? }. Pass add and ActivityLog also shows a box for a new note.

If the list already has a columns array, reuse it: <ProDescriptions columns={columns as ProDescriptionsItemProps<Req>[]} dataSource={r} />. Then valueEnum and valueType render exactly as in the table. Add hideInDescriptions to filter-only columns.

Status buttons with FlowActions

The request lifecycle is declared once with defineFlow in app/shared/request.ts. FlowActions from manh/shell reads it and shows only the moves the current role may make from the current status. The creator sees Cancel request, the approver sees Approve and Reject, and a decided request has no buttons.

app/requests/[id:int]/page.tsx
const move = (to: string, row: RequestDetail, v?: { note?: string }) => to === "approved" ? api.requests.approve(row.id, v ?? {}) : to === "rejected" ? api.requests.reject(row.id, { note: v?.note }) : api.requests.cancel(row.id, {}); const actions = ( <FlowActions flow={RequestFlow} record={r} labels={RequestStatus} move={move} onDone={refresh} ask={{ rejected: [{ title: "Reason for rejection", dataIndex: "note", valueType: "textarea", formItemProps: { rules: [{ required: true, whitespace: true, message: "Enter a reason to reject" }] } }] }} /> );
  • ask opens a small form before the move. Here, rejecting requires a reason.
  • Cancel and reject moves ask before they run. After a move it shows a message and calls onDone; on an error it shows the server’s error text.
  • Other buttons, such as Edit, call the API through useAction from app/hooks: const save = useAction((v) => api.requests.update(r.id, v), { ok: "Saved", reload: refresh }).

Check again on the server

Hidden buttons only keep users from clicking by mistake. The handler must still check the role and the status:

app/requests/[id:int]/reject/post.ts
import { z } from "@hono/zod-openapi"; import { decide } from "../../repository"; export const access = ["manager"]; // not a manager → 403 export const schema = { body: z.object({ note: z.string().max(1000).optional() }) }; export default (c, { user, param, body }) => decide(user, param.id, "rejected", body.note);

Inside decide: a rejection without a reason → 400; a request that is no longer pending → 409. Each decision adds a history row, so the ActivityLog stays complete.

The page and the server share one table of moves in app/shared/request.ts. decide calls RequestFlow.assert(user, row.status, "rejected"): a move that does not exist returns 409, the wrong role returns 403. FlowActions gets the moves from RequestFlow.next(r.status, role). Conditions on the creator, such as cancelling only your own request, are still checked in the repository. See Build a CRUD feature.

Good to know

  • Don’t use onBack on PageContainer, because the page crashes. Use header.breadcrumb.
  • Build the Details / History columns with Row gutter + Col, not ProCard gutter.
  • When two approvers act at once, the second one gets a 409. Show the error text as is and reload the record so they see who decided.
  • To edit in place: ProDescriptions editable={{ onSave }}, with editable: false on columns that can’t change.

Next steps

Last updated