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: PageContainer (breadcrumb, tag, summary, key figure) + progress Steps + Info + Timeline + decision buttons pinned to the footer.
// No PageContainer onBack (it crashes the page on this runtime) — use the breadcrumb.
import { useState } from "react";
import { ModalForm, PageContainer, ProCard, ProDescriptions, ProFormTextArea } from "@ant-design/pro-components";
import { Alert, App, Button, Col, Flex, Row, Space, Steps, Tag, Timeline, Typography } from "antd";
import { CheckOutlined, CloseOutlined } from "@ant-design/icons";
export default function Page() {
const { message } = App.useApp();
const [status, setStatus] = useState<"pending" | "approved" | "rejected">("pending");
const [note, setNote] = useState<string | null>(null);
const events = [
{ color: "blue", text: <><b>Laura Bennett</b> created the request</>, at: "Nov 10, 2026 · 12:52 PM" },
...(status !== "pending" ? [{ color: status === "approved" ? "green" : "red", text: <><b>Hannah Reed</b> {status === "approved" ? "approved" : "rejected"}{note ? <> — <i>“{note}”</i></> : null}</>, at: "just now" }] : []),
];
const decide = (to: "approved" | "rejected") => async (v: { note?: string }) => {
setStatus(to); setNote(v.note ?? null);
message.success(to === "approved" ? "Approved" : "Rejected");
return true;
};
return (
<PageContainer
header={{
title: "Renew Microsoft 365 Business (12 months, 10 users)",
breadcrumb: { items: [{ title: <a>Requests</a> }, { title: "#9" }] },
tags: <Tag color={status === "pending" ? "processing" : status === "approved" ? "success" : "error"}>{status === "pending" ? "Pending" : status === "approved" ? "Approved" : "Rejected"}</Tag>,
}}
content={
<ProDescriptions column={{ xs: 1, sm: 2, lg: 3 }}>
<ProDescriptions.Item label="Requested by">Laura Bennett · Operations</ProDescriptions.Item>
<ProDescriptions.Item label="Category">Software</ProDescriptions.Item>
<ProDescriptions.Item label="Needed by">Nov 13, 2026</ProDescriptions.Item>
</ProDescriptions>
}
extraContent={
<Space orientation="vertical" size={0} style={{ textAlign: "right" }}>
<Typography.Text type="secondary">Requested amount</Typography.Text>
<Typography.Text strong style={{ fontSize: 28 }}>$1,500.00</Typography.Text>
</Space>
}
footer={status === "pending" ? [
<ModalForm key="r" title="Reject request" width={480} trigger={<Button danger icon={<CloseOutlined />}>Reject</Button>} onFinish={decide("rejected")} modalProps={{ okText: "Reject", okButtonProps: { danger: true } }}>
<ProFormTextArea name="note" label="Reason for rejection" rules={[{ required: true, whitespace: true, message: "Please add a reason" }]} />
</ModalForm>,
<ModalForm key="a" title="Approve request" width={480} trigger={<Button type="primary" icon={<CheckOutlined />}>Approve</Button>} onFinish={decide("approved")} modalProps={{ okText: "Approve" }}>
<ProFormTextArea name="note" label="Note (optional)" />
</ModalForm>,
] : undefined}
>
<Flex vertical gap={16}>
<ProCard title="Progress" headerBordered>
<Steps current={status === "pending" ? 1 : 2} status={status === "rejected" ? "error" : status === "approved" ? "finish" : "process"}
items={[{ title: "Submitted", content: "Laura Bennett · Nov 10, 12:52 PM" }, { title: status === "pending" ? "Manager approval" : status === "approved" ? "Approved" : "Rejected", content: status === "pending" ? "Needed by Nov 13" : "Hannah Reed" }]} />
</ProCard>
{status === "rejected" && <Alert type="error" showIcon title="Rejected by Hannah Reed" description={`Reason: ${note}`} />}
<Row gutter={[16, 16]}>
<Col xs={24} lg={15}>
<ProCard title="Details" headerBordered style={{ height: "100%" }}>
<Typography.Paragraph>The current plan expires at the end of the month. We need to renew it so email isn't interrupted.</Typography.Paragraph>
</ProCard>
</Col>
<Col xs={24} lg={9}>
<ProCard title="History" headerBordered style={{ height: "100%" }}>
<Timeline items={events.map((e) => ({ color: e.color, children: <><div>{e.text}</div><Typography.Text type="secondary" style={{ fontSize: 12 }}>{e.at}</Typography.Text></> }))} />
</ProCard>
</Col>
</Row>
</Flex>
</PageContainer>
);
}
Build the "Detail page + approval" screen for my app following the Manh UI playbook (framework_docs("pro")): Detail page: PageContainer (breadcrumb, tag, summary, key numbers) + progress Steps + info + Timeline + decision buttons fixed at the bottom. Data comes from the app's API through useApiClient(); labels and fields follow my spec.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.
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.
<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".
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”.
<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.
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" }] } }] }} />
);askopens 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
useActionfromapp/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:
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
onBackonPageContainer, because the page crashes. Useheader.breadcrumb. - Build the Details / History columns with
Row gutter+Col, notProCard 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 }}, witheditable: falseon columns that can’t change.
Next steps
- Forms — the
DrawerFormbehind the Edit button. - Sign-in and permissions —
accessand the user in a handler. - Pages and layouts — the
[id:int]dynamic path.