Open this example in the interactive library
Source code
// app/warehouse/page.tsx
export default function LeastFullBinRecommendation() {
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 [b] = [...bins].sort((a, b) => a.qty / a.limit - b.qty / b.limit);
return (
<aside>
Restock {b.id} first ({Math.round((b.qty / b.limit) * 100)}% full).
</aside>
);
}
