From fcf86a5363a5f7f5b145ea7f476c4267845ee758 Mon Sep 17 00:00:00 2001 From: k2the4 Date: Sun, 30 Aug 2026 01:34:02 +0530 Subject: [PATCH 1/8] Add teacher class selector for Class Analysis --- pages/class-analysis/index.tsx | 60 ++++++++++++++++++++++++++++++++++ 1 file changed, 60 insertions(+) create mode 100644 pages/class-analysis/index.tsx diff --git a/pages/class-analysis/index.tsx b/pages/class-analysis/index.tsx new file mode 100644 index 0000000..6e0a239 --- /dev/null +++ b/pages/class-analysis/index.tsx @@ -0,0 +1,60 @@ +import { GetServerSideProps } from "next"; +import { getServerSession } from "next-auth/next"; +import { authOptions } from "../../lib/authOptions"; +import { prisma } from "../../lib/prisma"; +import Link from "next/link"; + +type ClassOption = { id: string; label: string }; +type Props = { classes: ClassOption[] }; + +function formatClassLabel(department: string, semester: number, classNumber: string) { + return `${department}${classNumber} Sem ${semester}`; +} + +export default function ClassAnalysisIndex({ classes }: Props) { + return ( +
+ ← Back to Dashboard +
+

Class Analysis

+

Choose a class

+

Select a class assigned to you to open its analysis.

+
+
+ {classes.map((classOption) => ( + + {classOption.label} + + ))} + {!classes.length &&

No classes are assigned to you.

} +
+
+ ); +} + +export const getServerSideProps: GetServerSideProps = async (ctx) => { + const session = await getServerSession(ctx.req, ctx.res, authOptions); + if (!session?.user) return { redirect: { destination: "/login", permanent: false } }; + + const userId = (session.user as any).id; + const role = (session.user as any).role; + const sections = await prisma.section.findMany({ + where: role === "ADMIN" ? undefined : { + OR: [ + { class: { proctorId: userId } }, + { subjects: { some: { assignments: { some: { teacherId: userId } } } } }, + ], + }, + include: { class: { include: { department: true } } }, + }); + + const classes = new Map(); + for (const section of sections) { + classes.set(section.class.id, { + id: section.class.id, + label: formatClassLabel(section.class.department.name, section.class.semester, section.name), + }); + } + + return { props: { classes: Array.from(classes.values()) } }; +}; From bc6cc8e64067b5b7aa32c39ffc14817f65a8b9e3 Mon Sep 17 00:00:00 2001 From: k2the4 Date: Sun, 30 Aug 2026 01:34:06 +0530 Subject: [PATCH 2/8] Route Class Analysis through class selector --- pages/section-analysis/index.tsx | 9 +++++++++ 1 file changed, 9 insertions(+) create mode 100644 pages/section-analysis/index.tsx diff --git a/pages/section-analysis/index.tsx b/pages/section-analysis/index.tsx new file mode 100644 index 0000000..6ef2ca4 --- /dev/null +++ b/pages/section-analysis/index.tsx @@ -0,0 +1,9 @@ +import { GetServerSideProps } from "next"; + +export const getServerSideProps: GetServerSideProps = async () => ({ + redirect: { destination: "/class-analysis", permanent: false }, +}); + +export default function SectionAnalysisRedirect() { + return null; +} From c3e2178c486e27bc63a0685ffe24a7aabda97bd0 Mon Sep 17 00:00:00 2001 From: k2the4 Date: Sun, 30 Aug 2026 01:34:12 +0530 Subject: [PATCH 3/8] Redirect legacy class analysis URLs to selector --- pages/section-analysis/[sectionId].tsx | 18 +++++------------- 1 file changed, 5 insertions(+), 13 deletions(-) diff --git a/pages/section-analysis/[sectionId].tsx b/pages/section-analysis/[sectionId].tsx index 93616a0..685a03f 100644 --- a/pages/section-analysis/[sectionId].tsx +++ b/pages/section-analysis/[sectionId].tsx @@ -1,18 +1,10 @@ import { GetServerSideProps } from "next"; -// The bare /section-analysis/[sectionId] URL isn't a page on its own — -// analysis lives under /attendance, /academic, /overall, /students. -// This just sends anyone landing here (dashboard links, bookmarks, etc.) -// straight to the default tab. -export const getServerSideProps: GetServerSideProps = async (ctx) => { - const { sectionId } = ctx.params as { sectionId: string }; - return { - redirect: { - destination: `/section-analysis/${sectionId}/attendance`, - permanent: false, - }, - }; -}; +// Keep legacy dashboard/bookmark URLs working, but always require +// class selection before opening Class Analysis. +export const getServerSideProps: GetServerSideProps = async () => ({ + redirect: { destination: "/class-analysis", permanent: false }, +}); export default function SectionAnalysisRedirect() { return null; From 28d246db1f121ce19b1fa58284a248d54ea0bac1 Mon Sep 17 00:00:00 2001 From: k2the4 Date: Sun, 30 Aug 2026 01:34:26 +0530 Subject: [PATCH 4/8] Fix Subject Analysis class identity and filtering --- pages/subject-analysis/index.tsx | 65 ++++++++++---------------------- 1 file changed, 19 insertions(+), 46 deletions(-) diff --git a/pages/subject-analysis/index.tsx b/pages/subject-analysis/index.tsx index e25b1dc..8b13248 100644 --- a/pages/subject-analysis/index.tsx +++ b/pages/subject-analysis/index.tsx @@ -24,6 +24,10 @@ interface Props { subjects: SubjectOption[]; } +function formatClassLabel(department: string, classNumber: string, semester: number) { + return `${department}${classNumber} Sem ${semester}`; +} + export default function SubjectAnalysisChooser({ teacherName, classes, subjects }: Props) { const [selectedClass, setSelectedClass] = useState(classes[0]?.id || ""); const selectedSubjects = subjects.filter((subject) => subject.sectionId === selectedClass); @@ -40,63 +44,39 @@ export default function SubjectAnalysisChooser({ teacherName, classes, subjects
- - Back to Dashboard - - + Back to Dashboard

