Files
twotalesanimation 42e614c592
Deploy / deploy (push) Successful in 2m41s
feat: link takes to pipeline shots via dropdown selector
2026-07-11 21:26:52 +02:00

35 lines
1.1 KiB
TypeScript

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