🐛 hide tabs of switched-off modules, role-aware /attendance
Browse files at this commitb84d86096b635e911c8034e9a66d54f77614f01dParent: 8e51fe0- fix
- 🐛 hide tabs of switched-off modules, role-aware /attendance
7 changed files +139 -31
- src/components/layout/attendance-redirect.tsx +29 -0
- src/components/layout/nav-items.ts +2 -0
- src/lib/route-module.test.ts +4 -0
- src/lib/route-module.ts +2 -0
- src/pages/course-detail-page.tsx +53 -16
- src/pages/instance-detail-page.tsx +46 -12
- src/routes/router.tsx +3 -3
src/components/layout/attendance-redirect.tsxadded+29 -0
| @@ -0,0 +1,29 @@ | |||
| 1 | +import { Navigate } from "@tanstack/solid-router"; | ||
| 2 | +import { Show } from "solid-js"; | ||
| 3 | +import { RouteGuard } from "@/components/layout/route-guard"; | ||
| 4 | +import { useAuth } from "@/stores/auth-context"; | ||
| 5 | + | ||
| 6 | +/** | ||
| 7 | + * `/attendance` is an old link every role may still hold. Attendance lives on | ||
| 8 | + * a different page per role — a student's own report, a parent's child view, | ||
| 9 | + * the staff roll-call tool — so the alias resolves once the role is known | ||
| 10 | + * instead of sending everyone to the student-only page (a 403 for staff). | ||
| 11 | + */ | ||
| 12 | +export function AttendanceRedirect() { | ||
| 13 | + const auth = useAuth(); | ||
| 14 | + return ( | ||
| 15 | + <RouteGuard> | ||
| 16 | + <Show when={auth.user()?.role} keyed> | ||
| 17 | + {(role) => | ||
| 18 | + role === "student" ? ( | ||
| 19 | + <Navigate to="/marks" search={{ tab: "attendance" }} replace /> | ||
| 20 | + ) : role === "parent" ? ( | ||
| 21 | + <Navigate to="/students/attendance" replace /> | ||
| 22 | + ) : ( | ||
| 23 | + <Navigate to="/management/student-attendance" replace /> | ||
| 24 | + ) | ||
| 25 | + } | ||
| 26 | + </Show> | ||
| 27 | + </RouteGuard> | ||
| 28 | + ); | ||
| 29 | +} | ||
src/components/layout/nav-items.tsmodified+2 -0
| @@ -79,6 +79,7 @@ const AI_STUDIO_ITEM: NavItem = { | |||
| 79 | to: "/ai/studio", | 79 | to: "/ai/studio", |
| 80 | labelKey: "aiHub.tab.studio", | 80 | labelKey: "aiHub.tab.studio", |
| 81 | Icon: IconWaveform, | 81 | Icon: IconWaveform, |
| 82 | + module: "course_notes", | ||
| 82 | }; | 83 | }; |
| 83 | 84 | ||
| 84 | const AI_STUDY_ITEM: NavItem = { | 85 | const AI_STUDY_ITEM: NavItem = { |
| @@ -101,6 +102,7 @@ const AI_CELEBI_ITEM: NavItem = { | |||
| 101 | labelKey: "nav.celebi", | 102 | labelKey: "nav.celebi", |
| 102 | Icon: IconSparkles, | 103 | Icon: IconSparkles, |
| 103 | action: "celebi", | 104 | action: "celebi", |
| 105 | + module: "chatbot", | ||
| 104 | }; | 106 | }; |
| 105 | 107 | ||
| 106 | const AI_GROUP: NavGroup = { | 108 | const AI_GROUP: NavGroup = { |
src/lib/route-module.test.tsmodified+4 -0
| @@ -6,6 +6,7 @@ describe("routeModule", () => { | |||
| 6 | expect(routeModule("/notes/abc")).toBe("notes"); | 6 | expect(routeModule("/notes/abc")).toBe("notes"); |
| 7 | expect(routeModule("/exam-room/1")).toBe("exams"); | 7 | expect(routeModule("/exam-room/1")).toBe("exams"); |
| 8 | expect(routeModule("/question-bank/9")).toBe("bank_questions"); | 8 | expect(routeModule("/question-bank/9")).toBe("bank_questions"); |
| 9 | + expect(routeModule("/ai/studio")).toBe("course_notes"); | ||
| 9 | }); | 10 | }); |
| 10 | 11 | ||
| 11 | it("prefers the longest prefix", () => { | 12 | it("prefers the longest prefix", () => { |
| @@ -18,5 +19,8 @@ describe("routeModule", () => { | |||
| 18 | expect(routeModule("/calendar")).toBeNull(); | 19 | expect(routeModule("/calendar")).toBeNull(); |
| 19 | expect(routeModule("/management/students")).toBeNull(); | 20 | expect(routeModule("/management/students")).toBeNull(); |
| 20 | expect(routeModule("/notebook")).toBeNull(); | 21 | expect(routeModule("/notebook")).toBeNull(); |
| 22 | + // Study and insights read RAG/insight doors no school module gates. | ||
| 23 | + expect(routeModule("/ai/study")).toBeNull(); | ||
| 24 | + expect(routeModule("/ai/insights")).toBeNull(); | ||
| 21 | }); | 25 | }); |
| 22 | }); | 26 | }); |
src/lib/route-module.tsmodified+2 -0
| @@ -18,6 +18,8 @@ const ROUTE_MODULES: ReadonlyArray<readonly [prefix: string, module: string]> = | |||
| 18 | ["/students/attendance", "attendance"], | 18 | ["/students/attendance", "attendance"], |
| 19 | ["/students/exams", "marks"], | 19 | ["/students/exams", "marks"], |
| 20 | ["/students/study", "pomodoro"], | 20 | ["/students/study", "pomodoro"], |
| 21 | + // Note Studio works on course notes (lists them, runs RAG/podcast over them). | ||
| 22 | + ["/ai/studio", "course_notes"], | ||
| 21 | ["/question-bank", "bank_questions"], | 23 | ["/question-bank", "bank_questions"], |
| 22 | ["/appointments", "appointments"], | 24 | ["/appointments", "appointments"], |
| 23 | ["/whiteboards", "boards"], | 25 | ["/whiteboards", "boards"], |
src/pages/course-detail-page.tsxmodified+53 -16
| @@ -1,4 +1,4 @@ | |||
| 1 | -import { For, Show, Suspense, createMemo, createSignal } from "solid-js"; | 1 | +import { For, Show, Suspense, createEffect, createMemo, createSignal } from "solid-js"; |
| 2 | import { createResource } from "@/lib/create-resource"; | 2 | import { createResource } from "@/lib/create-resource"; |
| 3 | import { Link, useLocation, useNavigate, useParams } from "@tanstack/solid-router"; | 3 | import { Link, useLocation, useNavigate, useParams } from "@tanstack/solid-router"; |
| 4 | import type { ColumnDef } from "@tanstack/solid-table"; | 4 | import type { ColumnDef } from "@tanstack/solid-table"; |
| @@ -37,6 +37,7 @@ import { TableRowActions } from "@/components/ui/table-row-actions"; | |||
| 37 | import { Textarea } from "@/components/ui/textarea"; | 37 | import { Textarea } from "@/components/ui/textarea"; |
| 38 | import { UserSearchSelect } from "@/components/users/user-search-select"; | 38 | import { UserSearchSelect } from "@/components/users/user-search-select"; |
| 39 | import { useAuth } from "@/stores/auth-context"; | 39 | import { useAuth } from "@/stores/auth-context"; |
| 40 | +import { useModules } from "@/stores/modules-context"; | ||
| 40 | import { useT } from "@/stores/preferences-context"; | 41 | import { useT } from "@/stores/preferences-context"; |
| 41 | import { hasMinRole } from "@/lib/roles"; | 42 | import { hasMinRole } from "@/lib/roles"; |
| 42 | import { cn } from "@/lib/cn"; | 43 | import { cn } from "@/lib/cn"; |
| @@ -47,6 +48,9 @@ const COURSE_KINDS: CourseKind[] = ["course", "study", "club"]; | |||
| 47 | /** One row of the "taught in" list: an instance plus the şube's name. */ | 48 | /** One row of the "taught in" list: an instance plus the şube's name. */ |
| 48 | type SectionRow = { instance: Instance | ClassCourse; className: string }; | 49 | type SectionRow = { instance: Instance | ClassCourse; className: string }; |
| 49 | 50 | ||
| 51 | +// Literal class names so Tailwind sees every column count the tab strip can take. | ||
| 52 | +const TAB_GRID_COLS: Record<number, string> = { 1: "sm:grid-cols-1", 2: "sm:grid-cols-2", 3: "sm:grid-cols-3", 4: "sm:grid-cols-4" }; | ||
| 53 | + | ||
| 50 | export default function CourseDetailPage() { | 54 | export default function CourseDetailPage() { |
| 51 | return ( | 55 | return ( |
| 52 | <RouteGuard> | 56 | <RouteGuard> |
| @@ -66,7 +70,26 @@ function CourseDetailContent() { | |||
| 66 | return params().id; | 70 | return params().id; |
| 67 | }); | 71 | }); |
| 68 | 72 | ||
| 73 | + // Subjects, sections and course notes are separately sold modules; a tab for | ||
| 74 | + // one the school switched off would only ever answer 403, so it is left out | ||
| 75 | + // and the page opens on the first tab still there. | ||
| 76 | + const modules = useModules(); | ||
| 77 | + const tabOn = { | ||
| 78 | + subjects: () => modules.isEnabled("subjects"), | ||
| 79 | + sections: () => modules.isEnabled("classes"), | ||
| 80 | + notes: () => modules.isEnabled("course_notes"), | ||
| 81 | + }; | ||
| 69 | const [courseTab, setCourseTab] = createSignal("subjects"); | 82 | const [courseTab, setCourseTab] = createSignal("subjects"); |
| 83 | + const availableTabs = () => [ | ||
| 84 | + ...(tabOn.subjects() ? ["subjects"] : []), | ||
| 85 | + ...(tabOn.sections() ? ["sections"] : []), | ||
| 86 | + ...(tabOn.notes() ? ["notes"] : []), | ||
| 87 | + ...(hasMembers() ? ["members"] : []), | ||
| 88 | + ]; | ||
| 89 | + createEffect(() => { | ||
| 90 | + const tabs = availableTabs(); | ||
| 91 | + if (tabs.length > 0 && !tabs.includes(courseTab())) setCourseTab(tabs[0]); | ||
| 92 | + }); | ||
| 70 | const [course, { refetch: refetchCourse }] = createResource(id, (courseId) => getCourseById(courseId)); | 93 | const [course, { refetch: refetchCourse }] = createResource(id, (courseId) => getCourseById(courseId)); |
| 71 | const [mine] = createResource( | 94 | const [mine] = createResource( |
| 72 | () => (auth.user()?.role === "student" ? true : null), | 95 | () => (auth.user()?.role === "student" ? true : null), |
| @@ -90,7 +113,7 @@ function CourseDetailContent() { | |||
| 90 | // in one call; the office has no course-scoped instance route, so it walks | 113 | // in one call; the office has no course-scoped instance route, so it walks |
| 91 | // the class list instead (one call per class, capped by the page limit). | 114 | // the class list instead (one call per class, capped by the page limit). |
| 92 | const [sections] = createResource( | 115 | const [sections] = createResource( |
| 93 | - () => (course() ? { courseId: id(), office: isOffice() } : null), | 116 | + () => (course() && tabOn.sections() ? { courseId: id(), office: isOffice() } : null), |
| 94 | async (args): Promise<SectionRow[]> => { | 117 | async (args): Promise<SectionRow[]> => { |
| 95 | if (!args) return []; | 118 | if (!args) return []; |
| 96 | if (!args.office) { | 119 | if (!args.office) { |
| @@ -429,15 +452,22 @@ function CourseDetailContent() { | |||
| 429 | </Show> | 452 | </Show> |
| 430 | 453 | ||
| 431 | <Tabs value={courseTab()} onChange={setCourseTab} class="space-y-4"> | 454 | <Tabs value={courseTab()} onChange={setCourseTab} class="space-y-4"> |
| 432 | - <TabsList class={cn("w-full justify-start gap-0 overflow-x-auto rounded-lg border-border-line bg-surface-base p-0 shadow-none sm:grid", hasMembers() ? "sm:grid-cols-4" : "sm:grid-cols-3")} aria-label={c().title}> | 455 | + <TabsList class={cn("w-full justify-start gap-0 overflow-x-auto rounded-lg border-border-line bg-surface-base p-0 shadow-none sm:grid", TAB_GRID_COLS[availableTabs().length] ?? "sm:grid-cols-4")} aria-label={c().title}> |
| 433 | - <TabsTrigger value="subjects" onClick={(event) => { event.preventDefault(); setCourseTab("subjects"); }} class="min-w-0 rounded-none border-r border-border-line last:border-r-0 data-selected:border-b-2 data-selected:border-b-primary data-selected:bg-surface-base data-selected:shadow-none"><IconBook class="h-4 w-4" />{t("subjects.title")}</TabsTrigger> | 456 | + <Show when={tabOn.subjects()}> |
| 434 | - <TabsTrigger value="sections" onClick={(event) => { event.preventDefault(); setCourseTab("sections"); }} class="min-w-0 rounded-none border-r border-border-line last:border-r-0 data-selected:border-b-2 data-selected:border-b-primary data-selected:bg-surface-base data-selected:shadow-none"><IconSchool class="h-4 w-4" />{t("instances.title")}</TabsTrigger> | 457 | + <TabsTrigger value="subjects" onClick={(event) => { event.preventDefault(); setCourseTab("subjects"); }} class="min-w-0 rounded-none border-r border-border-line last:border-r-0 data-selected:border-b-2 data-selected:border-b-primary data-selected:bg-surface-base data-selected:shadow-none"><IconBook class="h-4 w-4" />{t("subjects.title")}</TabsTrigger> |
| 435 | - <TabsTrigger value="notes" onClick={(event) => { event.preventDefault(); setCourseTab("notes"); }} class="min-w-0 rounded-none border-r border-border-line last:border-r-0 data-selected:border-b-2 data-selected:border-b-primary data-selected:bg-surface-base data-selected:shadow-none"><IconNote class="h-4 w-4" />{t("courseNotes.title")}<Show when={noteCount() != null}><span class="ml-0.5 tabular-nums">{noteCount()}</span></Show></TabsTrigger> | 458 | + </Show> |
| 459 | + <Show when={tabOn.sections()}> | ||
| 460 | + <TabsTrigger value="sections" onClick={(event) => { event.preventDefault(); setCourseTab("sections"); }} class="min-w-0 rounded-none border-r border-border-line last:border-r-0 data-selected:border-b-2 data-selected:border-b-primary data-selected:bg-surface-base data-selected:shadow-none"><IconSchool class="h-4 w-4" />{t("instances.title")}</TabsTrigger> | ||
| 461 | + </Show> | ||
| 462 | + <Show when={tabOn.notes()}> | ||
| 463 | + <TabsTrigger value="notes" onClick={(event) => { event.preventDefault(); setCourseTab("notes"); }} class="min-w-0 rounded-none border-r border-border-line last:border-r-0 data-selected:border-b-2 data-selected:border-b-primary data-selected:bg-surface-base data-selected:shadow-none"><IconNote class="h-4 w-4" />{t("courseNotes.title")}<Show when={noteCount() != null}><span class="ml-0.5 tabular-nums">{noteCount()}</span></Show></TabsTrigger> | ||
| 464 | + </Show> | ||
| 436 | <Show when={hasMembers()}> | 465 | <Show when={hasMembers()}> |
| 437 | <TabsTrigger value="members" onClick={(event) => { event.preventDefault(); setCourseTab("members"); }} class="min-w-0 rounded-none border-r border-border-line last:border-r-0 data-selected:border-b-2 data-selected:border-b-primary data-selected:bg-surface-base data-selected:shadow-none"><IconUsers class="h-4 w-4" />{t("courses.members")}</TabsTrigger> | 466 | <TabsTrigger value="members" onClick={(event) => { event.preventDefault(); setCourseTab("members"); }} class="min-w-0 rounded-none border-r border-border-line last:border-r-0 data-selected:border-b-2 data-selected:border-b-primary data-selected:bg-surface-base data-selected:shadow-none"><IconUsers class="h-4 w-4" />{t("courses.members")}</TabsTrigger> |
| 438 | </Show> | 467 | </Show> |
| 439 | </TabsList> | 468 | </TabsList> |
| 440 | 469 | ||
| 470 | + <Show when={tabOn.subjects()}> | ||
| 441 | <TabsContent value="subjects" forceMount class="space-y-3"> | 471 | <TabsContent value="subjects" forceMount class="space-y-3"> |
| 442 | <CourseSubjectsPanel | 472 | <CourseSubjectsPanel |
| 443 | courseId={id()} | 473 | courseId={id()} |
| @@ -446,7 +476,9 @@ function CourseDetailContent() { | |||
| 446 | onCreateOpenChange={setShowSubjectForm} | 476 | onCreateOpenChange={setShowSubjectForm} |
| 447 | /> | 477 | /> |
| 448 | </TabsContent> | 478 | </TabsContent> |
| 479 | + </Show> | ||
| 449 | 480 | ||
| 481 | + <Show when={tabOn.sections()}> | ||
| 450 | <TabsContent value="sections" forceMount class="space-y-3"> | 482 | <TabsContent value="sections" forceMount class="space-y-3"> |
| 451 | <div class="rounded-xl border border-border-line bg-surface-base p-3 shadow-xs"> | 483 | <div class="rounded-xl border border-border-line bg-surface-base p-3 shadow-xs"> |
| 452 | <DataToolbar | 484 | <DataToolbar |
| @@ -474,8 +506,11 @@ function CourseDetailContent() { | |||
| 474 | </Suspense> | 506 | </Suspense> |
| 475 | </div> | 507 | </div> |
| 476 | </TabsContent> | 508 | </TabsContent> |
| 509 | + </Show> | ||
| 477 | 510 | ||
| 478 | - <TabsContent value="notes" forceMount class="space-y-3" /> | 511 | + <Show when={tabOn.notes()}> |
| 512 | + <TabsContent value="notes" forceMount class="space-y-3" /> | ||
| 513 | + </Show> | ||
| 479 | 514 | ||
| 480 | <Show when={hasMembers()}> | 515 | <Show when={hasMembers()}> |
| 481 | <TabsContent value="members" forceMount class="space-y-3"> | 516 | <TabsContent value="members" forceMount class="space-y-3"> |
| @@ -498,15 +533,17 @@ function CourseDetailContent() { | |||
| 498 | </TabsContent> | 533 | </TabsContent> |
| 499 | </Show> | 534 | </Show> |
| 500 | </Tabs> | 535 | </Tabs> |
| 501 | - <div class={courseTab() === "notes" ? "" : "hidden"}> | 536 | + <Show when={tabOn.notes()}> |
| 502 | - <CourseNotesPanel | 537 | + <div class={courseTab() === "notes" ? "" : "hidden"}> |
| 503 | - courseId={id()} | 538 | + <CourseNotesPanel |
| 504 | - canManage={canManageCatalog()} | 539 | + courseId={id()} |
| 505 | - createOpen={showNoteForm()} | 540 | + canManage={canManageCatalog()} |
| 506 | - onCreateOpenChange={setShowNoteForm} | 541 | + createOpen={showNoteForm()} |
| 507 | - onCountChange={setNoteCount} | 542 | + onCreateOpenChange={setShowNoteForm} |
| 508 | - /> | 543 | + onCountChange={setNoteCount} |
| 509 | - </div> | 544 | + /> |
| 545 | + </div> | ||
| 546 | + </Show> | ||
| 510 | </div> | 547 | </div> |
| 511 | </Show> | 548 | </Show> |
| 512 | </Show> | 549 | </Show> |
src/pages/instance-detail-page.tsxmodified+46 -12
| @@ -45,6 +45,7 @@ import { examKindLabel } from "@/lib/exam-labels"; | |||
| 45 | import { examWeight } from "@/lib/exam-weight"; | 45 | import { examWeight } from "@/lib/exam-weight"; |
| 46 | import { hasMinRole } from "@/lib/roles"; | 46 | import { hasMinRole } from "@/lib/roles"; |
| 47 | import { useAuth } from "@/stores/auth-context"; | 47 | import { useAuth } from "@/stores/auth-context"; |
| 48 | +import { useModules } from "@/stores/modules-context"; | ||
| 48 | import { useT } from "@/stores/preferences-context"; | 49 | import { useT } from "@/stores/preferences-context"; |
| 49 | 50 | ||
| 50 | export default function InstanceDetailPage() { | 51 | export default function InstanceDetailPage() { |
| @@ -72,6 +73,25 @@ function InstanceDetailContent() { | |||
| 72 | const linkedTab = () => (typeof linkedSearch().tab === "string" ? (linkedSearch().tab as string) : null); | 73 | const linkedTab = () => (typeof linkedSearch().tab === "string" ? (linkedSearch().tab as string) : null); |
| 73 | const linkedRollCall = () => (typeof linkedSearch().rollCall === "string" ? (linkedSearch().rollCall as string) : undefined); | 74 | const linkedRollCall = () => (typeof linkedSearch().rollCall === "string" ? (linkedSearch().rollCall as string) : undefined); |
| 74 | const [tab, setTab] = createSignal(linkedTab() ?? "exams"); | 75 | const [tab, setTab] = createSignal(linkedTab() ?? "exams"); |
| 76 | + // Exams, homework and sessions are separately sold modules; a tab for one the | ||
| 77 | + // school switched off would only ever answer 403, so it is left out and the | ||
| 78 | + // page falls back to the first tab still there. | ||
| 79 | + const modules = useModules(); | ||
| 80 | + const tabOn = { | ||
| 81 | + exams: () => modules.isEnabled("exams"), | ||
| 82 | + homework: () => modules.isEnabled("homework"), | ||
| 83 | + sessions: () => modules.isEnabled("sessions"), | ||
| 84 | + }; | ||
| 85 | + createEffect(() => { | ||
| 86 | + const tabs = [ | ||
| 87 | + ...(tabOn.exams() ? ["exams"] : []), | ||
| 88 | + ...(tabOn.homework() ? ["homework"] : []), | ||
| 89 | + ...(tabOn.sessions() ? ["sessions"] : []), | ||
| 90 | + "teachers", | ||
| 91 | + ...(canManage() ? ["students"] : []), | ||
| 92 | + ]; | ||
| 93 | + if (!tabs.includes(tab())) setTab(tabs[0]); | ||
| 94 | + }); | ||
| 75 | const [instance, { refetch: refetchInstance }] = createResource(id, (instanceId) => getInstanceById(instanceId)); | 95 | const [instance, { refetch: refetchInstance }] = createResource(id, (instanceId) => getInstanceById(instanceId)); |
| 76 | const [course] = createResource(() => instance()?.course ?? null, (courseId) => getCourseById(courseId)); | 96 | const [course] = createResource(() => instance()?.course ?? null, (courseId) => getCourseById(courseId)); |
| 77 | const [klass] = createResource(() => instance()?.class ?? null, (classId) => getClassById(classId).catch(() => null)); | 97 | const [klass] = createResource(() => instance()?.class ?? null, (classId) => getClassById(classId).catch(() => null)); |
| @@ -89,7 +109,7 @@ function InstanceDetailContent() { | |||
| 89 | const canStaff = () => hasMinRole(auth.user()?.role ?? "student", "manager"); | 109 | const canStaff = () => hasMinRole(auth.user()?.role ?? "student", "manager"); |
| 90 | 110 | ||
| 91 | const [exams, { refetch: refetchExams }] = createResource( | 111 | const [exams, { refetch: refetchExams }] = createResource( |
| 92 | - () => id(), | 112 | + () => (tabOn.exams() ? id() : null), |
| 93 | async (instanceId) => (instanceId ? (await getInstanceExams(instanceId)).items : []), | 113 | async (instanceId) => (instanceId ? (await getInstanceExams(instanceId)).items : []), |
| 94 | ); | 114 | ); |
| 95 | const [roster, { refetch: refetchRoster }] = createResource( | 115 | const [roster, { refetch: refetchRoster }] = createResource( |
| @@ -349,15 +369,17 @@ function InstanceDetailContent() { | |||
| 349 | <p class="truncate text-sm font-semibold text-text-default">{inst().enrollment_count}</p> | 369 | <p class="truncate text-sm font-semibold text-text-default">{inst().enrollment_count}</p> |
| 350 | </div> | 370 | </div> |
| 351 | </div> | 371 | </div> |
| 352 | - <div class="flex min-w-0 items-center gap-3 rounded-xl border border-border-line bg-surface-base p-3"> | 372 | + <Show when={tabOn.exams()}> |
| 353 | - <span class="flex h-9 w-9 shrink-0 items-center justify-center rounded-xl bg-surface-tint text-text-subtle"> | 373 | + <div class="flex min-w-0 items-center gap-3 rounded-xl border border-border-line bg-surface-base p-3"> |
| 354 | - <IconExam class="h-4 w-4" /> | 374 | + <span class="flex h-9 w-9 shrink-0 items-center justify-center rounded-xl bg-surface-tint text-text-subtle"> |
| 355 | - </span> | 375 | + <IconExam class="h-4 w-4" /> |
| 356 | - <div class="min-w-0"> | 376 | + </span> |
| 357 | - <p class="text-xs font-medium text-text-subtle">{t("courses.exams")}</p> | 377 | + <div class="min-w-0"> |
| 358 | - <p class="truncate text-sm font-semibold text-text-default">{examCount()}</p> | 378 | + <p class="text-xs font-medium text-text-subtle">{t("courses.exams")}</p> |
| 379 | + <p class="truncate text-sm font-semibold text-text-default">{examCount()}</p> | ||
| 380 | + </div> | ||
| 359 | </div> | 381 | </div> |
| 360 | - </div> | 382 | + </Show> |
| 361 | </div> | 383 | </div> |
| 362 | </div> | 384 | </div> |
| 363 | 385 | ||
| @@ -518,15 +540,22 @@ function InstanceDetailContent() { | |||
| 518 | 540 | ||
| 519 | <Tabs value={tab()} onChange={setTab} class="space-y-4"> | 541 | <Tabs value={tab()} onChange={setTab} class="space-y-4"> |
| 520 | <TabsList class="flex w-full justify-start overflow-x-auto sm:grid sm:grid-cols-3 xl:grid-cols-5" aria-label={course.latest?.title ?? ""}> | 542 | <TabsList class="flex w-full justify-start overflow-x-auto sm:grid sm:grid-cols-3 xl:grid-cols-5" aria-label={course.latest?.title ?? ""}> |
| 521 | - <TabsTrigger value="exams" class="min-w-0"><IconExam class="h-4 w-4" />{t("courses.exams")}<Badge variant="secondary" class="h-5 min-w-5 justify-center rounded-full px-1.5 py-0 text-[11px] group-data-selected:bg-background group-data-selected:text-foreground">{examCount()}</Badge></TabsTrigger> | 543 | + <Show when={tabOn.exams()}> |
| 522 | - <TabsTrigger value="homework" class="min-w-0"><IconHomework class="h-4 w-4" />{t("homework.title")}<Badge variant="secondary" class="h-5 min-w-5 justify-center rounded-full px-1.5 py-0 text-[11px] group-data-selected:bg-background group-data-selected:text-foreground">{homeworkCount()}</Badge></TabsTrigger> | 544 | + <TabsTrigger value="exams" class="min-w-0"><IconExam class="h-4 w-4" />{t("courses.exams")}<Badge variant="secondary" class="h-5 min-w-5 justify-center rounded-full px-1.5 py-0 text-[11px] group-data-selected:bg-background group-data-selected:text-foreground">{examCount()}</Badge></TabsTrigger> |
| 523 | - <TabsTrigger value="sessions" class="min-w-0"><IconCalendarDays class="h-4 w-4" />{t("sessions.title")}<Badge variant="secondary" class="h-5 min-w-5 justify-center rounded-full px-1.5 py-0 text-[11px] group-data-selected:bg-background group-data-selected:text-foreground">{sessionCount()}</Badge></TabsTrigger> | 545 | + </Show> |
| 546 | + <Show when={tabOn.homework()}> | ||
| 547 | + <TabsTrigger value="homework" class="min-w-0"><IconHomework class="h-4 w-4" />{t("homework.title")}<Badge variant="secondary" class="h-5 min-w-5 justify-center rounded-full px-1.5 py-0 text-[11px] group-data-selected:bg-background group-data-selected:text-foreground">{homeworkCount()}</Badge></TabsTrigger> | ||
| 548 | + </Show> | ||
| 549 | + <Show when={tabOn.sessions()}> | ||
| 550 | + <TabsTrigger value="sessions" class="min-w-0"><IconCalendarDays class="h-4 w-4" />{t("sessions.title")}<Badge variant="secondary" class="h-5 min-w-5 justify-center rounded-full px-1.5 py-0 text-[11px] group-data-selected:bg-background group-data-selected:text-foreground">{sessionCount()}</Badge></TabsTrigger> | ||
| 551 | + </Show> | ||
| 524 | <TabsTrigger value="teachers" class="min-w-0"><IconSchool class="h-4 w-4" />{t("courses.teachers")}<Badge variant="secondary" class="h-5 min-w-5 justify-center rounded-full px-1.5 py-0 text-[11px] group-data-selected:bg-background group-data-selected:text-foreground">{inst().teachers.length}</Badge></TabsTrigger> | 552 | <TabsTrigger value="teachers" class="min-w-0"><IconSchool class="h-4 w-4" />{t("courses.teachers")}<Badge variant="secondary" class="h-5 min-w-5 justify-center rounded-full px-1.5 py-0 text-[11px] group-data-selected:bg-background group-data-selected:text-foreground">{inst().teachers.length}</Badge></TabsTrigger> |
| 525 | <Show when={canManage()}> | 553 | <Show when={canManage()}> |
| 526 | <TabsTrigger value="students" class="min-w-0"><IconUsers class="h-4 w-4" />{t("courses.roster")}<Badge variant="secondary" class="h-5 min-w-5 justify-center rounded-full px-1.5 py-0 text-[11px] group-data-selected:bg-background group-data-selected:text-foreground">{rosterCount()}</Badge></TabsTrigger> | 554 | <TabsTrigger value="students" class="min-w-0"><IconUsers class="h-4 w-4" />{t("courses.roster")}<Badge variant="secondary" class="h-5 min-w-5 justify-center rounded-full px-1.5 py-0 text-[11px] group-data-selected:bg-background group-data-selected:text-foreground">{rosterCount()}</Badge></TabsTrigger> |
| 527 | </Show> | 555 | </Show> |
| 528 | </TabsList> | 556 | </TabsList> |
| 529 | 557 | ||
| 558 | + <Show when={tabOn.exams()}> | ||
| 530 | <TabsContent value="exams" class="space-y-3"> | 559 | <TabsContent value="exams" class="space-y-3"> |
| 531 | <div class="flex flex-wrap items-center gap-2"> | 560 | <div class="flex flex-wrap items-center gap-2"> |
| 532 | <Badge variant="secondary" class="rounded-full">{countDescription(examCount(), t("courses.examItem"))}</Badge> | 561 | <Badge variant="secondary" class="rounded-full">{countDescription(examCount(), t("courses.examItem"))}</Badge> |
| @@ -548,7 +577,9 @@ function InstanceDetailContent() { | |||
| 548 | /> | 577 | /> |
| 549 | </Suspense> | 578 | </Suspense> |
| 550 | </TabsContent> | 579 | </TabsContent> |
| 580 | + </Show> | ||
| 551 | 581 | ||
| 582 | + <Show when={tabOn.homework()}> | ||
| 552 | <TabsContent value="homework" class="space-y-3"> | 583 | <TabsContent value="homework" class="space-y-3"> |
| 553 | <div class="flex flex-wrap items-center gap-2"> | 584 | <div class="flex flex-wrap items-center gap-2"> |
| 554 | <Badge variant="secondary" class="rounded-full">{countDescription(homeworkCount(), t("homework.item"))}</Badge> | 585 | <Badge variant="secondary" class="rounded-full">{countDescription(homeworkCount(), t("homework.item"))}</Badge> |
| @@ -568,7 +599,9 @@ function InstanceDetailContent() { | |||
| 568 | onCountChange={setHomeworkCount} | 599 | onCountChange={setHomeworkCount} |
| 569 | /> | 600 | /> |
| 570 | </TabsContent> | 601 | </TabsContent> |
| 602 | + </Show> | ||
| 571 | 603 | ||
| 604 | + <Show when={tabOn.sessions()}> | ||
| 572 | <TabsContent value="sessions" class="space-y-3"> | 605 | <TabsContent value="sessions" class="space-y-3"> |
| 573 | <div class="flex flex-wrap items-center gap-2"> | 606 | <div class="flex flex-wrap items-center gap-2"> |
| 574 | <Badge variant="secondary" class="rounded-full">{countDescription(sessionCount(), t("sessions.item"))}</Badge> | 607 | <Badge variant="secondary" class="rounded-full">{countDescription(sessionCount(), t("sessions.item"))}</Badge> |
| @@ -591,6 +624,7 @@ function InstanceDetailContent() { | |||
| 591 | openRollCallFor={linkedRollCall()} | 624 | openRollCallFor={linkedRollCall()} |
| 592 | /> | 625 | /> |
| 593 | </TabsContent> | 626 | </TabsContent> |
| 627 | + </Show> | ||
| 594 | 628 | ||
| 595 | <TabsContent value="teachers" class="space-y-3"> | 629 | <TabsContent value="teachers" class="space-y-3"> |
| 596 | <div class="flex flex-wrap items-center gap-2 text-sm"> | 630 | <div class="flex flex-wrap items-center gap-2 text-sm"> |
src/routes/router.tsxmodified+3 -3
| @@ -12,6 +12,7 @@ import { NotFoundPage } from "@/components/system/not-found-page"; | |||
| 12 | import { PageSpinner } from "@/components/ui/page-spinner"; | 12 | import { PageSpinner } from "@/components/ui/page-spinner"; |
| 13 | import { AuthProvider } from "@/stores/auth-context"; | 13 | import { AuthProvider } from "@/stores/auth-context"; |
| 14 | import { ModulesProvider } from "@/stores/modules-context"; | 14 | import { ModulesProvider } from "@/stores/modules-context"; |
| 15 | +import { AttendanceRedirect } from "@/components/layout/attendance-redirect"; | ||
| 15 | import { PreferencesProvider } from "@/stores/preferences-context"; | 16 | import { PreferencesProvider } from "@/stores/preferences-context"; |
| 16 | 17 | ||
| 17 | function lazyRoute(loader: () => Promise<{ default: Component }>): Component { | 18 | function lazyRoute(loader: () => Promise<{ default: Component }>): Component { |
| @@ -272,9 +273,8 @@ const studentPomodoroRoute = createRoute({ | |||
| 272 | const attendanceRoute = createRoute({ | 273 | const attendanceRoute = createRoute({ |
| 273 | getParentRoute: () => rootRoute, | 274 | getParentRoute: () => rootRoute, |
| 274 | path: "/attendance", | 275 | path: "/attendance", |
| 275 | - beforeLoad: () => { | 276 | + // Role-aware, so it has to wait for the session: see AttendanceRedirect. |
| 276 | - throw redirect({ to: "/marks", search: { tab: "attendance" } }); | 277 | + component: AttendanceRedirect, |
| 277 | - }, | ||
| 278 | }); | 278 | }); |
| 279 | 279 | ||
| 280 | const studentAttendanceRoute = createRoute({ | 280 | const studentAttendanceRoute = createRoute({ |