Call local chapters groups, everywhere
The organization kind is 'group', its side table is groups, pages live at /groups/<id> and the Community page's section is #groups. Migration 052 converts existing databases: the kind and the tables whose CHECKs name chapters are rebuilt, the front page count and request category follow, and the site's own /chapters/ and #chapters links in records are rewritten. Request files now go in Requests/Groups on the shared drive. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
parent
175a18976d
commit
38aff34c97
42 changed files with 473 additions and 254 deletions
|
|
@ -28,7 +28,7 @@ const STAT_SOURCES = [
|
|||
["manual", "Print Value Field"],
|
||||
["years_since", "Years Since Value"],
|
||||
["regions", "Count: regions"],
|
||||
["chapters", "Count: chapters"],
|
||||
["groups", "Count: groups"],
|
||||
["partners", "Count: partners"],
|
||||
["events_held", "Count: past events"],
|
||||
["retreats_held", "Count: past retreats"],
|
||||
|
|
|
|||
|
|
@ -20,7 +20,7 @@ export const organizations = {
|
|||
{ key: "is_listed", label: "Listed", widget: "bool" },
|
||||
],
|
||||
filters: [
|
||||
{ key: "kind", label: "Kind", options: ["national", "region", "chapter", "partner"] },
|
||||
{ key: "kind", label: "Kind", options: ["national", "region", "group", "partner"] },
|
||||
{ key: "is_published", label: "Published", options: [["1", "Live"], ["0", "Hidden"]] },
|
||||
{ key: "is_listed", label: "Listed", options: [["1", "Listed"], ["0", "Link only"]] },
|
||||
],
|
||||
|
|
@ -34,7 +34,7 @@ export const organizations = {
|
|||
path: "kind",
|
||||
label: "Kind",
|
||||
widget: "select",
|
||||
options: ["national", "region", "chapter", "partner"],
|
||||
options: ["national", "region", "group", "partner"],
|
||||
required: true,
|
||||
help: "Changing this swaps which extra fields apply",
|
||||
},
|
||||
|
|
@ -60,18 +60,18 @@ export const organizations = {
|
|||
],
|
||||
},
|
||||
{
|
||||
legend: "Chapter",
|
||||
when: { path: "kind", value: "chapter" },
|
||||
legend: "Group",
|
||||
when: { path: "kind", value: "group" },
|
||||
fields: [
|
||||
{
|
||||
path: "chapter.region_id",
|
||||
path: "group.region_id",
|
||||
label: "Region",
|
||||
widget: "select",
|
||||
optionsFrom: "regions",
|
||||
blankLabel: "Default: none",
|
||||
},
|
||||
{ path: "chapter.meets", label: "Meets", help: "2nd Sundays, 6:00pm" },
|
||||
{ path: "chapter.started", label: "Started", help: "Since 2021" },
|
||||
{ path: "group.meets", label: "Meets", help: "2nd Sundays, 6:00pm" },
|
||||
{ path: "group.started", label: "Started", help: "Since 2021" },
|
||||
],
|
||||
},
|
||||
{ legend: "Place", fields: PLACE_FIELDS },
|
||||
|
|
|
|||
|
|
@ -5,7 +5,7 @@
|
|||
never sends paths, it sends `{ kind, id }` and, for an
|
||||
organization, the `org_kind` that decides which of the three
|
||||
routes a slug belongs to. Deciding that in each component is how
|
||||
/regions/x and /chapters/x end up both existing for the same
|
||||
/regions/x and /groups/x end up both existing for the same
|
||||
record, and how the history timeline ended up emitting /event/:id
|
||||
while the router only knew /retreats/:id.
|
||||
|
||||
|
|
@ -30,16 +30,16 @@
|
|||
detailPath() returns null for it, so useRecord never fetches it.
|
||||
═══════════════════════════════════════════════════════════════ */
|
||||
|
||||
export type OrgKind = 'national' | 'region' | 'chapter' | 'partner'
|
||||
export type OrgKind = 'national' | 'region' | 'group' | 'partner'
|
||||
export type RefKind = 'event' | 'organization' | 'team' | 'award' | 'person'
|
||||
|
||||
/* A region, a chapter and a partner read as different things to a
|
||||
/* A region, a group and a partner read as different things to a
|
||||
visitor even though they are one table, so they get one route
|
||||
each. 'national' is NGU itself, one record, no listing to sit
|
||||
under, so it falls through to the generic path. */
|
||||
const ORG_BASE: Record<string, string> = {
|
||||
region: '/regions',
|
||||
chapter: '/chapters',
|
||||
group: '/groups',
|
||||
partner: '/partners',
|
||||
national: '/organizations',
|
||||
}
|
||||
|
|
@ -152,14 +152,14 @@ export function refHref(
|
|||
}
|
||||
}
|
||||
|
||||
/* Where "back" goes from a record page. A chapter belongs to
|
||||
/* Where "back" goes from a record page. A group belongs to
|
||||
/community, a retreat to /retreats. */
|
||||
export function orgListHref(kind?: string | null): { to: string; label: string } {
|
||||
switch (kind) {
|
||||
case 'region':
|
||||
return { to: '/community#regions', label: 'All regions' }
|
||||
case 'chapter':
|
||||
return { to: '/community#chapters', label: 'All chapters' }
|
||||
case 'group':
|
||||
return { to: '/community#groups', label: 'All groups' }
|
||||
case 'partner':
|
||||
return { to: '/community#partners', label: 'All partner organizations' }
|
||||
default:
|
||||
|
|
|
|||
|
|
@ -1,7 +1,7 @@
|
|||
/* ═══════════════════════════════════════════════════════════════
|
||||
ORGANIZATIONS
|
||||
|
||||
Regions, chapters, partners and NGU itself are one table and one
|
||||
Regions, groups, partners and NGU itself are one table and one
|
||||
endpoint. Anything that lists organizations reads them the same
|
||||
way and filters by kind:
|
||||
|
||||
|
|
@ -14,8 +14,8 @@
|
|||
`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 }
|
||||
region { scope, map_note, areas[], groups[] }
|
||||
group { region_id, region_name, region_color, meets, started }
|
||||
partner {}
|
||||
|
||||
Each kind is a separate request path, so the cache in api.ts
|
||||
|
|
@ -47,7 +47,7 @@ export function useOrganizations(kind) {
|
|||
one for the rest (NGU itself) or a bad id.
|
||||
───────────────────────────────────────────────────────────── */
|
||||
|
||||
const WITH_PAGE = new Set(["region", "chapter", "partner"]);
|
||||
const WITH_PAGE = new Set(["region", "group", "partner"]);
|
||||
|
||||
export function orgPath(org) {
|
||||
return WITH_PAGE.has(org?.kind) && !isBadId(org.id) ? orgHref(org.id, org.kind) : null;
|
||||
|
|
|
|||
|
|
@ -7,7 +7,7 @@ import RequestLink from "../components/RequestLink.tsx";
|
|||
|
||||
A page is a list of sections, and a section is a view over data
|
||||
the database already holds, narrowed by a filter. The map of
|
||||
chapters and the vertical list of regions are the same rows seen
|
||||
groups and the vertical list of regions are the same rows seen
|
||||
two ways; the three bands of retreats are one view seen three
|
||||
times with a different filter each.
|
||||
|
||||
|
|
@ -24,8 +24,8 @@ import RequestLink from "../components/RequestLink.tsx";
|
|||
Toggle: EventCardsToggle,
|
||||
},
|
||||
request: { // optional button
|
||||
type: "chapter", // to the Request form
|
||||
label: "Add or update a chapter",
|
||||
type: "group", // to the Request form
|
||||
label: "Add or update a group",
|
||||
},
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -1,10 +1,10 @@
|
|||
/* ═══════════════════════════════════════════════════════════════
|
||||
useCommunity
|
||||
|
||||
The chapter map's view of the organization list (OrgList-Map).
|
||||
Regions and chapters are the same table and the same endpoint;
|
||||
The group map's view of the organization list (OrgList-Map).
|
||||
Regions and groups 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.
|
||||
counts per tile, groups grouped by region.
|
||||
|
||||
Two things live elsewhere:
|
||||
|
||||
|
|
@ -24,17 +24,17 @@ import {
|
|||
useOrganizations,
|
||||
} from "./organizations.ts";
|
||||
import {
|
||||
areaForChapter,
|
||||
areaForGroup,
|
||||
buildAreaSlices,
|
||||
countChaptersByArea,
|
||||
countGroupsByArea,
|
||||
} from "../data/mapGrid.ts";
|
||||
|
||||
export function useCommunity() {
|
||||
const regionsQuery = useOrganizations("region");
|
||||
const chaptersQuery = useOrganizations("chapter");
|
||||
const groupsQuery = useOrganizations("group");
|
||||
|
||||
const rawRegions = regionsQuery.organizations;
|
||||
const rawChapters = chaptersQuery.organizations;
|
||||
const rawGroups = groupsQuery.organizations;
|
||||
|
||||
return useMemo(() => {
|
||||
/* ── Regions ───────────────────────────────────────────────
|
||||
|
|
@ -52,18 +52,18 @@ export function useCommunity() {
|
|||
region.areas.map((area) => ({ ...area, region_id: region.id })),
|
||||
);
|
||||
|
||||
/* ── Chapters, each tagged with the tile it lights up ──────
|
||||
/* ── Groups, 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) => ({
|
||||
const groups = rawGroups.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),
|
||||
area_code: areaForGroup(org),
|
||||
}));
|
||||
|
||||
const regionById = Object.fromEntries(regions.map((r) => [r.id, r]));
|
||||
|
|
@ -73,17 +73,17 @@ export function useCommunity() {
|
|||
primary and a remainder, so the SVG never does arithmetic. */
|
||||
const slices = buildAreaSlices(regionAreas, regions);
|
||||
|
||||
const chapterCounts = countChaptersByArea(chapters);
|
||||
const groupCounts = countGroupsByArea(groups);
|
||||
|
||||
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 groupsByRegion = new Map();
|
||||
for (const group of groups) {
|
||||
if (!group.region_id) continue;
|
||||
const list = groupsByRegion.get(group.region_id);
|
||||
if (list) list.push(group);
|
||||
else groupsByRegion.set(group.region_id, [group]);
|
||||
}
|
||||
|
||||
const chaptersIn = (regionId) => chaptersByRegion.get(regionId) ?? [];
|
||||
const groupsIn = (regionId) => groupsByRegion.get(regionId) ?? [];
|
||||
|
||||
/* Sorted by name to match how the page has always shown them,
|
||||
rather than by the sort_order the API returns. */
|
||||
|
|
@ -108,8 +108,8 @@ export function useCommunity() {
|
|||
.filter(Boolean);
|
||||
|
||||
return {
|
||||
loading: regionsQuery.loading || chaptersQuery.loading,
|
||||
error: regionsQuery.error ?? chaptersQuery.error,
|
||||
loading: regionsQuery.loading || groupsQuery.loading,
|
||||
error: regionsQuery.error ?? groupsQuery.error,
|
||||
|
||||
regions,
|
||||
regionAreas,
|
||||
|
|
@ -118,11 +118,11 @@ export function useCommunity() {
|
|||
international,
|
||||
virtual,
|
||||
|
||||
chapters,
|
||||
chaptersIn,
|
||||
groups,
|
||||
groupsIn,
|
||||
|
||||
slices,
|
||||
chapterCounts,
|
||||
groupCounts,
|
||||
regionsForArea,
|
||||
|
||||
areasLabelFor,
|
||||
|
|
@ -130,10 +130,10 @@ export function useCommunity() {
|
|||
};
|
||||
}, [
|
||||
rawRegions,
|
||||
rawChapters,
|
||||
rawGroups,
|
||||
regionsQuery.loading,
|
||||
regionsQuery.error,
|
||||
chaptersQuery.loading,
|
||||
chaptersQuery.error,
|
||||
groupsQuery.loading,
|
||||
groupsQuery.error,
|
||||
]);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -76,7 +76,7 @@ export type Link = {
|
|||
export type OrgRef = { id: string; name: string; kind?: string | null }
|
||||
|
||||
/* One host of an event. `kind` says which table the id is in;
|
||||
`org_kind` is the region/chapter/partner split that decides an
|
||||
`org_kind` is the region/group/partner split that decides an
|
||||
organization's route, and is null for a person. The triple is
|
||||
exactly what refHref() in hrefs.ts takes. */
|
||||
export type EventHost = {
|
||||
|
|
@ -207,7 +207,7 @@ export type RegionArea = {
|
|||
|
||||
export type OrganizationRecord = {
|
||||
id: string
|
||||
kind: 'national' | 'region' | 'chapter' | 'partner'
|
||||
kind: 'national' | 'region' | 'group' | 'partner'
|
||||
name: string
|
||||
short_name?: string | null
|
||||
tagline?: string | null
|
||||
|
|
@ -234,7 +234,7 @@ export type OrganizationRecord = {
|
|||
scope?: RegionScope | null
|
||||
map_note?: string | null
|
||||
areas?: RegionArea[]
|
||||
chapters?: Array<{ id: string; name: string; location_label?: string | null; logo?: string | null }>
|
||||
groups?: Array<{ id: string; name: string; location_label?: string | null; logo?: string | null }>
|
||||
region_id?: string | null
|
||||
region_name?: string | null
|
||||
region_color?: string | null
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue