Open this example in the interactive library
Source code
// app/issues/page.tsx
import Form from "next/form";
export default async function AssignedIssueSummary({
searchParams,
}: {
searchParams: Promise<Record<string, string | string[] | undefined>>;
}) {
const issues = [
{ id: 12, title: "Header spacing", owner: "Kim", severity: 1, open: true },
{ id: 14, title: "Invoice rounding", owner: "Sam", severity: 3, open: true },
{ id: 21, title: "Alt text", owner: "Kim", severity: 2, open: false },
];
const { owner } = await searchParams;
return (
<main>
<Form action="/issues">
<label>
Owner
<select name="owner">
{[...new Set(issues.map((i) => i.owner))].map((o) => (
<option key={o}>{o}</option>
))}
</select>
</label>
<button>Apply</button>
</Form>
<p>
{issues.filter((i) => i.owner === owner && i.open).length} open for{" "}
{owner ?? "selected owner"}
</p>
</main>
);
}
