Open this example in the interactive library
Source code
// app/rental/page.tsx
import Link from "next/link";
export default async function KitBundleQuote({
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 { items } = await searchParams;
const names = typeof items === "string" ? items.split(",") : [];
const kit = equipment.filter((e) => names.includes(e.id));
return (
<main>
<Link href="?items=lamp,stand">Lighting kit</Link>
<p>Total daily rate: {kit.reduce((s, e) => s + e.day, 0)}</p>
</main>
);
}
