- Email buttons went to the link's label, not its URL (splitLinks took the label); they use the URL now, with or without mailto:. - Every website and email row is listed, each with its own label, instead of only the first. - The facts at the top of an organization page sit in a framed card: City, Part of <name> Region, Ministry, Meets, Since, and its tags. - Tags (070): Data -> Tags (Online, In-Person to start) replace the Online checkbox on organizations and events. Ticked records get the Online tag; v_events reads the "online" tag as is_online, so the calendar filter and place lines are unchanged. Tags show on the record's page and on group entries in the Community map list and grid. The map no longer keeps online groups off their state's tile. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
406 lines
13 KiB
TypeScript
406 lines
13 KiB
TypeScript
/* ═══════════════════════════════════════════════════════════════
|
||
EVENT DETAIL: /retreats/:id
|
||
|
||
Reached from the cards on Retreats.tsx. The API has already
|
||
resolved the fallbacks, `color` is the event's own or its first
|
||
host's, `status` is derived from the dates when nobody set it,
|
||
so nothing here reimplements those rules.
|
||
|
||
Hosts arrive as a list in billing order, each one either an
|
||
organization or a person. refHref takes the kind and works out
|
||
the route, which is why this file doesn't branch on it.
|
||
|
||
People are grouped by their billing role rather than listed flat.
|
||
A retreat with four speakers and eleven volunteers reads as two
|
||
different things, and v_event_people already sorts within a role
|
||
by sort_order.
|
||
═══════════════════════════════════════════════════════════════ */
|
||
|
||
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 Tags from '../components/Tags.tsx'
|
||
import PeopleTiles, { type PeopleGroupInput } from '../components/PeopleTiles.tsx'
|
||
import {
|
||
useEvent,
|
||
type EventHost,
|
||
type EventPerson,
|
||
type EventRecord,
|
||
} from '../lib/useContent.ts'
|
||
import { awardHref, personHref, refHref } from '../lib/hrefs.ts'
|
||
import { mediaUrl } from '../lib/media.ts'
|
||
import { eventTypeLabel } from '../lib/eventTypes.ts'
|
||
import { occurrenceLabel, seriesLabel, seriesTimes, upcomingOccurrences } from '../lib/eventSeries.ts'
|
||
import { capitalize } from '../lib/text.ts'
|
||
import { accentText, readableOn, BRAND } from '../lib/color.ts'
|
||
|
||
const BODY = 'var(--color-muted)'
|
||
|
||
/* Billing order. A role missing from here still renders, at the
|
||
end, under its own name, better than a speaker vanishing
|
||
because somebody added a role to the CHECK and not to this list. */
|
||
const ROLE_ORDER = [
|
||
'speaker',
|
||
'leader',
|
||
'facilitator',
|
||
'host',
|
||
'musician',
|
||
'volunteer',
|
||
'attendee',
|
||
] as const
|
||
|
||
const ROLE_LABEL: Record<string, string> = {
|
||
speaker: 'Speakers',
|
||
leader: 'Leaders',
|
||
facilitator: 'Facilitators',
|
||
host: 'Hosts',
|
||
musician: 'Music',
|
||
volunteer: 'Volunteers',
|
||
attendee: 'Also there',
|
||
}
|
||
|
||
const STATUS_LABEL: Record<string, string> = {
|
||
upcoming: 'Upcoming',
|
||
past: 'Past',
|
||
cancelled: 'Canceled',
|
||
}
|
||
|
||
export default function EventDetail() {
|
||
const { id } = useParams()
|
||
const { data: event, loading, error, notFound, reload } = useEvent(id)
|
||
|
||
if (!event) {
|
||
return (
|
||
<PageState
|
||
loading={loading}
|
||
error={error}
|
||
notFound={notFound}
|
||
onRetry={reload}
|
||
noun="retreat"
|
||
backTo="/retreats"
|
||
backLabel="All retreats"
|
||
/>
|
||
)
|
||
}
|
||
|
||
const accent = event.color || BRAND
|
||
const groups = peopleGroups(event.people, accent)
|
||
|
||
const sections: ShellSection[] = [
|
||
{
|
||
id: 'about',
|
||
title: event.theme || 'About',
|
||
blurb: event.theme ? event.tagline ?? undefined : undefined,
|
||
accent,
|
||
content: (
|
||
<div className="max-w-6xl mx-auto px-6 space-y-8">
|
||
<Facts event={event} accent={accent} />
|
||
|
||
{/* The event's own 16:9 photo (not the card's background). */}
|
||
{event.photo && (
|
||
<img
|
||
src={mediaUrl(event.photo) ?? ''}
|
||
alt={event.photo_alt ?? ''}
|
||
className="aspect-video w-full max-w-3xl object-cover"
|
||
/>
|
||
)}
|
||
|
||
{event.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={event.blocks} accent={accent} presentAt={`/events/${encodeURIComponent(event.id)}/present`} />
|
||
</div>
|
||
|
||
{event.links.length > 0 && (
|
||
<div className="flex flex-wrap gap-3">
|
||
{event.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>
|
||
),
|
||
},
|
||
]
|
||
|
||
// A canceled series has no next meeting, whatever its dates say.
|
||
const upcoming =
|
||
event.status === 'cancelled'
|
||
? []
|
||
: upcomingOccurrences(event.series, event.starts_on, event.ends_on)
|
||
|
||
if (upcoming.length > 0) {
|
||
const times = seriesTimes(event.series)
|
||
|
||
sections.push({
|
||
id: 'dates',
|
||
title: 'Upcoming dates',
|
||
blurb: seriesLabel(event.series, event.starts_on) ?? undefined,
|
||
accent,
|
||
content: (
|
||
<div className="max-w-6xl mx-auto px-6">
|
||
<ul className="grid gap-3 sm:grid-cols-2 lg:grid-cols-3">
|
||
{upcoming.map((date) => (
|
||
<li
|
||
key={date}
|
||
className="border-l-4 bg-surface px-5 py-3"
|
||
style={{ borderColor: accent }}
|
||
>
|
||
<p className="font-semibold" style={{ color: accentText(accent) }}>
|
||
{occurrenceLabel(date)}
|
||
</p>
|
||
{times && (
|
||
<p className="text-sm" style={{ color: BODY }}>
|
||
{times}
|
||
</p>
|
||
)}
|
||
</li>
|
||
))}
|
||
</ul>
|
||
</div>
|
||
),
|
||
})
|
||
}
|
||
|
||
if (groups.length > 0) {
|
||
sections.push({
|
||
id: 'people',
|
||
title: 'Who’s there',
|
||
accent,
|
||
content: (
|
||
<div className="max-w-6xl mx-auto px-6">
|
||
<PeopleTiles size="lg" groups={groups} accent={accent} />
|
||
</div>
|
||
),
|
||
})
|
||
}
|
||
|
||
if (event.awards.length > 0) {
|
||
sections.push({
|
||
id: 'awards',
|
||
title: 'Presented here',
|
||
blurb: 'Awards given at this gathering.',
|
||
accent,
|
||
content: (
|
||
<div className="max-w-6xl mx-auto px-6 space-y-6">
|
||
{event.awards.map((entry, index) => (
|
||
<div
|
||
key={`${entry.award.id}:${entry.person.id}:${index}`}
|
||
className="flex gap-4 border-l-2 pl-5"
|
||
style={{ borderColor: accent }}
|
||
>
|
||
<div>
|
||
<p className="font-semibold" style={{ color: accentText(accent) }}>
|
||
<Link to={awardHref(entry.award.id)} className="hover:underline">
|
||
{entry.award.name}
|
||
</Link>
|
||
</p>
|
||
<p style={{ color: BODY }}>
|
||
<Link to={personHref(entry.person.id)} className="hover:underline">
|
||
{entry.person.name}
|
||
</Link>
|
||
</p>
|
||
{entry.citation && (
|
||
<p className="mt-1 text-sm italic opacity-80" style={{ color: BODY }}>
|
||
{entry.citation}
|
||
</p>
|
||
)}
|
||
</div>
|
||
</div>
|
||
))}
|
||
</div>
|
||
),
|
||
})
|
||
}
|
||
|
||
return (
|
||
<PageShell
|
||
title={event.title}
|
||
intro={event.theme ? event.tagline ?? undefined : event.tagline ?? undefined}
|
||
sections={sections}
|
||
/>
|
||
)
|
||
}
|
||
|
||
/* ── The strip of facts under the heading ────────────────────── */
|
||
|
||
function Facts({ event, accent }: { event: EventRecord; accent: string }) {
|
||
const where =
|
||
event.location_label ||
|
||
[event.locality, event.state_code].filter(Boolean).join(', ')
|
||
|
||
const schedule = seriesLabel(event.series, event.starts_on)
|
||
// A series with no label of its own is described by its schedule
|
||
// rather than by a start-to-end range that reads like one long
|
||
// gathering.
|
||
const when =
|
||
event.date_label || (schedule ? null : dateRange(event.starts_on, event.ends_on))
|
||
|
||
return (
|
||
<div className="flex flex-wrap items-center gap-x-6 gap-y-3 text-sm">
|
||
<span
|
||
className="px-3 py-1 font-semibold uppercase tracking-wide"
|
||
style={{
|
||
background: event.status === 'cancelled' ? '#b3261e' : accent,
|
||
color: event.status === 'cancelled' ? '#ffffff' : readableOn(accent),
|
||
}}
|
||
>
|
||
{STATUS_LABEL[event.status] ?? event.status}
|
||
</span>
|
||
|
||
{/* Outlined rather than filled: the status pill is the one
|
||
thing in this strip that should read as loud, and two
|
||
solid blocks side by side would compete. Shown
|
||
unconditionally, a card suppresses its own type badge in
|
||
a band of one kind, but here there is no band to make it
|
||
redundant. */}
|
||
{event.event_type && (
|
||
<span
|
||
className="px-3 py-1 font-semibold uppercase tracking-wide"
|
||
style={{ border: `1px solid ${accent}`, color: accentText(accent) }}
|
||
>
|
||
{eventTypeLabel(event.event_type)}
|
||
</span>
|
||
)}
|
||
|
||
{when && <span style={{ color: BODY }}>{when}</span>}
|
||
{schedule && <span style={{ color: BODY }}>{schedule}</span>}
|
||
{where && <span style={{ color: BODY }}>{where}</span>}
|
||
<Tags tags={event.tags} accent={accent} />
|
||
|
||
{(event.hosts?.length ?? 0) > 0 && (
|
||
<span style={{ color: BODY }}>
|
||
Hosted by <HostList hosts={event.hosts} accent={accent} />
|
||
</span>
|
||
)}
|
||
|
||
<Link to="/retreats" className="ml-auto hover:underline" style={{ color: accentText(accent) }}>
|
||
All retreats
|
||
</Link>
|
||
</div>
|
||
)
|
||
}
|
||
|
||
/* One host reads as "Hosted by Northwest"; several read as a
|
||
sentence, so they're joined with commas and an "and" rather than
|
||
stacked. A host whose id didn't resolve to a route renders as
|
||
plain text, refHref returns null for that, because a dead link
|
||
is worse than a name. An organization host with a team set shows
|
||
the team instead, linked to the team's page. */
|
||
function HostList({ hosts, accent }: { hosts: EventHost[]; accent: string }) {
|
||
return (
|
||
<>
|
||
{hosts.map((host, index) => {
|
||
const to = host.team ? refHref('team', host.team.id) : refHref(host.kind, host.id, host.org_kind)
|
||
const name = host.team?.name ?? host.name
|
||
|
||
return (
|
||
<span key={`${host.kind}:${host.id}`}>
|
||
{index > 0 && (hosts.length > 2 ? ', ' : ' ')}
|
||
{index > 0 && index === hosts.length - 1 && 'and '}
|
||
{to ? (
|
||
<Link
|
||
to={to}
|
||
className="font-medium hover:underline"
|
||
style={{ color: accentText(accent) }}
|
||
>
|
||
{name}
|
||
</Link>
|
||
) : (
|
||
<span className="font-medium">{name}</span>
|
||
)}
|
||
</span>
|
||
)
|
||
})}
|
||
</>
|
||
)
|
||
}
|
||
|
||
/* date_label is what a card shows and is free text, "March/April
|
||
2026" is legitimate. This is only the fallback for an event that
|
||
has dates and no label. */
|
||
function dateRange(start?: string | null, end?: string | null): string | null {
|
||
if (!start) return null
|
||
const from = new Date(`${start}T00:00:00`)
|
||
if (Number.isNaN(from.getTime())) return start
|
||
|
||
const full: Intl.DateTimeFormatOptions = {
|
||
month: 'long',
|
||
day: 'numeric',
|
||
year: 'numeric',
|
||
}
|
||
|
||
if (!end || end === start) return from.toLocaleDateString(undefined, full)
|
||
|
||
const to = new Date(`${end}T00:00:00`)
|
||
if (Number.isNaN(to.getTime())) return from.toLocaleDateString(undefined, full)
|
||
|
||
const sameYear = from.getFullYear() === to.getFullYear()
|
||
const sameMonth = sameYear && from.getMonth() === to.getMonth()
|
||
|
||
const left = from.toLocaleDateString(
|
||
undefined,
|
||
sameMonth
|
||
? { month: 'long', day: 'numeric' }
|
||
: sameYear
|
||
? { month: 'long', day: 'numeric' }
|
||
: full,
|
||
)
|
||
|
||
return `${left} – ${to.toLocaleDateString(undefined, full)}`
|
||
}
|
||
|
||
/* ── v_event_people → PeopleTiles groups ─────────────────────── */
|
||
|
||
function peopleGroups(people: EventPerson[], accent: string): PeopleGroupInput[] {
|
||
if (!people.length) return []
|
||
|
||
const byRole = new Map<string, EventPerson[]>()
|
||
for (const person of people) {
|
||
const role = person.role || 'attendee'
|
||
const list = byRole.get(role)
|
||
if (list) list.push(person)
|
||
else byRole.set(role, [person])
|
||
}
|
||
|
||
// Known roles in billing order, then anything the CHECK has
|
||
// gained since this file was written.
|
||
const roles = [
|
||
...ROLE_ORDER.filter((role) => byRole.has(role)),
|
||
...[...byRole.keys()].filter((role) => !ROLE_ORDER.includes(role as never)),
|
||
]
|
||
|
||
return roles.map((role) => ({
|
||
id: `role-${role}`,
|
||
label: ROLE_LABEL[role] ?? capitalize(role),
|
||
accent,
|
||
people: (byRole.get(role) ?? []).map((person) => ({
|
||
id: person.person_id,
|
||
name: person.display_name,
|
||
title: person.title,
|
||
tagline: person.tagline,
|
||
pronouns: person.pronouns,
|
||
// PeopleTiles resolves a bare filename itself; this is here
|
||
// so a hand-written entry elsewhere can't diverge.
|
||
photo: mediaUrl(person.photo),
|
||
})),
|
||
}))
|
||
}
|
||
|