@@ -0,0 +1,22 @@
|
||||
import { auth } from "@/auth";
|
||||
import { redirect } from "next/navigation";
|
||||
import { db } from "@/lib/db";
|
||||
import { StoryboardGenerator } from "@/components/storyboard/StoryboardGenerator";
|
||||
|
||||
export const metadata = { title: "Storyboard Generator" };
|
||||
|
||||
export default async function StoryboardPage() {
|
||||
const session = await auth();
|
||||
if (!session?.user) redirect("/login");
|
||||
if (!["ADMIN", "PRODUCER", "SUPERVISOR"].includes(session.user.role)) {
|
||||
redirect("/dashboard");
|
||||
}
|
||||
|
||||
const projects = await db.project.findMany({
|
||||
where: { status: { in: ["ACTIVE", "ON_HOLD"] } },
|
||||
select: { id: true, name: true, code: true, projectType: true },
|
||||
orderBy: { name: "asc" },
|
||||
});
|
||||
|
||||
return <StoryboardGenerator projects={projects} />;
|
||||
}
|
||||
@@ -0,0 +1,44 @@
|
||||
import { NextRequest, NextResponse } from "next/server";
|
||||
import { auth } from "@/auth";
|
||||
import { db } from "@/lib/db";
|
||||
|
||||
// GET /api/storyboard/shots?projectId=xxx
|
||||
export async function GET(req: NextRequest) {
|
||||
const session = await auth();
|
||||
if (!session?.user) return NextResponse.json({ error: "Unauthorized" }, { status: 401 });
|
||||
if (!["ADMIN", "PRODUCER", "SUPERVISOR"].includes(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,
|
||||
shotNumber: true,
|
||||
sequence: true,
|
||||
description: true,
|
||||
notes: true,
|
||||
status: true,
|
||||
thumbnailUrl: true,
|
||||
frameStart: true,
|
||||
frameEnd: true,
|
||||
fps: true,
|
||||
isKeyShot: true,
|
||||
shotVersion: true,
|
||||
shotGroup: { select: { id: true, name: true } },
|
||||
},
|
||||
orderBy: [
|
||||
{ episode: "asc" },
|
||||
{ scene: "asc" },
|
||||
{ shotNumber: "asc" },
|
||||
],
|
||||
});
|
||||
|
||||
return NextResponse.json({ shots });
|
||||
}
|
||||
Reference in New Issue
Block a user