new Approval Updates
Deploy / deploy (push) Failing after 3m34s

This commit is contained in:
twotalesanimation
2026-06-11 12:30:28 +02:00
parent b9610454d9
commit 3f0c5d1dbe
19 changed files with 2015 additions and 70 deletions
+40 -2
View File
@@ -34,8 +34,47 @@ export async function POST(
}
const body = await req.json();
const { versionId, status, notes } = body;
const { versionId, shotId, action, status, notes } = body;
// ── Shot-level approval action ──────────────────────────────────────────────
if (shotId && action) {
const shot = await db.shot.findUnique({
where: { id: shotId },
select: { projectId: true, sharedWithClient: true },
});
if (!shot || shot.projectId !== session.projectId) {
return NextResponse.json({ error: "Shot not found" }, { status: 404 });
}
if (!shot.sharedWithClient) {
return NextResponse.json({ error: "Shot is not available for client review" }, { status: 403 });
}
if (action === "APPROVE") {
await db.shot.update({
where: { id: shotId },
data: { shotApprovalStatus: "CLIENT_APPROVED", status: "COMPLETE" },
});
} else if (action === "NEEDS_CHANGES") {
await db.$transaction(async (tx) => {
await tx.shot.update({
where: { id: shotId },
data: { shotApprovalStatus: "PENDING", sharedWithClient: false },
});
// Mark all non-DONE tasks as CHANGES
await tx.task.updateMany({
where: { shotId, status: { not: "DONE" } },
data: { status: "CHANGES" },
});
await recalcShotStatus(shotId, tx);
});
} else {
return NextResponse.json({ error: "Invalid action" }, { status: 400 });
}
return NextResponse.json({ success: true });
}
// ── Version-level approval (legacy task-based flow) ─────────────────────────
const validStatuses: ApprovalStatus[] = ["APPROVED", "REJECTED", "NEEDS_CHANGES"];
if (!versionId || !validStatuses.includes(status)) {
return NextResponse.json({ error: "versionId and valid status required" }, { status: 400 });
@@ -101,4 +140,3 @@ export async function POST(
return NextResponse.json({ success: true });
}