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

import { StudentDashboard } from "@/modules/dashboard/components/student-dashboard/student-dashboard-view"
import { getStudentDashboardAction } from "@/modules/dashboard/actions"

export const dynamic = "force-dynamic"

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

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