import Link from 'next/link';
import { Section } from '@/components/ui/section';
import { EmptyState } from '@/components/ui/empty-state';
import { Freshness } from '@/components/ui/freshness';
import { Badge, ClaimBadge } from '@/components/ui/badge';
import { SourceBadge } from '@/components/ui/source-badge';
import { getGeographyBySlug, topCancersFor, yearsFor, type TopCancersResult } from '@/lib/queries/geography';
import { EPI_METRIC_LABEL } from '@/lib/queries/epidemiology';
import { fmtInt, fmtValue, unitLabel, toDate } from '@/lib/format';
/**
* Home module "Cancer burden in the United States (latest year)" (§105, §328): top 5 by deaths and top 5 by
* age-standardized incidence, straight from observations, with year and source on every row.
*/
export async function BurdenModule({ slug = 'united-states' }: { slug?: string }) {
const geo = await getGeographyBySlug(slug);
const years = geo ? await yearsFor(geo.id) : [];
const latest = years[0];
const [deaths, asir] = geo && latest ? await Promise.all([topCancersFor(geo, 'mortality_count', latest, 'all', 5), topCancersFor(geo, 'as_incidence_rate', latest, 'all', 5)]) : [null, null];
const has = !!(deaths?.rows.length || asir?.rows.length);
const freshest = [...(deaths?.rows ?? []), ...(asir?.rows ?? [])].map((r) => toDate(r.updated_at)).filter((d): d is Date => !!d).sort((a, b) => b.getTime() - a.getTime())[0] ?? null;
return (
{EPI_METRIC_LABEL[res.metric] ?? res.metric}
Top 5 · {EPI_METRIC_LABEL[res.metric] ?? res.metric} {res.year} {res.year !== res.requestedYear ? ` (latest available; ${res.requestedYear} not yet published)` : ''} · {unitLabel(first.unit)}
| # | Cancer | {unitLabel(first.unit)} | Type |
|---|---|---|---|
| {r.rank ?? i + 1} | {r.canonical_name} | {fmtValue(r.value, r.unit)} |
|
(hydration mismatch). */}