WIP 2.0.0: React Compiler lint rules back to errors; docs

- The 192 places the rules flagged are fixed and the rules are errors
  again (npx eslint src: nothing). lib/hooks.ts: useStateSync (state
  that follows other state, set while rendering), useExternalEffect
  (API loads and browser reads), useNow; lib/navigation.ts hardNavigate
  for full reloads after sign-out or identity switches; other pages use
  the router. Resets moved into the handlers that cause them.
- The banner shows and hides at its times on open pages.
- HANDOVER, roadmap, README, FEATURES, SETTINGS, CHANGELOG updated;
  2.0.0 section drafted in WHATS-NEW.

e2e 102/102 (PayFast sandbox skipped); production build passes.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
2026-11-02 17:45:25 +02:00
co-authored by Claude Opus 5.5
parent 3f59164ab2
commit abd2c36e97
102 changed files with 613 additions and 354 deletions
@@ -1,12 +1,13 @@
"use client";
import React, { useCallback, useEffect, useState } from "react";
import React, { useCallback, useState } from "react";
import { useAuth } from "@/hooks/useAuth";
import { API_BASE } from "@/lib/api";
import { useDismissingState } from "@/hooks/useDismissingState";
import { DatabaseBackup, Download } from "lucide-react";
import { errorMessage } from "@/lib/utils";
import { apiV2Data } from "@/lib/apiV2";
import { useExternalEffect } from "@/lib/hooks";
interface BackupEntry {
filename: string;
@@ -60,7 +61,7 @@ export function BackupsTab({ active }: { active: boolean }) {
}
};
useEffect(() => { if (active) load(); }, [active, load]);
useExternalEffect(() => { if (active) load(); }, [active, load]);
const runBackup = async () => {
if (!token) return;
@@ -8,6 +8,7 @@ import { useDismissingState } from "@/hooks/useDismissingState";
import { reloadCampuses, type Campus } from "@/hooks/useCampuses";
import { errorMessage } from "@/lib/utils";
import { apiV2Data } from "@/lib/apiV2";
import { useExternalEffect } from "@/lib/hooks";
type Person = { id: string; name: string; email: string };
type AdminCampus = Campus & {
@@ -36,7 +37,7 @@ function RecipientsField({ value, onChange }: { value: Person[]; onChange: (v: P
const [search, setSearch] = useState("");
const [results, setResults] = useState<Person[]>([]);
useEffect(() => {
if (!search.trim()) { setResults([]); return; }
if (!search.trim()) return;
let cancelled = false;
const t = setTimeout(async () => {
try {
@@ -46,7 +47,8 @@ function RecipientsField({ value, onChange }: { value: Person[]; onChange: (v: P
}, 300);
return () => { cancelled = true; clearTimeout(t); };
}, [search, token]);
const shown = results.filter(r => !value.some(v => v.id === r.id));
// Only while there's a search (clearing the box clears the list without another render).
const shown = (search.trim() ? results : []).filter(r => !value.some(v => v.id === r.id));
return (
<div className="space-y-2">
{value.length > 0 && (
@@ -134,7 +136,7 @@ export function CampusesTab({ active }: { active: boolean }) {
setCampuses(res.campuses);
} catch (e) { setMsg({ type: "err", text: errorMessage(e) || "Could not load campuses." }); }
}, [token, setMsg]);
useEffect(() => { if (active) load(); }, [active, load]);
useExternalEffect(() => { if (active) load(); }, [active, load]);
const run = async (fn: () => Promise<unknown>, ok?: string) => {
setBusy(true);
@@ -1,11 +1,12 @@
"use client";
import React, { useCallback, useEffect, useState } from "react";
import React, { useCallback, useState } from "react";
import { Timer, Play, RefreshCw } from "lucide-react";
import { useAuth } from "@/hooks/useAuth";
import { useDismissingState } from "@/hooks/useDismissingState";
import { errorMessage } from "@/lib/utils";
import { apiV2Data } from "@/lib/apiV2";
import { useExternalEffect } from "@/lib/hooks";
type JobRun = { state: string; createdOn?: string; startedOn: string | null; completedOn: string | null; output: unknown };
type JobInfo = { name: string; label: string; cron: string; enabled: boolean; envFlag: string | null; nextRun: string | null; recent: JobRun[] };
@@ -58,7 +59,7 @@ export function JobsTab({ active }: { active: boolean }) {
}
}, [token, setMessage]);
useEffect(() => { if (active) load(); }, [active, load]);
useExternalEffect(() => { if (active) load(); }, [active, load]);
const runNow = async (job: JobInfo) => {
if (!token) return;
@@ -1,10 +1,11 @@
"use client";
import React, { useCallback, useEffect, useState } from "react";
import React, { useCallback, useState } from "react";
import { KeyRound, RefreshCw, ShieldCheck, ShieldAlert, ArrowUpCircle, Undo2, BellOff, BellRing, Megaphone } from "lucide-react";
import { useAuth } from "@/hooks/useAuth";
import { errorMessage } from "@/lib/utils";
import { apiV2Data, apiV2Raw } from "@/lib/apiV2";
import { useExternalEffect } from "@/lib/hooks";
export type HubStatus = {
state: "active" | "grace" | "suspended" | "revoked" | "unlicensed";
@@ -109,7 +110,7 @@ export function LicenceTab({ active }: { active: boolean }) {
if (!token) return;
try { setStatus(await (apiV2Data("get", "/hub/status", { authToken: token }) as Promise<HubStatus>)); } catch (e) { setMsg({ type: "err", text: errorMessage(e) || "Could not load the licence." }); }
}, [token]);
useEffect(() => { if (active) load(); }, [active, load]);
useExternalEffect(() => { if (active) load(); }, [active, load]);
const checkNow = async () => {
setBusy(true);
@@ -1,11 +1,12 @@
"use client";
import React, { useCallback, useEffect, useState } from "react";
import React, { useCallback, useState } from "react";
import { useAuth } from "@/hooks/useAuth";
import { useDismissingState } from "@/hooks/useDismissingState";
import { Wallet } from "lucide-react";
import { errorMessage } from "@/lib/utils";
import { apiV2Data } from "@/lib/apiV2";
import { useExternalEffect } from "@/lib/hooks";
interface PayFastConfig {
merchantId: string;
@@ -50,7 +51,7 @@ export function PayFastSettings({ active, onChanged }: { active: boolean; onChan
}
}, [token, setMessage]);
useEffect(() => { if (active) load(); }, [active, load]);
useExternalEffect(() => { if (active) load(); }, [active, load]);
const save = async (e: React.FormEvent) => {
e.preventDefault();
@@ -1,6 +1,6 @@
"use client";
import React, { useCallback, useEffect, useState } from "react";
import React, { useCallback, useState } from "react";
import { ArrowDown, ArrowUp, Wallet } from "lucide-react";
import { useAuth } from "@/hooks/useAuth";
import { useDismissingState } from "@/hooks/useDismissingState";
@@ -8,6 +8,7 @@ import { errorMessage } from "@/lib/utils";
import { YocoTab } from "@/components/admin/YocoTab";
import { PayFastSettings } from "@/components/admin/PayFastSettings";
import { apiV2Data } from "@/lib/apiV2";
import { useExternalEffect } from "@/lib/hooks";
type ProviderSetting = { id: string; label: string; enabled: boolean; configured: boolean };
@@ -33,7 +34,7 @@ export function PaymentsTab({ active }: { active: boolean }) {
}
}, [token, setMessage]);
useEffect(() => { if (active) load(); }, [active, load]);
useExternalEffect(() => { if (active) load(); }, [active, load]);
const save = async (next: ProviderSetting[]) => {
if (!token) return;
@@ -1,12 +1,13 @@
"use client";
import React, { useEffect, useMemo, useState } from "react";
import React, { useMemo, useState } from "react";
import { CheckSquare, X, Download } from "lucide-react";
import { API_BASE } from "@/lib/api";
import { errorMessage } from "@/lib/utils";
import { downloadReportExcel } from "@/lib/export";
import type { Event, Registration } from "@/types";
import { apiV2Data } from "@/lib/apiV2";
import { useExternalEffect } from "@/lib/hooks";
type Action = "" | "message" | "markPaid" | "moveOption" | "allocate" | "cancel" | "export";
type Result = { id: string; ok: boolean; skipped?: boolean; message: string };
@@ -54,7 +55,7 @@ export function RegistrationBulkBar({ selected, events, token, onClear, onDone }
const options = useMemo(() => (oneEvent?.eventOptions || []).filter(o => o.id !== oneEvent?.kidsOptionId && o.id !== oneEvent?.volunteerOptionId), [oneEvent]);
const totalOwing = useMemo(() => selected.filter(r => r.status !== "cancelled").reduce((s, r) => s + owing(r), 0), [selected]);
useEffect(() => {
useExternalEffect(() => {
if (action !== "allocate" || !oneEvent) { setSets([]); return; }
(apiV2Data("get", "/events/{id}/allocations", { params: { id: oneEvent.id }, authToken: token }) as Promise<{ sets?: AllocationSet[] }>)
.then(b => setSets((b.sets || []).filter(s => s.groups.length)))
@@ -1,11 +1,12 @@
"use client";
import React, { useCallback, useEffect, useState } from "react";
import React, { useCallback, useState } from "react";
import { Webhook, Send, RefreshCw, KeyRound, Trash2, Pencil, Copy, ChevronDown, ChevronRight, RotateCcw } from "lucide-react";
import { useAuth } from "@/hooks/useAuth";
import { errorMessage } from "@/lib/utils";
import { WebhookGuide } from "./WebhookGuide";
import { apiV2Data } from "@/lib/apiV2";
import { useExternalEffect } from "@/lib/hooks";
type EventType = { type: string; label: string; description: string; example?: unknown };
type Endpoint = {
@@ -67,7 +68,7 @@ function Deliveries({ endpointId, token }: { endpointId: string; token: string }
setRows(page);
setMore(page.length === PAGE);
}, [fetchPage]);
useEffect(() => { load(); }, [load]);
useExternalEffect(() => { load(); }, [load]);
const loadOlder = async () => {
if (!rows?.length) return;
const page = await fetchPage(rows[rows.length - 1].createdAt);
@@ -141,7 +142,7 @@ export function WebhooksTab({ active }: { active: boolean }) {
if (!token) return;
try { setData(await (apiV2Data("get", "/outbound-webhooks", { authToken: token }) as Promise<ListResponse>)); } catch (e) { setMsg({ type: "err", text: errorMessage(e) || "Couldn't load webhooks" }); }
}, [token]);
useEffect(() => { if (active) load(); }, [active, load]);
useExternalEffect(() => { if (active) load(); }, [active, load]);
const run = async (fn: () => Promise<void>) => {
setBusy(true); setMsg(null);
@@ -1,11 +1,12 @@
"use client";
import React, { useCallback, useEffect, useState } from "react";
import React, { useCallback, useState } from "react";
import { useAuth } from "@/hooks/useAuth";
import { useDismissingState } from "@/hooks/useDismissingState";
import { Copy, CreditCard, KeyRound, Trash2, Webhook } from "lucide-react";
import { errorMessage } from "@/lib/utils";
import { apiV2Data } from "@/lib/apiV2";
import { useExternalEffect } from "@/lib/hooks";
type Source = "db" | "env" | "none";
@@ -123,7 +124,7 @@ export function YocoTab({ active, onChanged }: { active: boolean; onChanged?: ()
}
}, [token, loadHooks, setMessage]);
useEffect(() => { if (active) load(); }, [active, load]);
useExternalEffect(() => { if (active) load(); }, [active, load]);
const run = async (label: string, fn: () => Promise<string>) => {
setBusy(label);
@@ -1,10 +1,11 @@
"use client";
import React, { useCallback, useEffect, useState } from "react";
import React, { useCallback, useState } from "react";
import { Plus, Copy, Pencil } from "lucide-react";
import { errorMessage } from "@/lib/utils";
import { useSiteSettings } from "@/contexts/SiteSettingsContext";
import { apiV2Data } from "@/lib/apiV2";
import { useExternalEffect } from "@/lib/hooks";
type Status = "open" | "contained" | "closed";
type Breach = {
@@ -95,7 +96,7 @@ export function BreachesPanel({ token }: { token: string }) {
setError(errorMessage(e) || "Could not load the register.");
}
}, [token]);
useEffect(() => { load(); }, [load]);
useExternalEffect(() => { load(); }, [load]);
const send = async (id: string | "new", body: Record<string, unknown>) => {
setBusy(true);
@@ -1,8 +1,9 @@
"use client";
import React, { useCallback, useEffect, useState } from "react";
import React, { useCallback, useState } from "react";
import { errorMessage } from "@/lib/utils";
import { apiV2Data } from "@/lib/apiV2";
import { useExternalEffect } from "@/lib/hooks";
const fmt = (d: string | null) => (d ? new Date(d).toLocaleString(undefined, { day: "numeric", month: "short", year: "numeric", hour: "2-digit", minute: "2-digit" }) : "—");
const selectCls = "border rounded-lg px-3 py-2 text-sm bg-white";
@@ -50,7 +51,7 @@ export function ConsentLogPanel({ token }: { token: string }) {
setError(errorMessage(e) || "Could not load the consent log.");
}
}, [token, type, page, query]);
useEffect(() => { load(); }, [load]);
useExternalEffect(() => { load(); }, [load]);
return (
<div className="space-y-3">
@@ -143,7 +144,7 @@ export function AccessLogPanel({ token }: { token: string }) {
setError(errorMessage(e) || "Could not load the access log.");
}
}, [token, action, actorId, sensitiveOnly, page]);
useEffect(() => { load(); }, [load]);
useExternalEffect(() => { load(); }, [load]);
return (
<div className="space-y-3">
@@ -1,11 +1,12 @@
"use client";
import React, { useCallback, useEffect, useState } from "react";
import React, { useCallback, useState } from "react";
import Link from "next/link";
import { ArrowUp, ArrowDown, Trash2, Plus, RotateCcw, Eye, PencilLine, Sparkles } from "lucide-react";
import { errorMessage } from "@/lib/utils";
import { PrivacyNoticeSection, type NoticeSection } from "@/components/shared/PrivacyNoticeSection";
import { apiV2Data } from "@/lib/apiV2";
import { useExternalEffect } from "@/lib/hooks";
type Version = { version: number; publishedAt: string; changeSummary: string | null; requiresAcceptance: boolean; publishedBy: string | null; acceptances: number };
// Changes to the built-in text since this site last reviewed them (only once it has published its own).
@@ -49,7 +50,7 @@ export function NoticeEditor({ token }: { token: string }) {
setMsg({ type: "err", text: errorMessage(e) || "Could not load the notice." });
}
}, [token]);
useEffect(() => { load(); }, [load]);
useExternalEffect(() => { load(); }, [load]);
const change = (next: NoticeSection[]) => { setSections(next); setDirty(true); };
const update = (i: number, patch: Partial<NoticeSection>) => change(sections.map((s, j) => (j === i ? { ...s, ...patch } : s)));
@@ -1,9 +1,10 @@
"use client";
import React, { useCallback, useEffect, useState } from "react";
import React, { useCallback, useState } from "react";
import { Plus, Pencil, Trash2 } from "lucide-react";
import { errorMessage } from "@/lib/utils";
import { apiV2Data } from "@/lib/apiV2";
import { useExternalEffect } from "@/lib/hooks";
type Operator = { id: string; name: string; purpose: string; dataShared: string; location: string | null; website: string | null; active: boolean; order: number };
type Form = { name: string; purpose: string; dataShared: string; location: string; website: string; active: boolean };
@@ -46,7 +47,7 @@ export function OperatorsPanel({ token }: { token: string }) {
setError(errorMessage(e) || "Could not load operators.");
}
}, [token]);
useEffect(() => { load(); }, [load]);
useExternalEffect(() => { load(); }, [load]);
const save = async (f: Form) => {
setBusy(true);
@@ -1,10 +1,11 @@
"use client";
import React, { useCallback, useEffect, useState } from "react";
import React, { useCallback, useState } from "react";
import Link from "next/link";
import { CheckCircle2, Circle, ArrowRight } from "lucide-react";
import { errorMessage } from "@/lib/utils";
import { apiV2Data } from "@/lib/apiV2";
import { useExternalEffect } from "@/lib/hooks";
type Check = { key: string; label: string; ok: boolean; detail: string; href: string | null; applies: boolean };
type Readiness = { score: number; passed: number; total: number; checks: Check[] };
@@ -21,7 +22,7 @@ export function ReadinessPanel({ token }: { token: string }) {
setError(errorMessage(e) || "Could not load the checklist.");
}
}, [token]);
useEffect(() => { load(); }, [load]);
useExternalEffect(() => { load(); }, [load]);
if (error) return <p className="text-sm text-red-700">{error}</p>;
if (!data) return <p className="text-sm text-gray-400">Loading…</p>;
@@ -1,9 +1,10 @@
"use client";
import React, { useCallback, useEffect, useState } from "react";
import React, { useCallback, useState } from "react";
import Link from "next/link";
import { errorMessage } from "@/lib/utils";
import { apiV2Data } from "@/lib/apiV2";
import { useExternalEffect } from "@/lib/hooks";
type Policy = { enabled: boolean; months: number };
type Definition = { label: string; description: string; minMonths: number; defaults: Policy };
@@ -44,7 +45,7 @@ export function RetentionPanel({ token }: { token: string }) {
setMsg({ type: "err", text: errorMessage(e) || "Could not load retention settings." });
}
}, [token]);
useEffect(() => { load(); }, [load]);
useExternalEffect(() => { load(); }, [load]);
const save = async () => {
const inactive = policies.inactive_accounts;