Open this example in the interactive library
Source code
// app/roll-back-a-batch-of-held-seat-codes/page.tsx
export const metadata = { title: "Roll back a batch of held seat codes" };
export default function Page() {
const rows = [
{ row: "A", seat: 1, held: true },
{ row: "A", seat: 2, held: false },
{ row: "B", seat: 1, held: false },
{ row: "B", seat: 2, held: false },
];
const result = rows.map((r) =>
["A1", "B2"].includes(r.row + r.seat) ? { ...r, held: false } : r,
);
const entries = Object.entries(
typeof result === "object" && result !== null ? result : { value: result },
);
return (
<section>
<h2>{"Roll back a batch of held seat codes"}</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>
);
}
