CSV TC import
Deploy / deploy (push) Successful in 3m9s

This commit is contained in:
twotalesanimation
2026-06-14 14:12:45 +02:00
parent 1bdb147d24
commit 8caf0f9bd1
6 changed files with 395 additions and 3 deletions
+51
View File
@@ -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.