NGU-Web/src/pages/TeamDetail.tsx
Zaldimmar 3c02eb8971 Show platform icons on link buttons
Links pick their platform from a preset dropdown (PLATFORMS in
src/lib/platforms.ts), and every link button draws that platform's
icon beside its label. The footer and event cards now share the same
PlatformIcon component instead of their own copies.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-09-27 14:45:20 -05:00

157 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'
const TEAL = '#138ba0'
const BODY = '#4a6b72'
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="/leadership"
backLabel="Leadership"
/>
)
}
const accent = team.color || TEAL
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,
background: '#ffffff',
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 rounded-full px-5 py-2 text-sm font-semibold 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,
background: hasAbout ? '#eef9fb' : '#ffffff',
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: accent }}
>
{orgName}
</Link>
</span>
<Link
to={orgHref(orgId, orgKind)}
className="ml-auto hover:underline"
style={{ color: accent }}
>
Back to {orgName}
</Link>
</div>
)
}