import { getGrades, getStaffOptions } from "@/modules/school/data-access"
import { getSubjectOptions } from "@/modules/elective/data-access"
import { ElectiveCourseForm } from "@/modules/elective/components/elective-course-form"

export const dynamic = "force-dynamic"

export default async function CreateElectiveCoursePage() {
  const [subjects, grades, teachers] = await Promise.all([
    getSubjectOptions(),
    getGrades(),
    getStaffOptions(),
  ])

  return (
    <div className="flex h-full flex-col space-y-8 p-8">
      <div>
        <h2 className="text-2xl font-bold tracking-tight">New Elective Course</h2>
        <p className="text-muted-foreground">Create a new elective course.</p>
      </div>
      <ElectiveCourseForm
        mode="create"
        subjects={subjects}
        grades={grades.map((g) => ({ id: g.id, name: g.name }))}
        teachers={teachers.map((t) => ({ id: t.id, name: t.name }))}
        backHref="/admin/elective"
      />
    </div>
  )
}
