import Link from 'next/link'; import { Section } from '@/components/ui/section'; import { EmptyState } from '@/components/ui/empty-state'; import { Badge, MatchBadge } from '@/components/ui/badge'; import { JsonView } from '@/components/ui/json-view'; import { getContributingSources, getChangeEvents } from '@/lib/queries/cancers'; import { CODE_SYSTEM_LABEL, codeUrl } from '@/lib/site'; import { fmtDate, fmtDateTime, humanize } from '@/lib/format'; import type { CancerBundle } from '../load'; export async function SourcesTab({ b }: { b: CancerBundle }) { const [contrib, events] = await Promise.all([getContributingSources(b.cancer.id, b.descendants), getChangeEvents('cancer', b.cancer.id)]); return (
{contrib.length ? (
{contrib.map((s) => ( ))}
Source License Contributions Ingest runs Last retrieved
{s.name} {' '} {s.slug} {s.license_status} {s.kinds.map(humanize).join(', ')} {s.run_ids.length ? ( s.run_ids.slice(0, 5).map((r) => ( {r} )) ) : ( — )} {s.run_ids.length > 5 ? +{s.run_ids.length - 5} more : null} {s.last_retrieved ? fmtDateTime(s.last_retrieved) : '—'}
) : ( No source contribution recorded. )}
{b.codes.length ? (
{b.codes.map((k) => { const url = codeUrl(k.system, k.code); return ( ); })}
System Code Match type Source
{CODE_SYSTEM_LABEL[k.system] ?? k.system} {url ? ( {k.code} ) : ( {k.code} )} {k.source_slug ? ( {k.source_slug} ) : ( '—' )}
) : ( No cross-reference code. )}
{b.aliases.length ? (
{b.aliases.map((a, i) => ( ))}
Alias Type Terminology Language
{a.alias} {a.alias_type} {a.source_terminology ?? a.source_slug ?? '—'} en
) : ( No alias recorded. )}
{events.length ? (
    {events.map((e) => (
  1. {humanize(e.kind)} {e.summary} {fmtDate(e.created_at)}
    {e.ingest_run_id ? ( {e.ingest_run_id} ) : null} {e.before || e.after ? (
    diff

    Before

    After

    ) : null}
  2. ))}
) : ( No change event recorded yet. Created {fmtDate(b.cancer.created_at)}; last updated {fmtDate(b.cancer.updated_at)}. )}
); }