/* ═══════════════════════════════════════════════════════════════ PERSON DETAIL: /people/:id Everything public that points at one person, gathered by GET /people/:id in people.js. Visibility is decided there, the same way each list's own page decides it, so nothing here filters. Roles are current and past. A roster only ever wants who holds a seat now; a person's record is also where "served on the board 2018–2022" belongs, so ended affiliations list under Previously. public_phone is never sent. The email is the one contact detail the page offers. Sections after About alternate background in the order they appear, so a person with no roles doesn't get two tinted bands in a row. ═══════════════════════════════════════════════════════════════ */ import { Link, useParams } from 'react-router-dom' import PageShell, { type ShellSection } from '../components/PageShell.tsx' import PageState from '../components/PageState.tsx' import PlatformIcon from '../components/PlatformIcon.tsx' import ContentBlocks from '../components/ContentBlocks.tsx' import { usePerson, type PersonEvent, type PersonRecord, type PersonRole, } from '../lib/useContent.ts' import { awardHref, eventHref, orgHref, teamHref } from '../lib/hrefs.ts' import { mediaUrl, initials } from '../lib/media.ts' import { eventTypeLabel } from '../lib/eventTypes.ts' import { capitalize } from '../lib/text.ts' import { accentText, BRAND } from '../lib/color.ts' const BODY = 'var(--color-muted)' const BACKGROUNDS = ['var(--color-surface)', 'var(--color-tint)'] /* affiliations.role, for a row with no title of its own. */ const ROLE_LABEL: Record = { lead: 'Lead', board: 'Board member', staff: 'Staff', volunteer: 'Volunteer', member: 'Member', } export default function PersonDetail() { const { id } = useParams() const { data: person, loading, error, notFound, reload } = usePerson(id) if (!person) { return ( ) } const accent = BRAND const current = person.roles.filter((role) => !role.ended_on) const previous = person.roles.filter((role) => role.ended_on) const sections: ShellSection[] = [ { id: 'about', title: 'About', accent, background: BACKGROUNDS[0], content: (
{[...person.bio, ...person.description].map((paragraph, index) => (

{paragraph}

))}
), }, ] if (person.roles.length > 0) { sections.push({ id: 'roles', title: 'Roles', accent, background: BACKGROUNDS[sections.length % 2], content: (
{current.length > 0 && } {previous.length > 0 && (
{current.length > 0 && (

Previously

)}
)}
), }) } if (person.events.length > 0) { sections.push({ id: 'events', title: 'Events', accent, background: BACKGROUNDS[sections.length % 2], content: (
    {person.events.map((event) => (
  • ))}
), }) } if (person.awards.length > 0) { sections.push({ id: 'awards', title: 'Awards', accent, background: BACKGROUNDS[sections.length % 2], content: (
{person.awards.map((entry, index) => (

{entry.award.name}

{(entry.awarded_on || entry.event) && (

{year(entry.awarded_on)} {entry.event && ( <> {entry.awarded_on && ' · '} {entry.event.title} )}

)} {entry.citation && (

{entry.citation}

)}
))}
), }) } return ( ) } /* ── The strip of facts under the heading ────────────────────── */ function Facts({ person, accent }: { person: PersonRecord; accent: string }) { const photo = mediaUrl(person.photo) return (
{photo ? ( ) : ( )} {person.pronouns && {person.pronouns}} {person.org && ( {person.org.name} )} {person.location_label && {person.location_label}} Leadership
) } function Contact({ person, accent }: { person: PersonRecord; accent: string }) { const outlined = [ person.website ? { url: person.website, label: 'Website', platform: null } : null, person.public_email ? { url: `mailto:${person.public_email}`, label: person.public_email, platform: null } : null, ...person.socials, ].filter((link): link is NonNullable => Boolean(link)) if (person.links.length === 0 && outlined.length === 0) return null return (
{person.links.map((link) => ( {link.label} ))} {outlined.map((link) => ( {link.label} ))}
) } /* ── Roles ───────────────────────────────────────────────────── */ function RoleList({ roles, accent }: { roles: PersonRole[]; accent: string }) { return (
    {roles.map((role, index) => (
  • {role.title || ROLE_LABEL[role.role] || capitalize(role.role)}

    {role.team && ( <> {role.team.name} {' · '} )} {role.org.name}

    {tenure(role) && (

    {tenure(role)}

    )}
  • ))}
) } /* "2018 – 2022", "Since 2021", "Until 2019", or null. Years only: affiliation dates are often backfilled from memory. */ function tenure(role: PersonRole): string | null { const from = year(role.started_on) const to = year(role.ended_on) if (from && to) return from === to ? from : `${from} – ${to}` if (from) return `Since ${from}` if (to) return `Until ${to}` return null } /* ── Events ──────────────────────────────────────────────────── */ function EventRow({ event, accent }: { event: PersonEvent; accent: string }) { const when = event.date_label || year(event.starts_on) const capacities = event.roles .map((role) => role.title || capitalize(role.role)) .join(', ') return (

{event.title}

{[capacities, eventTypeLabel(event.event_type), when].filter(Boolean).join(' · ')}

) } /* Dates here may be partial ('2019', '2019-06'), so take the leading year rather than parsing. */ function year(date?: string | null): string | null { if (!date) return null const match = /^(\d{4})/.exec(date) return match ? match[1] : date }