import { notFound } from "next/navigation";

import { ForeshadowBoard } from "@/components/foreshadow/ForeshadowBoard";
import { fetchForeshadow, fetchProject } from "@/lib/api/server";

interface PageProps {
  params: Promise<{ id: string }>;
}

// 伏笔看板页（UX §6.8）。Server Component 取项目 + 全量伏笔（GET .../foreshadow）；
// ForeshadowBoard（Client）按 status 分四泳道并承载登记/状态变更交互。
export default async function ForeshadowPage({ params }: PageProps) {
  const { id } = await params;
  try {
    const project = await fetchProject(id);
    const board = await fetchForeshadow(id);
    return (
      <ForeshadowBoard project={project} initialItems={board.foreshadow ?? []} />
    );
  } catch {
    notFound();
  }
}
