From 0691d474dd7dedf2d74eb7de2f6b30ef0a860b79 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Burak=20Boduro=C4=9Flu?= <80620802+burakboduroglu@users.noreply.github.com> Date: Sat, 12 Sep 2026 13:58:15 +0300 Subject: [PATCH] =?UTF-8?q?feat:=20=F0=9F=A7=AD=20rebuild=20the=20navigati?= =?UTF-8?q?on=20tree=20from=20the=20Figma=20design?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit - the sidebar was an information architecture of its own invention — Today, Education, Academics, Planning, Workspace, Community — against a design that groups the same routes under Operasyon, Yapay zekâ and Kurum; all four role trees now carry Figma's groups, labels and order - every menu entry the design names is present, including the ones no API can serve yet: they wear a "yakında" badge and resolve to a shared coming-soon page rather than a half-drawn screen - entries whose label implies a screen we already have reuse that route instead of inventing one: Ders programı is /calendar, Tahta is /whiteboards, Veli iletişimi is /messages, Mesai is /work - Çelebi and Ayarlar open the panel and the profile dialog in place, so they no longer need a URL of their own - the design nests Soru bankası and Optik okuma under Sınavlar; the sidebar's data model is group-then-item, so that third level is flattened for now - manager keeps the admin tree minus the three admin-only Kurum entries, and every route guard is untouched: regrouping a menu must not widen anyone's access Walked as admin, teacher, student and parent at 1440px and 393px, in both languages. Page composition still follows the old layouts — that is the next pass. --- src/components/layout/app-shell.tsx | 8 +- src/components/layout/command-palette.tsx | 4 + src/components/layout/mobile-nav-sheet.tsx | 48 +++- src/components/layout/nav-items.test.ts | 168 ++++++++---- src/components/layout/nav-items.ts | 289 ++++++++++++--------- src/components/layout/side-nav.tsx | 105 ++++---- src/components/ui/icons.tsx | 35 +++ src/i18n/messages.ts | 137 +++++++++- src/pages/coming-soon-page.tsx | 58 +++++ src/routes/router.tsx | 32 +++ 10 files changed, 650 insertions(+), 234 deletions(-) create mode 100644 src/pages/coming-soon-page.tsx diff --git a/src/components/layout/app-shell.tsx b/src/components/layout/app-shell.tsx index fe21d5a..1b0a8be 100644 --- a/src/components/layout/app-shell.tsx +++ b/src/components/layout/app-shell.tsx @@ -93,7 +93,11 @@ export function AppShell(props: ParentProps) {
- + setCelebiOpen(true)} + onOpenProfile={() => setProfileOpen(true)} + />
@@ -105,6 +109,8 @@ export function AppShell(props: ParentProps) { open={mobileOpen()} onClose={() => setMobileOpen(false)} onLogout={logout} + onOpenCelebi={() => setCelebiOpen(true)} + onOpenProfile={() => setProfileOpen(true)} /> diff --git a/src/components/layout/command-palette.tsx b/src/components/layout/command-palette.tsx index cc54dc9..3c22db3 100644 --- a/src/components/layout/command-palette.tsx +++ b/src/components/layout/command-palette.tsx @@ -205,6 +205,10 @@ export function CommandPalette(props: CommandPaletteProps) { for (const group of visibleNavGroups(userRole, modules.enabled())) { const groupName = t(group.labelKey); for (const item of group.items) { + // Çelebi and the account-settings entries open an existing shell + // surface rather than a route — the palette already offers both + // above, wired to the panel/dialog directly. + if (item.action) continue; list.push({ id: `page-${item.to}`, category: "pages", diff --git a/src/components/layout/mobile-nav-sheet.tsx b/src/components/layout/mobile-nav-sheet.tsx index 3969d4f..b43d090 100644 --- a/src/components/layout/mobile-nav-sheet.tsx +++ b/src/components/layout/mobile-nav-sheet.tsx @@ -1,6 +1,6 @@ import { For, Show, createSignal } from "solid-js"; import { Link, useRouterState } from "@tanstack/solid-router"; -import { routeNavItem, sidebarNavGroups, type NavItem } from "@/components/layout/nav-items"; +import { routeNavItem, visibleNavGroups, type NavItem } from "@/components/layout/nav-items"; import { SidebarAccount } from "@/components/layout/sidebar-account"; import { IconX } from "@/components/ui/icons"; import { cn } from "@/lib/cn"; @@ -27,6 +27,8 @@ export function MobileNavSheet(props: { open: boolean; onClose: () => void; onLogout: () => void | Promise; + onOpenCelebi?: () => void; + onOpenProfile?: () => void; }) { const auth = useAuth(); const t = useT(); @@ -36,9 +38,14 @@ export function MobileNavSheet(props: { // The primary destinations are already one tap away in the tab bar, so the // sheet lists everything else. - const groups = () => sidebarNavGroups(auth.user()?.role, modules.enabled()); + const groups = () => visibleNavGroups(auth.user()?.role, modules.enabled()); const current = () => routeNavItem(pathname(), auth.user()?.role); const badgeFor = (item: NavItem) => (item.id === "messages" ? feed.unreadMessages().total : 0); + const runAction = (item: NavItem) => { + props.onClose(); + if (item.action === "celebi") props.onOpenCelebi?.(); + if (item.action === "profile") props.onOpenProfile?.(); + }; // Drag-to-dismiss. Only the grab area drives it, so a flick inside the list // still scrolls the list. While dragging, the sheet follows the finger with @@ -135,16 +142,12 @@ export function MobileNavSheet(props: { {(item) => { const active = () => current()?.id === item.id; - return ( - + const rowClass = cn( + "flex w-full items-center gap-2.5 rounded-md px-3 py-1.5 text-left transition-colors active:bg-muted", + active() ? "text-primary" : "text-foreground", + ); + const content = ( + <> {t(item.labelKey)} + + + {t("nav.soon")} + + 0}> {badgeFor(item) > 99 ? "99+" : badgeFor(item)} - + + ); + return ( + runAction(item)} class={rowClass}> + {content} + + } + > + + {content} + + ); }} diff --git a/src/components/layout/nav-items.test.ts b/src/components/layout/nav-items.test.ts index 5768eaf..4e5fa3b 100644 --- a/src/components/layout/nav-items.test.ts +++ b/src/components/layout/nav-items.test.ts @@ -1,70 +1,138 @@ -import { moduleVisible, pathActive, primaryNavItems, primaryPathActive, routeLabelKey, routeNavItem, sidebarNavGroups, visibleNavItems } from "@/components/layout/nav-items"; +import { moduleVisible, pathActive, primaryNavItems, primaryPathActive, routeLabelKey, routeNavItem, visibleNavGroups, visibleNavItems } from "@/components/layout/nav-items"; test.each([ - ["student", ["/", "/courses", "/calendar", "/marks"]], - ["teacher", ["/", "/courses", "/calendar"]], - ["manager", ["/", "/courses", "/calendar"]], - ["admin", ["/", "/courses", "/calendar"]], - ["parent", ["/", "/students", "/calendar"]], + ["student", ["/", "/exams", "/marks"]], + ["teacher", ["/", "/management/classes", "/calendar"]], + ["manager", ["/", "/management/classes", "/exams"]], + ["admin", ["/", "/management/classes", "/exams"]], + ["parent", ["/", "/students", "/appointments"]], ] as const)("%s gets role-specific primary destinations", (role, expected) => { expect(primaryNavItems(role).map((item) => item.to)).toEqual(expected); }); test("invalid role destinations stay hidden", () => { - expect(visibleNavItems("student").map((item) => item.to)).not.toContain("/school"); - expect(visibleNavItems("parent").map((item) => item.to)).not.toContain("/courses"); expect(visibleNavItems("teacher").map((item) => item.to)).not.toContain("/admin/users"); + expect(visibleNavItems("student").map((item) => item.to)).not.toContain("/admin/users"); + expect(visibleNavItems("parent").map((item) => item.to)).not.toContain("/management/staff-work"); }); -test("student secondary navigation follows the academic, planning, workspace, services, community flow", () => { +test("admin's sidebar mirrors the Figma Operasyon / Yapay zekâ / Kurum tree", () => { expect( - sidebarNavGroups("student").map((group) => ({ + visibleNavGroups("admin").map((group) => ({ id: group.id, items: group.items.map((item) => item.id), })), ).toEqual([ - { id: "classes", items: ["homework", "exams"] }, - { id: "planning", items: ["events", "appointments"] }, - { id: "workspace", items: ["notes", "whiteboards", "pomodoro"] }, - { id: "services", items: ["meals", "payment-statement"] }, - { id: "community", items: ["messages", "questions"] }, + { + id: "operations", + items: [ + "students-roster", + "teachers-roster", + "class-groups", + "schedule", + "student-attendance", + "exams", + "question-bank", + "mock-exams", + "optical-reading", + "payments-collection", + ], + }, + { id: "ai", items: ["hezarfen-zeka", "celebi", "sound-studio"] }, + { + id: "institution", + items: ["reports", "license-modules", "users", "data-protection", "school-meals", "staff-work", "settings"], + }, ]); }); -test("parent's services group includes meals and payment-statement, consistent with every other role", () => { - const services = sidebarNavGroups("parent").find((group) => group.id === "services"); - expect(services?.items.map((item) => item.id)).toEqual(["meals", "payment-statement"]); +test("manager sees the same admin tree minus the admin-only entries", () => { + const institution = visibleNavGroups("manager").find((group) => group.id === "institution"); + expect(institution?.items.map((item) => item.id)).toEqual(["reports", "school-meals", "staff-work", "settings"]); + expect(institution?.items.map((item) => item.id)).not.toContain("license-modules"); + expect(institution?.items.map((item) => item.id)).not.toContain("users"); + expect(institution?.items.map((item) => item.id)).not.toContain("data-protection"); }); -test.each(["student", "parent", "teacher", "manager", "admin"] as const)( - "%s can reach every visible feature and appointments from the sidebar", - (role) => { - const paths = [ - ...primaryNavItems(role).map((item) => item.to), - ...sidebarNavGroups(role).flatMap((group) => group.items.map((item) => item.to)), - ]; - expect(new Set(paths)).toEqual(new Set(visibleNavItems(role).map((item) => item.to))); - expect(paths).toContain("/appointments"); - }, -); +test("teacher's sidebar mirrors the Figma Sınıfım / Yapay zekâ / Diğer tree", () => { + expect( + visibleNavGroups("teacher").map((group) => ({ + id: group.id, + items: group.items.map((item) => item.id), + })), + ).toEqual([ + { id: "my-classroom", items: ["my-classes", "my-schedule", "student-attendance", "homework", "exams", "whiteboards"] }, + { id: "ai", items: ["student-analysis", "pending-approvals", "question-generation", "sound-studio"] }, + { id: "other", items: ["parent-communication", "work", "settings-teacher"] }, + ]); +}); + +test("student's sidebar mirrors the Figma Çalışma / Yapay zekâ / Diğer tree", () => { + expect( + visibleNavGroups("student").map((group) => ({ + id: group.id, + items: group.items.map((item) => item.id), + })), + ).toEqual([ + { id: "study", items: ["study-plan", "topic-mastery", "exam-results", "my-homework", "whiteboards", "pomodoro"] }, + { id: "ai", items: ["celebi", "sound-studio"] }, + { id: "other", items: ["calendar", "settings-student"] }, + ]); +}); + +test("parent's sidebar mirrors the Figma Öğrencim / Kurum tree", () => { + expect( + visibleNavGroups("parent").map((group) => ({ + id: group.id, + items: group.items.map((item) => item.id), + })), + ).toEqual([ + { id: "my-student", items: ["progress-report", "absence", "child-exam-results", "child-study-plan"] }, + { id: "institution", items: ["payment-statement", "appointments", "settings-parent"] }, + ]); +}); + +test("appointments is a parent-only sidebar entry, matching the Figma parent screen", () => { + expect(visibleNavGroups("parent").flatMap((g) => g.items).map((i) => i.to)).toContain("/appointments"); + for (const role of ["student", "teacher", "manager", "admin"] as const) { + const paths = [...primaryNavItems(role).map((i) => i.to), ...visibleNavGroups(role).flatMap((g) => g.items.map((i) => i.to))]; + expect(paths).not.toContain("/appointments"); + } +}); + +test("entries with no backend yet are flagged soon and route to the shared placeholder", () => { + const hezarfenZeka = visibleNavGroups("admin") + .flatMap((g) => g.items) + .find((i) => i.id === "hezarfen-zeka"); + expect(hezarfenZeka?.soon).toBe(true); + expect(hezarfenZeka?.to).toBe("/coming-soon/hezarfen-zeka"); +}); + +test("Çelebi and account settings open an existing shell surface instead of navigating", () => { + const celebi = visibleNavGroups("student") + .flatMap((g) => g.items) + .find((i) => i.id === "celebi"); + expect(celebi?.action).toBe("celebi"); + const settings = visibleNavGroups("student") + .flatMap((g) => g.items) + .find((i) => i.id === "settings-student"); + expect(settings?.action).toBe("profile"); +}); test("nested entity routes keep their primary destination active", () => { - expect(pathActive("/courses/course-1", "/courses")).toBe(true); - expect(routeNavItem("/courses/course-1", "teacher")?.id).toBe("classes"); + expect(pathActive("/management/classes/class-1", "/management/classes")).toBe(true); + expect(routeNavItem("/management/classes/class-1", "teacher")?.id).toBe("my-classes"); expect(routeNavItem("/management/student-attendance", "teacher")?.id).toBe("student-attendance"); expect(primaryPathActive("/exams/exam-1", primaryNavItems("student")[1]!)).toBe(true); }); test.each([ - ["/homework", "student", "homework"], - ["/events/event-1", "teacher", "events"], + ["/homework/hw-1", "student", "my-homework"], + ["/homework/hw-1", "teacher", "homework"], ["/management/student-attendance", "teacher", "student-attendance"], ["/management/settings", "manager", "settings"], ] as const)("sidebar resolves one active item for %s", (pathname, role, expected) => { - const items = [ - ...primaryNavItems(role), - ...sidebarNavGroups(role).flatMap((group) => group.items), - ]; + const items = [...primaryNavItems(role), ...visibleNavGroups(role).flatMap((group) => group.items)]; const current = routeNavItem(pathname, role); expect(items.filter((item) => item.id === current?.id).map((item) => item.id)).toEqual([expected]); @@ -79,12 +147,18 @@ test.each([ ["/attendance", "nav.attendance"], ["/studies", "courses.kind.study"], ["/clubs", "courses.kind.club"], + ["/courses", "nav.courses"], + ["/courses/course-1", "nav.courses"], + ["/notes", "nav.notes"], + ["/questions", "nav.questions"], + ["/events", "nav.events"], + ["/meals", "nav.meals"], ] as const)("%s has a header label", (pathname, expected) => { expect(routeLabelKey(pathname, "student")).toBe(expected); }); test("routes with a sidebar entry still take their nav label", () => { - expect(routeLabelKey("/courses/course-1", "teacher")).toBe(routeNavItem("/courses/course-1", "teacher")?.labelKey); + expect(routeLabelKey("/homework/hw-1", "teacher")).toBe(routeNavItem("/homework/hw-1", "teacher")?.labelKey); }); test("a route rendered outside the shell has no label rather than a raw path", () => { @@ -94,8 +168,8 @@ test("a route rendered outside the shell has no label rather than a raw path", ( test("a page keeps its name for a viewer who may not open it", () => { // /students is parent-only; an admin lands on the no-access screen, and the // shell header must still say what page that is. - expect(routeLabelKey("/students", "admin")).toBe("nav.children"); - expect(routeLabelKey("/students", "parent")).toBe("nav.children"); + expect(routeLabelKey("/students", "admin")).toBe("nav.progressReport"); + expect(routeLabelKey("/students", "parent")).toBe("nav.progressReport"); }); test("module gate fails open while the entitlement lookup is unknown", () => { @@ -104,13 +178,13 @@ test("module gate fails open while the entitlement lookup is unknown", () => { }); test("module gate hides nests the school did not buy", () => { - const enabled = ["courses", "notes"]; - const primary = primaryNavItems("student", enabled).map((item) => item.to); - expect(primary).toContain("/courses"); - expect(primary).not.toContain("/marks"); - const sidebar = sidebarNavGroups("teacher", enabled).flatMap((group) => group.items.map((item) => item.to)); - expect(sidebar).not.toContain("/meals"); - expect(sidebar).not.toContain("/messages"); + const enabled = ["courses"]; + const teacherPaths = visibleNavGroups("teacher", enabled).flatMap((group) => group.items.map((item) => item.to)); + expect(teacherPaths).not.toContain("/homework"); + expect(teacherPaths).not.toContain("/exams"); + expect(teacherPaths).not.toContain("/whiteboards"); + expect(teacherPaths).toContain("/management/classes"); + expect(teacherPaths).toContain("/calendar"); }); test("ungated entries never drop on module filtering", () => { diff --git a/src/components/layout/nav-items.ts b/src/components/layout/nav-items.ts index ef9c3ef..ba3199e 100644 --- a/src/components/layout/nav-items.ts +++ b/src/components/layout/nav-items.ts @@ -2,29 +2,32 @@ import type { Component } from "solid-js"; import type { Role } from "@/api/client"; import { IconArchive, - IconBook, + IconBotSquare, IconBriefcase, - IconCalendar, IconCalendarDays, + IconChalkboardTeacher, IconChart, - IconClock, + IconChartPie, IconClipboardCheck, + IconClock, + IconEdit, IconExam, - IconGlobe, - IconGrid, - IconGuide, IconHelpCircle, IconHomework, IconHome, IconMessage, - IconEdit, - IconNote, + IconPackage, IconReportAnalytics, + IconScan, IconSchool, IconSettings, + IconShieldCheck, + IconSparkles, + IconTarget, IconUserCog, IconUsers, IconUtensils, + IconWaveform, } from "@/components/ui/icons"; import type { MessageKey } from "@/i18n/messages"; import { hasExactRole, roleInRange } from "@/lib/roles"; @@ -40,6 +43,11 @@ export type NavItem = { exact?: boolean; /** Backend module nest behind this entry; hidden when the school did not buy it. */ module?: string; + /** No backend yet — routes to the shared placeholder and carries a "yakında" badge. */ + soon?: boolean; + /** Opens an existing shell surface instead of navigating (the Çelebi panel, + * the account settings dialog) — both already live elsewhere in the shell. */ + action?: "celebi" | "profile"; }; export type NavGroup = { @@ -57,139 +65,190 @@ export const HOME_ITEM: NavItem = { exact: true, }; -const CLASSES_ITEM: NavItem = { - id: "classes", - to: "/courses", - labelKey: "nav.classes", - Icon: IconBook, - module: "courses", -}; - -const CALENDAR_ITEM: NavItem = { - id: "calendar", - to: "/calendar", - labelKey: "nav.calendar", - Icon: IconCalendarDays, -}; - -const CHILDREN_ITEM: NavItem = { - id: "children", - to: "/students", - labelKey: "nav.children", - Icon: IconUsers, - exactRole: "parent", +const CELEBI_ITEM: NavItem = { + id: "celebi", + to: "", + labelKey: "nav.celebi", + Icon: IconSparkles, + action: "celebi", }; -const PROGRESS_ITEM: NavItem = { - id: "progress", - to: "/marks", - labelKey: "nav.marks", - Icon: IconChart, - exactRole: "student", - module: "marks", +const SOUND_STUDIO_ITEM: NavItem = { + id: "sound-studio", + to: "/coming-soon/ses-atolyesi", + labelKey: "nav.soundStudio", + Icon: IconWaveform, + soon: true, }; -const MEALS_ITEM: NavItem = { - id: "meals", - to: "/meals", - labelKey: "nav.meals", - Icon: IconUtensils, - module: "meals", -}; +function settingsAction(id: string): NavItem { + return { id, to: "", labelKey: "nav.settings", Icon: IconSettings, action: "profile" }; +} -const PRIMARY_BY_ROLE: Record = { - student: [HOME_ITEM, CLASSES_ITEM, CALENDAR_ITEM, PROGRESS_ITEM], - teacher: [HOME_ITEM, CLASSES_ITEM, CALENDAR_ITEM], - manager: [HOME_ITEM, CLASSES_ITEM, CALENDAR_ITEM], - admin: [HOME_ITEM, CLASSES_ITEM, CALENDAR_ITEM], - // Meals stays out of the primary strip so it lives under "Community" for - // every role consistently, same as teacher/manager/admin/student. - parent: [HOME_ITEM, CHILDREN_ITEM, CALENDAR_ITEM], -}; +// Admin and manager share one Figma information architecture (Operasyon / +// Yapay zekâ / Kurum) — manager just qualifies for fewer of its items, via +// the same minRole gates the rest of this file already uses. +const ADMIN_GROUPS: NavGroup[] = [ + { + id: "operations", + labelKey: "nav.group.operations", + Icon: IconSchool, + items: [ + { id: "students-roster", to: "/coming-soon/ogrenciler", labelKey: "nav.studentsRoster", Icon: IconUsers, soon: true, minRole: "manager" }, + { id: "teachers-roster", to: "/coming-soon/ogretmenler", labelKey: "nav.teachersRoster", Icon: IconChalkboardTeacher, soon: true, minRole: "manager" }, + { id: "class-groups", to: "/management/classes", labelKey: "nav.classGroups", Icon: IconSchool, minRole: "teacher" }, + { id: "schedule", to: "/calendar", labelKey: "nav.schedule", Icon: IconCalendarDays, minRole: "manager" }, + { id: "student-attendance", to: "/management/student-attendance", labelKey: "nav.attendance", Icon: IconClipboardCheck, minRole: "teacher", module: "attendance" }, + { id: "exams", to: "/exams", labelKey: "nav.exams", Icon: IconExam, minRole: "teacher", module: "exams" }, + { id: "question-bank", to: "/question-bank", labelKey: "nav.questionBank", Icon: IconArchive, minRole: "teacher", module: "bank_questions" }, + { id: "mock-exams", to: "/coming-soon/deneme-sinavlari", labelKey: "nav.mockExams", Icon: IconTarget, soon: true, minRole: "manager" }, + { id: "optical-reading", to: "/coming-soon/optik-okuma", labelKey: "nav.opticalReading", Icon: IconScan, soon: true, minRole: "manager" }, + { id: "payments-collection", to: "/management/payments", labelKey: "nav.payments", Icon: IconReportAnalytics, minRole: "manager", module: "payments" }, + ], + }, + { + id: "ai", + labelKey: "nav.group.ai", + Icon: IconSparkles, + items: [ + { id: "hezarfen-zeka", to: "/coming-soon/hezarfen-zeka", labelKey: "nav.hezarfenZeka", Icon: IconBotSquare, soon: true, minRole: "manager" }, + CELEBI_ITEM, + SOUND_STUDIO_ITEM, + ], + }, + { + id: "institution", + labelKey: "nav.group.institution", + Icon: IconUserCog, + items: [ + { id: "reports", to: "/coming-soon/raporlar", labelKey: "nav.reports", Icon: IconChartPie, soon: true, minRole: "manager" }, + { id: "license-modules", to: "/coming-soon/lisans-modulleri", labelKey: "nav.licenseModules", Icon: IconPackage, soon: true, minRole: "admin" }, + { id: "users", to: "/admin/users", labelKey: "nav.users", Icon: IconUserCog, minRole: "admin" }, + { id: "data-protection", to: "/coming-soon/kvkk-denetim", labelKey: "nav.dataProtection", Icon: IconShieldCheck, soon: true, minRole: "admin" }, + { id: "school-meals", to: "/meals", labelKey: "nav.schoolMeals", Icon: IconUtensils, minRole: "manager", module: "meals" }, + { id: "staff-work", to: "/management/staff-work", labelKey: "nav.staffWork", Icon: IconBriefcase, minRole: "manager", module: "work" }, + { id: "settings", to: "/management/settings", labelKey: "nav.settings", Icon: IconSettings, minRole: "manager" }, + ], + }, +]; -const NAV_GROUPS: NavGroup[] = [ +const TEACHER_GROUPS: NavGroup[] = [ { - id: "classes", - labelKey: "nav.group.classes", + id: "my-classroom", + labelKey: "nav.group.myClassroom", Icon: IconSchool, items: [ - CLASSES_ITEM, + { id: "my-classes", to: "/management/classes", labelKey: "nav.myClasses", Icon: IconSchool }, + { id: "my-schedule", to: "/calendar", labelKey: "nav.mySchedule", Icon: IconCalendarDays }, + { id: "student-attendance", to: "/management/student-attendance", labelKey: "nav.attendance", Icon: IconClipboardCheck, module: "attendance" }, { id: "homework", to: "/homework", labelKey: "nav.homework", Icon: IconHomework, module: "homework" }, { id: "exams", to: "/exams", labelKey: "nav.exams", Icon: IconExam, module: "exams" }, - { id: "question-bank", to: "/question-bank", labelKey: "nav.questionBank", Icon: IconArchive, minRole: "teacher", module: "bank_questions" }, - { id: "marks", to: "/marks", labelKey: "nav.marks", Icon: IconChart, exactRole: "student", module: "marks" }, + { id: "whiteboards", to: "/whiteboards", labelKey: "nav.whiteboards", Icon: IconEdit, module: "boards" }, ], }, { - id: "planning", - labelKey: "nav.group.planning", - Icon: IconCalendarDays, + id: "ai", + labelKey: "nav.group.ai", + Icon: IconSparkles, items: [ - { id: "events", to: "/events", labelKey: "nav.events", Icon: IconCalendar, module: "events" }, - CALENDAR_ITEM, - { id: "appointments", to: "/appointments", labelKey: "nav.appointments", Icon: IconClock, module: "appointments" }, + { id: "student-analysis", to: "/coming-soon/ogrenci-analizi", labelKey: "nav.studentAnalysis", Icon: IconChart, soon: true }, + { id: "pending-approvals", to: "/coming-soon/bekleyen-onaylar", labelKey: "nav.pendingApprovals", Icon: IconHelpCircle, soon: true }, + { id: "question-generation", to: "/coming-soon/soru-uretimi", labelKey: "nav.questionGeneration", Icon: IconEdit, soon: true }, + SOUND_STUDIO_ITEM, ], }, { - id: "workspace", - labelKey: "nav.group.workspace", - Icon: IconNote, + id: "other", + labelKey: "nav.group.other", + Icon: IconMessage, items: [ - { id: "notes", to: "/notes", labelKey: "nav.notes", Icon: IconNote, module: "notes" }, - { id: "whiteboards", to: "/whiteboards", labelKey: "nav.whiteboards", Icon: IconEdit, minRole: "student", module: "boards" }, - { id: "pomodoro", to: "/pomodoro", labelKey: "nav.pomodoro", Icon: IconClock, exactRole: "student", module: "pomodoro" }, - { id: "work", to: "/work", labelKey: "nav.work", Icon: IconBriefcase, minRole: "teacher", maxRole: "manager", module: "work" }, + { id: "parent-communication", to: "/messages", labelKey: "nav.parentCommunication", Icon: IconMessage, module: "messages" }, + { id: "work", to: "/work", labelKey: "nav.work", Icon: IconClock, minRole: "teacher", maxRole: "manager", module: "work" }, + settingsAction("settings-teacher"), ], }, +]; + +const STUDENT_GROUPS: NavGroup[] = [ { - id: "students", - labelKey: "nav.group.students", - Icon: IconReportAnalytics, + id: "study", + labelKey: "nav.group.study", + Icon: IconSchool, items: [ - CHILDREN_ITEM, - { id: "class-groups", to: "/management/classes", labelKey: "nav.classGroups", Icon: IconUsers, minRole: "teacher", module: "classes" }, - { id: "student-marks", to: "/management/student-marks", labelKey: "nav.studentMarks", Icon: IconChart, minRole: "teacher", module: "marks" }, - { id: "student-attendance", to: "/management/student-attendance", labelKey: "nav.studentAttendance", Icon: IconClipboardCheck, minRole: "teacher", module: "attendance" }, - { id: "student-pomodoro", to: "/management/pomodoros", labelKey: "nav.studentPomodoro", Icon: IconClock, minRole: "teacher", module: "pomodoro" }, + { id: "study-plan", to: "/coming-soon/calisma-programim", labelKey: "nav.studyPlan", Icon: IconClock, soon: true }, + { id: "topic-mastery", to: "/marks", labelKey: "nav.topicMastery", Icon: IconChart, exactRole: "student", module: "marks" }, + { id: "exam-results", to: "/exams", labelKey: "nav.examResults", Icon: IconExam, module: "exams" }, + { id: "my-homework", to: "/homework", labelKey: "nav.myHomework", Icon: IconHomework, module: "homework" }, + { id: "whiteboards", to: "/whiteboards", labelKey: "nav.whiteboards", Icon: IconEdit, module: "boards" }, + { id: "pomodoro", to: "/pomodoro", labelKey: "nav.pomodoro", Icon: IconClock, exactRole: "student", module: "pomodoro" }, ], }, { - id: "services", - labelKey: "nav.group.services", - Icon: IconGuide, + id: "ai", + labelKey: "nav.group.ai", + Icon: IconSparkles, + items: [CELEBI_ITEM, SOUND_STUDIO_ITEM], + }, + { + id: "other", + labelKey: "nav.group.other", + Icon: IconCalendarDays, items: [ - MEALS_ITEM, - { id: "payment-statement", to: "/payments", labelKey: "nav.paymentStatement", Icon: IconChart, maxRole: "student", module: "payments" }, + { id: "calendar", to: "/calendar", labelKey: "nav.mySchedule", Icon: IconCalendarDays }, + settingsAction("settings-student"), ], }, +]; + +const PARENT_GROUPS: NavGroup[] = [ { - id: "community", - labelKey: "nav.group.community", - Icon: IconGlobe, + id: "my-student", + labelKey: "nav.group.myStudent", + Icon: IconUsers, items: [ - { id: "messages", to: "/messages", labelKey: "nav.messages", Icon: IconMessage, module: "messages" }, - { id: "questions", to: "/questions", labelKey: "nav.questions", Icon: IconHelpCircle, module: "questions" }, + { id: "progress-report", to: "/students", labelKey: "nav.progressReport", Icon: IconReportAnalytics, exactRole: "parent" }, + { id: "absence", to: "/coming-soon/devamsizlik", labelKey: "nav.absence", Icon: IconClipboardCheck, soon: true }, + { id: "child-exam-results", to: "/coming-soon/sinav-sonuclari-veli", labelKey: "nav.childExamResults", Icon: IconExam, soon: true }, + { id: "child-study-plan", to: "/coming-soon/calisma-plani", labelKey: "nav.childStudyPlan", Icon: IconClock, soon: true }, ], }, { - id: "school", - labelKey: "nav.group.school", - Icon: IconGrid, + id: "institution", + labelKey: "nav.group.institution", + Icon: IconUserCog, items: [ - { id: "staff-work", to: "/management/staff-work", labelKey: "nav.staffWork", Icon: IconBriefcase, minRole: "manager", module: "work" }, - { id: "settings", to: "/management/settings", labelKey: "nav.settings", Icon: IconSettings, minRole: "manager" }, - { id: "terms", to: "/management/terms", labelKey: "nav.terms", Icon: IconCalendarDays, minRole: "manager" }, - { id: "payments", to: "/management/payments", labelKey: "nav.payments", Icon: IconReportAnalytics, minRole: "manager", module: "payments" }, - { id: "users", to: "/admin/users", labelKey: "nav.users", Icon: IconUserCog, minRole: "admin" }, + { id: "payment-statement", to: "/payments", labelKey: "nav.payments", Icon: IconReportAnalytics, exactRole: "parent", module: "payments" }, + { id: "appointments", to: "/appointments", labelKey: "nav.appointmentsAndCommunication", Icon: IconClock, exactRole: "parent", module: "appointments" }, + settingsAction("settings-parent"), ], }, ]; +const GROUPS_BY_ROLE: Record = { + student: STUDENT_GROUPS, + teacher: TEACHER_GROUPS, + manager: ADMIN_GROUPS, + admin: ADMIN_GROUPS, + parent: PARENT_GROUPS, +}; + +// The mobile bottom tab bar keeps its own small, role-specific set — Figma's +// desktop sidebar has no equivalent "primary strip" (only "Ana Sayfa" sits +// outside the groups there), so this stays a phone-only affordance built +// from items that also exist in the role's group tree above. +const PRIMARY_BY_ROLE: Record = { + student: [HOME_ITEM, { id: "exam-results", to: "/exams", labelKey: "nav.examResults", Icon: IconExam, module: "exams" }, { id: "topic-mastery", to: "/marks", labelKey: "nav.topicMastery", Icon: IconChart, exactRole: "student", module: "marks" }], + teacher: [HOME_ITEM, { id: "my-classes", to: "/management/classes", labelKey: "nav.myClasses", Icon: IconSchool }, { id: "my-schedule", to: "/calendar", labelKey: "nav.mySchedule", Icon: IconCalendarDays }], + manager: [HOME_ITEM, { id: "class-groups", to: "/management/classes", labelKey: "nav.classGroups", Icon: IconSchool, minRole: "teacher" }, { id: "exams", to: "/exams", labelKey: "nav.exams", Icon: IconExam, minRole: "teacher", module: "exams" }], + admin: [HOME_ITEM, { id: "class-groups", to: "/management/classes", labelKey: "nav.classGroups", Icon: IconSchool, minRole: "teacher" }, { id: "exams", to: "/exams", labelKey: "nav.exams", Icon: IconExam, minRole: "teacher", module: "exams" }], + parent: [HOME_ITEM, { id: "progress-report", to: "/students", labelKey: "nav.progressReport", Icon: IconReportAnalytics, exactRole: "parent" }, { id: "appointments", to: "/appointments", labelKey: "nav.appointmentsAndCommunication", Icon: IconClock, exactRole: "parent", module: "appointments" }], +}; + function itemVisible(item: NavItem, role: Role | undefined) { if (!role) return false; if (item.exactRole) return hasExactRole(role, item.exactRole); if (item.minRole || item.maxRole) return roleInRange(role, item.minRole, item.maxRole); - return role !== "parent" || ["/", "/calendar", "/appointments", "/meals", "/messages"].includes(item.to); + return true; } /** @@ -208,8 +267,12 @@ export function primaryNavItems(role: Role | undefined, enabled?: readonly strin return PRIMARY_BY_ROLE[role].filter((item) => moduleVisible(item, enabled)); } +/** The full, role-specific group tree — desktop sidebar and the mobile menu + * sheet both render this directly; it mirrors the Figma sidebar as-is, with + * no items pulled out for a separate "primary" section. */ export function visibleNavGroups(role: Role | undefined, enabled?: readonly string[] | null): NavGroup[] { - return NAV_GROUPS + if (!role) return []; + return GROUPS_BY_ROLE[role] .map((group) => ({ ...group, items: group.items.filter((item) => itemVisible(item, role) && moduleVisible(item, enabled)), @@ -217,31 +280,19 @@ export function visibleNavGroups(role: Role | undefined, enabled?: readonly stri .filter((group) => group.items.length > 0); } -export function sidebarNavGroups(role: Role | undefined, enabled?: readonly string[] | null): NavGroup[] { - const primaryPaths = new Set(primaryNavItems(role, enabled).map((item) => item.to)); - return visibleNavGroups(role, enabled) - .map((group) => ({ ...group, items: group.items.filter((item) => !primaryPaths.has(item.to)) })) - .filter((group) => group.items.length > 0); -} - export function visibleNavItems(role: Role | undefined, enabled?: readonly string[] | null): NavItem[] { - const items = [HOME_ITEM, ...visibleNavGroups(role, enabled).flatMap((group) => group.items)]; - return items.filter((item, index) => items.findIndex((candidate) => candidate.to === item.to) === index); + const items = [HOME_ITEM, ...primaryNavItems(role, enabled), ...visibleNavGroups(role, enabled).flatMap((group) => group.items)]; + return items.filter((item, index) => items.findIndex((candidate) => candidate.id === item.id && candidate.to === item.to) === index); } export function pathActive(pathname: string, to: string, exact?: boolean) { + if (!to) return false; if (exact) return pathname === to; return pathname === to || pathname.startsWith(`${to}/`); } export function primaryPathActive(pathname: string, item: NavItem) { - if (pathActive(pathname, item.to, item.exact)) return true; - const prefixes: Partial> = { - classes: ["/homework", "/exams", "/question-bank"], - calendar: ["/events", "/appointments"], - progress: ["/attendance", "/pomodoro"], - }; - return (prefixes[item.id] ?? []).some((prefix) => pathname.startsWith(prefix)); + return pathActive(pathname, item.to, item.exact); } export function routeNavItem(pathname: string, role: Role | undefined): NavItem | undefined { @@ -262,6 +313,11 @@ const UNLISTED_ROUTE_LABELS: { prefix: string; labelKey: MessageKey }[] = [ { prefix: "/attendance", labelKey: "nav.attendance" }, { prefix: "/studies", labelKey: "courses.kind.study" }, { prefix: "/clubs", labelKey: "courses.kind.club" }, + { prefix: "/courses", labelKey: "nav.courses" }, + { prefix: "/notes", labelKey: "nav.notes" }, + { prefix: "/questions", labelKey: "nav.questions" }, + { prefix: "/events", labelKey: "nav.events" }, + { prefix: "/meals", labelKey: "nav.meals" }, ]; /** @@ -281,7 +337,8 @@ export function routeLabelKey(pathname: string, role: Role | undefined): Message // A page still has a name when the viewer may not open it — the shell title // must not go blank on the "no access" screen — so fall back to the nav entry // for any role, not just this one. - return [HOME_ITEM, ...NAV_GROUPS.flatMap((group) => group.items)] + const allItems = [HOME_ITEM, ...Object.values(GROUPS_BY_ROLE).flatMap((groups) => groups.flatMap((group) => group.items))]; + return allItems .filter((entry) => pathActive(pathname, entry.to, entry.exact)) .sort((a, b) => b.to.length - a.to.length)[0]?.labelKey; } diff --git a/src/components/layout/side-nav.tsx b/src/components/layout/side-nav.tsx index 68c1305..437445b 100644 --- a/src/components/layout/side-nav.tsx +++ b/src/components/layout/side-nav.tsx @@ -1,6 +1,6 @@ import { For, Show } from "solid-js"; import { Link, useNavigate, useRouterState } from "@tanstack/solid-router"; -import { primaryNavItems, routeNavItem, sidebarNavGroups, type NavItem } from "@/components/layout/nav-items"; +import { HOME_ITEM, routeNavItem, visibleNavGroups, type NavItem } from "@/components/layout/nav-items"; import { DropdownMenu, DropdownMenuContent, DropdownMenuItem, DropdownMenuSeparator, DropdownMenuTrigger } from "@/components/ui/dropdown-menu"; import { IconChevronRight } from "@/components/ui/icons"; import { cn } from "@/lib/cn"; @@ -9,7 +9,12 @@ import { useModules } from "@/stores/modules-context"; import { useShellFeed } from "@/stores/shell-feed-context"; import { useT } from "@/stores/preferences-context"; -export function SideNav(props: { onNavigate?: () => void; collapsed?: boolean }) { +export function SideNav(props: { + onNavigate?: () => void; + collapsed?: boolean; + onOpenCelebi?: () => void; + onOpenProfile?: () => void; +}) { const auth = useAuth(); const t = useT(); const feed = useShellFeed(); @@ -17,16 +22,22 @@ export function SideNav(props: { onNavigate?: () => void; collapsed?: boolean }) const navigate = useNavigate(); const pathname = useRouterState({ select: (state) => state.location.pathname }); - const primary = () => primaryNavItems(auth.user()?.role, modules.enabled()); - const groups = () => sidebarNavGroups(auth.user()?.role, modules.enabled()); + const home = () => (auth.user() ? [HOME_ITEM] : []); + const groups = () => visibleNavGroups(auth.user()?.role, modules.enabled()); const current = () => routeNavItem(pathname(), auth.user()?.role); const unread = () => feed.unreadMessages().total; const badgeFor = (item: NavItem) => (item.id === "messages" ? unread() : 0); + const runAction = (item: NavItem) => { + props.onNavigate?.(); + if (item.action === "celebi") props.onOpenCelebi?.(); + if (item.action === "profile") props.onOpenProfile?.(); + }; + return (