import { notFound } from "next/navigation";

import { StylePage } from "@/components/style/StylePage";
import { fetchProject, fetchStyleFingerprint } from "@/lib/api/server";
import { normalizeFingerprint } from "@/lib/style/style";

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

// 文风页（UX §6.9）。Server Component 取项目 + 最新指纹（GET /style，无则 null）；
// StylePage（Client）承载上传/学文风/指纹展示交互。
export default async function StyleRoutePage({ params }: PageProps) {
  const { id } = await params;
  try {
    const project = await fetchProject(id);
    const fingerprint = await fetchStyleFingerprint(id);
    return (
      <StylePage
        project={project}
        initialFingerprint={normalizeFingerprint(fingerprint ?? undefined)}
      />
    );
  } catch {
    notFound();
  }
}
