import type { JSX } from "react"
import { requirePermission } from "@/shared/lib/auth-guard"
import { Permissions } from "@/shared/types/permissions"
import { getClassSubjects, getTeacherClasses } from "@/modules/classes/data-access"
import { MyClassesGrid } from "@/modules/classes/components/my-classes-grid"

export const dynamic = "force-dynamic"

export default async function MyClassesPage(): Promise<JSX.Element> {
  await requirePermission(Permissions.CLASS_READ)
  const [classes, subjectOptions] = await Promise.all([getTeacherClasses(), getClassSubjects()])

  return (
    <div className="flex h-full flex-col space-y-4 p-8">
      <MyClassesGrid classes={classes} subjectOptions={subjectOptions} />
    </div>
  )
}
