import { projectRef } from "@/lib/projects";
import { playView } from "@/lib/report/playView.mjs";
export const dynamic = "force-dynamic";
// PLAY'S VIEW as JSON (lib/report/playView.mjs): what `/projects/
/play` renders, read again
// in place after an edit (components/projects/review/PlayCut.tsx reloadView) rather than by a
// router refresh. GET ?project=[&take= | &cut=1]; no take: the draft (the manifest).
export async function GET(request: Request) {
const q = new URL(request.url).searchParams;
const project = await projectRef(q.get("project") ?? "");
if (!project) return Response.json({ error: "no such project" }, { status: 404 });
const view = await playView(project, { take: q.get("take") || null, bare: q.get("cut") === "1" });
if ("error" in view) return Response.json(view, { status: 400 });
return Response.json(view, { headers: { "cache-control": "no-store" } });
}