"use client";

/**
 * 考试作答页面（ai14）
 *
 * 路由：/my-exams/[id]/take
 * 获取 URL 中的 examId，渲染 ExamTaking 组件
 */

import { useParams } from "next/navigation";
import { ExamTaking } from "@/components/exam-taking/exam-taking";

export default function TakeExamPage(): JSX.Element {
  const params = useParams();
  const id =
    typeof params?.id === "string"
      ? params.id
      : Array.isArray(params?.id)
        ? params.id[0]
        : "";

  if (!id) {
    return (
      <div className="flex h-screen items-center justify-center bg-paper">
        <div className="text-center">
          <p className="font-serif text-xl text-danger">考试 ID 缺失</p>
          <p className="mt-sm text-sm text-ink-muted">
            URL 中未包含有效的考试 ID
          </p>
        </div>
      </div>
    );
  }

  return <ExamTaking examId={id} />;
}
