Open this example in the interactive library
Source code
// app/billing/page.tsx
export default async function AgingReportCutoff({
searchParams,
}: {
searchParams: Promise<Record<string, string | string[] | undefined>>;
}) {
const invoices = [
{ id: "A", cents: 3200, paid: true, due: "2028-01-10" },
{ id: "B", cents: 7900, paid: false, due: "2028-02-15" },
{ id: "C", cents: 4600, paid: false, due: "2028-03-20" },
];
const { asof } = await searchParams;
const d = typeof asof === "string" ? asof : "2028-03-01";
return (
<ul>
{invoices
.filter((i) => !i.paid && i.due < d)
.map((i) => (
<li key={i.id}>
{i.id}: {Math.floor((Date.parse(d) - Date.parse(i.due)) / 86400000)} days
overdue
</li>
))}
</ul>
);
}
