feat(api): POST /api/insights/[id]/status (status + optional notes)
This commit is contained in:
19
apps/web/src/app/api/insights/[id]/status/route.ts
Normal file
19
apps/web/src/app/api/insights/[id]/status/route.ts
Normal file
@@ -0,0 +1,19 @@
|
||||
import { NextResponse } from "next/server";
|
||||
import { setStatus, setFounderNotes } from "@/app/insights/_actions";
|
||||
|
||||
export const dynamic = "force-dynamic";
|
||||
|
||||
// POST /api/insights/[id]/status { status, notes? }
|
||||
export async function POST(req: Request, { params }: { params: Promise<{ id: string }> }) {
|
||||
const { id } = await params;
|
||||
const body = (await req.json().catch(() => ({}))) as { status?: string; notes?: string };
|
||||
if (!body.status) return NextResponse.json({ ok: false, error: "missing_status" }, { status: 400 });
|
||||
|
||||
try {
|
||||
await setStatus(id, body.status);
|
||||
if (body.notes) await setFounderNotes(id, body.notes);
|
||||
return NextResponse.json({ ok: true });
|
||||
} catch (e) {
|
||||
return NextResponse.json({ ok: false, error: (e as Error).message }, { status: 500 });
|
||||
}
|
||||
}
|
||||
File diff suppressed because one or more lines are too long
Reference in New Issue
Block a user