@@ -504,6 +504,51 @@ export async function deleteShot(shotId: string) {
|
||||
return { success: true, projectId: shot.projectId };
|
||||
}
|
||||
|
||||
// ── Bulk Update Due Dates ─────────────────────────────────────────────────────
|
||||
|
||||
export async function bulkUpdateDueDates(
|
||||
shotIds: string[],
|
||||
dueDate: string,
|
||||
includeTasks: 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");
|
||||
}
|
||||
|
||||
if (!shotIds.length) return { success: true, updated: 0 };
|
||||
|
||||
const date = new Date(dueDate);
|
||||
|
||||
const shots = await db.shot.findMany({
|
||||
where: { id: { in: shotIds } },
|
||||
select: { id: true, projectId: true },
|
||||
});
|
||||
if (shots.length !== shotIds.length) throw new Error("Some shots not found");
|
||||
|
||||
const projectIds = [...new Set(shots.map((s) => s.projectId))];
|
||||
|
||||
await db.shot.updateMany({
|
||||
where: { id: { in: shotIds } },
|
||||
data: { dueDate: date },
|
||||
});
|
||||
|
||||
if (includeTasks) {
|
||||
await db.task.updateMany({
|
||||
where: { shotId: { in: shotIds } },
|
||||
data: { dueDate: date },
|
||||
});
|
||||
}
|
||||
|
||||
for (const pid of projectIds) {
|
||||
revalidatePath(`/projects/${pid}`);
|
||||
}
|
||||
revalidatePath(`/shot-status`);
|
||||
|
||||
return { success: true, updated: shots.length };
|
||||
}
|
||||
|
||||
export async function renameFootagePlate(plateId: string, label: string) {
|
||||
const session = await auth();
|
||||
if (!session?.user) throw new Error("Unauthorized");
|
||||
|
||||
Reference in New Issue
Block a user