Clean up code found in the audit
- Replace every em-dash in src and server/src with a colon, comma or hyphen - Give every relative import its file extension (.jsx imports of .tsx fixed) - Delete old-historyMock.ts, unused exports, unused CSS utilities, the unused @ alias and the fallback option nothing passed - One copy each of initials, capitalize, byName and the server's marks() - Move the organization, chapter and event hooks from src/data to src/lib - Schema sync always throws on a mismatch (strict was never turned off) - Replace the placeholder README Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
parent
4066e9ec61
commit
5274e09571
75 changed files with 282 additions and 688 deletions
|
|
@ -1,5 +1,5 @@
|
|||
// Site-wide announcement banner. Set `enabled: false` to hide it entirely.
|
||||
// Bump `id` whenever the message changes — that re-shows the banner to
|
||||
// Bump `id` whenever the message changes, that re-shows the banner to
|
||||
// people who dismissed the previous one.
|
||||
|
||||
export const SITE_BANNER = {
|
||||
|
|
|
|||
|
|
@ -1,146 +0,0 @@
|
|||
/* ═══════════════════════════════════════════════════════════════
|
||||
LOCAL CHAPTER DATA
|
||||
|
||||
The chapter map's view of the organization list. Regions and
|
||||
chapters are the same table and the same endpoint; this hook
|
||||
reshapes them into what a map needs — slices per tile, counts
|
||||
per tile, chapters grouped by region.
|
||||
|
||||
Its return shape is unchanged from the version that called
|
||||
/regions and /chapters, so LocalChapters didn't have to move.
|
||||
|
||||
Two things live elsewhere:
|
||||
|
||||
the tile grid src/data/mapGrid.ts. Where a state sits never
|
||||
changes, so it isn't worth a round trip.
|
||||
|
||||
the fetch src/data/organizations.ts. One endpoint for
|
||||
every kind, so a section listing regions and
|
||||
a section listing partners read alike.
|
||||
═══════════════════════════════════════════════════════════════ */
|
||||
|
||||
import { useMemo } from "react";
|
||||
|
||||
import {
|
||||
areasSentence,
|
||||
initialsFor,
|
||||
useOrganizations,
|
||||
} from "./organizations.ts";
|
||||
import {
|
||||
areaForChapter,
|
||||
buildAreaSlices,
|
||||
countChaptersByArea,
|
||||
} from "./mapGrid.ts";
|
||||
|
||||
const byName = (a, b) => a.name.localeCompare(b.name);
|
||||
|
||||
export { initialsFor };
|
||||
|
||||
export function useCommunity() {
|
||||
const regionsQuery = useOrganizations("region");
|
||||
const chaptersQuery = useOrganizations("chapter");
|
||||
|
||||
const rawRegions = regionsQuery.organizations;
|
||||
const rawChapters = chaptersQuery.organizations;
|
||||
|
||||
return useMemo(() => {
|
||||
/* ── Regions ───────────────────────────────────────────────
|
||||
scope and map_note are lifted out of `details` so the rest
|
||||
of the app doesn't have to know they're kind-specific. */
|
||||
const regions = rawRegions.map((org) => ({
|
||||
...org,
|
||||
scope: org.details?.scope ?? null,
|
||||
map_note: org.details?.map_note ?? null,
|
||||
areas: org.details?.areas ?? [],
|
||||
}));
|
||||
|
||||
// Flat, because buildAreaSlices takes it that way.
|
||||
const regionAreas = regions.flatMap((region) =>
|
||||
region.areas.map((area) => ({ ...area, region_id: region.id })),
|
||||
);
|
||||
|
||||
/* ── Chapters, each tagged with the tile it lights up ──────
|
||||
The database stores a real address; which square that maps
|
||||
to is a rendering question, answered here once rather than
|
||||
at every call site. */
|
||||
const chapters = rawChapters.map((org) => ({
|
||||
...org,
|
||||
region_id: org.details?.region_id ?? null,
|
||||
region_name: org.details?.region_name ?? null,
|
||||
region_color: org.details?.region_color ?? null,
|
||||
meets: org.details?.meets ?? null,
|
||||
started: org.details?.started ?? null,
|
||||
area_code: areaForChapter(org),
|
||||
}));
|
||||
|
||||
const regionById = Object.fromEntries(regions.map((r) => [r.id, r]));
|
||||
|
||||
/* { WA: [{ regionId, name, color, share, edge, note }], ... }
|
||||
California comes back as two half slices rather than a
|
||||
primary and a remainder, so the SVG never does arithmetic. */
|
||||
const slices = buildAreaSlices(regionAreas, regions);
|
||||
|
||||
const chapterCounts = countChaptersByArea(chapters);
|
||||
|
||||
const chaptersByRegion = new Map();
|
||||
for (const chapter of chapters) {
|
||||
if (!chapter.region_id) continue;
|
||||
const list = chaptersByRegion.get(chapter.region_id);
|
||||
if (list) list.push(chapter);
|
||||
else chaptersByRegion.set(chapter.region_id, [chapter]);
|
||||
}
|
||||
|
||||
const chaptersIn = (regionId) => chaptersByRegion.get(regionId) ?? [];
|
||||
|
||||
/* Sorted by name to match how the page has always shown them,
|
||||
rather than by the sort_order the API returns. */
|
||||
const domestic = regions.filter((r) => r.scope === "domestic").sort(byName);
|
||||
const international = regions
|
||||
.filter((r) => r.scope === "international")
|
||||
.sort(byName);
|
||||
const virtual = regions.filter((r) => r.scope === "virtual");
|
||||
|
||||
const areasLabelFor = (regionId) =>
|
||||
areasSentence(regionById[regionId]?.areas ?? []);
|
||||
|
||||
const subtextFor = (region) => {
|
||||
const label = areasLabelFor(region.id);
|
||||
if (label && region.map_note) return `${label} · ${region.map_note}`;
|
||||
return label || region.map_note || "";
|
||||
};
|
||||
|
||||
const regionsForArea = (areaCode) =>
|
||||
(slices[areaCode] ?? [])
|
||||
.map((slice) => regionById[slice.regionId])
|
||||
.filter(Boolean);
|
||||
|
||||
return {
|
||||
loading: regionsQuery.loading || chaptersQuery.loading,
|
||||
error: regionsQuery.error ?? chaptersQuery.error,
|
||||
|
||||
regions,
|
||||
regionAreas,
|
||||
regionById,
|
||||
domestic,
|
||||
international,
|
||||
virtual,
|
||||
|
||||
chapters,
|
||||
chaptersIn,
|
||||
|
||||
slices,
|
||||
chapterCounts,
|
||||
regionsForArea,
|
||||
|
||||
areasLabelFor,
|
||||
subtextFor,
|
||||
};
|
||||
}, [
|
||||
rawRegions,
|
||||
rawChapters,
|
||||
regionsQuery.loading,
|
||||
regionsQuery.error,
|
||||
chaptersQuery.loading,
|
||||
chaptersQuery.error,
|
||||
]);
|
||||
}
|
||||
|
|
@ -1,92 +0,0 @@
|
|||
/* ═══════════════════════════════════════════════════════════════
|
||||
EVENT DATA
|
||||
|
||||
One request, filtered per band. The Retreats page has three
|
||||
bands of events, and all three call this hook — the cache in
|
||||
api.ts keys on the path, so they share a single fetch and each
|
||||
narrows the result to what it shows.
|
||||
|
||||
useEvents({ scope: "national" }) one band
|
||||
useEvents({ host: "northwest" }) one host's events
|
||||
useEvents({ status: "upcoming" }) a home page strip
|
||||
useEvents({ type: "workshop" }) one kind, wherever it is
|
||||
useEvents({ type: ["class", "workshop"] })
|
||||
useEvents() everything
|
||||
|
||||
`scope` and `type` are different questions and stack rather
|
||||
than overlap: the scope is whose gathering an event is, the type
|
||||
is what kind of gathering it is. A regional class matches both
|
||||
{ scope: "regional" } and { type: "class" }.
|
||||
|
||||
The event_scopes rows come back alongside, for anything that
|
||||
offers a scope filter.
|
||||
|
||||
No fallback. An empty list on a failed request would read as
|
||||
"nothing scheduled" when the truth is "the server is down", so
|
||||
the error comes back and each caller says so.
|
||||
|
||||
Filtering here rather than in the query keeps the endpoint to
|
||||
one cached response. At a few dozen events that's the right
|
||||
trade; if the list ever runs to hundreds, move the filters into
|
||||
the URL and let each become its own cache entry.
|
||||
═══════════════════════════════════════════════════════════════ */
|
||||
|
||||
import { useMemo } from "react";
|
||||
|
||||
import { useResource } from "../lib/useResource.ts";
|
||||
|
||||
/* One shared empty list, so a memo keyed on `scopes` doesn't
|
||||
restart on every render before the data arrives. */
|
||||
const NO_SCOPES: any[] = [];
|
||||
|
||||
export function useEvents({ scope, host, status, type }: any = {}) {
|
||||
const { data, error, loading } = useResource("/events");
|
||||
|
||||
const all = data?.events;
|
||||
const scopes = data?.scopes ?? NO_SCOPES;
|
||||
|
||||
/* An array prop is a new identity on every render, which would
|
||||
restart the memo each time. Joining it gives the dependency
|
||||
list something stable to compare. */
|
||||
const typeKey = Array.isArray(type) ? type.join(",") : (type ?? "");
|
||||
|
||||
const events = useMemo(() => {
|
||||
let list = all ?? [];
|
||||
if (scope) list = list.filter(e => e.scope_id === scope);
|
||||
// `host` is an organization or a person slug, and an event can
|
||||
// have several of either — co-hosting puts one event on both
|
||||
// hosts' lists, which is the point.
|
||||
if (host) list = list.filter(e => e.hosts?.some(h => h.id === host));
|
||||
if (status) list = list.filter(e => e.status === status);
|
||||
if (typeKey) {
|
||||
const wanted = new Set(typeKey.split(","));
|
||||
list = list.filter(e => wanted.has(e.event_type));
|
||||
}
|
||||
return list;
|
||||
}, [all, scope, host, status, typeKey]);
|
||||
|
||||
return { events, scopes, loading, error };
|
||||
}
|
||||
|
||||
/* Past and upcoming, split. `status` arrives already resolved — the
|
||||
explicit value when there is one, otherwise derived from ends_on
|
||||
— so nothing here needs to know which of the two it got. */
|
||||
export function splitByStatus(events: any[] = []) {
|
||||
const upcoming: any[] = [];
|
||||
const past: any[] = [];
|
||||
|
||||
for (const event of events) {
|
||||
(event.status === "past" ? past : upcoming).push(event);
|
||||
}
|
||||
|
||||
return { upcoming, past };
|
||||
}
|
||||
|
||||
/* Which of the declared types a list actually contains, in
|
||||
EVENT_TYPES order rather than whatever order the rows arrived
|
||||
in. A section with one type has nothing to filter, which is what
|
||||
lets the chip bar hide itself. */
|
||||
export function typesPresent(events: any[] = [], declared: any[] = []) {
|
||||
const seen = new Set(events.map(e => e.event_type));
|
||||
return declared.filter(entry => seen.has(entry.id));
|
||||
}
|
||||
|
|
@ -3,7 +3,7 @@
|
|||
|
||||
Used by the public form (to render the tiles) and the admin
|
||||
triage view (to label them). The ids must match TYPES in
|
||||
server/src/routes/feedback.js — that list stays separate because
|
||||
server/src/routes/feedback.js, that list stays separate because
|
||||
the server isn't in this workspace, and it's the thing that
|
||||
decides what's storable.
|
||||
|
||||
|
|
|
|||
|
|
@ -2,7 +2,7 @@
|
|||
* Decade headers for the history page.
|
||||
*
|
||||
* Not in the database on purpose. There are four of them, they change
|
||||
* about never, and they're editorial voice rather than record — the same
|
||||
* about never, and they're editorial voice rather than record, the same
|
||||
* reasoning that keeps the map grid config in code. A table for four
|
||||
* rows that nobody edits is a migration and an admin page for nothing.
|
||||
*
|
||||
|
|
@ -12,7 +12,7 @@
|
|||
* date is ever revised.
|
||||
*/
|
||||
|
||||
import type { DecadeMeta } from '../lib/timeline'
|
||||
import type { DecadeMeta } from '../lib/timeline.ts'
|
||||
|
||||
export const HISTORY_DECADES: DecadeMeta[] = [
|
||||
{
|
||||
|
|
|
|||
|
|
@ -3,7 +3,7 @@
|
|||
|
||||
Pure layout. Where each tile sits, what it's called, and how to
|
||||
work out which tile a chapter belongs to. None of this is in the
|
||||
database because none of it changes — Rhode Island will not be
|
||||
database because none of it changes, Rhode Island will not be
|
||||
moving, and no admin form should offer to move it.
|
||||
|
||||
What IS in the database is which regions cover which areas, and
|
||||
|
|
@ -13,8 +13,6 @@
|
|||
as regions with no tile.
|
||||
═══════════════════════════════════════════════════════════════ */
|
||||
|
||||
export const GRID_COLS = 13;
|
||||
export const GRID_ROWS = 7;
|
||||
|
||||
/* ── States ────────────────────────────────────────────────────
|
||||
[column, row], both 1-based. A tile grid rather than true
|
||||
|
|
@ -86,8 +84,8 @@ export const AREAS = Object.freeze([
|
|||
export const AREA_BY_CODE = Object.fromEntries(AREAS.map((a) => [a.code, a]));
|
||||
|
||||
/* ── Which tile a chapter sits on ──────────────────────────────
|
||||
The database stores a real address — state_code for US, and a
|
||||
country code otherwise — rather than a tile name. This is the
|
||||
The database stores a real address, state_code for US, and a
|
||||
country code otherwise, rather than a tile name. This is the
|
||||
one place that translates between the two, so adding a Mexico
|
||||
band later means a line here and nothing in SQL.
|
||||
|
||||
|
|
@ -115,7 +113,7 @@ export function areaForChapter(chapter) {
|
|||
A region with share 1 and no edge fills the tile. A shared
|
||||
tile has one row per region, each declaring its own slice, so
|
||||
California is two entries of 0.5 rather than a primary plus a
|
||||
remainder — no arithmetic, and the renderer doesn't need to
|
||||
remainder, no arithmetic, and the renderer doesn't need to
|
||||
know which region "really" owns it.
|
||||
|
||||
regionAreas [{ region_id, area_code, share, edge, note }]
|
||||
|
|
@ -165,10 +163,3 @@ export function countChaptersByArea(chapters: any[] = []) {
|
|||
from the row rather than being looked up in a splits table and
|
||||
branched on whether this region is the primary.
|
||||
───────────────────────────────────────────────────────────── */
|
||||
export function areasLabel(regionId, regionAreas: any[] = []) {
|
||||
return regionAreas
|
||||
.filter((row) => row.region_id === regionId && row.area_code !== "CANADA")
|
||||
.map((row) => (row.note ? `${row.area_code} (${row.note})` : row.area_code))
|
||||
.sort()
|
||||
.join(", ");
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1,299 +0,0 @@
|
|||
/**
|
||||
* PLACEHOLDER DATA — delete this file once `GET /api/history` lands.
|
||||
*
|
||||
* Shaped exactly like the aggregation route's payload, so swapping it out
|
||||
* is a two-line change in History.tsx.
|
||||
*
|
||||
* Note what is and isn't here. Entries that point at a record carry a
|
||||
* `ref` and little else: no venue, no host name, no copy that also lives
|
||||
* in `events`. The few that do carry a title are overriding it on
|
||||
* purpose. Titles and blurbs below are invented scaffolding, not real NGU
|
||||
* history — replace them before anyone sees this.
|
||||
*
|
||||
* Decade headers are not here — they live in historyDecades.ts and stay
|
||||
* in code even after the API lands.
|
||||
*
|
||||
* Upcoming items are not flagged. `partitionByDate` decides what's
|
||||
* upcoming by comparing dates to the wall clock, so nothing here needs
|
||||
* editing as dates pass.
|
||||
*/
|
||||
|
||||
import type { TimelineItem } from '../lib/timeline'
|
||||
|
||||
export const MOCK_ITEMS: TimelineItem[] = [
|
||||
// ——— Upcoming (relative to the wall clock, not a flag) ———
|
||||
{
|
||||
id: 'tl-0001',
|
||||
date: '2027-06',
|
||||
precision: 'month',
|
||||
kind: 'event',
|
||||
title: 'Summer Conference 2027',
|
||||
meta: 'Unity Village, MO',
|
||||
ref: { kind: 'event', id: 'summer-2027' },
|
||||
logo: { file: 'summer-conference.svg', kind: 'event' },
|
||||
},
|
||||
{
|
||||
id: 'tl-0002',
|
||||
date: '2026-11-14',
|
||||
precision: 'day',
|
||||
kind: 'event',
|
||||
title: 'Fall Regional Rally',
|
||||
meta: 'Southeast',
|
||||
ref: { kind: 'event', id: 'fall-rally-2026' },
|
||||
logo: { file: 'regional-rally.svg', kind: 'event' },
|
||||
},
|
||||
{
|
||||
id: 'tl-0003',
|
||||
date: '2026-10-03',
|
||||
precision: 'day',
|
||||
kind: 'event',
|
||||
title: 'Chapter Leads Intensive',
|
||||
meta: 'Online',
|
||||
ref: { kind: 'event', id: 'leads-intensive-2026' },
|
||||
},
|
||||
|
||||
// ——— 2020s ———
|
||||
{
|
||||
id: 'tl-0010',
|
||||
date: '2026-03',
|
||||
precision: 'month',
|
||||
kind: 'organization',
|
||||
title: 'Twentieth chapter chartered',
|
||||
blurb:
|
||||
'The first new charter in the region since 2017, started by three people who met at a rally two summers earlier.',
|
||||
featured: true,
|
||||
ref: { kind: 'organization', id: 'boise', orgKind: 'chapter' },
|
||||
logo: { file: 'boise.svg', kind: 'organization' },
|
||||
},
|
||||
{
|
||||
id: 'tl-0011',
|
||||
date: '2026-04-17',
|
||||
precision: 'day',
|
||||
kind: 'event',
|
||||
title: 'Spring Regional Rally',
|
||||
ref: { kind: 'event', id: 'spring-rally-2026' },
|
||||
logo: { file: 'regional-rally.svg', kind: 'event' },
|
||||
},
|
||||
{
|
||||
id: 'tl-0012',
|
||||
date: '2026-01',
|
||||
precision: 'month',
|
||||
kind: 'people',
|
||||
title: 'New leadership team seated',
|
||||
blurb: 'A four-person exec on a two-year term, the first under the 2024 bylaws.',
|
||||
ref: { kind: 'team', id: 'ngu-leadership' },
|
||||
team: { id: 'ngu-leadership', name: 'Leadership Team', orgId: 'ngu', orgName: 'NGU National' },
|
||||
people: [
|
||||
{ id: 'jane-doe', name: 'Jane Doe', title: 'Chair', photo: 'jane-doe.jpg' },
|
||||
{ id: 'sam-ruiz', name: 'Sam Ruiz', title: 'Vice Chair', photo: 'sam-ruiz.jpg' },
|
||||
{ id: 'ada-mensah', name: 'Ada Mensah', title: 'Secretary' },
|
||||
{ id: 'tom-baird', name: 'Tom Baird', title: 'Treasurer', photo: 'tom-baird.jpg' },
|
||||
],
|
||||
},
|
||||
{
|
||||
id: 'tl-0013',
|
||||
date: '2025-12-28',
|
||||
precision: 'day',
|
||||
kind: 'event',
|
||||
title: 'Winter Gathering',
|
||||
ref: { kind: 'event', id: 'winter-gathering-2025' },
|
||||
},
|
||||
{
|
||||
id: 'tl-0014',
|
||||
date: '2025-07-19',
|
||||
precision: 'day',
|
||||
kind: 'award',
|
||||
title: 'Service Award',
|
||||
meta: 'Presented to the Southeast chapter leads',
|
||||
ref: { kind: 'award', id: 'service' },
|
||||
logo: { file: 'service-award.svg', kind: 'award' },
|
||||
},
|
||||
{
|
||||
id: 'tl-0015',
|
||||
date: '2025-07-17',
|
||||
precision: 'day',
|
||||
kind: 'event',
|
||||
title: 'Summer Conference',
|
||||
meta: 'Three days, 140 attendees',
|
||||
ref: { kind: 'event', id: 'summer-2025' },
|
||||
logo: { file: 'summer-conference.svg', kind: 'event' },
|
||||
},
|
||||
{
|
||||
id: 'tl-0016',
|
||||
date: '2025',
|
||||
precision: 'year',
|
||||
kind: 'milestone',
|
||||
title: 'Photo archive digitized',
|
||||
blurb: 'Roughly 4,000 images from 2003 onward, scanned by volunteers.',
|
||||
href: 'https://archive.nextgenerationofunity.org',
|
||||
},
|
||||
{
|
||||
id: 'tl-0017',
|
||||
date: '2024-09',
|
||||
precision: 'month',
|
||||
kind: 'milestone',
|
||||
title: 'Bylaws rewritten',
|
||||
blurb:
|
||||
'Term limits, a defined handoff window, and the first written process for chartering a chapter.',
|
||||
featured: true,
|
||||
},
|
||||
{
|
||||
id: 'tl-0018',
|
||||
date: '2024-07-11',
|
||||
precision: 'day',
|
||||
kind: 'event',
|
||||
title: 'Summer Conference',
|
||||
ref: { kind: 'event', id: 'summer-2024' },
|
||||
logo: { file: 'summer-conference.svg', kind: 'event' },
|
||||
},
|
||||
{
|
||||
id: 'tl-0019',
|
||||
date: '2024-07-13',
|
||||
precision: 'day',
|
||||
kind: 'award',
|
||||
title: 'Emerging Leader Award',
|
||||
meta: 'First year the award was given',
|
||||
ref: { kind: 'award', id: 'emerging-leader' },
|
||||
logo: { file: 'emerging-leader.svg', kind: 'award' },
|
||||
},
|
||||
{
|
||||
id: 'tl-0020',
|
||||
date: '2022-06',
|
||||
precision: 'month',
|
||||
kind: 'event',
|
||||
title: 'First in-person rally since 2019',
|
||||
blurb: 'Sixty-one people, most of whom had only ever met on a video call.',
|
||||
featured: true,
|
||||
ref: { kind: 'event', id: 'return-rally-2022' },
|
||||
},
|
||||
{
|
||||
id: 'tl-0021',
|
||||
date: '2021-08',
|
||||
precision: 'month',
|
||||
kind: 'event',
|
||||
title: 'Online Summer Intensive',
|
||||
meta: 'Six sessions across two weeks',
|
||||
ref: { kind: 'event', id: 'online-intensive-2021' },
|
||||
},
|
||||
{
|
||||
id: 'tl-0022',
|
||||
date: '2020-03',
|
||||
precision: 'month',
|
||||
kind: 'milestone',
|
||||
title: 'All gatherings suspended',
|
||||
blurb: 'Weekly online rooms started the following week and ran for 118 weeks.',
|
||||
},
|
||||
|
||||
// ——— 2010s ———
|
||||
{
|
||||
id: 'tl-0030',
|
||||
date: '2018-05',
|
||||
precision: 'month',
|
||||
kind: 'organization',
|
||||
title: 'Eighth region recognized',
|
||||
featured: true,
|
||||
ref: { kind: 'organization', id: 'northwest', orgKind: 'region' },
|
||||
logo: { file: 'northwest.svg', kind: 'organization' },
|
||||
},
|
||||
{
|
||||
id: 'tl-0031',
|
||||
date: '2018-07-20',
|
||||
precision: 'day',
|
||||
kind: 'event',
|
||||
title: 'Summer Conference',
|
||||
ref: { kind: 'event', id: 'summer-2018' },
|
||||
logo: { file: 'summer-conference.svg', kind: 'event' },
|
||||
},
|
||||
{
|
||||
id: 'tl-0032',
|
||||
date: '2016-02',
|
||||
precision: 'month',
|
||||
kind: 'people',
|
||||
title: 'Retreat Team formed',
|
||||
blurb:
|
||||
'Programming had been whoever volunteered. This made it a standing team with a handoff.',
|
||||
ref: { kind: 'team', id: 'ngu-retreat-team' },
|
||||
team: { id: 'ngu-retreat-team', name: 'Retreat Team', orgId: 'ngu', orgName: 'NGU National' },
|
||||
people: [
|
||||
{ id: 'marcus-hale', name: 'Marcus Hale', title: 'Founding lead', photo: 'marcus-hale.jpg' },
|
||||
{ id: 'priya-nair', name: 'Priya Nair', photo: 'priya-nair.jpg' },
|
||||
],
|
||||
},
|
||||
{
|
||||
id: 'tl-0033',
|
||||
date: '2015-07',
|
||||
precision: 'month',
|
||||
kind: 'award',
|
||||
title: 'First Service Award presented',
|
||||
blurb: 'Created to name the work that had been going unnamed for a decade.',
|
||||
featured: true,
|
||||
ref: { kind: 'award', id: 'service' },
|
||||
logo: { file: 'service-award.svg', kind: 'award' },
|
||||
},
|
||||
{
|
||||
id: 'tl-0034',
|
||||
date: '2015-02',
|
||||
precision: 'month',
|
||||
kind: 'milestone',
|
||||
title: 'Shared calendar goes live',
|
||||
blurb: 'Regions stop scheduling on top of each other.',
|
||||
},
|
||||
{
|
||||
id: 'tl-0035',
|
||||
date: '2012-06',
|
||||
precision: 'month',
|
||||
kind: 'event',
|
||||
title: 'Summer Conference',
|
||||
meta: 'The year attendance first passed 100',
|
||||
ref: { kind: 'event', id: 'summer-2012' },
|
||||
logo: { file: 'summer-conference.svg', kind: 'event' },
|
||||
},
|
||||
{
|
||||
id: 'tl-0036',
|
||||
date: '2012',
|
||||
precision: 'year',
|
||||
kind: 'milestone',
|
||||
title: 'Adopted the name Next Generation of Unity',
|
||||
},
|
||||
|
||||
// ——— 2000s ———
|
||||
{
|
||||
id: 'tl-0040',
|
||||
date: '2009',
|
||||
precision: 'year',
|
||||
kind: 'milestone',
|
||||
title: 'Four regions drawn on a map for the first time',
|
||||
},
|
||||
{
|
||||
id: 'tl-0041',
|
||||
date: '2005-08',
|
||||
precision: 'month',
|
||||
kind: 'milestone',
|
||||
title: 'The gathering becomes annual',
|
||||
blurb: 'Before this it happened when someone had the energy to organize it.',
|
||||
featured: true,
|
||||
},
|
||||
{
|
||||
id: 'tl-0042',
|
||||
date: '2002-08',
|
||||
precision: 'month',
|
||||
kind: 'event',
|
||||
title: 'First young adult retreat',
|
||||
meta: 'Nineteen attendees',
|
||||
blurb:
|
||||
'Organized over six weeks at a borrowed retreat center. Everything else on this page follows from it.',
|
||||
featured: true,
|
||||
ref: { kind: 'event', id: 'first-retreat-2002' },
|
||||
},
|
||||
|
||||
// ——— Pre-program ———
|
||||
{
|
||||
id: 'tl-0050',
|
||||
date: '1997',
|
||||
precision: 'year',
|
||||
kind: 'milestone',
|
||||
title: 'Regional youth programs running independently',
|
||||
blurb:
|
||||
'Not NGU, and not connected to each other — but the people who started NGU came out of these.',
|
||||
},
|
||||
]
|
||||
|
|
@ -1,90 +0,0 @@
|
|||
/* ═══════════════════════════════════════════════════════════════
|
||||
ORGANIZATIONS
|
||||
|
||||
Regions, chapters, partners and NGU itself are one table and one
|
||||
endpoint. Anything that lists organizations reads them the same
|
||||
way and filters by kind:
|
||||
|
||||
const { organizations } = useOrganizations("region");
|
||||
const { organizations } = useOrganizations("partner");
|
||||
const { organizations } = useOrganizations(); // all
|
||||
|
||||
Every organization has the same card surface — name, colour,
|
||||
logo, description, links. What differs by kind sits under
|
||||
`details`, so a list component can render the common parts
|
||||
without knowing what it's holding:
|
||||
|
||||
region { scope, map_note, areas[], chapters[] }
|
||||
chapter { region_id, region_name, region_color, meets, started }
|
||||
partner {}
|
||||
|
||||
Each kind is a separate request path, so the cache in api.ts
|
||||
keys them apart and two sections asking for regions share one
|
||||
fetch.
|
||||
═══════════════════════════════════════════════════════════════ */
|
||||
|
||||
import { useResource } from "../lib/useResource.ts";
|
||||
|
||||
const EMPTY = { organizations: [] };
|
||||
|
||||
export function useOrganizations(kind) {
|
||||
const path = kind
|
||||
? `/organizations?kind=${encodeURIComponent(kind)}`
|
||||
: "/organizations";
|
||||
|
||||
const { data, error, loading } = useResource(path);
|
||||
|
||||
return {
|
||||
organizations: data?.organizations ?? [],
|
||||
loading,
|
||||
error,
|
||||
};
|
||||
}
|
||||
|
||||
/* ── Where an organization's page lives ────────────────────────
|
||||
One place to change when routes move. Kinds with no page of
|
||||
their own return null, and a list should render no link rather
|
||||
than a dead one.
|
||||
───────────────────────────────────────────────────────────── */
|
||||
|
||||
const PATHS = {
|
||||
region: "/regions",
|
||||
chapter: "/chapters",
|
||||
partner: "/partners",
|
||||
};
|
||||
|
||||
export function orgPath(org) {
|
||||
const base = PATHS[org?.kind];
|
||||
return base ? `${base}/${org.id}` : null;
|
||||
}
|
||||
|
||||
/* ── "AK, ID, MT, OR, UT (Salt Lake City area), WA" ────────────
|
||||
The areas a region covers, annotated where it holds only part
|
||||
of one. Canada is a band on the map rather than somewhere you'd
|
||||
list, so it's left out of the sentence.
|
||||
|
||||
The note comes straight off the row. The old statesLabel had to
|
||||
work out whether this region was the primary or the secondary of
|
||||
a split before it knew which note applied; there's no such thing
|
||||
any more.
|
||||
───────────────────────────────────────────────────────────── */
|
||||
|
||||
export function areasSentence(areas: any[] = []) {
|
||||
return areas
|
||||
.filter((area) => area.area_code !== "CANADA")
|
||||
.map((area) => (area.note ? `${area.area_code} (${area.note})` : area.area_code))
|
||||
.sort()
|
||||
.join(", ");
|
||||
}
|
||||
|
||||
/* Initials for a card with no logo. "NGU Lynnwood" → "NL", dropping
|
||||
the org prefix so every card doesn't read "NG". */
|
||||
export function initialsFor(name = "") {
|
||||
return name
|
||||
.replace(/^NGU\s+/i, "")
|
||||
.split(/\s+/)
|
||||
.filter(Boolean)
|
||||
.slice(0, 2)
|
||||
.map((word) => word[0].toUpperCase())
|
||||
.join("");
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue