import { NextResponse } from "next/server";
import { auth } from "@/auth";
import { getTaskComments } from "@/lib/kanban/queries";

export async function GET(
  _req: Request,
  { params }: { params: Promise<{ id: string }> },
) {
  const session = await auth();
  if (!session?.user) {
    return NextResponse.json({ error: "Unauthorized" }, { status: 401 });
  }
  if (!session.user.permissions?.includes("kanban.view")) {
    return NextResponse.json({ error: "Forbidden" }, { status: 403 });
  }
  const { id } = await params;
  return NextResponse.json({ comments: await getTaskComments(id) });
}
