Open this example in the interactive library
Source code
// app/register/page.tsx
export default async function SessionClashDetector({
searchParams,
}: {
searchParams: Promise<Record<string, string | string[] | undefined>>;
}) {
const q = await searchParams;
const list = [q.a, q.b];
const time: Record<string, number> = { design: 10, print: 10, ink: 14 };
const [a, b] = list.map((x) => (typeof x === "string" ? time[x] : undefined));
return (
<p>
{a === undefined || b === undefined
? "Choose two sessions"
: a === b
? "These sessions overlap"
: "Both sessions fit"}
</p>
);
}
