Open this example in the interactive library
Source code
// app/warehouse/page.tsx
export default function CombinedSKUBalance() {
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 totals = new Map<string, number>();
for (const b of bins) totals.set(b.sku, (totals.get(b.sku) ?? 0) + b.qty);
return (
<dl>
{[...totals].map(([sku, n]) => (
<div key={sku}>
<dt>{sku}</dt>
<dd>{n}</dd>
</div>
))}
</dl>
);
}
