import Link from 'next/link';
import { Section, Note } from '@/components/ui/section';
import { EmptyState } from '@/components/ui/empty-state';
import { Freshness } from '@/components/ui/freshness';
import { Badge } from '@/components/ui/badge';
import { ApprovalsTable } from '@/components/data/approvals-table';
import { approvalsForCancer } from '@/lib/queries/drugs';
import { therapyMentionsForCancer } from '@/lib/queries/evidence';
import { loadProvenance } from '@/lib/queries/provenance';
import { fmtInt } from '@/lib/format';
import type { CancerBundle } from '../load';
export async function DrugsTab({ b, jurisdiction, aPage = 1 }: { b: CancerBundle; jurisdiction: string | null; aPage?: number }) {
// Therapies mentioned in curated evidence (not approvals) — aggregated in SQL (no evidence rows
// are shipped to the page), listed separately and never called "approved".
const [approvals, therapies] = await Promise.all([approvalsForCancer(b.descendants), therapyMentionsForCancer(b.descendants)]);
const jurisdictions = [...new Set(approvals.map((a) => a.jurisdiction))].sort();
const selected = jurisdiction && jurisdictions.includes(jurisdiction) ? jurisdiction : null;
const shownApprovals = selected ? approvals.filter((a) => a.jurisdiction === selected) : approvals;
if (approvals.length === 0 && therapies.length === 0) {
return (
| Therapy | Evidence items (count) | Sensitivity / response | Resistance |
|---|---|---|---|
| {t.name} | {fmtInt(t.n)} | {fmtInt(t.sensitivity)} | {fmtInt(t.resistance)} |