import { notFound } from "next/navigation";
import { CourseDetailClient } from "./client";
import { apiGet } from "@/lib/api/server";
import type { Course } from "@/lib/types";

interface Props {
  params: Promise<{ slug: string }>;
}

export default async function CourseDetailPage({ params }: Props) {
  const { slug } = await params;
  const course = await apiGet<Course>(`/api/courses/${slug}`).catch(() => null);

  if (!course) notFound();

  return <CourseDetailClient course={course} />;
}
