@@ -38,7 +38,7 @@ export async function POST(
|
||||
if (shotId && action) {
|
||||
const shot = await db.shot.findUnique({
|
||||
where: { id: shotId },
|
||||
select: { projectId: true, sharedWithClient: true },
|
||||
select: { projectId: true, sharedWithClient: true, shotVersion: true },
|
||||
});
|
||||
if (!shot || shot.projectId !== session.projectId) {
|
||||
return NextResponse.json({ error: "Shot not found" }, { status: 404 });
|
||||
@@ -53,10 +53,16 @@ export async function POST(
|
||||
data: { shotApprovalStatus: "CLIENT_APPROVED", status: "COMPLETE" },
|
||||
});
|
||||
} else if (action === "NEEDS_CHANGES") {
|
||||
// Increment shotVersion: v001 → v002, v009 → v010, etc.
|
||||
const currentVer = shot.shotVersion ?? "v001";
|
||||
const verMatch = currentVer.match(/^v(\d+)$/);
|
||||
const nextNum = verMatch ? parseInt(verMatch[1], 10) + 1 : 2;
|
||||
const nextVersion = "v" + String(nextNum).padStart(3, "0");
|
||||
|
||||
await db.$transaction(async (tx) => {
|
||||
await tx.shot.update({
|
||||
where: { id: shotId },
|
||||
data: { shotApprovalStatus: "PENDING", sharedWithClient: false },
|
||||
data: { shotApprovalStatus: "PENDING", sharedWithClient: false, shotVersion: nextVersion },
|
||||
});
|
||||
// Mark all non-DONE tasks as CHANGES
|
||||
await tx.task.updateMany({
|
||||
|
||||
Reference in New Issue
Block a user