feat(admin): setProjectShowInIntakeAction

Phase 9a Task 4. Owner-only. Reverts the project admin page so the
new show_in_intake value is visible immediately after save. The
toggle component that calls this lands in Task 5.
This commit is contained in:
Dave 2026-09-21 13:17:02 +02:00
parent b824f02f02
commit 00c70eba8e

View file

@ -0,0 +1,34 @@
"use server";
import { revalidatePath } from "next/cache";
import { getAdminPb } from "@/lib/pb/admin";
import { requireSession } from "@/lib/auth/session";
/** Owner-only entry point. */
async function requireOwner() {
const session = await requireSession();
if (session.role !== "owner") throw new Error("Not found");
return session;
}
/**
* Flip the `show_in_intake` flag on a project.
*
* Default false. Owners opt projects in so the picker lists them. The
* picker is the only place a project is exposed to the public; the flag
* is the leak-prevention boundary — see the Phase 9 spec §3.
*/
export async function setProjectShowInIntakeAction(input: {
projectId: string;
show: boolean;
}): Promise<void> {
await requireOwner();
const pb = await getAdminPb();
await pb.collection("projects").update(input.projectId, {
show_in_intake: input.show,
});
revalidatePath(`/admin/projects/${input.projectId}`);
}