Open this example in the interactive library
Live preview
Source code
// CollectionView.tsx
export default function CollectionView() {
const rows = [
{ sku: "pen", bin: "A", qty: 4 },
{ sku: "pad", bin: "B", qty: 0 },
{ sku: "pen", bin: "B", qty: 3 },
{ sku: "clip", bin: "A", qty: 9 },
];
const result = rows
.map((r) => ({ sku: r.sku, bin: r.bin, order: Math.max(0, 5 - r.qty) }))
.filter((r) => r.order > 0);
const entries = Object.entries(
typeof result === "object" && result !== null ? result : { value: result },
);
return (
<section>
<h2>{"Calculate each shelf's restock quantity"}</h2>
{entries.length ? (
<dl>
{entries.map(([key, value]) => (
<div key={key}>
<dt>{key}</dt>
<dd>
{typeof value === "string" ? value : JSON.stringify(value)}
</dd>
</div>
))}
</dl>
) : (
<p>No matching entries.</p>
)}
</section>
);
}
