30 lines
991 B
TypeScript
30 lines
991 B
TypeScript
import { notFound, redirect } from "next/navigation";
|
|
|
|
import { auth } from "@/auth";
|
|
import { prisma } from "@/lib/db";
|
|
import { projectAccessFilter } from "@/lib/access";
|
|
import { getBoard } from "@/lib/board";
|
|
import { KanbanBoard } from "@/components/board/kanban-board";
|
|
|
|
export default async function ProjectPage({
|
|
params,
|
|
}: {
|
|
params: Promise<{ projectId: string }>;
|
|
}) {
|
|
const session = await auth();
|
|
if (!session?.user) redirect("/login");
|
|
const { projectId } = await params;
|
|
|
|
const project = await prisma.project.findFirst({
|
|
where: { id: projectId, ...projectAccessFilter(session.user.id) },
|
|
select: { id: true, title: true },
|
|
});
|
|
// Same response whether the project doesn't exist or just isn't this
|
|
// user's -- no need to distinguish "not found" from "not yours".
|
|
if (!project) notFound();
|
|
|
|
const board = await getBoard({ projectId: project.id });
|
|
|
|
return <KanbanBoard initialCategories={board} projectId={project.id} title={project.title} />;
|
|
}
|