This commit is contained in:
@@ -0,0 +1,34 @@
|
||||
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?projectId=xxx
|
||||
// Returns a lightweight shot list for the pipeline-link selector
|
||||
export async function GET(req: NextRequest) {
|
||||
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 projectId = req.nextUrl.searchParams.get("projectId");
|
||||
if (!projectId) return NextResponse.json({ error: "projectId required" }, { status: 400 });
|
||||
|
||||
const shots = await db.shot.findMany({
|
||||
where: { projectId },
|
||||
select: {
|
||||
id: true,
|
||||
shotCode: true,
|
||||
scene: true,
|
||||
episode: true,
|
||||
description: true,
|
||||
status: true,
|
||||
},
|
||||
orderBy: [{ episode: "asc" }, { shotCode: "asc" }],
|
||||
});
|
||||
|
||||
return NextResponse.json({ shots });
|
||||
}
|
||||
Reference in New Issue
Block a user