forge
Explore
Log in

Don't you dare go Hollow

hezarfen_frontend

Clone
★ 0

0 watching0 forksTypeScript5.5 MiB5fcd955Burak Boduroğlu2 months ago730 commits

nav-items.ts500 lines, 21.4 KiBHistoryRawDownload
1import type { Component } from "solid-js";
2import type { Role } from "@/api/client";
3import {
4 IconArchive,
5 IconBook,
6 IconBriefcase,
7 IconCalendarBlank,
8 IconCalendarCheck,
9 IconCalendarX,
10 IconCalendarDays,
11 IconCalendarStar,
12 IconChalkboardTeacher,
13 IconChart,
14 IconChartPie,
15 IconClipboardCheck,
16 IconClockUser,
17 IconEdit,
18 IconExam,
19 IconHandshake,
20 IconHelpCircle,
21 IconHome,
22 IconHomework,
23 IconListChecks,
24 IconMessage,
25 IconNote,
26 IconPackage,
27 IconReportAnalytics,
28 IconScan,
29 IconSchool,
30 IconSettings,
31 IconShieldCheck,
32 IconSparkles,
33 IconTarget,
34 IconTimer,
35 IconUserCog,
36 IconUsers,
37 IconUtensils,
38 IconWaveform,
39} from "@/components/ui/icons";
40import type { MessageKey } from "@/i18n/messages";
41import { hasExactRole, roleInRange } from "@/lib/roles";
42
43export type NavItem = {
44 id: string;
45 to: string;
46 labelKey: MessageKey;
47 Icon: Component<{ class?: string }>;
48 minRole?: Role;
49 maxRole?: Role;
50 exactRole?: Role;
51 exact?: boolean;
52 /**
53 * Search params the entry links with (`/questions?status=pending`). It is
54 * active only while the URL carries them, and then wins over a plain entry
55 * for the same path.
56 */
57 search?: Record<string, string>;
58 /** Backend module nest behind this entry; hidden when the school did not buy it. */
59 module?: string;
60 /** No backend yet — routes to the shared placeholder and carries a "yakında" badge. */
61 soon?: boolean;
62 /** Opens an existing shell surface instead of navigating (the Çelebi panel,
63 * the account settings dialog) — both already live elsewhere in the shell. */
64 action?: "celebi" | "profile";
65};
66
67export type NavGroup = {
68 id: string;
69 labelKey: MessageKey;
70 Icon: Component<{ class?: string }>;
71 items: NavItem[];
72 /** Starts folded in the sidebar until the viewer opens it (the "yakında" shelf). */
73 defaultFolded?: boolean;
74};
75
76export const HOME_ITEM: NavItem = {
77 id: "today",
78 to: "/",
79 labelKey: "nav.today",
80 Icon: IconHome,
81 exact: true,
82};
83
84const AI_STUDIO_ITEM: NavItem = {
85 id: "ai-studio",
86 to: "/ai/studio",
87 labelKey: "aiHub.tab.studio",
88 Icon: IconWaveform,
89 module: "course_notes",
90};
91
92const AI_STUDY_ITEM: NavItem = {
93 id: "ai-study",
94 to: "/ai/study",
95 labelKey: "aiHub.tab.study",
96 Icon: IconBook,
97};
98
99const AI_INSIGHTS_ITEM: NavItem = {
100 id: "ai-insights",
101 to: "/ai/insights",
102 labelKey: "aiHub.tab.insights",
103 Icon: IconChart,
104};
105
106const AI_CELEBI_ITEM: NavItem = {
107 id: "ai-celebi",
108 to: "",
109 labelKey: "nav.celebi",
110 Icon: IconSparkles,
111 action: "celebi",
112 module: "chatbot",
113};
114
115const AI_GROUP: NavGroup = {
116 id: "ai",
117 labelKey: "nav.group.ai",
118 Icon: IconSparkles,
119 items: [AI_STUDIO_ITEM, AI_STUDY_ITEM, AI_INSIGHTS_ITEM, AI_CELEBI_ITEM],
120};
121
122// A teacher's student analysis is the same board, listed under Tracking as
123// "Öğrenci analizi" — so their AI group leaves it out instead of listing it twice.
124const TEACHER_AI_GROUP: NavGroup = {
125 id: "ai",
126 labelKey: "nav.group.ai",
127 Icon: IconSparkles,
128 items: [AI_STUDIO_ITEM, AI_STUDY_ITEM, AI_CELEBI_ITEM],
129};
130
131const PARENT_AI_GROUP: NavGroup = {
132 id: "ai",
133 labelKey: "nav.group.ai",
134 Icon: IconSparkles,
135 items: [AI_INSIGHTS_ITEM],
136};
137
138function settingsAction(id: string): NavItem {
139 return { id, to: "", labelKey: "nav.settings", Icon: IconSettings, action: "profile" };
140}
141
142// Every role's tree is short, labelled sections that stay open (Fintables
143// style) instead of a few accordions hiding 20 entries each. Entries without a
144// backend yet all move to one trailing "Yakında" section, folded by default, so
145// they stay visible without crowding the live pages.
146function soonGroup(items: NavItem[]): NavGroup {
147 return { id: "soon", labelKey: "nav.soon", Icon: IconTarget, items, defaultFolded: true };
148}
149
150// Admin and manager share one tree — manager just qualifies for fewer of its
151// items, via the same minRole gates the rest of this file already uses.
152const ADMIN_GROUPS: NavGroup[] = [
153 AI_GROUP,
154 {
155 id: "school",
156 labelKey: "nav.group.school",
157 Icon: IconSchool,
158 items: [
159 { id: "students-roster", to: "/management/students", labelKey: "nav.studentsRoster", Icon: IconUsers, minRole: "manager" },
160 { id: "teachers-roster", to: "/management/teachers", labelKey: "nav.teachersRoster", Icon: IconChalkboardTeacher, minRole: "manager" },
161 { id: "class-groups", to: "/management/classes", labelKey: "nav.classGroups", Icon: IconSchool, minRole: "teacher", module: "classes" },
162 { id: "academic-years", to: "/management/academic-years", labelKey: "nav.academicYears", Icon: IconCalendarBlank, minRole: "manager" },
163 { id: "terms", to: "/management/terms", labelKey: "nav.terms", Icon: IconCalendarCheck, minRole: "manager" },
164 { id: "holidays", to: "/management/holidays", labelKey: "nav.holidays", Icon: IconCalendarX, minRole: "manager" },
165 { id: "schedule", to: "/calendar", labelKey: "nav.schedule", Icon: IconCalendarDays, minRole: "manager" },
166 ],
167 },
168 {
169 id: "teaching",
170 labelKey: "nav.group.teaching",
171 Icon: IconBook,
172 items: [
173 { id: "courses", to: "/courses", labelKey: "nav.classes", Icon: IconBook, module: "courses" },
174 { id: "homework", to: "/homework", labelKey: "nav.homework", Icon: IconHomework, module: "homework" },
175 { id: "exams", to: "/exams", labelKey: "nav.exams", Icon: IconExam, minRole: "teacher", module: "exams" },
176 { id: "question-bank", to: "/question-bank", labelKey: "nav.questionBank", Icon: IconArchive, minRole: "teacher", module: "bank_questions" },
177 { id: "questions", to: "/questions", labelKey: "nav.questions", Icon: IconHelpCircle, module: "questions" },
178 { id: "notes", to: "/notes", labelKey: "nav.notes", Icon: IconNote, module: "notes" },
179 { id: "whiteboards", to: "/whiteboards", labelKey: "nav.whiteboards", Icon: IconEdit, module: "boards" },
180 ],
181 },
182 {
183 id: "tracking",
184 labelKey: "nav.group.tracking",
185 Icon: IconClipboardCheck,
186 items: [
187 { id: "student-attendance", to: "/management/student-attendance", labelKey: "nav.studentAttendance", Icon: IconClipboardCheck, minRole: "teacher", module: "attendance" },
188 { id: "student-marks", to: "/management/student-marks", labelKey: "nav.studentMarks", Icon: IconChart, minRole: "teacher", module: "marks" },
189 { id: "student-pomodoros", to: "/management/pomodoros", labelKey: "nav.studentPomodoro", Icon: IconTimer, minRole: "teacher", module: "pomodoro" },
190 ],
191 },
192 {
193 id: "services",
194 labelKey: "nav.group.services",
195 Icon: IconCalendarDays,
196 items: [
197 { id: "events", to: "/events", labelKey: "nav.events", Icon: IconCalendarStar, module: "events" },
198 { id: "appointments", to: "/appointments", labelKey: "nav.appointments", Icon: IconHandshake, module: "appointments" },
199 { id: "school-meals", to: "/meals", labelKey: "nav.schoolMeals", Icon: IconUtensils, minRole: "manager", module: "meals" },
200 ],
201 },
202 {
203 id: "institution",
204 labelKey: "nav.group.institution",
205 Icon: IconUserCog,
206 items: [
207 { id: "payments-collection", to: "/management/payments", labelKey: "nav.payments", Icon: IconReportAnalytics, minRole: "manager", module: "payments" },
208 { id: "staff-work", to: "/management/staff-work", labelKey: "nav.staffWork", Icon: IconBriefcase, minRole: "manager", module: "work" },
209 { id: "work", to: "/work", labelKey: "nav.work", Icon: IconClockUser, minRole: "teacher", module: "work" },
210 { id: "users", to: "/admin/users", labelKey: "nav.users", Icon: IconUserCog, minRole: "admin" },
211 { id: "license-modules", to: "/management/modules", labelKey: "nav.licenseModules", Icon: IconPackage, minRole: "admin" },
212 { id: "settings", to: "/management/settings", labelKey: "settings.title", Icon: IconSettings, minRole: "manager" },
213 ],
214 },
215 soonGroup([
216 { id: "mock-exams", to: "/coming-soon/deneme-sinavlari", labelKey: "nav.mockExams", Icon: IconTarget, soon: true, minRole: "manager" },
217 { id: "optical-reading", to: "/coming-soon/optik-okuma", labelKey: "nav.opticalReading", Icon: IconScan, soon: true, minRole: "manager" },
218 { id: "reports", to: "/coming-soon/raporlar", labelKey: "nav.reports", Icon: IconChartPie, soon: true, minRole: "manager" },
219 { id: "data-protection", to: "/coming-soon/kvkk-denetim", labelKey: "nav.dataProtection", Icon: IconShieldCheck, soon: true, minRole: "admin" },
220 ]),
221];
222
223const TEACHER_GROUPS: NavGroup[] = [
224 TEACHER_AI_GROUP,
225 {
226 id: "my-classroom",
227 labelKey: "nav.group.myClassroom",
228 Icon: IconSchool,
229 items: [
230 { id: "my-classes", to: "/management/classes", labelKey: "nav.myClasses", Icon: IconSchool, module: "classes" },
231 { id: "my-schedule", to: "/calendar", labelKey: "nav.mySchedule", Icon: IconCalendarDays },
232 { id: "courses", to: "/courses", labelKey: "nav.classes", Icon: IconBook, module: "courses" },
233 ],
234 },
235 {
236 id: "tracking",
237 labelKey: "nav.group.tracking",
238 Icon: IconClipboardCheck,
239 items: [
240 { id: "student-attendance", to: "/management/student-attendance", labelKey: "nav.studentAttendance", Icon: IconClipboardCheck, module: "attendance" },
241 { id: "student-marks", to: "/management/student-marks", labelKey: "nav.studentMarks", Icon: IconChart, module: "marks" },
242 { id: "student-pomodoros", to: "/management/pomodoros", labelKey: "nav.studentPomodoro", Icon: IconTimer, module: "pomodoro" },
243 { id: "student-analysis", to: "/ai/insights", labelKey: "nav.studentAnalysis", Icon: IconChart },
244 ],
245 },
246 {
247 id: "teaching",
248 labelKey: "nav.group.teaching",
249 Icon: IconBook,
250 items: [
251 { id: "homework", to: "/homework", labelKey: "nav.homework", Icon: IconHomework, module: "homework" },
252 { id: "exams", to: "/exams", labelKey: "nav.exams", Icon: IconExam, module: "exams" },
253 { id: "question-bank", to: "/question-bank", labelKey: "nav.questionBank", Icon: IconArchive, module: "bank_questions" },
254 { id: "question-generation", to: "/ai/question-generation", labelKey: "nav.questionGeneration", Icon: IconSparkles },
255 { id: "questions", to: "/questions", labelKey: "nav.questions", Icon: IconHelpCircle, module: "questions" },
256 // The pool's own pending tab: for a teacher, `?status=pending` is the
257 // approval queue (`POST /questions/{id}/approve`).
258 { id: "pending-approvals", to: "/questions", search: { status: "pending" }, labelKey: "nav.pendingApprovals", Icon: IconClipboardCheck, module: "questions" },
259 { id: "notes", to: "/notes", labelKey: "nav.notes", Icon: IconNote, module: "notes" },
260 { id: "whiteboards", to: "/whiteboards", labelKey: "nav.whiteboards", Icon: IconEdit, module: "boards" },
261 ],
262 },
263 {
264 id: "other",
265 labelKey: "nav.group.other",
266 Icon: IconMessage,
267 items: [
268 { id: "parent-communication", to: "/messages", labelKey: "nav.parentCommunication", Icon: IconMessage, module: "messages" },
269 { id: "appointments", to: "/appointments", labelKey: "nav.appointments", Icon: IconHandshake, module: "appointments" },
270 { id: "events", to: "/events", labelKey: "nav.events", Icon: IconCalendarStar, module: "events" },
271 { id: "meals", to: "/meals", labelKey: "nav.meals", Icon: IconUtensils, module: "meals" },
272 { id: "work", to: "/work", labelKey: "nav.work", Icon: IconClockUser, minRole: "teacher", module: "work" },
273 settingsAction("settings-teacher"),
274 ],
275 },
276];
277
278const STUDENT_GROUPS: NavGroup[] = [
279 AI_GROUP,
280 {
281 id: "study",
282 labelKey: "nav.group.study",
283 Icon: IconSchool,
284 items: [
285 { id: "topic-mastery", to: "/marks", labelKey: "nav.topicMastery", Icon: IconChart, exactRole: "student", module: "marks" },
286 { id: "exam-results", to: "/exams", labelKey: "nav.examResults", Icon: IconExam, module: "exams" },
287 { id: "my-homework", to: "/homework", labelKey: "nav.myHomework", Icon: IconHomework, module: "homework" },
288 { id: "pomodoro", to: "/pomodoro", labelKey: "nav.pomodoro", Icon: IconTimer, exactRole: "student", module: "pomodoro" },
289 ],
290 },
291 {
292 id: "teaching",
293 labelKey: "nav.group.teaching",
294 Icon: IconBook,
295 items: [
296 { id: "courses", to: "/courses", labelKey: "nav.classes", Icon: IconBook, module: "courses" },
297 { id: "notes", to: "/notes", labelKey: "nav.notes", Icon: IconNote, module: "notes" },
298 { id: "questions", to: "/questions", labelKey: "nav.questions", Icon: IconHelpCircle, module: "questions" },
299 { id: "whiteboards", to: "/whiteboards", labelKey: "nav.whiteboards", Icon: IconEdit, module: "boards" },
300 ],
301 },
302 {
303 id: "other",
304 labelKey: "nav.group.other",
305 Icon: IconCalendarDays,
306 items: [
307 { id: "calendar", to: "/calendar", labelKey: "nav.mySchedule", Icon: IconCalendarDays },
308 { id: "events", to: "/events", labelKey: "nav.events", Icon: IconCalendarStar, module: "events" },
309 { id: "messages", to: "/messages", labelKey: "nav.messages", Icon: IconMessage, module: "messages" },
310 { id: "appointments", to: "/appointments", labelKey: "nav.appointments", Icon: IconHandshake, module: "appointments" },
311 { id: "meals", to: "/meals", labelKey: "nav.meals", Icon: IconUtensils, module: "meals" },
312 settingsAction("settings-student"),
313 ],
314 },
315 soonGroup([
316 { id: "study-plan", to: "/coming-soon/calisma-programim", labelKey: "nav.studyPlan", Icon: IconListChecks, soon: true },
317 ]),
318];
319
320const PARENT_GROUPS: NavGroup[] = [
321 PARENT_AI_GROUP,
322 {
323 id: "my-student",
324 labelKey: "nav.group.myStudent",
325 Icon: IconUsers,
326 items: [
327 { id: "progress-report", to: "/students", labelKey: "nav.progressReport", Icon: IconReportAnalytics, exactRole: "parent" },
328 { id: "absence", to: "/students/attendance", labelKey: "nav.absence", Icon: IconClipboardCheck, exactRole: "parent", module: "attendance" },
329 { id: "child-exam-results", to: "/students/exams", labelKey: "nav.childExamResults", Icon: IconExam, exactRole: "parent", module: "marks" },
330 { id: "child-study-plan", to: "/students/study", labelKey: "nav.childStudyPlan", Icon: IconListChecks, exactRole: "parent", module: "pomodoro" },
331 ],
332 },
333 {
334 id: "institution",
335 labelKey: "nav.group.institution",
336 Icon: IconUserCog,
337 items: [
338 { id: "payment-statement", to: "/payments", labelKey: "nav.payments", Icon: IconReportAnalytics, exactRole: "parent", module: "payments" },
339 { id: "appointments", to: "/appointments", labelKey: "nav.appointmentsAndCommunication", Icon: IconHandshake, exactRole: "parent", module: "appointments" },
340 { id: "messages", to: "/messages", labelKey: "nav.messages", Icon: IconMessage, module: "messages" },
341 { id: "calendar", to: "/calendar", labelKey: "nav.mySchedule", Icon: IconCalendarDays },
342 { id: "events", to: "/events", labelKey: "nav.events", Icon: IconCalendarStar, module: "events" },
343 { id: "meals", to: "/meals", labelKey: "nav.meals", Icon: IconUtensils, module: "meals" },
344 settingsAction("settings-parent"),
345 ],
346 },
347];
348
349const GROUPS_BY_ROLE: Record<Role, NavGroup[]> = {
350 student: STUDENT_GROUPS,
351 teacher: TEACHER_GROUPS,
352 manager: ADMIN_GROUPS,
353 admin: ADMIN_GROUPS,
354 parent: PARENT_GROUPS,
355};
356
357// The mobile bottom tab bar: Home plus two of the role's busiest pages, then
358// the bar's own Search and Menu buttons. Entries are picked by id from the
359// role's sidebar tree, so a tab always carries the same icon and label as its
360// sidebar row.
361const PRIMARY_IDS_BY_ROLE: Record<Role, string[]> = {
362 student: ["my-homework", "exam-results"],
363 teacher: ["my-classes", "student-attendance"],
364 manager: ["students-roster", "class-groups"],
365 admin: ["students-roster", "class-groups"],
366 parent: ["progress-report", "appointments"],
367};
368
369function primaryItemsFor(role: Role): NavItem[] {
370 const all = GROUPS_BY_ROLE[role].flatMap((group) => group.items);
371 const picked = PRIMARY_IDS_BY_ROLE[role]
372 .map((id) => all.find((item) => item.id === id))
373 .filter((item): item is NavItem => item !== undefined);
374 return [HOME_ITEM, ...picked];
375}
376
377function itemVisible(item: NavItem, role: Role | undefined) {
378 if (!role) return false;
379 if (item.exactRole) return hasExactRole(role, item.exactRole);
380 if (item.minRole || item.maxRole) return roleInRange(role, item.minRole, item.maxRole);
381 return true;
382}
383
384/**
385 * The school's entitlement gate. Null/undefined means "unknown" (still
386 * loading, logged out, or the lookup failed) and shows everything — a modules
387 * outage must never blank the shell; the backend still 403s the nest itself.
388 */
389export function moduleVisible(item: NavItem, enabled: readonly string[] | null | undefined): boolean {
390 if (enabled == null) return true;
391 if (item.module == null) return true;
392 return enabled.includes(item.module);
393}
394
395export function primaryNavItems(role: Role | undefined, enabled?: readonly string[] | null): NavItem[] {
396 if (!role) return [];
397 return primaryItemsFor(role).filter((item) => itemVisible(item, role) && moduleVisible(item, enabled));
398}
399
400/** The full, role-specific group tree — desktop sidebar and the mobile menu
401 * sheet both render this directly; it mirrors the Figma sidebar as-is, with
402 * no items pulled out for a separate "primary" section. */
403export function visibleNavGroups(role: Role | undefined, enabled?: readonly string[] | null): NavGroup[] {
404 if (!role) return [];
405 return GROUPS_BY_ROLE[role]
406 .map((group) => ({
407 ...group,
408 items: group.items.filter((item) => itemVisible(item, role) && moduleVisible(item, enabled)),
409 }))
410 .filter((group) => group.items.length > 0);
411}
412
413export function visibleNavItems(role: Role | undefined, enabled?: readonly string[] | null): NavItem[] {
414 const items = [HOME_ITEM, ...primaryNavItems(role, enabled), ...visibleNavGroups(role, enabled).flatMap((group) => group.items)];
415 return items.filter((item, index) => items.findIndex((candidate) => candidate.id === item.id && candidate.to === item.to) === index);
416}
417
418export function pathActive(pathname: string, to: string, exact?: boolean) {
419 if (!to) return false;
420 if (exact) return pathname === to;
421 return pathname === to || pathname.startsWith(`${to}/`);
422}
423
424export function primaryPathActive(pathname: string, item: NavItem) {
425 return pathActive(pathname, item.to, item.exact);
426}
427
428function searchMatches(item: NavItem, search: Record<string, unknown> | undefined) {
429 if (!item.search) return true;
430 return Object.entries(item.search).every(([key, value]) => search?.[key] === value);
431}
432
433// Pages with no nav entry of their own that live under one: a şube×ders
434// instance is reached from Dersler, so the sidebar keeps Dersler lit there.
435const NAV_PARENT_PREFIXES: { prefix: string; parent: string }[] = [{ prefix: "/instances", parent: "/courses" }];
436
437function navPath(pathname: string) {
438 const alias = NAV_PARENT_PREFIXES.find((entry) => pathname === entry.prefix || pathname.startsWith(`${entry.prefix}/`));
439 return alias ? alias.parent : pathname;
440}
441
442export function routeNavItem(pathname: string, role: Role | undefined, search?: Record<string, unknown>): NavItem | undefined {
443 const path = navPath(pathname);
444 return [...primaryNavItems(role), ...visibleNavItems(role)]
445 .filter((item) => pathActive(path, item.to, item.exact) && searchMatches(item, search))
446 .sort((a, b) => b.to.length - a.to.length || Number(!!b.search) - Number(!!a.search))[0];
447}
448
449// Routes that are reachable but carry no sidebar entry — the account menu, a
450// course-kind view, a deep link. Without these the shell's title falls back to
451// the raw pathname and the header reads "/profile/me".
452const UNLISTED_ROUTE_LABELS: { prefix: string; labelKey: MessageKey }[] = [
453 // Longest prefix first — /profile/me is the viewer's own, every other
454 // /profile/{id} belongs to somebody else and must not read "My profile".
455 { prefix: "/profile/me", labelKey: "profile.myProfile" },
456 { prefix: "/profile", labelKey: "profile.title" },
457 { prefix: "/guide", labelKey: "nav.guide" },
458 { prefix: "/attendance", labelKey: "nav.attendance" },
459 { prefix: "/studies", labelKey: "courses.kind.study" },
460 { prefix: "/clubs", labelKey: "courses.kind.club" },
461 { prefix: "/courses", labelKey: "nav.classes" },
462 { prefix: "/notes", labelKey: "nav.notes" },
463 { prefix: "/questions", labelKey: "nav.questions" },
464 { prefix: "/events", labelKey: "nav.events" },
465 { prefix: "/meals", labelKey: "nav.meals" },
466];
467
468/**
469 * The label the shell header shows for a route: its nav entry when it has one,
470 * otherwise an explicit fallback. Returns undefined only for routes rendered
471 * without the shell (login, register, the exam room).
472 */
473export function routeLabelKey(
474 pathname: string,
475 role: Role | undefined,
476 search?: Record<string, unknown>,
477): MessageKey | undefined {
478 // The catalog filtered to one course kind is that kind's page.
479 if (pathname === "/courses" && (search?.kind === "club" || search?.kind === "study")) {
480 return search.kind === "club" ? "courses.kind.club" : "courses.kind.study";
481 }
482 // An aliased page (an instance) is named by its own heading, not the
483 // parent entry it keeps lit in the sidebar.
484 if (navPath(pathname) !== pathname) return undefined;
485 const item = routeNavItem(pathname, role, search);
486 if (item) return item.labelKey;
487
488 const unlisted = UNLISTED_ROUTE_LABELS.find(
489 (entry) => pathname === entry.prefix || pathname.startsWith(`${entry.prefix}/`),
490 );
491 if (unlisted) return unlisted.labelKey;
492
493 // A page still has a name when the viewer may not open it — the shell title
494 // must not go blank on the "no access" screen — so fall back to the nav entry
495 // for any role, not just this one.
496 const allItems = [HOME_ITEM, ...Object.values(GROUPS_BY_ROLE).flatMap((groups) => groups.flatMap((group) => group.items))];
497 return allItems
498 .filter((entry) => pathActive(pathname, entry.to, entry.exact))
499 .sort((a, b) => b.to.length - a.to.length)[0]?.labelKey;
500}