Tidy the structure the audit found

- The colour defaults have one source, server/src/themeDefaults.js,
  read by the server and the admin; the build stops if src/index.css
  disagrees with it
- server/src/admin-schema.js split into admin-schema/, one file per
  entity plus columns.js (the registry checked identical)
- loadOwned() in shape.js replaces the same three loads on four
  detail routes (every public route checked identical); one NO_STORE
- One OrgLogo component for the org lists and the chapter map; an
  organization's own page now shows the same initials as the lists
- One localISO() for the viewer's calendar day, in place of three
- Boot refuses a descriptor dropdown value the table's CHECK doesn't
  allow, instead of it failing on save
- Deleted the unused Other.tsx and white-background logo;
  chapters.ts is useCommunity.ts; isSuper() in the Panel; stale
  comments and docs corrected

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
Zaldimmar 2026-09-29 03:02:21 -05:00
parent 048c7599ce
commit f934b1dd93
44 changed files with 1187 additions and 1170 deletions

View file

@ -50,7 +50,7 @@ each entity:
| File | What it holds |
| ----------------------------- | ----------------------------------------------------- |
| `src/lib/adminSchema/` (one file per entity, `shared.ts` for common fields; `src/lib/adminSchema.ts` lists them) | The **form**: field labels, help text, dropdown labels, list columns and filters |
| `server/src/admin-schema.js` | What the server **accepts**: columns, types, the allowed values of each `enumeration(...)` |
| `server/src/admin-schema/` (one file per entity, `columns.js` for shared helpers; `server/src/admin-schema.js` lists them) | What the server **accepts**: columns, types, the allowed values of each `enumeration(...)` |
And the database itself holds the final word: most fixed lists are a
`CHECK (... IN (...))` constraint on the column (read them in
@ -145,7 +145,7 @@ together, in one branch:
**Renaming** a value also needs an `UPDATE` in the same migration so
existing rows move to the new value. **Removing** one needs you to
decide what existing rows become first.
2. **`server/src/admin-schema.js`**: the `enumeration("column", [...])`
2. **`server/src/admin-schema/<entity>.js`**: the `enumeration("column", [...])`
list for that column.
3. **`src/lib/adminSchema/<entity>.ts`**: the `options` on the form field, and on
the list filter if there is one.
@ -161,11 +161,11 @@ wrong rather than working around it.
### Every dropdown in the editor
**Fixed lists** (`options`: labels in `src/lib/adminSchema/`, values
also in `admin-schema.js` and a CHECK):
also in `server/src/admin-schema/` and a CHECK):
| Entity → field | Stored values | Labelled? | Also used on the public site by |
| --- | --- | --- | --- |
| Organizations → Kind (+ list filter) | national, region, chapter, partner | no, shows values | `ORG_KIND_LABEL` in `src/lib/hrefs.ts`, and the route each kind uses |
| Organizations → Kind (+ list filter) | national, region, chapter, partner | no, shows values | `ORG_BASE` in `src/lib/hrefs.ts` (the route each kind uses) and `orgListHref` there (its back link) |
| Organizations → Region → Scope | domestic, international, virtual | no | the Community page groups regions by it |
| Organizations → Region areas → Edge | top, bottom | no | the chapter map (`OrgList-Map.tsx`) |
| Events → Type (+ list filter) | retreat, class, workshop, meeting, other | no | `EVENT_TYPES` in `src/lib/eventTypes.ts` (public labels and plurals) |
@ -206,7 +206,6 @@ code):
| Affiliations → Team | `teams` | teams, filtered to the chosen organization |
| Person awards → Award | `awards` | awards, labelled "Award (Organization)" |
| Person awards → Presented at; Front page → Count down to; Front page → Featured event | `events` | events |
| Timeline → Record | `timeline_refs` | all five kinds, filtered by "Points at" |
---
@ -243,7 +242,7 @@ change the band's `id`.
**Adding a new kind of band** (not just renaming one) is a feature,
not a relabel: it needs a component, an entry in `SECTIONS` in
`Home.tsx`, the key added to `FRONT_PAGE_SECTIONS`, to the
`enumeration("section", …)` in `server/src/admin-schema.js`, to the
`enumeration("section", …)` in `server/src/admin-schema/frontPage.js`, to the
`FrontPageSectionKey` type in `src/lib/useFrontPage.ts`, and to the
CHECK on `front_page_sections.section` via a migration.
@ -259,7 +258,7 @@ The numbers band's "Number Source" dropdown works the same way:
matching public page shows (published rows), or the number and the
page will disagree.
- **Add a source:** the CHECK on `front_page_stats.source` (migration),
the `enumeration("source", …)` in `server/src/admin-schema.js`,
the `enumeration("source", …)` in `server/src/admin-schema/frontPage.js`,
`STAT_SOURCES`, and a query in `STAT_QUERIES`.
---
@ -274,13 +273,13 @@ The numbers band's "Number Source" dropdown works the same way:
| History page decade headers | `src/data/historyDecades.ts` | Title, tagline and blurb per decade. |
| Chapter map tiles and area names | `src/data/mapGrid.ts` | `AREAS` (tile positions) and `AREA_NAMES`. Which region paints which tile is in the database (Admin → Data → Organizations → a region → Map areas). |
| Feedback form types | `src/data/feedbackTypes.ts` **and** `TYPES` in `server/src/routes/feedback.js` | Keep the ids identical in both; the server stores unknown ids as `general`. Labels and hints are client-only. `DATA_REQUEST` ('privacy') isn't a tile: the Privacy page's form sends it, and the server requires an email for it. |
| The site's colours, light and dark | the database over `src/index.css` | Admin → Panel → Site settings → Colours (superadmins): pick a colour, set its light and/or dark value; saving refuses anything that makes text hard to read. The defaults are the `@theme` tokens and dark block in `src/index.css`, and must stay the same in `THEME_DEFAULTS` (`server/src/theme.js`) and `THEME_COLORS` (`src/lib/adminSchema/siteSettings.ts`). Change a token's value in both modes and every use follows. Use the token utilities (`text-muted`, `bg-surface`, `border-brand/20`) or `var(--color-…)`, not hex. A colour that arrives as data (a page accent, an event's or region's colour) goes through `src/lib/color.ts`: `withAlpha` for tints, `accentText` for text in it, `readableOn` for text on it. |
| The site's colours, light and dark | the database over `src/index.css` | Admin → Panel → Site settings → Colours (superadmins): pick a colour, set its light and/or dark value; saving refuses anything that makes text hard to read. The defaults are `THEME_DEFAULTS` in `server/src/themeDefaults.js` (the admin and the contrast check read it) and the same values as CSS in `src/index.css`; the build stops if the two differ. The admin's labels for them are `THEME_LABELS` in `src/lib/adminSchema/siteSettings.ts`. Change a token's value in both modes and every use follows. Use the token utilities (`text-muted`, `bg-surface`, `border-brand/20`) or `var(--color-…)`, not hex. A colour that arrives as data (a page accent, an event's or region's colour) goes through `src/lib/color.ts`: `withAlpha` for tints, `accentText` for text in it, `readableOn` for text on it. |
| The icons a Front page "Find your way in" path can pick | `src/data/pathIcons.ts` (keys and labels) **and** `ICONS` in `src/pages/sections/home/Pathfinder.tsx` (the Phosphor icon for each key) | Add a line to both. A path saved with an emoji from before the list shows it as it is. |
| A page section's accent colour | `BRAND` and `ACCENTS` in `src/lib/color.ts` | Pages pick from these (`accent: ACCENTS.green`); add a colour there, not a hex in a page. Each is readable as text on white and the tints. |
| Privacy Policy and Terms wording | `src/pages/Privacy.tsx`, `src/pages/Terms.tsx` | The `PARTS` list, and `LAST_UPDATED` whenever the wording changes. The Privacy page must stay true of the code: what the feedback form stores, what the browser keeps, which embeds wait for a click. |
| Event type labels and plurals (public site) | `src/lib/eventTypes.ts` | Also the order of the type filter chips. |
| Event and person role labels (public site) | `ROLE_LABEL` in `src/pages/EventDetail.tsx` and `src/pages/PersonDetail.tsx` | |
| Organization kind labels ("Region", "Chapter") | `ORG_KIND_LABEL` in `src/lib/hrefs.ts` | |
| Organization kind labels ("Region", "Chapter") | the Kind options in `src/lib/adminSchema/organizations.ts` (admin); `orgListHref` in `src/lib/hrefs.ts` (the public back link, "All regions") | |
| Admin account roles | `src/lib/roles.ts` (labels, notes) and `ROLES` in `server/src/auth.js` | Adding a role is also a CHECK change on `admin_users.role`. |
| Admin navigation | `src/pages/admin/adminNav.ts` | |
| The live site's address (used by QR codes) | `SITE_ORIGIN` in `src/lib/site.ts` | |