Added status tracking & episode due dates
Deploy / deploy (push) Failing after 2m30s

This commit is contained in:
twotalesanimation
2026-06-03 14:49:12 +02:00
parent 15046892d1
commit e75a15132e
12 changed files with 915 additions and 25 deletions
+54
View File
@@ -0,0 +1,54 @@
"use server";
import { auth } from "@/auth";
import { db } from "@/lib/db";
import { revalidatePath } from "next/cache";
import { z } from "zod";
const setEpisodeDueDateSchema = z.object({
projectId: z.string().cuid(),
episode: z.string().min(1).max(50),
dueDate: z.string().nullable(),
});
export async function setEpisodeDueDate(data: z.infer<typeof setEpisodeDueDateSchema>) {
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 parsed = setEpisodeDueDateSchema.parse(data);
if (!parsed.dueDate) {
// Remove the due date
await db.episodeDueDate.deleteMany({
where: { projectId: parsed.projectId, episode: parsed.episode },
});
} else {
await db.episodeDueDate.upsert({
where: {
projectId_episode: { projectId: parsed.projectId, episode: parsed.episode },
},
create: {
projectId: parsed.projectId,
episode: parsed.episode,
dueDate: new Date(parsed.dueDate),
},
update: {
dueDate: new Date(parsed.dueDate),
},
});
}
revalidatePath(`/projects/${parsed.projectId}`);
return { success: true };
}
export async function getEpisodeDueDates(projectId: string) {
const rows = await db.episodeDueDate.findMany({
where: { projectId },
orderBy: { episode: "asc" },
});
return rows;
}
+25
View File
@@ -459,6 +459,31 @@ export async function removeFootagePlate(plateId: string) {
return { success: true };
}
// ── Update Shot Notes ─────────────────────────────────────────────────────────
export async function updateShotNotes(shotId: string, notes: 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");
}
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: { notes: notes.trim() || null },
});
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");