Three sections: Mission, Vision & Values from the national organization record's own description and content blocks; Leadership as that record's teams with their people; Details & Contact with NGU's address, nonprofit status, email and the record's contact links. /leadership answers with a 301 to /organization (MOVED in routes/pages.js), and a page title or intro saved for it in Site settings moves with it (migration 054). OrganizationDetail's team list and contact buttons are now shared components (OrgTeams, OrgContact), and NGU's address and email live once in src/data/organizationDetails.ts for the footer, the page and ComingSoon. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
155 lines
4.5 KiB
TypeScript
155 lines
4.5 KiB
TypeScript
/* ═══════════════════════════════════════════════════════════════
|
|
TEAM DETAIL: /teams/:id
|
|
|
|
teams.id is a global primary key rather than scoped to the
|
|
organization, which is what lets this route be flat: 'ngu-board'
|
|
can only mean one thing site-wide.
|
|
|
|
The roster is not in this page's data. PeopleTiles fetches
|
|
/teams/:id/people itself, off v_org_leadership, which already
|
|
decides who counts as current and public. Two requests, both
|
|
cached for 60s by api.ts, and one set of visibility rules.
|
|
═══════════════════════════════════════════════════════════════ */
|
|
|
|
import { Link, useParams } from 'react-router-dom'
|
|
|
|
import PageShell from '../components/PageShell.tsx'
|
|
import PageState from '../components/PageState.tsx'
|
|
import PlatformIcon from '../components/PlatformIcon.tsx'
|
|
import ContentBlocks from '../components/ContentBlocks.tsx'
|
|
import PeopleTiles from '../components/PeopleTiles.tsx'
|
|
import { useTeam } from '../lib/useContent.ts'
|
|
import { orgHref } from '../lib/hrefs.ts'
|
|
import { accentText, BRAND } from '../lib/color.ts'
|
|
|
|
const BODY = 'var(--color-muted)'
|
|
|
|
export default function TeamDetail() {
|
|
const { id } = useParams()
|
|
const { data: team, loading, error, notFound, reload } = useTeam(id)
|
|
|
|
if (!team) {
|
|
return (
|
|
<PageState
|
|
loading={loading}
|
|
error={error}
|
|
notFound={notFound}
|
|
onRetry={reload}
|
|
noun="team"
|
|
backTo="/organization"
|
|
backLabel="Organization"
|
|
/>
|
|
)
|
|
}
|
|
|
|
const accent = team.color || BRAND
|
|
const hasAbout =
|
|
team.description.length > 0 || team.blocks.length > 0 || team.links.length > 0
|
|
|
|
const sections: any[] = []
|
|
|
|
if (hasAbout) {
|
|
sections.push({
|
|
id: 'about',
|
|
title: 'About',
|
|
accent,
|
|
content: (
|
|
<div className="max-w-6xl mx-auto px-6 space-y-8">
|
|
<Facts orgId={team.org.id} orgKind={team.org.kind} orgName={team.org.name} accent={accent} />
|
|
|
|
{team.description.map((paragraph, index) => (
|
|
<p key={index} className="leading-relaxed max-w-3xl" style={{ color: BODY }}>
|
|
{paragraph}
|
|
</p>
|
|
))}
|
|
|
|
<div className="max-w-3xl">
|
|
<ContentBlocks blocks={team.blocks} accent={accent} />
|
|
</div>
|
|
|
|
{team.links.length > 0 && (
|
|
<div className="flex flex-wrap gap-3">
|
|
{team.links.map((link) => (
|
|
<a
|
|
key={link.url}
|
|
href={link.url}
|
|
target="_blank"
|
|
rel="noreferrer"
|
|
className="inline-flex items-center gap-2 btn px-5 py-2 text-sm text-white transition-transform hover:scale-105"
|
|
style={{ background: accent }}
|
|
>
|
|
<PlatformIcon platform={link.platform} />
|
|
{link.label}
|
|
</a>
|
|
))}
|
|
</div>
|
|
)}
|
|
</div>
|
|
),
|
|
})
|
|
}
|
|
|
|
sections.push({
|
|
id: 'members',
|
|
title: hasAbout ? 'Members' : team.name,
|
|
accent,
|
|
content: (
|
|
<div className="max-w-6xl mx-auto px-6 space-y-6">
|
|
{!hasAbout && (
|
|
<Facts
|
|
orgId={team.org.id}
|
|
orgKind={team.org.kind}
|
|
orgName={team.org.name}
|
|
accent={accent}
|
|
/>
|
|
)}
|
|
|
|
<PeopleTiles
|
|
size="lg"
|
|
accent={accent}
|
|
teams={[{ id: team.id, label: 'Members', accent }]}
|
|
emptyMessage="Nobody is currently listed on this team."
|
|
/>
|
|
</div>
|
|
),
|
|
})
|
|
|
|
return (
|
|
<PageShell title={team.name} intro={team.tagline ?? undefined} sections={sections} />
|
|
)
|
|
}
|
|
|
|
function Facts({
|
|
orgId,
|
|
orgKind,
|
|
orgName,
|
|
accent,
|
|
}: {
|
|
orgId: string
|
|
orgKind?: string | null
|
|
orgName: string
|
|
accent: string
|
|
}) {
|
|
return (
|
|
<div className="flex flex-wrap items-center gap-x-6 gap-y-3 text-sm">
|
|
<span style={{ color: BODY }}>
|
|
A team of{' '}
|
|
<Link
|
|
to={orgHref(orgId, orgKind)}
|
|
className="font-medium hover:underline"
|
|
style={{ color: accentText(accent) }}
|
|
>
|
|
{orgName}
|
|
</Link>
|
|
</span>
|
|
|
|
<Link
|
|
to={orgHref(orgId, orgKind)}
|
|
className="ml-auto hover:underline"
|
|
style={{ color: accentText(accent) }}
|
|
>
|
|
Back to {orgName}
|
|
</Link>
|
|
</div>
|
|
)
|
|
}
|