Third audit, UI half; side nav on top; request button colors

- Event cards: lazy -640 photo, only nearby slides drawn, a counter
  past 12 events, past grid paged with Show more
- Community map: search over list and grid, 12 per region then Show
  all, list no longer redrawn on hover
- People tiles: one clip check for the list, Show all past 30
- Person pages: 6 events and posts then Show all; excerpts load only
  the first paragraph
- Admin: filter box on long pickers and the QR select, options sent
  per form, Media thumbnails from the small copy, debounced searches
  that drop stale answers
- Pages show their last data while refreshing after the cache TTL
- Side nav stacks above page content (the carousel arrows)
- No event request button on National Retreats; request buttons take
  their section's accent
- Version v1.11.1-audit

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
Zaldimmar 2026-10-01 19:09:21 -05:00
parent 11a4555683
commit 222c9e69a2
22 changed files with 686 additions and 259 deletions

View file

@ -52,6 +52,23 @@ export const ADMIN_ENTITIES: Record<string, any> = {
site_settings: siteSettings,
};
/* The /admin/options request for the option lists `part` of a
manifest names (any `optionsFrom` inside it, at any depth), so a
form gets only the lists its selects use. An empty request would
mean every list, so a part that names none asks for nothing. */
export function optionsPath(part: any): string | null {
const names = new Set<string>();
const seen = new Set<any>();
const walk = (value: any) => {
if (!value || typeof value !== "object" || seen.has(value)) return;
seen.add(value);
if (typeof value.optionsFrom === "string") names.add(value.optionsFrom);
for (const child of Object.values(value)) walk(child);
};
walk(part);
return names.size ? `/admin/options?only=${[...names].sort().join(",")}` : null;
}
export function slugify(value) {
return String(value ?? "")
.toLowerCase()

View file

@ -10,12 +10,17 @@
costs nothing. It resets on page load, which is the right
lifetime for content that changes weekly. A failure isn't
cached, and surfaces as an error rather than empty data.
The last body each path answered with is kept too (`peek`), so a
page opened again after the TTL shows it at once while the fresh
request runs, instead of a loading skeleton.
═══════════════════════════════════════════════════════════════ */
const BASE = import.meta.env?.VITE_API_BASE ?? "/api";
const DEFAULT_TTL = 60_000;
const cache = new Map(); // path → { at, promise }
const settled = new Map(); // path → the last body it answered with
export class ApiError extends Error {
status;
@ -77,18 +82,34 @@ export function get(path, { ttl = DEFAULT_TTL }: { ttl?: number } = {}) {
if (hit && Date.now() - hit.at < ttl) return hit.promise;
const promise = request(path).catch((err) => {
cache.delete(path); // a failure shouldn't be cached
throw err;
});
const promise = request(path).then(
(body) => {
settled.set(path, body);
return body;
},
(err) => {
cache.delete(path); // a failure shouldn't be cached
throw err;
},
);
cache.set(path, { at: Date.now(), promise });
return promise;
}
/* The last body `path` answered with, however old, or undefined. */
export function peek(path) {
return settled.get(path);
}
export function invalidate(path) {
if (path) cache.delete(path);
else cache.clear();
if (path) {
cache.delete(path);
settled.delete(path);
} else {
cache.clear();
settled.clear();
}
}
/* ── Writes ──────────────────────────────────────────────────── */

View file

@ -65,7 +65,7 @@ export function useSectionManifest(manifest) {
actions: Toggle || request ? (
<div className="flex flex-wrap items-center gap-3">
{request && <RequestLink type={request.type} label={request.label} />}
{request && <RequestLink type={request.type} label={request.label} accent={entry.accent} />}
{Toggle && (
<Toggle
view={view}

View file

@ -35,6 +35,10 @@
* · no `fallback`. Rendering plausible-looking content with no
* sign the server is down is worse than a visible error.
*
* · a path asked for before starts from its last answer (api.ts,
* peek) and isn't `loading` while it refreshes, so a page opened
* again after the TTL doesn't flash its skeleton.
*
* `notFound` is separated from `error` because they are different
* pages: a 404 is a slug that doesn't exist and retrying won't help,
* anything else is worth a Try again button.
@ -46,7 +50,7 @@
*/
import { useCallback, useEffect, useState } from 'react'
import { get, invalidate, ApiError } from './api.ts'
import { get, invalidate, peek, ApiError } from './api.ts'
export type Resource<T> = {
data: T | null
@ -57,8 +61,9 @@ export type Resource<T> = {
}
export function useRecord<T>(path: string | null, key: string): Resource<T> {
const [data, setData] = useState<T | null>(null)
const [loading, setLoading] = useState(true)
const stale = path ? peek(path)?.[key] : undefined
const [data, setData] = useState<T | null>(stale ?? null)
const [loading, setLoading] = useState(stale === undefined)
const [error, setError] = useState<string | null>(null)
const [notFound, setNotFound] = useState(false)
const [attempt, setAttempt] = useState(0)
@ -84,7 +89,12 @@ export function useRecord<T>(path: string | null, key: string): Resource<T> {
let live = true
async function load() {
setLoading(true)
const last = peek(path as string)?.[key]
if (last === undefined) setLoading(true)
else {
setData(last as T)
setLoading(false)
}
setError(null)
setNotFound(false)
try {

View file

@ -9,18 +9,30 @@
request is shared and cached, so canceling it would throw away
work another component may still want. We just stop writing
state after unmount.
A path asked for before starts from its last answer (api.ts,
peek) and isn't `loading` while it refreshes, so a page opened
again after the TTL doesn't flash its skeleton.
═══════════════════════════════════════════════════════════════ */
import { useEffect, useState } from "react";
import { get } from "./api.ts";
import { get, peek } from "./api.ts";
export function useResource(path, { ttl }: { ttl?: number } = {}) {
const [state, setState] = useState<any>({ data: undefined, error: null, loading: true });
const [state, setState] = useState<any>(() => {
const stale = peek(path);
return { data: stale, error: null, loading: stale === undefined };
});
useEffect(() => {
let ignore = false;
setState((prev) => ({ ...prev, loading: true, error: null }));
const stale = peek(path);
setState((prev) =>
stale === undefined
? { ...prev, loading: true, error: null }
: { data: stale, error: null, loading: false },
);
get(path, { ttl })
.then((data) => {

View file

@ -7,4 +7,4 @@
box or a build banner can read the same value later.
═══════════════════════════════════════════════════════════════ */
export const SITE_VERSION = "NGU-Web.v1.11.0-audit";
export const SITE_VERSION = "NGU-Web.v1.11.1-audit";