import { notFound, redirect } from "next/navigation"; import Link from "next/link"; import { db } from "@/lib/db"; import { auth } from "@/auth"; import { KanbanBoard } from "@/components/tasks/KanbanBoard"; import { ArrowLeft, LayoutDashboard } from "lucide-react"; export async function generateMetadata({ params, }: { params: Promise<{ id: string }>; }) { const { id } = await params; const project = await db.project.findUnique({ where: { id }, select: { name: true }, }); return { title: project ? `${project.name} — Kanban` : "Kanban" }; } export default async function KanbanPage({ params, }: { params: Promise<{ id: string }>; }) { const { id } = await params; const session = await auth(); if (!session?.user) redirect("/login"); // Clients cannot access kanban if (session.user.role === "CLIENT") redirect(`/projects/${id}`); const project = await db.project.findUnique({ where: { id }, select: { id: true, name: true, code: true }, }); if (!project) notFound(); const [tasks, artists] = await Promise.all([ db.task.findMany({ where: { projectId: id }, orderBy: [{ status: "asc" }, { sortOrder: "asc" }], include: { shot: { select: { id: true, shotCode: true } }, asset: { select: { id: true, assetCode: true, name: true } }, assignedArtist: { select: { id: true, name: true, email: true, image: true }, }, _count: { select: { versions: true } }, versions: { take: 1, orderBy: { versionNumber: "desc" }, select: { id: true, versionNumber: true, approvalStatus: true, createdAt: true, }, }, }, }), db.user.findMany({ where: { isActive: true }, select: { id: true, name: true, email: true }, orderBy: { name: "asc" }, }), ]); return (
{/* Breadcrumb */}
Projects / {project.name} / Kanban
{/* Header */}

{project.name}

Kanban Board — {tasks.length} tasks

{/* Board */}
); }