45459e4b12
Deploy / deploy (push) Successful in 4m14s
The review player's button only made the viewed version client-visible. It never set shot.sharedWithClient, and the client portal lists only shared shots (and only each task's latest version), so the button reported "Shared with Client" while the client saw nothing. It also skipped the internal approval the shot page requires. For a version that belongs to a shot (directly or through its task), the button now runs the shot page's shareWithClient: shot marked shared, latest version of each task visible, status to Client Review. It is disabled with an explanation until the shot is internally approved, and the player's Approve Internally button now appears for task versions too, only while the shot awaits approval. Asset versions keep the per-version share. Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
128 lines
3.5 KiB
TypeScript
128 lines
3.5 KiB
TypeScript
import { notFound } from "next/navigation";
|
|
import { auth } from "@/auth";
|
|
import { db } from "@/lib/db";
|
|
import { ReviewPageClient } from "./ReviewPageClient";
|
|
|
|
export async function generateMetadata({ params }: { params: Promise<{ versionId: string }> }) {
|
|
const { versionId } = await params;
|
|
const version = await db.version.findUnique({
|
|
where: { id: versionId },
|
|
include: {
|
|
shot: { select: { shotCode: true } },
|
|
task: { select: { title: true } },
|
|
},
|
|
});
|
|
if (!version) return { title: "Not Found" };
|
|
const label = version.shot?.shotCode ?? version.task?.title ?? "Version";
|
|
return { title: `Review — ${label} v${version.versionNumber}` };
|
|
}
|
|
|
|
async function getReviewData(versionId: string) {
|
|
const version = await db.version.findUnique({
|
|
where: { id: versionId },
|
|
include: {
|
|
shot: {
|
|
include: {
|
|
project: {
|
|
select: { id: true, name: true, code: true },
|
|
},
|
|
versions: {
|
|
orderBy: { versionNumber: "desc" },
|
|
select: {
|
|
id: true,
|
|
versionNumber: true,
|
|
approvalStatus: true,
|
|
isLatest: true,
|
|
fps: true,
|
|
duration: true,
|
|
notes: true,
|
|
fileSize: true,
|
|
createdAt: true,
|
|
},
|
|
},
|
|
},
|
|
},
|
|
task: {
|
|
include: {
|
|
project: { select: { id: true, name: true, code: true } },
|
|
shot: { select: { id: true, shotCode: true, shotApprovalStatus: true, sharedWithClient: true } },
|
|
asset: { select: { id: true, assetCode: true, name: true } },
|
|
versions: {
|
|
orderBy: { versionNumber: "desc" },
|
|
select: {
|
|
id: true,
|
|
versionNumber: true,
|
|
approvalStatus: true,
|
|
isLatest: true,
|
|
fps: true,
|
|
duration: true,
|
|
notes: true,
|
|
fileSize: true,
|
|
createdAt: true,
|
|
},
|
|
},
|
|
},
|
|
},
|
|
artist: {
|
|
select: { id: true, name: true, image: true, email: true },
|
|
},
|
|
},
|
|
});
|
|
|
|
if (!version) return null;
|
|
|
|
const comments = await db.comment.findMany({
|
|
where: { versionId },
|
|
orderBy: { frameNumber: "asc" },
|
|
include: {
|
|
author: { select: { id: true, name: true, image: true, email: true } },
|
|
replies: {
|
|
orderBy: { createdAt: "asc" },
|
|
include: {
|
|
author: { select: { id: true, name: true, image: true, email: true } },
|
|
},
|
|
},
|
|
},
|
|
});
|
|
|
|
const annotations = await db.annotation.findMany({
|
|
where: { versionId },
|
|
orderBy: { frameNumber: "asc" },
|
|
});
|
|
|
|
return { version, comments, annotations };
|
|
}
|
|
|
|
export default async function ReviewPage({
|
|
params,
|
|
}: {
|
|
params: Promise<{ versionId: string }>;
|
|
}) {
|
|
const { versionId } = await params;
|
|
const session = await auth();
|
|
if (!session?.user) {
|
|
// Already handled by middleware but be safe
|
|
return null;
|
|
}
|
|
|
|
const data = await getReviewData(versionId);
|
|
if (!data) notFound();
|
|
|
|
const canApprove = ["ADMIN", "PRODUCER", "SUPERVISOR", "CLIENT"].includes(
|
|
session.user.role
|
|
);
|
|
const canShare = ["ADMIN", "PRODUCER", "SUPERVISOR"].includes(session.user.role);
|
|
|
|
return (
|
|
<ReviewPageClient
|
|
version={data.version as any}
|
|
comments={data.comments as any}
|
|
annotations={data.annotations as any}
|
|
canApprove={canApprove}
|
|
canShare={canShare}
|
|
currentUserId={session.user.id}
|
|
userRole={session.user.role as string}
|
|
/>
|
|
);
|
|
}
|