@@ -873,6 +873,57 @@ export async function importShotsFromEdl(
|
||||
return { created, updated, skipped, errors };
|
||||
}
|
||||
|
||||
// ── Picture Tracker / Sequence Timecode Update ────────────────────────────────
|
||||
|
||||
export interface SeqTimecodeRow {
|
||||
shotCode: string;
|
||||
seqTimecodeStart: string;
|
||||
seqTimecodeEnd: string;
|
||||
}
|
||||
|
||||
export async function updateShotsSeqTimecodes(
|
||||
projectId: string,
|
||||
rows: SeqTimecodeRow[]
|
||||
): Promise<{ updated: string[]; skipped: string[]; errors: 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 updated: string[] = [];
|
||||
const skipped: string[] = [];
|
||||
const errors: string[] = [];
|
||||
|
||||
for (const row of rows) {
|
||||
try {
|
||||
const existing = await db.shot.findFirst({
|
||||
where: { projectId, shotCode: row.shotCode },
|
||||
select: { id: true },
|
||||
});
|
||||
|
||||
if (!existing) {
|
||||
skipped.push(row.shotCode);
|
||||
continue;
|
||||
}
|
||||
|
||||
await db.shot.update({
|
||||
where: { id: existing.id },
|
||||
data: {
|
||||
seqTimecodeStart: row.seqTimecodeStart || null,
|
||||
seqTimecodeEnd: row.seqTimecodeEnd || null,
|
||||
},
|
||||
});
|
||||
updated.push(row.shotCode);
|
||||
} catch (e) {
|
||||
errors.push(`${row.shotCode}: ${e instanceof Error ? e.message : "Unknown error"}`);
|
||||
}
|
||||
}
|
||||
|
||||
revalidatePath(`/projects/${projectId}`);
|
||||
return { updated, skipped, errors };
|
||||
}
|
||||
|
||||
/**
|
||||
* Internal: handle client requesting changes on a shot.
|
||||
* Resets shotApprovalStatus = PENDING, sharedWithClient = false.
|
||||
|
||||
Reference in New Issue
Block a user