Open this example in the interactive library
Source code
// app/rental/page.tsx
export default async function DepositDueBreakdown({
searchParams,
}: {
searchParams: Promise<Record<string, string | string[] | undefined>>;
}) {
const equipment = [
{ id: "press", day: 40, deposit: 100, qty: 2 },
{ id: "lamp", day: 12, deposit: 25, qty: 8 },
{ id: "stand", day: 8, deposit: 10, qty: 5 },
];
const { item } = await searchParams;
const e = equipment.find((x) => x.id === item) ?? equipment[0];
return (
<dl>
<dt>Rental</dt>
<dd>{e.day}</dd>
<dt>Refundable deposit</dt>
<dd>{e.deposit}</dd>
<dt>Due at pickup</dt>
<dd>{e.day + e.deposit}</dd>
</dl>
);
}
