Open this example in the interactive library
Source code
// app/stores/[branch]/page.tsx
import Form from "next/form";
import { notFound } from "next/navigation";
export default async function StoreReservationQuantityForm({
params,
}: {
params: Promise<{ branch: string }>;
}) {
const branches = [
{ key: "market", opens: 9, closes: 18, sat: true, stock: 12 },
{ key: "pier", opens: 11, closes: 19, sat: false, stock: 4 },
];
const { branch } = await params;
const store = branches.find((b) => b.key === branch);
if (!store) notFound();
return (
<Form action="/reserve">
<input type="hidden" name="branch" value={branch} />
<label>
Units
<input name="units" type="number" min={1} max={store.stock} required />
</label>
<button>Check reservation</button>
</Form>
);
}
