reference support
Deploy / deploy (push) Successful in 3m38s

This commit is contained in:
twotalesanimation
2026-07-12 10:27:46 +02:00
parent 42e614c592
commit c09d06b6c7
6 changed files with 413 additions and 3 deletions
+45
View File
@@ -0,0 +1,45 @@
import { NextRequest, NextResponse } from "next/server";
import { auth } from "@/auth";
import { db } from "@/lib/db";
function requireRole(role: string) {
return ["ADMIN", "PRODUCER", "SUPERVISOR"].includes(role);
}
// GET /api/shoot-log/shots/[shotId]
// Returns a shot's thumbnail + references for display in the shoot-log
export async function GET(
_req: NextRequest,
{ params }: { params: Promise<{ shotId: string }> }
) {
const session = await auth();
if (!session?.user) return NextResponse.json({ error: "Unauthorized" }, { status: 401 });
if (!requireRole(session.user.role))
return NextResponse.json({ error: "Forbidden" }, { status: 403 });
const { shotId } = await params;
const shot = await db.shot.findUnique({
where: { id: shotId },
select: {
id: true,
shotCode: true,
scene: true,
episode: true,
thumbnailUrl: true,
references: {
orderBy: { sortOrder: "asc" },
select: {
id: true,
fileUrl: true,
fileName: true,
label: true,
sortOrder: true,
},
},
},
});
if (!shot) return NextResponse.json({ error: "Not found" }, { status: 404 });
return NextResponse.json({ shot });
}