Subject Analysis

Choose a class and subject

-

- Select a class you are assigned to, then choose one of your assigned subjects for that class. -

+

Select a class you are assigned to, then choose one of your assigned subjects for that class.

- setSelectedClass(event.target.value)} className="mt-2 w-full rounded-xl border border-[#dfe2e8] bg-white px-4 py-3 text-sm text-[#26314a] outline-none focus:border-[#6b5be7] focus:ring-2 focus:ring-[#6b5be7]/10"> {classes.map((item) => )}
-
{selectedSubjects.length} available
- {selectedSubjects.length === 0 ? ( -
- No subjects are assigned to you for this class. -
+
No subjects are assigned to you for this class.
) : (
{selectedSubjects.map((subject) => ( - - - - + + {subject.name} {subject.code} @@ -108,7 +88,6 @@ export default function SubjectAnalysisChooser({ teacherName, classes, subjects )}
-

Signed in as {teacherName}. Only your assigned classes and subjects are shown.

@@ -118,28 +97,22 @@ export default function SubjectAnalysisChooser({ teacherName, classes, subjects export const getServerSideProps: GetServerSideProps = async (ctx) => { const session = await getServerSession(ctx.req, ctx.res, authOptions); - if (!session?.user) { - return { redirect: { destination: "/login", permanent: false } }; - } + if (!session?.user) return { redirect: { destination: "/login", permanent: false } }; const userId = (session.user as any).id; const role = (session.user as any).role; - const subjectsRaw = await prisma.subject.findMany({ where: role === "ADMIN" ? {} : { assignments: { some: { teacherId: userId } } }, - include: { - section: { include: { class: { include: { department: true } } } }, - }, + include: { section: { include: { class: { include: { department: true } } } } }, orderBy: [{ section: { class: { semester: "asc" } } }, { name: "asc" }], }); const classMap = new Map(); for (const subject of subjectsRaw) { - const section = subject.section; - const sectionClass = section.class; - classMap.set(section.id, { - id: section.id, - label: `${sectionClass.department.name} — ${sectionClass.program}, Sem ${sectionClass.semester}, Section ${section.name}`, + const sectionClass = subject.section.class; + classMap.set(sectionClass.id, { + id: sectionClass.id, + label: formatClassLabel(sectionClass.department.name, subject.section.name, sectionClass.semester), }); } @@ -149,7 +122,7 @@ export const getServerSideProps: GetServerSideProps = async (ctx) => { classes: Array.from(classMap.values()), subjects: subjectsRaw.map((subject) => ({ id: subject.id, - sectionId: subject.section.id, + sectionId: subject.section.class.id, name: subject.name, code: subject.code, })), From 0f86299a824b4341dba64cd4625b0bd1c9979fde Mon Sep 17 00:00:00 2001 From: k2the4 Date: Sun, 30 Aug 2026 01:36:14 +0530 Subject: [PATCH 5/8] Route dashboard Class Analysis through assigned class selector --- pages/dashboard.tsx | 265 +++++--------------------------------------- 1 file changed, 27 insertions(+), 238 deletions(-) diff --git a/pages/dashboard.tsx b/pages/dashboard.tsx index 2229489..8308939 100644 --- a/pages/dashboard.tsx +++ b/pages/dashboard.tsx @@ -28,34 +28,10 @@ interface Props { } const quickActions = [ - { - title: "Attendance Agent", - description: "Take attendance for your current class", - href: "/attendance-agent", - icon: UserRoundPlus, - tone: "bg-[#eef1ff] text-[#4b6bff]", - }, - { - title: "Timetable", - description: "View your full class schedule", - href: "/timetable", - icon: CalendarDays, - tone: "bg-[#eef7ff] text-[#4388d8]", - }, - { - title: "Class Analysis", - description: "Analyze performance of a class/section", - href: "/section-analysis", - icon: BarChart3, - tone: "bg-[#eaf9f1] text-[#159b62]", - }, - { - title: "Subject Analysis", - description: "Deep dive into a subject in a section", - href: "/subject-analysis", - icon: BookOpen, - tone: "bg-[#fff5e7] text-[#ee9412]", - }, + { title: "Attendance Agent", description: "Take attendance for your current class", href: "/attendance-agent", icon: UserRoundPlus, tone: "bg-[#eef1ff] text-[#4b6bff]" }, + { title: "Timetable", description: "View your full class schedule", href: "/timetable", icon: CalendarDays, tone: "bg-[#eef7ff] text-[#4388d8]" }, + { title: "Class Analysis", description: "Analyze performance of a class", href: "/class-analysis", icon: BarChart3, tone: "bg-[#eaf9f1] text-[#159b62]" }, + { title: "Subject Analysis", description: "Deep dive into a subject", href: "/subject-analysis", icon: BookOpen, tone: "bg-[#fff5e7] text-[#ee9412]" }, ]; const todaySchedule = [ @@ -74,230 +50,43 @@ const recentActivity = [ ]; export default function Dashboard({ teacherName, sections, subjects }: Props) { - const initials = teacherName - .split(" ") - .filter(Boolean) - .slice(0, 2) - .map((part) => part[0]?.toUpperCase()) - .join(""); + const initials = teacherName.split(" ").filter(Boolean).slice(0, 2).map((part) => part[0]?.toUpperCase()).join(""); return (
-
-
-
-
-
- - ClassPulse -
-

Welcome back, {teacherName}

-

Here's an overview of your day.

-
-
- -
- - {new Date().toLocaleDateString("en-IN", { day: "numeric", month: "short", year: "numeric" })} -
- -
-
- -
-
-

Quick Actions

-

Jump straight into the tools you use most.

-
-
- {quickActions.map((action) => { - const Icon = action.icon; - const href = action.title === "Class Analysis" - ? sections[0]?.id ? `/section-analysis/${sections[0].id}` : "/section-analysis" - : action.title === "Subject Analysis" - ? "/subject-analysis" - : action.href; - - return ( - - - - {action.title} - {action.description} - - - - ); - })} -
-
- -
-
-
-
-

Today's Timetable

-

Your scheduled classes for today.

-
- View full timetable -
-
- {todaySchedule.map((item, index) => ( -
-
- {item.time} - {item.end} -
-
- - {index < todaySchedule.length - 1 && } -

{item.subject}

-

{item.section} {item.room}

- {item.active && Next class} -
-
- ))} -
-
- -
-
-
-

Recent Activity

-

Your latest updates and actions.

-
-
-
- {recentActivity.map((activity, index) => { - const Icon = activity.icon; - return ( -
- -

{activity.text}

- {activity.time} -
- ); - })} -
-
-
- -
© 2026 ClassPulse. All rights reserved.
-
-
+
+
ClassPulse

Welcome back, {teacherName}

Here's an overview of your day.

{new Date().toLocaleDateString("en-IN", { day: "numeric", month: "short", year: "numeric" })}
+

Quick Actions

Jump straight into the tools you use most.

{quickActions.map((action) => { const Icon = action.icon; return {action.title}{action.description}; })}
+

Today's Timetable

Your scheduled classes for today.

View full timetable
{todaySchedule.map((item, index) =>
{item.time}{item.end}
{index < todaySchedule.length - 1 && }

{item.subject}

{item.section} {item.room}

{item.active && Next class}
)}

Recent Activity

Your latest activity.

{recentActivity.map((activity, index) => { const Icon = activity.icon; return

{activity.text}

{activity.time}
; })}
+
© 2026 ClassPulse. All rights reserved.
+
); } export const getServerSideProps: GetServerSideProps = async (ctx) => { const session = await getServerSession(ctx.req, ctx.res, authOptions); - if (!session?.user) { - return { redirect: { destination: "/login", permanent: false } }; - } - + if (!session?.user) return { redirect: { destination: "/login", permanent: false } }; const userId = (session.user as any).id; const role = (session.user as any).role; - - const sectionsRaw = - role === "ADMIN" - ? await prisma.section.findMany({ include: { class: { include: { department: true } } } }) - : await prisma.section.findMany({ - where: { - OR: [ - { class: { proctorId: userId } }, - { subjects: { some: { assignments: { some: { teacherId: userId } } } } }, - ], - }, - include: { class: { include: { department: true } } }, - }); - - const subjectsRaw = await prisma.subject.findMany({ - where: role === "ADMIN" ? {} : { assignments: { some: { teacherId: userId } } }, - include: { section: { include: { class: true } } }, - }); - - return { - props: { - teacherName: session.user.name || session.user.email, - sections: sectionsRaw.map((s) => ({ - id: s.id, - label: `${s.class.department.name} — ${s.class.program}, Sem ${s.class.semester}, Section ${s.name}`, - })), - subjects: subjectsRaw.map((s) => ({ - id: s.id, - label: `${s.name} (${s.code}) — Section ${s.section.name}`, - })), - }, - }; + const sectionsRaw = await prisma.section.findMany({ where: role === "ADMIN" ? undefined : { OR: [{ class: { proctorId: userId } }, { subjects: { some: { assignments: { some: { teacherId: userId } } } } }] }, include: { class: { include: { department: true } } } }); + const subjectsRaw = await prisma.subject.findMany({ where: role === "ADMIN" ? {} : { assignments: { some: { teacherId: userId } } }, include: { section: { include: { class: true } } } }); + const classMap = new Map(); + for (const section of sectionsRaw) classMap.set(section.class.id, { id: section.class.id, label: `${section.class.department.name}${section.name} Sem ${section.class.semester}` }); + return { props: { teacherName: session.user.name || session.user.email, sections: Array.from(classMap.values()), subjects: subjectsRaw.map((subject) => ({ id: subject.id, label: `${subject.name} (${subject.code})`, classId: subject.section.classId })) } }; }; From 8c48ced919420bca2b48c69fd98bfcbfd6fbd9da Mon Sep 17 00:00:00 2001 From: k2the4 Date: Sun, 30 Aug 2026 13:10:16 +0530 Subject: [PATCH 6/8] Style Class Analysis selector to match Subject Analysis and use ECE-2 label --- pages/class-analysis/index.tsx | 80 ++++++++++++++++++++++++---------- 1 file changed, 58 insertions(+), 22 deletions(-) diff --git a/pages/class-analysis/index.tsx b/pages/class-analysis/index.tsx index 6e0a239..07871b6 100644 --- a/pages/class-analysis/index.tsx +++ b/pages/class-analysis/index.tsx @@ -3,31 +3,70 @@ import { getServerSession } from "next-auth/next"; import { authOptions } from "../../lib/authOptions"; import { prisma } from "../../lib/prisma"; import Link from "next/link"; +import { ArrowLeft, ArrowRight, BarChart3, BookOpen, CalendarDays, LayoutDashboard, LogOut, UserRoundPlus } from "lucide-react"; +import { signOut } from "next-auth/react"; type ClassOption = { id: string; label: string }; -type Props = { classes: ClassOption[] }; +type Props = { classes: ClassOption[]; teacherName: string }; function formatClassLabel(department: string, semester: number, classNumber: string) { - return `${department}${classNumber} Sem ${semester}`; + return `${department}-${classNumber} Sem ${semester}`; } -export default function ClassAnalysisIndex({ classes }: Props) { +export default function ClassAnalysisIndex({ classes, teacherName }: Props) { + const initials = teacherName.split(" ").filter(Boolean).slice(0, 2).map((part) => part[0]?.toUpperCase()).join("") || "T"; + return ( -
- ← Back to Dashboard -
-

Class Analysis

-

Choose a class

-

Select a class assigned to you to open its analysis.

-
-
- {classes.map((classOption) => ( - - {classOption.label} +
+
+
+ {initials} +

{teacherName}

Faculty

+
+ +
+ +
+ + +
+
+
+
+ Back to Dashboard +
+

Class Analysis

+

Choose a class

+

Select a class assigned to you to open its analysis.

+
+ +
+
+ {classes.map((classOption) => ( + + + {classOption.label}Open attendance, academic and student analysis + + + ))} + {!classes.length &&
No classes are assigned to you.
} +
+
+
+
+
); } @@ -50,11 +89,8 @@ export const getServerSideProps: GetServerSideProps = async (ctx) => { const classes = new Map(); for (const section of sections) { - classes.set(section.class.id, { - id: section.class.id, - label: formatClassLabel(section.class.department.name, section.class.semester, section.name), - }); + classes.set(section.class.id, { id: section.class.id, label: formatClassLabel(section.class.department.name, section.class.semester, section.name) }); } - return { props: { classes: Array.from(classes.values()) } }; + return { props: { classes: Array.from(classes.values()), teacherName: session.user.name || session.user.email } }; }; From 3408932355ec494b0db8b240d967ae74ee12528b Mon Sep 17 00:00:00 2001 From: k2the4 Date: Sun, 30 Aug 2026 13:10:34 +0530 Subject: [PATCH 7/8] Use ECE-2 class naming consistently in Subject Analysis --- pages/subject-analysis/index.tsx | 120 +++++-------------------------- 1 file changed, 17 insertions(+), 103 deletions(-) diff --git a/pages/subject-analysis/index.tsx b/pages/subject-analysis/index.tsx index 8b13248..13dfe92 100644 --- a/pages/subject-analysis/index.tsx +++ b/pages/subject-analysis/index.tsx @@ -6,91 +6,30 @@ import Link from "next/link"; import { useState } from "react"; import { BookOpen, ArrowLeft, ArrowRight, BarChart3 } from "lucide-react"; -interface SubjectOption { - id: string; - sectionId: string; - name: string; - code: string; -} - -interface ClassOption { - id: string; - label: string; -} - -interface Props { - teacherName: string; - classes: ClassOption[]; - subjects: SubjectOption[]; -} +interface SubjectOption { id: string; sectionId: string; name: string; code: string; } +interface ClassOption { id: string; label: string; } +interface Props { teacherName: string; classes: ClassOption[]; subjects: SubjectOption[]; } function formatClassLabel(department: string, classNumber: string, semester: number) { - return `${department}${classNumber} Sem ${semester}`; + return `${department}-${classNumber} Sem ${semester}`; } export default function SubjectAnalysisChooser({ teacherName, classes, subjects }: Props) { const [selectedClass, setSelectedClass] = useState(classes[0]?.id || ""); const selectedSubjects = subjects.filter((subject) => subject.sectionId === selectedClass); - return (
- -
-
- Back to Dashboard -
-

Subject Analysis

-

Choose a class and subject

-

Select a class you are assigned to, then choose one of your assigned subjects for that class.

-
- -
-
- - -
-
-
- - {selectedSubjects.length} available -
- {selectedSubjects.length === 0 ? ( -
No subjects are assigned to you for this class.
- ) : ( -
- {selectedSubjects.map((subject) => ( - - - - {subject.name} - {subject.code} - - - - ))} -
- )} -
-
-

Signed in as {teacherName}. Only your assigned classes and subjects are shown.

-
-
+
+ Back to Dashboard +

Subject Analysis

Choose a class and subject

Select a class you are assigned to, then choose one of your assigned subjects for that class.

+
+
{selectedSubjects.length} available
{selectedSubjects.length === 0 ?
No subjects are assigned to you for this class.
:
{selectedSubjects.map((subject) => {subject.name}{subject.code})}
}
+

Signed in as {teacherName}. Only your assigned classes and subjects are shown.

+
); } @@ -98,34 +37,9 @@ export default function SubjectAnalysisChooser({ teacherName, classes, subjects export const getServerSideProps: GetServerSideProps = async (ctx) => { const session = await getServerSession(ctx.req, ctx.res, authOptions); if (!session?.user) return { redirect: { destination: "/login", permanent: false } }; - - const userId = (session.user as any).id; - const role = (session.user as any).role; - const subjectsRaw = await prisma.subject.findMany({ - where: role === "ADMIN" ? {} : { assignments: { some: { teacherId: userId } } }, - include: { section: { include: { class: { include: { department: true } } } } }, - orderBy: [{ section: { class: { semester: "asc" } } }, { name: "asc" }], - }); - + const userId = (session.user as any).id; const role = (session.user as any).role; + const subjectsRaw = await prisma.subject.findMany({ where: role === "ADMIN" ? {} : { assignments: { some: { teacherId: userId } } }, include: { section: { include: { class: { include: { department: true } } } } }, orderBy: [{ section: { class: { semester: "asc" } } }, { name: "asc" }] }); const classMap = new Map(); - for (const subject of subjectsRaw) { - const sectionClass = subject.section.class; - classMap.set(sectionClass.id, { - id: sectionClass.id, - label: formatClassLabel(sectionClass.department.name, subject.section.name, sectionClass.semester), - }); - } - - return { - props: { - teacherName: session.user.name || session.user.email, - classes: Array.from(classMap.values()), - subjects: subjectsRaw.map((subject) => ({ - id: subject.id, - sectionId: subject.section.class.id, - name: subject.name, - code: subject.code, - })), - }, - }; + for (const subject of subjectsRaw) { const c = subject.section.class; classMap.set(c.id, { id: c.id, label: formatClassLabel(c.department.name, subject.section.name, c.semester) }); } + return { props: { teacherName: session.user.name || session.user.email, classes: Array.from(classMap.values()), subjects: subjectsRaw.map((subject) => ({ id: subject.id, sectionId: subject.section.class.id, name: subject.name, code: subject.code })) } }; }; From 42cea994dcaeda2ad3b09c56413ec30799d10569 Mon Sep 17 00:00:00 2001 From: k2the4 Date: Sun, 30 Aug 2026 14:03:23 +0530 Subject: [PATCH 8/8] Route dashboard analysis actions through selectors and use ECE-2 class identity --- pages/dashboard.tsx | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/pages/dashboard.tsx b/pages/dashboard.tsx index 8308939..a42adf2 100644 --- a/pages/dashboard.tsx +++ b/pages/dashboard.tsx @@ -49,7 +49,7 @@ const recentActivity = [ { icon: CalendarDays, tone: "text-[#4388d8] bg-[#eef7ff]", text: "Timetable updated", time: "Aug 27, 3:45 PM" }, ]; -export default function Dashboard({ teacherName, sections, subjects }: Props) { +export default function Dashboard({ teacherName }: Props) { const initials = teacherName.split(" ").filter(Boolean).slice(0, 2).map((part) => part[0]?.toUpperCase()).join(""); return ( @@ -68,7 +68,6 @@ export default function Dashboard({ teacherName, sections, subjects }: Props) {

Need Help?

Visit our help center or contact support.

-
ClassPulse

Welcome back, {teacherName}

Here's an overview of your day.

{new Date().toLocaleDateString("en-IN", { day: "numeric", month: "short", year: "numeric" })}

Quick Actions

Jump straight into the tools you use most.

{quickActions.map((action) => { const Icon = action.icon; return {action.title}{action.description}; })}
@@ -87,6 +86,6 @@ export const getServerSideProps: GetServerSideProps = async (ctx) => { const sectionsRaw = await prisma.section.findMany({ where: role === "ADMIN" ? undefined : { OR: [{ class: { proctorId: userId } }, { subjects: { some: { assignments: { some: { teacherId: userId } } } } }] }, include: { class: { include: { department: true } } } }); const subjectsRaw = await prisma.subject.findMany({ where: role === "ADMIN" ? {} : { assignments: { some: { teacherId: userId } } }, include: { section: { include: { class: true } } } }); const classMap = new Map(); - for (const section of sectionsRaw) classMap.set(section.class.id, { id: section.class.id, label: `${section.class.department.name}${section.name} Sem ${section.class.semester}` }); - return { props: { teacherName: session.user.name || session.user.email, sections: Array.from(classMap.values()), subjects: subjectsRaw.map((subject) => ({ id: subject.id, label: `${subject.name} (${subject.code})`, classId: subject.section.classId })) } }; + for (const section of sectionsRaw) classMap.set(section.class.id, { id: section.class.id, label: `${section.class.department.name}-${section.name} Sem ${section.class.semester}` }); + return { props: { teacherName: session.user.name || session.user.email, sections: Array.from(classMap.values()), subjects: subjectsRaw.map((subject) => ({ id: subject.id, label: `${subject.name} (${subject.code})` })) } }; };