@@ -970,3 +970,35 @@ export async function clientRequestShotChanges(shotId: string, taskId?: string)
|
||||
revalidatePath(`/shot-status`);
|
||||
return { success: true };
|
||||
}
|
||||
|
||||
// ── Shot Version ──────────────────────────────────────────────────────────────
|
||||
|
||||
const VERSION_RE = /^v\d{3}$/;
|
||||
|
||||
/**
|
||||
* Set or manually override the shot's version string (format: v###).
|
||||
*/
|
||||
export async function updateShotVersion(shotId: string, version: string) {
|
||||
const session = await auth();
|
||||
if (!session?.user) throw new Error("Unauthorized");
|
||||
if (!["ADMIN", "PRODUCER", "SUPERVISOR"].includes(session.user.role)) {
|
||||
throw new Error("Insufficient permissions");
|
||||
}
|
||||
if (!VERSION_RE.test(version)) {
|
||||
throw new Error("Version must be in format v### (e.g. v001, v012)");
|
||||
}
|
||||
|
||||
const shot = await db.shot.findUnique({
|
||||
where: { id: shotId },
|
||||
select: { projectId: true },
|
||||
});
|
||||
if (!shot) throw new Error("Shot not found");
|
||||
|
||||
await db.shot.update({
|
||||
where: { id: shotId },
|
||||
data: { shotVersion: version },
|
||||
});
|
||||
|
||||
revalidatePath(`/projects/${shot.projectId}/shots/${shotId}`);
|
||||
return { success: true, shotVersion: version };
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user