versioning added
Deploy / deploy (push) Successful in 3m12s

This commit is contained in:
twotalesanimation
2026-06-25 22:19:22 +02:00
parent 935a293777
commit 75d5149bea
8 changed files with 172 additions and 3 deletions
+8 -2
View File
@@ -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({