From 0c310801b51faa19177c5969fc0f6f5694869488 Mon Sep 17 00:00:00 2001 From: Dave Date: Mon, 21 Sep 2026 13:17:45 +0200 Subject: [PATCH] feat(admin): 'List on request page' toggle on project page MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Phase 9a Task 5. Single switch, owner-only via the Server Action wired in Task 4. Saves immediately on click; reverts on error so a transient PB failure can't leave the UI lying. Default off, per the Phase 9 spec §4.5. --- src/app/admin/projects/[projectId]/page.tsx | 5 ++ .../admin/show-in-intake-toggle.tsx | 87 +++++++++++++++++++ 2 files changed, 92 insertions(+) create mode 100644 src/components/admin/show-in-intake-toggle.tsx diff --git a/src/app/admin/projects/[projectId]/page.tsx b/src/app/admin/projects/[projectId]/page.tsx index a027e95..bbc932c 100644 --- a/src/app/admin/projects/[projectId]/page.tsx +++ b/src/app/admin/projects/[projectId]/page.tsx @@ -6,6 +6,7 @@ import { IngestPanel } from "@/components/admin/ingest-panel"; import { SummaryPanel } from "@/components/admin/summary-panel"; import { IntakeLinksPanel } from "@/components/admin/intake-links-panel"; import { BackgroundMdEditor } from "@/components/admin/background-md-editor"; +import { ShowInIntakeToggle } from "@/components/admin/show-in-intake-toggle"; import { getAdminPb } from "@/lib/pb/admin"; import { summaryStatus } from "@/lib/ai/summarise"; import type { IntakeLinkRecord, ProjectRecord } from "@/lib/pb/types"; @@ -65,6 +66,10 @@ export default async function ProjectAdminPage({ /> + (false); + const [error, setError] = useState(null); + + function flip() { + const next = !value; + setValue(next); + setSaved(false); + setError(null); + startTransition(async () => { + try { + await setProjectShowInIntakeAction({ projectId, show: next }); + setSaved(true); + } catch (e) { + setError(e instanceof Error ? e.message : "Could not save"); + setValue(!next); // revert + } + }); + } + + return ( +
+
+

+ List on request page +

+

+ Show this project in the public request page's project picker. + Off by default. +

+
+
+ + {pending && Saving…} + {error && ( + + {error} + + )} + {!pending && saved && ( + Saved. + )} +
+
+ ); +}