import { notFound } from "next/navigation";
import { FrontendNotesPage } from "@/components/frontend-notes-page";
import { frontendArticles } from "@/content/notes/frontend/articles";

const modules = ["frontend", "backend", "ai-agent"] as const;

type PageProps = {
  params: Promise<{
    module: string;
  }>;
};

export function generateStaticParams() {
  return modules.map((module) => ({ module }));
}

export default async function NotesModulePage({ params }: PageProps) {
  const { module } = await params;

  if (!modules.includes(module as (typeof modules)[number])) {
    notFound();
  }

  if (module === "frontend") {
    const articles = frontendArticles.map((article) => ({
      slug: article.slug,
      title: article.title,
      description: article.description,
      href: `/notes/frontend/${article.slug}`,
    }));

    return (
      <FrontendNotesPage
        eyebrow="Frontend knowledge base"
        title="前端笔记"
        description="fly 的前端知识索引，覆盖基础语言、框架机制、浏览器、网络、性能与代码执行题。"
        listDescription="每个入口都是一组可独立阅读的知识点，适合快速定位概念、机制与常见问题。"
        articles={articles}
      />
    );
  }

  if (module === "backend") {
    return (
      <FrontendNotesPage
        eyebrow="Backend knowledge base"
        title="后端笔记"
        description="后端方向会整理服务端基础、接口设计、数据库、部署、鉴权、缓存和稳定性相关内容。"
        featuredTitle="敬请期待"
        listTitle="规划内容"
        listDescription="这些模块会在后续逐步补齐，先保留入口和内容结构。"
        articles={[
          {
            slug: "backend-api",
            title: "API 设计",
            description: "接口规范、请求响应结构、错误码、鉴权边界和版本管理等内容整理。",
            status: "soon",
          },
          {
            slug: "backend-database",
            title: "数据库",
            description: "数据建模、索引、事务、查询优化和常见业务存储方案。",
            status: "soon",
          },
          {
            slug: "backend-deployment",
            title: "部署与服务稳定性",
            description: "服务部署、日志、监控、缓存、限流和故障排查相关实践。",
            status: "soon",
          },
        ]}
      />
    );
  }

  if (module === "ai-agent") {
    return (
      <FrontendNotesPage
        eyebrow="AI Agent knowledge base"
        title="AI Agent 笔记"
        description="AI Agent 方向会记录工作流、工具调用、上下文工程、提示词和自动化场景实践。"
        featuredTitle="敬请期待"
        listTitle="规划内容"
        listDescription="这些方向会随着实践逐步沉淀成可回看的技术文章。"
        articles={[
          {
            slug: "agent-workflow",
            title: "Agent 工作流",
            description: "任务拆解、执行循环、状态管理和人机协作流程。",
            status: "soon",
          },
          {
            slug: "agent-tools",
            title: "工具调用",
            description: "函数调用、MCP、浏览器自动化、文件操作和外部系统集成。",
            status: "soon",
          },
          {
            slug: "agent-prompting",
            title: "提示词与上下文工程",
            description: "角色约束、上下文压缩、记忆策略和输出质量控制。",
            status: "soon",
          },
        ]}
      />
    );
  }

  notFound();
}
