Added bulk date changes
Deploy / deploy (push) Failing after 2m53s

This commit is contained in:
twotalesanimation
2026-06-05 08:01:38 +02:00
parent f5c97fd9a7
commit b187e1b16e
2 changed files with 349 additions and 31 deletions
+45
View File
@@ -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");