sync-docs-and-fixes
This commit is contained in:
@@ -2,7 +2,7 @@ import Link from "next/link"
|
||||
import { redirect } from "next/navigation"
|
||||
|
||||
import { auth } from "@/auth"
|
||||
import { getStudentClasses, getStudentSchedule } from "@/modules/classes/data-access"
|
||||
import { getStudentClasses, getStudentSchedule, getTeacherClasses, getTeacherTeachingSubjects } from "@/modules/classes/data-access"
|
||||
import { StudentGradesCard } from "@/modules/dashboard/components/student-dashboard/student-grades-card"
|
||||
import { StudentStatsGrid } from "@/modules/dashboard/components/student-dashboard/student-stats-grid"
|
||||
import { StudentTodayScheduleCard } from "@/modules/dashboard/components/student-dashboard/student-today-schedule-card"
|
||||
@@ -44,6 +44,7 @@ export default async function ProfilePage() {
|
||||
|
||||
const role = userProfile.role || "student"
|
||||
const isStudent = role === "student"
|
||||
const isTeacher = role === "teacher"
|
||||
|
||||
const studentData =
|
||||
isStudent
|
||||
@@ -107,6 +108,14 @@ export default async function ProfilePage() {
|
||||
})()
|
||||
: null
|
||||
|
||||
const teacherData =
|
||||
isTeacher
|
||||
? await (async () => {
|
||||
const [subjects, classes] = await Promise.all([getTeacherTeachingSubjects(), getTeacherClasses()])
|
||||
return { subjects, classes }
|
||||
})()
|
||||
: null
|
||||
|
||||
return (
|
||||
<div className="flex h-full flex-col gap-8 p-8">
|
||||
<div className="flex flex-col justify-between gap-4 md:flex-row md:items-center">
|
||||
@@ -231,6 +240,65 @@ export default async function ProfilePage() {
|
||||
</div>
|
||||
</div>
|
||||
) : null}
|
||||
|
||||
{teacherData ? (
|
||||
<div className="space-y-6">
|
||||
<Separator />
|
||||
<div className="space-y-1">
|
||||
<h2 className="text-xl font-semibold tracking-tight">Teacher Overview</h2>
|
||||
<div className="text-sm text-muted-foreground">Your teaching subjects and classes.</div>
|
||||
</div>
|
||||
|
||||
<div className="grid gap-6 lg:grid-cols-2">
|
||||
<Card>
|
||||
<CardHeader>
|
||||
<CardTitle>Teaching Subjects</CardTitle>
|
||||
<CardDescription>Subjects you are currently assigned to teach.</CardDescription>
|
||||
</CardHeader>
|
||||
<CardContent>
|
||||
{teacherData.subjects.length === 0 ? (
|
||||
<div className="text-sm text-muted-foreground">No subjects assigned yet.</div>
|
||||
) : (
|
||||
<div className="flex flex-wrap gap-2">
|
||||
{teacherData.subjects.map((subject) => (
|
||||
<Badge key={subject} variant="secondary">
|
||||
{subject}
|
||||
</Badge>
|
||||
))}
|
||||
</div>
|
||||
)}
|
||||
</CardContent>
|
||||
</Card>
|
||||
|
||||
<Card>
|
||||
<CardHeader>
|
||||
<CardTitle>Teaching Classes</CardTitle>
|
||||
<CardDescription>Classes you are currently managing.</CardDescription>
|
||||
</CardHeader>
|
||||
<CardContent className="space-y-3">
|
||||
{teacherData.classes.length === 0 ? (
|
||||
<div className="text-sm text-muted-foreground">No classes assigned yet.</div>
|
||||
) : (
|
||||
teacherData.classes.map((cls) => (
|
||||
<div key={cls.id} className="flex items-center justify-between gap-4 rounded-md border px-3 py-2">
|
||||
<div className="min-w-0">
|
||||
<div className="truncate text-sm font-medium">{cls.name}</div>
|
||||
<div className="text-xs text-muted-foreground">
|
||||
{cls.grade}
|
||||
{cls.homeroom ? ` • ${cls.homeroom}` : ""}
|
||||
</div>
|
||||
</div>
|
||||
<Button asChild variant="outline" size="sm">
|
||||
<Link href={`/teacher/classes/my/${encodeURIComponent(cls.id)}`}>View</Link>
|
||||
</Button>
|
||||
</div>
|
||||
))
|
||||
)}
|
||||
</CardContent>
|
||||
</Card>
|
||||
</div>
|
||||
</div>
|
||||
) : null}
|
||||
</div>
|
||||
)
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user