Open this example in the interactive library
Source code
// app/warehouse/page.tsx
import Form from "next/form";
export default async function SingleBinLookup({
searchParams,
}: {
searchParams: Promise<Record<string, string | string[] | undefined>>;
}) {
const bins = [
{ id: "A01", sku: "pen", qty: 12, limit: 20 },
{ id: "B04", sku: "pad", qty: 3, limit: 15 },
{ id: "A09", sku: "pen", qty: 5, limit: 10 },
];
const { bin } = await searchParams;
const b = bins.find((x) => x.id === bin);
return (
<main>
<Form action="/warehouse">
<input name="bin" aria-label="Bin code" />
<button>Locate</button>
</Form>
<output>{b ? b.sku + " × " + b.qty : "Enter a listed bin code."}</output>
</main>
);
}
