Files

32 lines
984 B
TypeScript

import { NextResponse } from "next/server";
import { applyTaskCallback } from "@/lib/tasks";
export async function POST(
request: Request,
{ params }: { params: Promise<{ id: string }> },
) {
const { id } = await params;
const numericId = Number(id);
if (!Number.isInteger(numericId) || numericId <= 0) {
return NextResponse.json({ error: "invalid_task_id" }, { status: 400 });
}
const payload = (await request.json()) as {
status?: "Backlog" | "Todo" | "In Progress" | "Review" | "Done";
dispatch_state?: "planned" | "assigned" | "dispatched" | "acknowledged" | "completed" | "failed";
summary?: string | null;
detail?: string | null;
completed_by?: string | null;
last_error?: string | null;
last_dispatch_at?: string | null;
};
const updated = await applyTaskCallback(numericId, payload);
if (!updated) {
return NextResponse.json({ error: "task_not_found" }, { status: 404 });
}
return NextResponse.json(updated);
}