@@ -113,6 +113,21 @@ export async function POST(
|
||||
if (version.task) {
|
||||
if (status === "APPROVED") {
|
||||
await db.task.update({ where: { id: version.task.id }, data: { status: "DONE" } });
|
||||
|
||||
// If this version belongs to a shot that is shared with the client,
|
||||
// also approve the shot at the shot level so it moves to COMPLETE.
|
||||
if (version.task.shot) {
|
||||
const shot = await db.shot.findUnique({
|
||||
where: { id: version.task.shot.id },
|
||||
select: { sharedWithClient: true, shotApprovalStatus: true },
|
||||
});
|
||||
if (shot?.sharedWithClient && shot.shotApprovalStatus !== "CLIENT_APPROVED") {
|
||||
await db.shot.update({
|
||||
where: { id: version.task.shot.id },
|
||||
data: { shotApprovalStatus: "CLIENT_APPROVED", status: "COMPLETE" },
|
||||
});
|
||||
}
|
||||
}
|
||||
} else {
|
||||
await db.task.update({ where: { id: version.task.id }, data: { status: "CHANGES" } });
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user