import { getAuthContext } from "@/shared/lib/auth-guard"
import { getStudentGradeSummary } from "@/modules/grades/data-access"
import { StudentGradeSummary } from "@/modules/grades/components/student-grade-summary"
import {
ParentChildrenDataPage,
ParentNoChildrenPage,
} from "@/modules/parent/components/parent-children-data-page"
import { GraduationCap } from "lucide-react"
export const dynamic = "force-dynamic"
export default async function ParentGradesPage() {
const ctx = await getAuthContext()
if (ctx.dataScope.type !== "children" || ctx.dataScope.childrenIds.length === 0) {
return (
)
}
// 使用 allSettled 容错:单个子女查询失败不影响其他子女展示
const results = await Promise.allSettled(
ctx.dataScope.childrenIds.map((id) => getStudentGradeSummary(id)),
)
const validSummaries = results
.filter(
(r): r is PromiseFulfilledResult>>> =>
r.status === "fulfilled" && r.value !== null,
)
.map((r) => r.value)
return (
(
<>
{summary.studentName}
>
)}
/>
)
}