import type { Metadata } from "next"
import type { JSX } from "react"
import { getTranslations } from "next-intl/server"

import { TeacherDashboardView } from "@/modules/dashboard/components/teacher-dashboard/teacher-dashboard-view"
import { getTeacherDashboardAction } from "@/modules/dashboard/actions"

export const dynamic = "force-dynamic"

export async function generateMetadata(): Promise<Metadata> {
  const t = await getTranslations("dashboard")
  return {
    title: t("title.teacher"),
    description: t("description.teacher"),
  }
}

export default async function TeacherDashboardPage(): Promise<JSX.Element> {
  // 传入未解析的 Promise，视图内用 React `use()` 消费，启用 Suspense 流式渲染
  const dataPromise = getTeacherDashboardAction()
  return <TeacherDashboardView dataPromise={dataPromise} />
}
