import 'server-only'; import { cache } from 'react'; import { getCancerBySlug, getCounters, getCodes, getAliases, getParents, getChildren, getBreadcrumbPath, getDescendantIds, getAnatomy, getCancerById, type CancerCore } from '@/lib/queries/cancers'; /** Everything the header and every tab need, loaded once per request (React cache). */ export const loadCancer = cache(async (slug: string) => { let cancer = await getCancerBySlug(slug); let redirectedFrom: CancerCore | null = null; if (cancer && cancer.status === 'merged' && cancer.merged_into) { const target = await getCancerById(cancer.merged_into); if (target) { redirectedFrom = cancer; cancer = target; } } if (!cancer) return null; const [counters, codes, aliases, parents, children, path, descendants, anatomy] = await Promise.all([ getCounters(cancer.id), getCodes(cancer.id), getAliases(cancer.id), getParents(cancer.id), getChildren(cancer.id), getBreadcrumbPath(cancer.id), getDescendantIds(cancer.id), getAnatomy(cancer.id), ]); return { cancer, redirectedFrom, counters, codes, aliases, parents, children, path, descendants, anatomy }; }); export type CancerBundle = NonNullable>>; export const TABS = [ { key: 'overview', label: 'Overview' }, { key: 'statistics', label: 'Statistics' }, { key: 'survival', label: 'Survival' }, { key: 'genomics', label: 'Genomics' }, { key: 'evidence', label: 'Variants & evidence' }, { key: 'drugs', label: 'Drugs' }, { key: 'trials', label: 'Trials' }, { key: 'research', label: 'Research' }, { key: 'rankings', label: 'Rankings' }, { key: 'sources', label: 'Sources & provenance' }, ] as const; export type TabKey = (typeof TABS)[number]['key'];