import { redirect } from "next/navigation";

import { auth } from "@/auth";
import { getBoard } from "@/lib/board";
import { getAiSettingsView } from "@/lib/ai-settings";
import { KanbanBoard } from "@/components/board/kanban-board";

export default async function HomePage() {
  const session = await auth();
  if (!session?.user) redirect("/login");

  const [board, aiSettings] = await Promise.all([
    getBoard({ userId: session.user.id, projectId: null }),
    getAiSettingsView(),
  ]);
  const aiConfigured = !!(aiSettings.apiUrl && aiSettings.model);

  return <KanbanBoard initialCategories={board} aiConfigured={aiConfigured} />;
}
