import type { Metadata } from 'next'; import { PageHeader } from '@/components/ui/section'; import { EmptyState } from '@/components/ui/empty-state'; import { Pager } from '@/components/ui/pager'; import { TrialTable } from '@/components/data/trial-list'; import { Freshness } from '@/components/ui/freshness'; import { listTrialRows, trialFacets, TRIAL_PAGE_SIZE } from '@/lib/queries/trials'; import { getCancerBySlug, getDescendantIds } from '@/lib/queries/cancers'; import { fmtInt, humanize, phaseLabel } from '@/lib/format'; import { pageInfo } from '@/lib/pagination'; import { str, int, withParams, type SP } from '@/lib/search-params'; export const metadata: Metadata = { title: 'Clinical trials', description: 'ClinicalTrials.gov oncology studies mapped to the cancer taxonomy, filterable by status, phase, country and cancer.' }; // Filtered list: rendered per request (searchParams); 600 s is the CDN/ISR hint shared by all list pages. export const revalidate = 600; export default async function TrialsPage({ searchParams }: { searchParams: Promise }) { const sp = await searchParams; const q = str(sp, 'q').slice(0, 200); const status = str(sp, 'status'); const phase = str(sp, 'phase'); const country = str(sp, 'country'); const cancerSlug = str(sp, 'cancer'); const page = int(sp, 'page', 1, 1, 100_000); const cancer = cancerSlug ? await getCancerBySlug(cancerSlug) : null; const cancerIds = cancer ? await getDescendantIds(cancer.id) : null; const [facets, { rows, total }] = await Promise.all([trialFacets(cancerIds), listTrialRows({ q, status, phase, country, cancerIds, page, pageSize: TRIAL_PAGE_SIZE })]); const info = pageInfo(page, TRIAL_PAGE_SIZE, total); const current = { q, status, phase, country, cancer: cancerSlug }; const href = (o: Record) => `/trials${withParams(current, o)}`; const anyTrials = facets.statuses.reduce((s, x) => s + x.n, 0); const filtered = Boolean(q || status || phase || country || cancer); return (

{fmtInt(total)} studies{filtered ? ' match' : ' indexed'} {cancer ? ( <> {' '} · mapped to {cancer.canonical_name} and descendants ) : cancerSlug ? ( — unknown cancer slug "{cancerSlug}" (ignored) ) : null}

{rows.length === 0 ? (
{anyTrials === 0 ? 'The ClinicalTrials.gov connector has not run on this environment. Studies appear here once ingested and their conditions reconciled to the taxonomy.' : 'Relax a filter or clear the search.'}
) : ( <>
Showing {fmtInt(info.from)}–{fmtInt(info.to)} of {fmtInt(total)} studies } />
href({ page: p === 1 ? '' : p })} label="Trial pages" noun="studies" /> ((m, t) => (m == null || String(t.updated_at) > String(m) ? t.updated_at : m), null)} extra="source: clinicaltrials" /> )}
); }