import Link from 'next/link'; import { Badge } from '@/components/ui/badge'; import { EPI_METRIC_LABEL } from '@/lib/queries/epidemiology'; import type { CoverageMatrixRow } from '@/lib/queries/explorer'; import { fmtDate, fmtInt, humanize, unitLabel } from '@/lib/format'; /** * Coverage matrix: what exists, per metric × geography × sex × age group × source × standard population, * with the year span, the number of distinct years, observations and cancers. Each row links to the * explorer with the same dimensions so a gap can be checked in one click. */ export function CoverageTable({ rows, cancers, compact = false }: { rows: CoverageMatrixRow[]; cancers?: string[]; compact?: boolean }) { if (rows.length === 0) return null; const hrefFor = (r: CoverageMatrixRow) => { const qs = new URLSearchParams({ metric: r.metric, geography: r.geography_slug, sex: r.sex, age: r.age_group, from: String(r.year_from), to: String(r.year_to) }); if (cancers && cancers.length > 0) qs.set('cancers', cancers.join(',')); return `/explore?${qs.toString()}`; }; return (
| Metric | Geography | Sex | Age | Source | Standard population | Years | Distinct years | Observations | {compact ? null : (Cancers | )}Type | {compact ? null :Updated | }Open |
|---|---|---|---|---|---|---|---|---|---|---|---|---|
| {EPI_METRIC_LABEL[r.metric] ?? humanize(r.metric)} ({unitLabel(r.unit)}) | {r.geography_name} {r.iso3 ? {r.iso3} : null} | {r.sex === 'all' ? 'Both' : humanize(r.sex)} | {r.age_group === 'all' ? 'All ages' : r.age_group} | {r.source_slug} | {r.standard_population ?? '—'} | {r.year_from === r.year_to ? r.year_from : `${r.year_from}–${r.year_to}`} | {fmtInt(r.years)} | {fmtInt(r.observations)} | {compact ? null :{fmtInt(r.n_cancers)} | }
{r.estimate_types.map((t) => (
|
{compact ? null : {fmtDate(r.last_updated)} | }Open → |