✨ add attendance management functionality with report views and user attendance lookup
Browse files at this commitf3367ac343fe59b3840e89f94647cdee25991ab5Parent: c645673- feat
- ✨ add attendance management functionality with report views and user attendance lookup
10 changed files +306 -3
- docs/backend-ui-alignment-plan.md +2 -2
- src/api/getMyAttendance.ts +6 -0
- src/api/getUserAttendance.ts +6 -0
- src/api/types.ts +22 -0
- src/components/attendance/attendance-report-view.tsx +102 -0
- src/components/layout/side-nav.tsx +2 -0
- src/i18n/messages.ts +37 -1
- src/pages/attendance-page.tsx +34 -0
- src/pages/student-attendance-page.tsx +79 -0
- src/routes/router.tsx +16 -0
docs/backend-ui-alignment-plan.mdmodified+2 -2
| @@ -35,13 +35,13 @@ This plan covers the remaining backend features that need simple, low-complexity | |||
| 35 | - Commit 3 complete in UI: manager settings page edits exam kinds, attendance statuses, and grade bands through `PATCH /settings`. | 35 | - Commit 3 complete in UI: manager settings page edits exam kinds, attendance statuses, and grade bands through `PATCH /settings`. |
| 36 | - Commit 4 complete in UI: manager terms page edits terms, and course create/edit can assign an optional term. | 36 | - Commit 4 complete in UI: manager terms page edits terms, and course create/edit can assign an optional term. |
| 37 | - Commit 5 complete in UI: course detail lists lesson sessions, creates sessions, and marks roll call for enrolled students. | 37 | - Commit 5 complete in UI: course detail lists lesson sessions, creates sessions, and marks roll call for enrolled students. |
| 38 | -- Commits 6-7 remain. | 38 | +- Commit 6 complete in UI: attendance report pages show event/session totals, rates, and course breakdowns. |
| 39 | +- Commit 7 remains. | ||
| 39 | 40 | ||
| 40 | ## Remaining Commit Order | 41 | ## Remaining Commit Order |
| 41 | 42 | ||
| 42 | | Commit | Scope | Priority | | 43 | | Commit | Scope | Priority | |
| 43 | | --- | --- | --- | | 44 | | --- | --- | --- | |
| 44 | -| 6 | Attendance report page | Medium | | ||
| 45 | | 7 | Work log page | Medium | | 45 | | 7 | Work log page | Medium | |
| 46 | 46 | ||
| 47 | ## Commit 1: Live Monitor And Exam Room Attempt Fields | 47 | ## Commit 1: Live Monitor And Exam Room Attempt Fields |
src/api/getMyAttendance.tsadded+6 -0
| @@ -0,0 +1,6 @@ | |||
| 1 | +import { client } from "./client"; | ||
| 2 | +import type { AttendanceReport } from "./types"; | ||
| 3 | + | ||
| 4 | +export function getMyAttendance(signal?: AbortSignal): Promise<AttendanceReport> { | ||
| 5 | + return client<AttendanceReport>("/attendance/me", { signal }); | ||
| 6 | +} | ||
src/api/getUserAttendance.tsadded+6 -0
| @@ -0,0 +1,6 @@ | |||
| 1 | +import { client } from "./client"; | ||
| 2 | +import type { AttendanceReport } from "./types"; | ||
| 3 | + | ||
| 4 | +export function getUserAttendance(userId: string, signal?: AbortSignal): Promise<AttendanceReport> { | ||
| 5 | + return client<AttendanceReport>(`/attendance/${userId}`, { signal }); | ||
| 6 | +} | ||
src/api/types.tsmodified+22 -0
| @@ -185,6 +185,28 @@ export type CourseMarks = { | |||
| 185 | average_grade?: string | null; | 185 | average_grade?: string | null; |
| 186 | }; | 186 | }; |
| 187 | 187 | ||
| 188 | +export type AttendanceCounts = { | ||
| 189 | + present: number; | ||
| 190 | + absent: number; | ||
| 191 | + late: number; | ||
| 192 | + excused: number; | ||
| 193 | + custom: Record<string, number>; | ||
| 194 | + total: number; | ||
| 195 | + rate: number | null; | ||
| 196 | +}; | ||
| 197 | + | ||
| 198 | +export type CourseAttendance = { | ||
| 199 | + course: Course; | ||
| 200 | + counts: AttendanceCounts; | ||
| 201 | +}; | ||
| 202 | + | ||
| 203 | +export type AttendanceReport = { | ||
| 204 | + user: string; | ||
| 205 | + events: AttendanceCounts; | ||
| 206 | + sessions: AttendanceCounts; | ||
| 207 | + courses: CourseAttendance[]; | ||
| 208 | +}; | ||
| 209 | + | ||
| 188 | export type MarksReport = { | 210 | export type MarksReport = { |
| 189 | user: string; | 211 | user: string; |
| 190 | courses: CourseMarks[]; | 212 | courses: CourseMarks[]; |
src/components/attendance/attendance-report-view.tsxadded+102 -0
| @@ -0,0 +1,102 @@ | |||
| 1 | +import { For, Show } from "solid-js"; | ||
| 2 | +import { Link } from "@tanstack/solid-router"; | ||
| 3 | +import type { AttendanceCounts, AttendanceReport } from "@/api/types"; | ||
| 4 | +import { Badge } from "@/components/ui/badge"; | ||
| 5 | +import { Table, TableBody, TableCell, TableHead, TableHeader, TableRow } from "@/components/ui/table"; | ||
| 6 | +import { useT } from "@/stores/preferences-context"; | ||
| 7 | + | ||
| 8 | +function percent(rate: number | null): string { | ||
| 9 | + if (rate == null) return "—"; | ||
| 10 | + return `${Math.round(rate * 100)}%`; | ||
| 11 | +} | ||
| 12 | + | ||
| 13 | +function customEntries(counts: AttendanceCounts) { | ||
| 14 | + return Object.entries(counts.custom ?? {}).filter(([, count]) => count > 0); | ||
| 15 | +} | ||
| 16 | + | ||
| 17 | +function CountsCard(props: { title: string; counts: AttendanceCounts }) { | ||
| 18 | + const t = useT(); | ||
| 19 | + return ( | ||
| 20 | + <article class="surface-card space-y-3 p-5"> | ||
| 21 | + <div class="flex items-center justify-between gap-3"> | ||
| 22 | + <h3 class="font-display text-lg font-semibold">{props.title}</h3> | ||
| 23 | + <Badge variant="secondary" class="rounded-full px-3 py-1">{percent(props.counts.rate)}</Badge> | ||
| 24 | + </div> | ||
| 25 | + <dl class="grid grid-cols-2 gap-2 text-sm sm:grid-cols-3"> | ||
| 26 | + <Stat label={t("status.present")} value={props.counts.present} /> | ||
| 27 | + <Stat label={t("status.absent")} value={props.counts.absent} /> | ||
| 28 | + <Stat label={t("status.late")} value={props.counts.late} /> | ||
| 29 | + <Stat label={t("status.excused")} value={props.counts.excused} /> | ||
| 30 | + <Stat label={t("common.all")} value={props.counts.total} /> | ||
| 31 | + <Stat label={t("attendance.rate")} value={percent(props.counts.rate)} /> | ||
| 32 | + </dl> | ||
| 33 | + <Show when={customEntries(props.counts).length > 0}> | ||
| 34 | + <div class="flex flex-wrap gap-2 pt-1"> | ||
| 35 | + <For each={customEntries(props.counts)}>{([label, count]) => <Badge variant="outline" class="rounded-full">{label}: {count}</Badge>}</For> | ||
| 36 | + </div> | ||
| 37 | + </Show> | ||
| 38 | + </article> | ||
| 39 | + ); | ||
| 40 | +} | ||
| 41 | + | ||
| 42 | +function Stat(props: { label: string; value: string | number }) { | ||
| 43 | + return ( | ||
| 44 | + <div class="rounded-md border bg-background/60 p-3"> | ||
| 45 | + <dt class="text-xs text-muted-foreground">{props.label}</dt> | ||
| 46 | + <dd class="mt-1 font-display text-xl font-semibold tabular-nums">{props.value}</dd> | ||
| 47 | + </div> | ||
| 48 | + ); | ||
| 49 | +} | ||
| 50 | + | ||
| 51 | +export function AttendanceReportView(props: { report: AttendanceReport }) { | ||
| 52 | + const t = useT(); | ||
| 53 | + return ( | ||
| 54 | + <div class="space-y-4"> | ||
| 55 | + <div class="grid gap-4 lg:grid-cols-2"> | ||
| 56 | + <CountsCard title={t("attendance.events")} counts={props.report.events} /> | ||
| 57 | + <CountsCard title={t("attendance.sessions")} counts={props.report.sessions} /> | ||
| 58 | + </div> | ||
| 59 | + | ||
| 60 | + <section class="surface-card space-y-4 p-5"> | ||
| 61 | + <h3 class="font-display text-lg font-semibold">{t("attendance.courseBreakdown")}</h3> | ||
| 62 | + <Show | ||
| 63 | + when={props.report.courses.length > 0} | ||
| 64 | + fallback={<div class="rounded-lg border border-dashed border-border/80 bg-muted/20 px-4 py-8 text-center text-sm text-muted-foreground">{t("attendance.emptyCourses")}</div>} | ||
| 65 | + > | ||
| 66 | + <div class="overflow-hidden rounded-lg border border-border/70 bg-background/60"> | ||
| 67 | + <Table> | ||
| 68 | + <TableHeader> | ||
| 69 | + <TableRow> | ||
| 70 | + <TableHead>{t("nav.courses")}</TableHead> | ||
| 71 | + <TableHead>{t("status.present")}</TableHead> | ||
| 72 | + <TableHead>{t("status.absent")}</TableHead> | ||
| 73 | + <TableHead>{t("status.late")}</TableHead> | ||
| 74 | + <TableHead>{t("status.excused")}</TableHead> | ||
| 75 | + <TableHead>{t("common.all")}</TableHead> | ||
| 76 | + <TableHead>{t("attendance.rate")}</TableHead> | ||
| 77 | + </TableRow> | ||
| 78 | + </TableHeader> | ||
| 79 | + <TableBody> | ||
| 80 | + <For each={props.report.courses}> | ||
| 81 | + {(block) => ( | ||
| 82 | + <TableRow> | ||
| 83 | + <TableCell class="font-medium"> | ||
| 84 | + <Link to="/courses/$id" params={{ id: block.course.id }} class="hover:underline">{block.course.title}</Link> | ||
| 85 | + </TableCell> | ||
| 86 | + <TableCell>{block.counts.present}</TableCell> | ||
| 87 | + <TableCell>{block.counts.absent}</TableCell> | ||
| 88 | + <TableCell>{block.counts.late}</TableCell> | ||
| 89 | + <TableCell>{block.counts.excused}</TableCell> | ||
| 90 | + <TableCell>{block.counts.total}</TableCell> | ||
| 91 | + <TableCell class="font-semibold tabular-nums">{percent(block.counts.rate)}</TableCell> | ||
| 92 | + </TableRow> | ||
| 93 | + )} | ||
| 94 | + </For> | ||
| 95 | + </TableBody> | ||
| 96 | + </Table> | ||
| 97 | + </div> | ||
| 98 | + </Show> | ||
| 99 | + </section> | ||
| 100 | + </div> | ||
| 101 | + ); | ||
| 102 | +} | ||
src/components/layout/side-nav.tsxmodified+2 -0
| @@ -31,9 +31,11 @@ const MAIN_ITEMS: NavItem[] = [ | |||
| 31 | { to: "/courses", labelKey: "nav.courses", Icon: IconBook }, | 31 | { to: "/courses", labelKey: "nav.courses", Icon: IconBook }, |
| 32 | { to: "/exams", labelKey: "nav.exams", Icon: IconExam }, | 32 | { to: "/exams", labelKey: "nav.exams", Icon: IconExam }, |
| 33 | { to: "/marks", labelKey: "nav.marks", Icon: IconChart }, | 33 | { to: "/marks", labelKey: "nav.marks", Icon: IconChart }, |
| 34 | + { to: "/attendance", labelKey: "nav.attendance", Icon: IconCalendar }, | ||
| 34 | { to: "/notes", labelKey: "nav.notes", Icon: IconNote }, | 35 | { to: "/notes", labelKey: "nav.notes", Icon: IconNote }, |
| 35 | { to: "/events", labelKey: "nav.events", Icon: IconCalendar }, | 36 | { to: "/events", labelKey: "nav.events", Icon: IconCalendar }, |
| 36 | { to: "/management/student-marks", labelKey: "nav.studentMarks", Icon: IconChart, minRole: "teacher" }, | 37 | { to: "/management/student-marks", labelKey: "nav.studentMarks", Icon: IconChart, minRole: "teacher" }, |
| 38 | + { to: "/management/student-attendance", labelKey: "nav.studentAttendance", Icon: IconCalendar, minRole: "teacher" }, | ||
| 37 | { to: "/management/settings", labelKey: "nav.settings", Icon: IconEdit, minRole: "manager" }, | 39 | { to: "/management/settings", labelKey: "nav.settings", Icon: IconEdit, minRole: "manager" }, |
| 38 | { to: "/management/terms", labelKey: "nav.terms", Icon: IconCalendar, minRole: "manager" }, | 40 | { to: "/management/terms", labelKey: "nav.terms", Icon: IconCalendar, minRole: "manager" }, |
| 39 | { to: "/admin/users", labelKey: "nav.users", Icon: IconUsers, minRole: "admin" }, | 41 | { to: "/admin/users", labelKey: "nav.users", Icon: IconUsers, minRole: "admin" }, |
src/i18n/messages.tsmodified+37 -1
| @@ -9,8 +9,10 @@ export type MessageKey = | |||
| 9 | | "nav.exams" | 9 | | "nav.exams" |
| 10 | | "nav.courses" | 10 | | "nav.courses" |
| 11 | | "nav.marks" | 11 | | "nav.marks" |
| 12 | + | "nav.attendance" | ||
| 12 | | "nav.users" | 13 | | "nav.users" |
| 13 | | "nav.studentMarks" | 14 | | "nav.studentMarks" |
| 15 | + | "nav.studentAttendance" | ||
| 14 | | "nav.settings" | 16 | | "nav.settings" |
| 15 | | "nav.terms" | 17 | | "nav.terms" |
| 16 | | "nav.guide" | 18 | | "nav.guide" |
| @@ -394,7 +396,17 @@ export type MessageKey = | |||
| 394 | | "sessions.teacher" | 396 | | "sessions.teacher" |
| 395 | | "sessions.rollCall" | 397 | | "sessions.rollCall" |
| 396 | | "sessions.startRequired" | 398 | | "sessions.startRequired" |
| 397 | - | "sessions.endInvalid"; | 399 | + | "sessions.endInvalid" |
| 400 | + | "attendance.title" | ||
| 401 | + | "attendance.subtitle" | ||
| 402 | + | "attendance.events" | ||
| 403 | + | "attendance.sessions" | ||
| 404 | + | "attendance.rate" | ||
| 405 | + | "attendance.courseBreakdown" | ||
| 406 | + | "attendance.emptyCourses" | ||
| 407 | + | "attendance.lookup" | ||
| 408 | + | "attendance.show" | ||
| 409 | + | "attendance.forUser"; | ||
| 398 | 410 | ||
| 399 | type Dict = Record<MessageKey, string>; | 411 | type Dict = Record<MessageKey, string>; |
| 400 | 412 | ||
| @@ -407,8 +419,10 @@ const en: Dict = { | |||
| 407 | "nav.exams": "Exams", | 419 | "nav.exams": "Exams", |
| 408 | "nav.courses": "Courses", | 420 | "nav.courses": "Courses", |
| 409 | "nav.marks": "Report card", | 421 | "nav.marks": "Report card", |
| 422 | + "nav.attendance": "Attendance", | ||
| 410 | "nav.users": "Users", | 423 | "nav.users": "Users", |
| 411 | "nav.studentMarks": "Student marks", | 424 | "nav.studentMarks": "Student marks", |
| 425 | + "nav.studentAttendance": "Student attendance", | ||
| 412 | "nav.settings": "Settings", | 426 | "nav.settings": "Settings", |
| 413 | "nav.terms": "Terms", | 427 | "nav.terms": "Terms", |
| 414 | "nav.guide": "Guide", | 428 | "nav.guide": "Guide", |
| @@ -807,6 +821,16 @@ const en: Dict = { | |||
| 807 | "sessions.rollCall": "Roll call", | 821 | "sessions.rollCall": "Roll call", |
| 808 | "sessions.startRequired": "Session start date and time are required.", | 822 | "sessions.startRequired": "Session start date and time are required.", |
| 809 | "sessions.endInvalid": "Enter both end date and end time, or leave both empty.", | 823 | "sessions.endInvalid": "Enter both end date and end time, or leave both empty.", |
| 824 | + "attendance.title": "Attendance report", | ||
| 825 | + "attendance.subtitle": "Event attendance and lesson roll-call rates.", | ||
| 826 | + "attendance.events": "Events", | ||
| 827 | + "attendance.sessions": "Lesson sessions", | ||
| 828 | + "attendance.rate": "Rate", | ||
| 829 | + "attendance.courseBreakdown": "Course breakdown", | ||
| 830 | + "attendance.emptyCourses": "No lesson attendance rows yet.", | ||
| 831 | + "attendance.lookup": "Look up a student's attendance report.", | ||
| 832 | + "attendance.show": "Show attendance", | ||
| 833 | + "attendance.forUser": "Attendance for {user}", | ||
| 810 | }; | 834 | }; |
| 811 | 835 | ||
| 812 | const tr: Dict = { | 836 | const tr: Dict = { |
| @@ -818,8 +842,10 @@ const tr: Dict = { | |||
| 818 | "nav.exams": "Sınavlar", | 842 | "nav.exams": "Sınavlar", |
| 819 | "nav.courses": "Dersler", | 843 | "nav.courses": "Dersler", |
| 820 | "nav.marks": "Karnem", | 844 | "nav.marks": "Karnem", |
| 845 | + "nav.attendance": "Yoklama", | ||
| 821 | "nav.users": "Kullanıcılar", | 846 | "nav.users": "Kullanıcılar", |
| 822 | "nav.studentMarks": "Öğrenci notları", | 847 | "nav.studentMarks": "Öğrenci notları", |
| 848 | + "nav.studentAttendance": "Öğrenci yoklaması", | ||
| 823 | "nav.settings": "Ayarlar", | 849 | "nav.settings": "Ayarlar", |
| 824 | "nav.terms": "Dönemler", | 850 | "nav.terms": "Dönemler", |
| 825 | "nav.guide": "Rehber", | 851 | "nav.guide": "Rehber", |
| @@ -1218,6 +1244,16 @@ const tr: Dict = { | |||
| 1218 | "sessions.rollCall": "Yoklama", | 1244 | "sessions.rollCall": "Yoklama", |
| 1219 | "sessions.startRequired": "Oturum başlangıç tarihi ve saati gerekli.", | 1245 | "sessions.startRequired": "Oturum başlangıç tarihi ve saati gerekli.", |
| 1220 | "sessions.endInvalid": "Bitiş için tarih ve saati birlikte gir ya da ikisini de boş bırak.", | 1246 | "sessions.endInvalid": "Bitiş için tarih ve saati birlikte gir ya da ikisini de boş bırak.", |
| 1247 | + "attendance.title": "Yoklama raporu", | ||
| 1248 | + "attendance.subtitle": "Etkinlik yoklaması ve ders oturumu devam oranları.", | ||
| 1249 | + "attendance.events": "Etkinlikler", | ||
| 1250 | + "attendance.sessions": "Ders oturumları", | ||
| 1251 | + "attendance.rate": "Oran", | ||
| 1252 | + "attendance.courseBreakdown": "Ders dökümü", | ||
| 1253 | + "attendance.emptyCourses": "Henüz ders yoklaması yok.", | ||
| 1254 | + "attendance.lookup": "Bir öğrencinin yoklama raporunu aç.", | ||
| 1255 | + "attendance.show": "Yoklamayı göster", | ||
| 1256 | + "attendance.forUser": "{user} yoklaması", | ||
| 1221 | }; | 1257 | }; |
| 1222 | 1258 | ||
| 1223 | export const messages: Record<Locale, Dict> = { en, tr }; | 1259 | export const messages: Record<Locale, Dict> = { en, tr }; |
src/pages/attendance-page.tsxadded+34 -0
| @@ -0,0 +1,34 @@ | |||
| 1 | +import { Show, Suspense, createResource } from "solid-js"; | ||
| 2 | +import { getMyAttendance } from "@/api/getMyAttendance"; | ||
| 3 | +import { formatApiError } from "@/api/client"; | ||
| 4 | +import { AttendanceReportView } from "@/components/attendance/attendance-report-view"; | ||
| 5 | +import { RouteGuard } from "@/components/layout/route-guard"; | ||
| 6 | +import { PageHeader } from "@/components/layout/page-header"; | ||
| 7 | +import { Alert } from "@/components/ui/alert"; | ||
| 8 | +import { PageSpinner } from "@/components/ui/page-spinner"; | ||
| 9 | +import { useT } from "@/stores/preferences-context"; | ||
| 10 | + | ||
| 11 | +export default function AttendancePage() { | ||
| 12 | + return ( | ||
| 13 | + <RouteGuard> | ||
| 14 | + <AttendanceContent /> | ||
| 15 | + </RouteGuard> | ||
| 16 | + ); | ||
| 17 | +} | ||
| 18 | + | ||
| 19 | +function AttendanceContent() { | ||
| 20 | + const t = useT(); | ||
| 21 | + const [report] = createResource(() => getMyAttendance()); | ||
| 22 | + | ||
| 23 | + return ( | ||
| 24 | + <div class="space-y-6"> | ||
| 25 | + <PageHeader accent="sky" eyebrow={t("nav.attendance")} title={t("attendance.title")} description={t("attendance.subtitle")} /> | ||
| 26 | + <Suspense fallback={<PageSpinner />}> | ||
| 27 | + <Show when={report.error}> | ||
| 28 | + <Alert variant="destructive">{formatApiError(report.error)}</Alert> | ||
| 29 | + </Show> | ||
| 30 | + <Show when={report()}>{(r) => <AttendanceReportView report={r()} />}</Show> | ||
| 31 | + </Suspense> | ||
| 32 | + </div> | ||
| 33 | + ); | ||
| 34 | +} | ||
src/pages/student-attendance-page.tsxadded+79 -0
| @@ -0,0 +1,79 @@ | |||
| 1 | +import { Show, Suspense, createResource, createSignal } from "solid-js"; | ||
| 2 | +import { getUserAttendance } from "@/api/getUserAttendance"; | ||
| 3 | +import { formatApiError } from "@/api/client"; | ||
| 4 | +import { AttendanceReportView } from "@/components/attendance/attendance-report-view"; | ||
| 5 | +import { RouteGuard } from "@/components/layout/route-guard"; | ||
| 6 | +import { PageHeader } from "@/components/layout/page-header"; | ||
| 7 | +import { UserSearchSelect } from "@/components/users/user-search-select"; | ||
| 8 | +import { Button } from "@/components/ui/button"; | ||
| 9 | +import { PageSpinner } from "@/components/ui/page-spinner"; | ||
| 10 | +import { useT } from "@/stores/preferences-context"; | ||
| 11 | + | ||
| 12 | +export default function StudentAttendancePage() { | ||
| 13 | + return ( | ||
| 14 | + <RouteGuard minRole="teacher"> | ||
| 15 | + <StudentAttendanceContent /> | ||
| 16 | + </RouteGuard> | ||
| 17 | + ); | ||
| 18 | +} | ||
| 19 | + | ||
| 20 | +function StudentAttendanceContent() { | ||
| 21 | + const t = useT(); | ||
| 22 | + const [userId, setUserId] = createSignal(""); | ||
| 23 | + const [lookupId, setLookupId] = createSignal<string | null>(null); | ||
| 24 | + const [report] = createResource(lookupId, async (id) => { | ||
| 25 | + if (!id) return null; | ||
| 26 | + return getUserAttendance(id); | ||
| 27 | + }); | ||
| 28 | + | ||
| 29 | + return ( | ||
| 30 | + <div class="space-y-6"> | ||
| 31 | + <PageHeader accent="sky" eyebrow={t("nav.admin")} title={t("nav.studentAttendance")} description={t("attendance.lookup")} /> | ||
| 32 | + | ||
| 33 | + <section class="surface-card space-y-4 p-5"> | ||
| 34 | + <div> | ||
| 35 | + <h2 class="font-display text-lg font-semibold">{t("nav.studentAttendance")}</h2> | ||
| 36 | + <p class="mt-1 text-sm text-muted-foreground">{t("attendance.lookup")}</p> | ||
| 37 | + </div> | ||
| 38 | + <form | ||
| 39 | + class="grid gap-3 sm:grid-cols-[minmax(0,1fr)_auto] sm:items-end" | ||
| 40 | + onSubmit={(e) => { | ||
| 41 | + e.preventDefault(); | ||
| 42 | + const id = userId().trim(); | ||
| 43 | + if (!id) return; | ||
| 44 | + setLookupId(id); | ||
| 45 | + }} | ||
| 46 | + > | ||
| 47 | + <UserSearchSelect | ||
| 48 | + id="student-attendance-user" | ||
| 49 | + label={t("marks.userIdentity")} | ||
| 50 | + value={userId()} | ||
| 51 | + onChange={setUserId} | ||
| 52 | + placeholder={t("common.searchPlaceholder")} | ||
| 53 | + selectPlaceholder={t("marks.userIdentity")} | ||
| 54 | + emptyMessage={t("admin.noUsers")} | ||
| 55 | + allowManualValue | ||
| 56 | + /> | ||
| 57 | + <Button type="submit" class="h-9 w-full sm:w-auto">{t("attendance.show")}</Button> | ||
| 58 | + </form> | ||
| 59 | + | ||
| 60 | + <Show when={report.error}> | ||
| 61 | + <p class="rounded-md bg-destructive/10 px-3 py-2 text-sm text-destructive">{formatApiError(report.error)}</p> | ||
| 62 | + </Show> | ||
| 63 | + </section> | ||
| 64 | + | ||
| 65 | + <Suspense fallback={<PageSpinner />}> | ||
| 66 | + <Show when={report()}> | ||
| 67 | + {(r) => ( | ||
| 68 | + <div class="space-y-4"> | ||
| 69 | + <p class="rounded-lg border bg-background/60 px-4 py-3 text-sm text-muted-foreground"> | ||
| 70 | + {t("attendance.forUser", { user: lookupId() ?? "" })} | ||
| 71 | + </p> | ||
| 72 | + <AttendanceReportView report={r()} /> | ||
| 73 | + </div> | ||
| 74 | + )} | ||
| 75 | + </Show> | ||
| 76 | + </Suspense> | ||
| 77 | + </div> | ||
| 78 | + ); | ||
| 79 | +} | ||
src/routes/router.tsxmodified+16 -0
| @@ -37,6 +37,8 @@ const CoursesPage = lazyRoute(() => import("@/pages/courses-page")); | |||
| 37 | const CourseDetailPage = lazyRoute(() => import("@/pages/course-detail-page")); | 37 | const CourseDetailPage = lazyRoute(() => import("@/pages/course-detail-page")); |
| 38 | const MarksPage = lazyRoute(() => import("@/pages/marks-page")); | 38 | const MarksPage = lazyRoute(() => import("@/pages/marks-page")); |
| 39 | const StudentMarksPage = lazyRoute(() => import("@/pages/student-marks-page")); | 39 | const StudentMarksPage = lazyRoute(() => import("@/pages/student-marks-page")); |
| 40 | +const AttendancePage = lazyRoute(() => import("@/pages/attendance-page")); | ||
| 41 | +const StudentAttendancePage = lazyRoute(() => import("@/pages/student-attendance-page")); | ||
| 40 | const ProfilePage = lazyRoute(() => import("@/pages/profile-page")); | 42 | const ProfilePage = lazyRoute(() => import("@/pages/profile-page")); |
| 41 | const LiveMonitorPage = lazyRoute(() => import("@/pages/live-monitor-page")); | 43 | const LiveMonitorPage = lazyRoute(() => import("@/pages/live-monitor-page")); |
| 42 | const AdminUsersPage = lazyRoute(() => import("@/pages/admin-users-page")); | 44 | const AdminUsersPage = lazyRoute(() => import("@/pages/admin-users-page")); |
| @@ -156,6 +158,18 @@ const studentMarksRoute = createRoute({ | |||
| 156 | component: StudentMarksPage, | 158 | component: StudentMarksPage, |
| 157 | }); | 159 | }); |
| 158 | 160 | ||
| 161 | +const attendanceRoute = createRoute({ | ||
| 162 | + getParentRoute: () => rootRoute, | ||
| 163 | + path: "/attendance", | ||
| 164 | + component: AttendancePage, | ||
| 165 | +}); | ||
| 166 | + | ||
| 167 | +const studentAttendanceRoute = createRoute({ | ||
| 168 | + getParentRoute: () => rootRoute, | ||
| 169 | + path: "/management/student-attendance", | ||
| 170 | + component: StudentAttendancePage, | ||
| 171 | +}); | ||
| 172 | + | ||
| 159 | const settingsRoute = createRoute({ | 173 | const settingsRoute = createRoute({ |
| 160 | getParentRoute: () => rootRoute, | 174 | getParentRoute: () => rootRoute, |
| 161 | path: "/management/settings", | 175 | path: "/management/settings", |
| @@ -221,6 +235,8 @@ const routeTree = rootRoute.addChildren([ | |||
| 221 | courseDetailRoute, | 235 | courseDetailRoute, |
| 222 | marksRoute, | 236 | marksRoute, |
| 223 | studentMarksRoute, | 237 | studentMarksRoute, |
| 238 | + attendanceRoute, | ||
| 239 | + studentAttendanceRoute, | ||
| 224 | settingsRoute, | 240 | settingsRoute, |
| 225 | termsRoute, | 241 | termsRoute, |
| 226 | profileRoute, | 242 | profileRoute, |