Open this example in the interactive library
Source code
// app/warehouse/page.tsx
export default async function ReplenishmentManifest({
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 { target } = await searchParams;
const pct = Math.min(1, Math.max(0, Number(target ?? 80) / 100));
return (
<table>
<caption>Restock to {pct * 100}%</caption>
<tbody>
{bins.map((b) => (
<tr key={b.id}>
<th>{b.id}</th>
<td>{Math.max(0, Math.ceil(b.limit * pct) - b.qty)}</td>
</tr>
))}
</tbody>
</table>
);
}
