Key Shots
Deploy / deploy (push) Successful in 3m0s

This commit is contained in:
twotalesanimation
2026-07-09 13:43:16 +02:00
parent 637b141c87
commit 4624a4f67d
6 changed files with 138 additions and 10 deletions
+27
View File
@@ -20,6 +20,7 @@ const createShotSchema = z.object({
dueDate: z.string().optional(),
thumbnailUrl: z.string().optional(),
shotGroupName: z.string().max(100).optional(),
isKeyShot: z.boolean().default(false),
});
export async function createShot(data: z.infer<typeof createShotSchema>) {
@@ -85,6 +86,7 @@ export async function createShot(data: z.infer<typeof createShotSchema>) {
frameEnd: parsed.frameEnd,
dueDate: parsed.dueDate ? new Date(parsed.dueDate) : undefined,
thumbnailUrl: parsed.thumbnailUrl,
isKeyShot: parsed.isKeyShot ?? false,
shotGroupId: parsed.shotGroupName?.trim()
? (await db.shotGroup.upsert({
where: { projectId_name: { projectId: parsed.projectId, name: parsed.shotGroupName.trim() } },
@@ -487,6 +489,31 @@ export async function updateShotNotes(shotId: string, notes: string) {
return { success: true };
}
// ── Toggle Key Shot ───────────────────────────────────────────────────────────
export async function toggleKeyShot(shotId: string, isKeyShot: boolean) {
const session = await auth();
if (!session?.user) throw new Error("Unauthorized");
if (!["ADMIN", "PRODUCER", "SUPERVISOR"].includes(session.user.role)) {
throw new Error("Insufficient permissions");
}
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: { isKeyShot },
});
revalidatePath(`/projects/${shot.projectId}`);
revalidatePath(`/shot-status`);
return { success: true };
}
export async function deleteShot(shotId: string) {
const session = await auth();
if (!session?.user) throw new Error("Unauthorized");