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 }); }