diff --git a/actions/tasks.ts b/actions/tasks.ts index c2f22a0..1685dcf 100644 --- a/actions/tasks.ts +++ b/actions/tasks.ts @@ -267,6 +267,26 @@ export async function updateTaskStatus(taskId: string, status: TaskStatus) { }).catch(() => {}); } + // When moved to CLIENT_REVIEW, mark the latest version as client-visible + // (same effect as clicking "Share with Client" on the video player page) + if (status === "CLIENT_REVIEW") { + const latestVersion = await db.version.findFirst({ + where: { taskId, isLatest: true }, + select: { id: true, isClientVisible: true }, + }); + if (latestVersion && !latestVersion.isClientVisible) { + await db.version.update({ + where: { id: latestVersion.id }, + data: { + isClientVisible: true, + sharedAt: new Date(), + sharedById: session.user.id, + }, + }); + revalidatePath(`/review/${latestVersion.id}`); + } + } + // Recalculate shot status from task states if (task.shot) { await recalcShotStatus(task.shot.id).catch(() => {});