🗂️ student and teacher rosters, license page on the ADM-05 layout
Browse files at this commit7eafcf73b55d32d53d09b6536e715cde87ccddb3Parent: b77456a- feat
- 🗂️ student and teacher rosters, license page on the ADM-05 layout
10 changed files +629 -21
- docs/ui/figma-migration-coverage.md +5 -0
- src/components/layout/nav-items.test.ts +4 -0
- src/components/layout/nav-items.ts +2 -2
- src/components/users/roster-person-cell.tsx +16 -0
- src/i18n/messages.ts +137 -2
- src/pages/coming-soon-page.tsx +0 -2
- src/pages/license-modules-page.tsx +142 -13
- src/pages/students-roster-page.tsx +173 -0
- src/pages/teachers-roster-page.tsx +134 -0
- src/routes/router.tsx +16 -2
docs/ui/figma-migration-coverage.mdmodified+5 -0
| @@ -71,6 +71,9 @@ are used; unknown values are not inferred. | |||
| 71 | | `/management/payments` | Admin payments | Keep ledger and permission behavior | | 71 | | `/management/payments` | Admin payments | Keep ledger and permission behavior | |
| 72 | | `/management/staff-work` | Admin staff work | Keep existing read/update/delete contract | | 72 | | `/management/staff-work` | Admin staff work | Keep existing read/update/delete contract | |
| 73 | | `/admin/users`, `/admin/users/:id` | Admin users and roles | Keep admin guard and critical confirmations | | 73 | | `/admin/users`, `/admin/users/:id` | Admin users and roles | Keep admin guard and critical confirmations | |
| 74 | +| `/management/students` | ADM-02 Öğrenciler | Real roster + class/term filters; mastery, attendance, plan and risk columns stay "yakında" | | ||
| 75 | +| `/management/teachers` | ADM-08 Öğretmenler | Real roster + homeroom class count; branch, load, AI acceptance and status stay "yakında" | | ||
| 76 | +| `/management/modules` | ADM-05 Lisans ve modüller | Real enabled/total modules per package; price, seats, renewal and invoices stay "yakında" | | ||
| 74 | | `/students` | Parent development views | Keep linked-child authorization | | 77 | | `/students` | Parent development views | Keep linked-child authorization | |
| 75 | | `/meals`, `/meals/:id` | Admin cafeteria | Keep menu, booking, balance, and attendance behavior | | 78 | | `/meals`, `/meals/:id` | Admin cafeteria | Keep menu, booking, balance, and attendance behavior | |
| 76 | | `/payments` | Parent/student statement | Remain read-only until a payment-provider API exists | | 79 | | `/payments` | Parent/student statement | Remain read-only until a payment-provider API exists | |
| @@ -110,6 +113,8 @@ Keep the current UI and behavior until a specific design is added: | |||
| 110 | - `/management/pomodoros` | 113 | - `/management/pomodoros` |
| 111 | - `/management/terms` | 114 | - `/management/terms` |
| 112 | - `/whiteboards/:id` live canvas details beyond the list concept | 115 | - `/whiteboards/:id` live canvas details beyond the list concept |
| 116 | +- `/builder/login`, `/builder`, `/builder/schools/:slug` (vendor operator console) | ||
| 117 | +- `/students/attendance`, `/students/exams`, `/students/study` parent tab routes | ||
| 113 | - `/meals/:id` detailed account/service/management tabs | 118 | - `/meals/:id` detailed account/service/management tabs |
| 114 | - `/studies`, `/clubs`, and `/attendance` redirect aliases | 119 | - `/studies`, `/clubs`, and `/attendance` redirect aliases |
| 115 | 120 | ||
src/components/layout/nav-items.test.tsmodified+4 -0
| @@ -141,6 +141,10 @@ test("license modules is a real admin page and the work log includes admin", () | |||
| 141 | expect(licenseModules?.to).toBe("/management/modules"); | 141 | expect(licenseModules?.to).toBe("/management/modules"); |
| 142 | expect(licenseModules?.soon).toBeFalsy(); | 142 | expect(licenseModules?.soon).toBeFalsy(); |
| 143 | expect(admin.map((i) => i.to)).toContain("/work"); | 143 | expect(admin.map((i) => i.to)).toContain("/work"); |
| 144 | + expect(admin.filter((i) => i.id.endsWith("-roster")).map((i) => [i.to, i.soon ?? false])).toEqual([ | ||
| 145 | + ["/management/students", false], | ||
| 146 | + ["/management/teachers", false], | ||
| 147 | + ]); | ||
| 144 | expect(visibleNavGroups("manager").flatMap((g) => g.items).map((i) => i.id)).not.toContain("license-modules"); | 148 | expect(visibleNavGroups("manager").flatMap((g) => g.items).map((i) => i.id)).not.toContain("license-modules"); |
| 145 | }); | 149 | }); |
| 146 | 150 | ||
src/components/layout/nav-items.tsmodified+2 -2
| @@ -97,8 +97,8 @@ const ADMIN_GROUPS: NavGroup[] = [ | |||
| 97 | labelKey: "nav.group.operations", | 97 | labelKey: "nav.group.operations", |
| 98 | Icon: IconSchool, | 98 | Icon: IconSchool, |
| 99 | items: [ | 99 | items: [ |
| 100 | - { id: "students-roster", to: "/coming-soon/ogrenciler", labelKey: "nav.studentsRoster", Icon: IconUsers, soon: true, minRole: "manager" }, | 100 | + { id: "students-roster", to: "/management/students", labelKey: "nav.studentsRoster", Icon: IconUsers, minRole: "manager" }, |
| 101 | - { id: "teachers-roster", to: "/coming-soon/ogretmenler", labelKey: "nav.teachersRoster", Icon: IconChalkboardTeacher, soon: true, minRole: "manager" }, | 101 | + { id: "teachers-roster", to: "/management/teachers", labelKey: "nav.teachersRoster", Icon: IconChalkboardTeacher, minRole: "manager" }, |
| 102 | { id: "class-groups", to: "/management/classes", labelKey: "nav.classGroups", Icon: IconSchool, minRole: "teacher" }, | 102 | { id: "class-groups", to: "/management/classes", labelKey: "nav.classGroups", Icon: IconSchool, minRole: "teacher" }, |
| 103 | { id: "courses", to: "/courses", labelKey: "nav.courses", Icon: IconBook, module: "courses" }, | 103 | { id: "courses", to: "/courses", labelKey: "nav.courses", Icon: IconBook, module: "courses" }, |
| 104 | { id: "terms", to: "/management/terms", labelKey: "nav.terms", Icon: IconCalendar, minRole: "manager" }, | 104 | { id: "terms", to: "/management/terms", labelKey: "nav.terms", Icon: IconCalendar, minRole: "manager" }, |
src/components/users/roster-person-cell.tsxadded+16 -0
| @@ -0,0 +1,16 @@ | |||
| 1 | +import type { PersonRef } from "@/api/client"; | ||
| 2 | +import { UserAvatar } from "@/components/users/user-avatar"; | ||
| 3 | +import { personLabel } from "@/lib/person"; | ||
| 4 | + | ||
| 5 | +/** Avatar initials, display name and @username — the first column of the ADM-02/ADM-08 rosters. */ | ||
| 6 | +export function RosterPersonCell(props: { person: PersonRef }) { | ||
| 7 | + return ( | ||
| 8 | + <div class="flex min-w-0 items-center gap-2.5"> | ||
| 9 | + <UserAvatar userId={props.person.id} name={personLabel(props.person)} hasAvatar={false} size="sm" /> | ||
| 10 | + <div class="min-w-0"> | ||
| 11 | + <p class="truncate text-sm font-medium text-text-strong">{personLabel(props.person)}</p> | ||
| 12 | + <p class="truncate text-xs text-text-subtle">@{props.person.username}</p> | ||
| 13 | + </div> | ||
| 14 | + </div> | ||
| 15 | + ); | ||
| 16 | +} | ||
src/i18n/messages.tsmodified+137 -2
| @@ -305,6 +305,35 @@ export type MessageKey = | |||
| 305 | | "comingSoon.description" | 305 | | "comingSoon.description" |
| 306 | | "comingSoon.emptyTitle" | 306 | | "comingSoon.emptyTitle" |
| 307 | | "comingSoon.emptyDescription" | 307 | | "comingSoon.emptyDescription" |
| 308 | + | "roster.student" | ||
| 309 | + | "roster.teacher" | ||
| 310 | + | "roster.class" | ||
| 311 | + | "roster.classAll" | ||
| 312 | + | "roster.term" | ||
| 313 | + | "roster.termAll" | ||
| 314 | + | "roster.mastery" | ||
| 315 | + | "roster.attendance" | ||
| 316 | + | "roster.planAdherence" | ||
| 317 | + | "roster.status" | ||
| 318 | + | "roster.branch" | ||
| 319 | + | "roster.weeklyLessons" | ||
| 320 | + | "roster.suggestionAcceptance" | ||
| 321 | + | "roster.tabAll" | ||
| 322 | + | "roster.tabActive" | ||
| 323 | + | "roster.tabNew" | ||
| 324 | + | "roster.tabAtRisk" | ||
| 325 | + | "roster.tabLeft" | ||
| 326 | + | "roster.tabPermanent" | ||
| 327 | + | "roster.tabContract" | ||
| 328 | + | "roster.tabAdvisor" | ||
| 329 | + | "roster.import" | ||
| 330 | + | "roster.addStudent" | ||
| 331 | + | "roster.addTeacher" | ||
| 332 | + | "roster.studentsSubtitle" | ||
| 333 | + | "roster.teachersSubtitle" | ||
| 334 | + | "roster.searchStudents" | ||
| 335 | + | "roster.searchTeachers" | ||
| 336 | + | "roster.noTeachers" | ||
| 308 | | "builder.console" | 337 | | "builder.console" |
| 309 | | "builder.logout" | 338 | | "builder.logout" |
| 310 | | "builder.loginTitle" | 339 | | "builder.loginTitle" |
| @@ -350,6 +379,22 @@ export type MessageKey = | |||
| 350 | | "modules.requires" | 379 | | "modules.requires" |
| 351 | | "modules.on" | 380 | | "modules.on" |
| 352 | | "modules.off" | 381 | | "modules.off" |
| 382 | + | "modules.module" | ||
| 383 | + | "modules.active" | ||
| 384 | + | "modules.unitPrice" | ||
| 385 | + | "modules.activeSeats" | ||
| 386 | + | "modules.annualAmount" | ||
| 387 | + | "modules.annualTotal" | ||
| 388 | + | "modules.tabOverview" | ||
| 389 | + | "modules.tabUsage" | ||
| 390 | + | "modules.tabInvoices" | ||
| 391 | + | "modules.tabContract" | ||
| 392 | + | "modules.downloadInvoices" | ||
| 393 | + | "modules.addLicense" | ||
| 394 | + | "modules.fullPackage" | ||
| 395 | + | "modules.customPackage" | ||
| 396 | + | "modules.renewal" | ||
| 397 | + | "modules.recentInvoices" | ||
| 353 | | "modules.conflictRequires" | 398 | | "modules.conflictRequires" |
| 354 | | "modules.conflictRequiredBy" | 399 | | "modules.conflictRequiredBy" |
| 355 | | "module.appointments" | 400 | | "module.appointments" |
| @@ -2087,6 +2132,35 @@ const en: Dict = { | |||
| 2087 | "comingSoon.description": "This module is on its way — there is nothing to show here yet.", | 2132 | "comingSoon.description": "This module is on its way — there is nothing to show here yet.", |
| 2088 | "comingSoon.emptyTitle": "Not available yet", | 2133 | "comingSoon.emptyTitle": "Not available yet", |
| 2089 | "comingSoon.emptyDescription": "This part of Hezarfen is still being built. Check back soon.", | 2134 | "comingSoon.emptyDescription": "This part of Hezarfen is still being built. Check back soon.", |
| 2135 | + "roster.student": "Student", | ||
| 2136 | + "roster.teacher": "Teacher", | ||
| 2137 | + "roster.class": "Class", | ||
| 2138 | + "roster.classAll": "Class: All", | ||
| 2139 | + "roster.term": "Term", | ||
| 2140 | + "roster.termAll": "Term: All", | ||
| 2141 | + "roster.mastery": "Topic mastery", | ||
| 2142 | + "roster.attendance": "Attendance", | ||
| 2143 | + "roster.planAdherence": "Plan adherence", | ||
| 2144 | + "roster.status": "Status", | ||
| 2145 | + "roster.branch": "Branch", | ||
| 2146 | + "roster.weeklyLessons": "Weekly lessons", | ||
| 2147 | + "roster.suggestionAcceptance": "Suggestion acceptance", | ||
| 2148 | + "roster.tabAll": "All", | ||
| 2149 | + "roster.tabActive": "Active", | ||
| 2150 | + "roster.tabNew": "New enrolment", | ||
| 2151 | + "roster.tabAtRisk": "At risk", | ||
| 2152 | + "roster.tabLeft": "Left", | ||
| 2153 | + "roster.tabPermanent": "Permanent", | ||
| 2154 | + "roster.tabContract": "Contract", | ||
| 2155 | + "roster.tabAdvisor": "Advisor", | ||
| 2156 | + "roster.import": "Import", | ||
| 2157 | + "roster.addStudent": "Add student", | ||
| 2158 | + "roster.addTeacher": "Add teacher", | ||
| 2159 | + "roster.studentsSubtitle": "Every student in the school, with their class.", | ||
| 2160 | + "roster.teachersSubtitle": "Every teacher in the school and the classes they lead.", | ||
| 2161 | + "roster.searchStudents": "Search student name or username…", | ||
| 2162 | + "roster.searchTeachers": "Search teacher name or username…", | ||
| 2163 | + "roster.noTeachers": "No teachers yet.", | ||
| 2090 | "builder.console": "Operator console", | 2164 | "builder.console": "Operator console", |
| 2091 | "builder.logout": "Sign out", | 2165 | "builder.logout": "Sign out", |
| 2092 | "builder.loginTitle": "Operator sign-in", | 2166 | "builder.loginTitle": "Operator sign-in", |
| @@ -2124,7 +2198,7 @@ const en: Dict = { | |||
| 2124 | "builder.editSchool": "Edit school", | 2198 | "builder.editSchool": "Edit school", |
| 2125 | "builder.editSchoolHint": "Rename the school or change its status.", | 2199 | "builder.editSchoolHint": "Rename the school or change its status.", |
| 2126 | "builder.suspendHint": "Suspension is immediate: every user of the school is refused, login included.", | 2200 | "builder.suspendHint": "Suspension is immediate: every user of the school is refused, login included.", |
| 2127 | - "modules.subtitle": "The modules your school has, grouped by package.", | 2201 | + "modules.subtitle": "Modular by design: the school has only the components it needs.", |
| 2128 | "modules.readOnlyHint": "Modules are enabled or disabled by your Hezarfen provider.", | 2202 | "modules.readOnlyHint": "Modules are enabled or disabled by your Hezarfen provider.", |
| 2129 | "modules.enabledCount": "{on} of {total} enabled", | 2203 | "modules.enabledCount": "{on} of {total} enabled", |
| 2130 | "modules.enableAll": "Enable all", | 2204 | "modules.enableAll": "Enable all", |
| @@ -2133,6 +2207,22 @@ const en: Dict = { | |||
| 2133 | "modules.on": "On", | 2207 | "modules.on": "On", |
| 2134 | "modules.conflictRequires": "{module} needs {needed}, which is not enabled.", | 2208 | "modules.conflictRequires": "{module} needs {needed}, which is not enabled.", |
| 2135 | "modules.conflictRequiredBy": "{module} cannot be turned off: {dependents} depend on it.", | 2209 | "modules.conflictRequiredBy": "{module} cannot be turned off: {dependents} depend on it.", |
| 2210 | + "modules.module": "Module", | ||
| 2211 | + "modules.active": "Active", | ||
| 2212 | + "modules.unitPrice": "Unit price", | ||
| 2213 | + "modules.activeSeats": "Active seats", | ||
| 2214 | + "modules.annualAmount": "Annual amount", | ||
| 2215 | + "modules.annualTotal": "annual total", | ||
| 2216 | + "modules.tabOverview": "Overview", | ||
| 2217 | + "modules.tabUsage": "Usage", | ||
| 2218 | + "modules.tabInvoices": "Invoices", | ||
| 2219 | + "modules.tabContract": "Contract", | ||
| 2220 | + "modules.downloadInvoices": "Download invoices", | ||
| 2221 | + "modules.addLicense": "Add license", | ||
| 2222 | + "modules.fullPackage": "Full package", | ||
| 2223 | + "modules.customPackage": "Custom package", | ||
| 2224 | + "modules.renewal": "Renewal", | ||
| 2225 | + "modules.recentInvoices": "Recent invoices", | ||
| 2136 | "modules.off": "Off", | 2226 | "modules.off": "Off", |
| 2137 | "module.appointments": "Appointments", | 2227 | "module.appointments": "Appointments", |
| 2138 | "module.attendance": "Attendance", | 2228 | "module.attendance": "Attendance", |
| @@ -3857,6 +3947,35 @@ const tr: Dict = { | |||
| 3857 | "comingSoon.description": "Bu modül hazırlanıyor — henüz gösterecek bir şey yok.", | 3947 | "comingSoon.description": "Bu modül hazırlanıyor — henüz gösterecek bir şey yok.", |
| 3858 | "comingSoon.emptyTitle": "Henüz kullanıma açık değil", | 3948 | "comingSoon.emptyTitle": "Henüz kullanıma açık değil", |
| 3859 | "comingSoon.emptyDescription": "Hezarfen'in bu bölümü hâlâ hazırlanıyor. Yakında tekrar bakın.", | 3949 | "comingSoon.emptyDescription": "Hezarfen'in bu bölümü hâlâ hazırlanıyor. Yakında tekrar bakın.", |
| 3950 | + "roster.student": "Öğrenci", | ||
| 3951 | + "roster.teacher": "Öğretmen", | ||
| 3952 | + "roster.class": "Sınıf", | ||
| 3953 | + "roster.classAll": "Sınıf: Tümü", | ||
| 3954 | + "roster.term": "Dönem", | ||
| 3955 | + "roster.termAll": "Dönem: Tümü", | ||
| 3956 | + "roster.mastery": "Konu yetkinliği", | ||
| 3957 | + "roster.attendance": "Devam", | ||
| 3958 | + "roster.planAdherence": "Plan uyumu", | ||
| 3959 | + "roster.status": "Durum", | ||
| 3960 | + "roster.branch": "Branş", | ||
| 3961 | + "roster.weeklyLessons": "Haftalık ders", | ||
| 3962 | + "roster.suggestionAcceptance": "Öneri kabulü", | ||
| 3963 | + "roster.tabAll": "Tümü", | ||
| 3964 | + "roster.tabActive": "Aktif", | ||
| 3965 | + "roster.tabNew": "Yeni kayıt", | ||
| 3966 | + "roster.tabAtRisk": "Risk altında", | ||
| 3967 | + "roster.tabLeft": "Ayrılan", | ||
| 3968 | + "roster.tabPermanent": "Kadrolu", | ||
| 3969 | + "roster.tabContract": "Ücretli", | ||
| 3970 | + "roster.tabAdvisor": "Danışman", | ||
| 3971 | + "roster.import": "İçe aktar", | ||
| 3972 | + "roster.addStudent": "Öğrenci ekle", | ||
| 3973 | + "roster.addTeacher": "Öğretmen ekle", | ||
| 3974 | + "roster.studentsSubtitle": "Kurumdaki tüm öğrenciler, sınıflarıyla birlikte.", | ||
| 3975 | + "roster.teachersSubtitle": "Kurumdaki öğretmenler ve sınıf öğretmenliği yaptıkları sınıflar.", | ||
| 3976 | + "roster.searchStudents": "Öğrenci adı veya kullanıcı adı ara…", | ||
| 3977 | + "roster.searchTeachers": "Öğretmen adı veya kullanıcı adı ara…", | ||
| 3978 | + "roster.noTeachers": "Henüz öğretmen yok.", | ||
| 3860 | "builder.console": "Operatör konsolu", | 3979 | "builder.console": "Operatör konsolu", |
| 3861 | "builder.logout": "Çıkış yap", | 3980 | "builder.logout": "Çıkış yap", |
| 3862 | "builder.loginTitle": "Operatör girişi", | 3981 | "builder.loginTitle": "Operatör girişi", |
| @@ -3894,7 +4013,7 @@ const tr: Dict = { | |||
| 3894 | "builder.editSchool": "Okulu düzenle", | 4013 | "builder.editSchool": "Okulu düzenle", |
| 3895 | "builder.editSchoolHint": "Okulun adını veya durumunu değiştir.", | 4014 | "builder.editSchoolHint": "Okulun adını veya durumunu değiştir.", |
| 3896 | "builder.suspendHint": "Askıya alma anında geçerlidir: okulun tüm kullanıcıları, giriş dahil, reddedilir.", | 4015 | "builder.suspendHint": "Askıya alma anında geçerlidir: okulun tüm kullanıcıları, giriş dahil, reddedilir.", |
| 3897 | - "modules.subtitle": "Okulunun sahip olduğu modüller, paketlere göre.", | 4016 | + "modules.subtitle": "Modüler yapı: okulun yalnızca ihtiyaç duyduğu bileşenlere sahip olur.", |
| 3898 | "modules.readOnlyHint": "Modüller Hezarfen sağlayıcın tarafından açılır veya kapatılır.", | 4017 | "modules.readOnlyHint": "Modüller Hezarfen sağlayıcın tarafından açılır veya kapatılır.", |
| 3899 | "modules.enabledCount": "{total} modülden {on} açık", | 4018 | "modules.enabledCount": "{total} modülden {on} açık", |
| 3900 | "modules.enableAll": "Hepsini aç", | 4019 | "modules.enableAll": "Hepsini aç", |
| @@ -3903,6 +4022,22 @@ const tr: Dict = { | |||
| 3903 | "modules.on": "Açık", | 4022 | "modules.on": "Açık", |
| 3904 | "modules.conflictRequires": "{module} için {needed} açık olmalı.", | 4023 | "modules.conflictRequires": "{module} için {needed} açık olmalı.", |
| 3905 | "modules.conflictRequiredBy": "{module} kapatılamaz: {dependents} buna bağlı.", | 4024 | "modules.conflictRequiredBy": "{module} kapatılamaz: {dependents} buna bağlı.", |
| 4025 | + "modules.module": "Modül", | ||
| 4026 | + "modules.active": "Etkin", | ||
| 4027 | + "modules.unitPrice": "Birim fiyat", | ||
| 4028 | + "modules.activeSeats": "Aktif lisans", | ||
| 4029 | + "modules.annualAmount": "Yıllık tutar", | ||
| 4030 | + "modules.annualTotal": "yıllık toplam", | ||
| 4031 | + "modules.tabOverview": "Genel bakış", | ||
| 4032 | + "modules.tabUsage": "Kullanım", | ||
| 4033 | + "modules.tabInvoices": "Faturalar", | ||
| 4034 | + "modules.tabContract": "Sözleşme", | ||
| 4035 | + "modules.downloadInvoices": "Faturaları indir", | ||
| 4036 | + "modules.addLicense": "Lisans ekle", | ||
| 4037 | + "modules.fullPackage": "Tam paket", | ||
| 4038 | + "modules.customPackage": "Özel paket", | ||
| 4039 | + "modules.renewal": "Yenileme", | ||
| 4040 | + "modules.recentInvoices": "Son faturalar", | ||
| 3906 | "modules.off": "Kapalı", | 4041 | "modules.off": "Kapalı", |
| 3907 | "module.appointments": "Randevular", | 4042 | "module.appointments": "Randevular", |
| 3908 | "module.attendance": "Yoklama", | 4043 | "module.attendance": "Yoklama", |
src/pages/coming-soon-page.tsxmodified+0 -2
| @@ -19,8 +19,6 @@ const COMING_SOON_LABELS: Record<string, MessageKey> = { | |||
| 19 | "optik-okuma": "nav.opticalReading", | 19 | "optik-okuma": "nav.opticalReading", |
| 20 | raporlar: "nav.reports", | 20 | raporlar: "nav.reports", |
| 21 | "kvkk-denetim": "nav.dataProtection", | 21 | "kvkk-denetim": "nav.dataProtection", |
| 22 | - ogrenciler: "nav.studentsRoster", | ||
| 23 | - ogretmenler: "nav.teachersRoster", | ||
| 24 | "ogrenci-analizi": "nav.studentAnalysis", | 22 | "ogrenci-analizi": "nav.studentAnalysis", |
| 25 | "bekleyen-onaylar": "nav.pendingApprovals", | 23 | "bekleyen-onaylar": "nav.pendingApprovals", |
| 26 | "soru-uretimi": "nav.questionGeneration", | 24 | "soru-uretimi": "nav.questionGeneration", |
src/pages/license-modules-page.tsxmodified+142 -13
| @@ -1,14 +1,20 @@ | |||
| 1 | -import { Show, Suspense, createResource } from "solid-js"; | 1 | +import type { ColumnDef } from "@tanstack/solid-table"; |
| 2 | +import { For, Show, Suspense, createMemo, createResource } from "solid-js"; | ||
| 2 | import { getModules, getModulesCatalog } from "@/api/modules"; | 3 | import { getModules, getModulesCatalog } from "@/api/modules"; |
| 3 | import { formatApiError } from "@/api/client"; | 4 | import { formatApiError } from "@/api/client"; |
| 4 | -import { PageHeader } from "@/components/layout/page-header"; | ||
| 5 | import { RouteGuard } from "@/components/layout/route-guard"; | 5 | import { RouteGuard } from "@/components/layout/route-guard"; |
| 6 | -import { ModuleCatalogGrid } from "@/components/modules/module-catalog-grid"; | 6 | +import { Badge } from "@/components/ui/badge"; |
| 7 | -import { Alert } from "@/components/ui/alert"; | 7 | +import { Button } from "@/components/ui/button"; |
| 8 | +import { ComingSoonBadge, ComingSoonPanel, ComingSoonValue } from "@/components/ui/coming-soon"; | ||
| 9 | +import { DataTable, DataTableSkeleton } from "@/components/ui/data-table"; | ||
| 8 | import { ErrorAlert } from "@/components/ui/error-alert"; | 10 | import { ErrorAlert } from "@/components/ui/error-alert"; |
| 9 | -import { PageSpinner } from "@/components/ui/page-spinner"; | 11 | +import { IconDownload, IconPackage, IconPlus } from "@/components/ui/icons"; |
| 12 | +import { Tabs, TabsList, TabsTrigger } from "@/components/ui/tabs"; | ||
| 13 | +import { moduleLabel, packageLabel } from "@/lib/module-labels"; | ||
| 10 | import { useT } from "@/stores/preferences-context"; | 14 | import { useT } from "@/stores/preferences-context"; |
| 11 | 15 | ||
| 16 | +type ModuleRow = { module: string; package: string; requires: string[]; enabled: boolean }; | ||
| 17 | + | ||
| 12 | export default function LicenseModulesPage() { | 18 | export default function LicenseModulesPage() { |
| 13 | return ( | 19 | return ( |
| 14 | <RouteGuard minRole="admin"> | 20 | <RouteGuard minRole="admin"> |
| @@ -17,25 +23,148 @@ export default function LicenseModulesPage() { | |||
| 17 | ); | 23 | ); |
| 18 | } | 24 | } |
| 19 | 25 | ||
| 20 | -// Read-only: a school sees what it bought. Selling a module is the operator's | 26 | +// ADM-05. What the school has is real (GET /modules over the catalog); price, |
| 21 | -// act on the builder surface (/builder), never a school admin's. | 27 | +// seat count, renewal and invoices belong to a billing API that does not |
| 28 | +// exist, so those slots say "yakında". Selling a module is the operator's | ||
| 29 | +// act on /builder, never a school admin's. | ||
| 22 | function LicenseModulesContent() { | 30 | function LicenseModulesContent() { |
| 23 | const t = useT(); | 31 | const t = useT(); |
| 24 | const [data, { refetch }] = createResource(async () => { | 32 | const [data, { refetch }] = createResource(async () => { |
| 25 | const [catalog, mine] = await Promise.all([getModulesCatalog(), getModules()]); | 33 | const [catalog, mine] = await Promise.all([getModulesCatalog(), getModules()]); |
| 26 | - return { catalog, enabled: mine.enabled }; | 34 | + const rows: ModuleRow[] = catalog.modules.map((entry) => ({ |
| 35 | + module: entry.module, | ||
| 36 | + package: entry.package, | ||
| 37 | + requires: entry.requires, | ||
| 38 | + enabled: mine.enabled.includes(entry.module), | ||
| 39 | + })); | ||
| 40 | + return { rows, packages: catalog.packages }; | ||
| 27 | }); | 41 | }); |
| 28 | 42 | ||
| 43 | + const enabledCount = () => (data()?.rows ?? []).filter((row) => row.enabled).length; | ||
| 44 | + const totalCount = () => data()?.rows.length ?? 0; | ||
| 45 | + const isFull = () => totalCount() > 0 && enabledCount() === totalCount(); | ||
| 46 | + const enabledPackages = () => | ||
| 47 | + (data()?.packages ?? []) | ||
| 48 | + .filter((pkg) => pkg.modules.some((module) => data()?.rows.find((row) => row.module === module)?.enabled)) | ||
| 49 | + .map((pkg) => packageLabel(pkg.package, t)); | ||
| 50 | + | ||
| 51 | + const columns = createMemo<ColumnDef<ModuleRow>[]>(() => [ | ||
| 52 | + { | ||
| 53 | + id: "module", | ||
| 54 | + header: t("modules.module"), | ||
| 55 | + cell: (cell) => ( | ||
| 56 | + <div class="flex min-w-0 items-center gap-2.5"> | ||
| 57 | + <span class="flex h-8 w-8 shrink-0 items-center justify-center rounded-md bg-surface-tint text-text-subtle"> | ||
| 58 | + <IconPackage class="h-4 w-4" /> | ||
| 59 | + </span> | ||
| 60 | + <div class="min-w-0"> | ||
| 61 | + <p class="truncate text-sm font-medium text-text-strong">{moduleLabel(cell.row.original.module, t)}</p> | ||
| 62 | + <p class="truncate text-xs text-text-subtle"> | ||
| 63 | + {packageLabel(cell.row.original.package, t)} | ||
| 64 | + <Show when={cell.row.original.requires.length > 0}> | ||
| 65 | + {` · ${t("modules.requires")}: ${cell.row.original.requires.map((name) => moduleLabel(name, t)).join(", ")}`} | ||
| 66 | + </Show> | ||
| 67 | + </p> | ||
| 68 | + </div> | ||
| 69 | + </div> | ||
| 70 | + ), | ||
| 71 | + }, | ||
| 72 | + { | ||
| 73 | + id: "status", | ||
| 74 | + header: t("builder.status"), | ||
| 75 | + cell: (cell) => ( | ||
| 76 | + <Badge variant={cell.row.original.enabled ? "success" : "secondary"} class="rounded-full"> | ||
| 77 | + {cell.row.original.enabled ? t("modules.active") : t("modules.off")} | ||
| 78 | + </Badge> | ||
| 79 | + ), | ||
| 80 | + }, | ||
| 81 | + { id: "unitPrice", header: t("modules.unitPrice"), meta: { align: "right" }, enableSorting: false, cell: () => <ComingSoonValue /> }, | ||
| 82 | + { id: "seats", header: t("modules.activeSeats"), meta: { align: "right" }, enableSorting: false, cell: () => <ComingSoonValue /> }, | ||
| 83 | + { id: "annual", header: t("modules.annualAmount"), meta: { align: "right" }, enableSorting: false, cell: () => <ComingSoonValue /> }, | ||
| 84 | + ]); | ||
| 85 | + | ||
| 29 | return ( | 86 | return ( |
| 30 | - <div class="space-y-6"> | 87 | + <div class="space-y-5"> |
| 31 | - <PageHeader eyebrow={t("nav.group.institution")} title={t("nav.licenseModules")} description={t("modules.subtitle")} /> | 88 | + <Tabs value="overview"> |
| 32 | - <Alert variant="info">{t("modules.readOnlyHint")}</Alert> | 89 | + <TabsList> |
| 33 | - <Suspense fallback={<PageSpinner />}> | 90 | + <TabsTrigger value="overview">{t("modules.tabOverview")}</TabsTrigger> |
| 91 | + <For each={["modules.tabUsage", "modules.tabInvoices", "modules.tabContract"] as const}> | ||
| 92 | + {(key) => ( | ||
| 93 | + <TabsTrigger value={key} disabled title={t("comingSoon.title")}> | ||
| 94 | + {t(key)} | ||
| 95 | + <ComingSoonBadge class="ml-1.5" /> | ||
| 96 | + </TabsTrigger> | ||
| 97 | + )} | ||
| 98 | + </For> | ||
| 99 | + </TabsList> | ||
| 100 | + </Tabs> | ||
| 101 | + | ||
| 102 | + <div class="flex flex-wrap items-start justify-between gap-3"> | ||
| 103 | + <div class="space-y-1"> | ||
| 104 | + <h1 class="text-2xl font-semibold tracking-tight text-text-strong">{t("nav.licenseModules")}</h1> | ||
| 105 | + <p class="text-sm text-text-subtle">{t("modules.subtitle")}</p> | ||
| 106 | + </div> | ||
| 107 | + <div class="flex flex-wrap gap-2"> | ||
| 108 | + <Button size="sm" variant="outline" class="min-w-[7.5rem] rounded-lg" disabled title={t("comingSoon.title")}> | ||
| 109 | + <IconDownload class="h-4 w-4" /> | ||
| 110 | + {t("modules.downloadInvoices")} | ||
| 111 | + <ComingSoonBadge class="ml-1.5" /> | ||
| 112 | + </Button> | ||
| 113 | + <Button size="sm" class="min-w-[7.5rem] rounded-lg" disabled title={t("modules.readOnlyHint")}> | ||
| 114 | + <IconPlus class="h-4 w-4" /> | ||
| 115 | + {t("modules.addLicense")} | ||
| 116 | + <ComingSoonBadge class="ml-1.5" /> | ||
| 117 | + </Button> | ||
| 118 | + </div> | ||
| 119 | + </div> | ||
| 120 | + | ||
| 121 | + <Suspense fallback={<DataTableSkeleton columns={5} rows={8} />}> | ||
| 34 | <Show when={data.error}> | 122 | <Show when={data.error}> |
| 35 | <ErrorAlert message={formatApiError(data.error)} onRetry={() => void refetch()} /> | 123 | <ErrorAlert message={formatApiError(data.error)} onRetry={() => void refetch()} /> |
| 36 | </Show> | 124 | </Show> |
| 37 | <Show when={!data.error && data()}> | 125 | <Show when={!data.error && data()}> |
| 38 | - {(value) => <ModuleCatalogGrid catalog={value().catalog} enabled={value().enabled} />} | 126 | + {(value) => ( |
| 127 | + <> | ||
| 128 | + <section class="data-shell space-y-4 p-5"> | ||
| 129 | + <div class="flex flex-wrap items-start justify-between gap-4"> | ||
| 130 | + <div class="min-w-0 space-y-1"> | ||
| 131 | + <div class="flex items-center gap-2"> | ||
| 132 | + <h2 class="text-2xl font-semibold tracking-tight text-text-strong"> | ||
| 133 | + {isFull() ? t("modules.fullPackage") : t("modules.customPackage")} | ||
| 134 | + </h2> | ||
| 135 | + <Badge variant="success" class="rounded-full">{t("modules.active")}</Badge> | ||
| 136 | + </div> | ||
| 137 | + <p class="text-sm text-text-subtle">{enabledPackages().join(" + ") || "—"}</p> | ||
| 138 | + </div> | ||
| 139 | + <div class="text-right"> | ||
| 140 | + <ComingSoonValue class="justify-end" /> | ||
| 141 | + <p class="mt-1 text-xs text-text-subtle">{t("modules.annualTotal")}</p> | ||
| 142 | + </div> | ||
| 143 | + </div> | ||
| 144 | + <div class="h-2 overflow-hidden rounded-full bg-surface-tint" role="progressbar" aria-valuemin={0} aria-valuemax={totalCount()} aria-valuenow={enabledCount()}> | ||
| 145 | + <div class="h-full rounded-full bg-primary" style={{ width: `${totalCount() ? (enabledCount() / totalCount()) * 100 : 0}%` }} /> | ||
| 146 | + </div> | ||
| 147 | + <div class="flex flex-wrap items-center justify-between gap-2 text-sm"> | ||
| 148 | + <span class="text-text-subtle">{t("modules.enabledCount", { on: String(enabledCount()), total: String(totalCount()) })}</span> | ||
| 149 | + <span class="flex items-center gap-2 text-text-default"> | ||
| 150 | + {t("modules.renewal")}: <ComingSoonValue /> | ||
| 151 | + </span> | ||
| 152 | + </div> | ||
| 153 | + </section> | ||
| 154 | + | ||
| 155 | + <DataTable | ||
| 156 | + title={t("builder.modules")} | ||
| 157 | + description={t("modules.readOnlyHint")} | ||
| 158 | + columns={columns()} | ||
| 159 | + data={value().rows} | ||
| 160 | + tableClass="min-w-[760px]" | ||
| 161 | + enablePagination={false} | ||
| 162 | + storageKey="license-modules" | ||
| 163 | + /> | ||
| 164 | + | ||
| 165 | + <ComingSoonPanel title={t("modules.recentInvoices")} /> | ||
| 166 | + </> | ||
| 167 | + )} | ||
| 39 | </Show> | 168 | </Show> |
| 40 | </Suspense> | 169 | </Suspense> |
| 41 | </div> | 170 | </div> |
src/pages/students-roster-page.tsxadded+173 -0
| @@ -0,0 +1,173 @@ | |||
| 1 | +import { useNavigate } from "@tanstack/solid-router"; | ||
| 2 | +import type { ColumnDef } from "@tanstack/solid-table"; | ||
| 3 | +import { For, Show, Suspense, createMemo, createResource, createSignal } from "solid-js"; | ||
| 4 | +import { getClassMembers, getClasses } from "@/api/classes"; | ||
| 5 | +import { getTerms } from "@/api/terms"; | ||
| 6 | +import { getUserSearch } from "@/api/users"; | ||
| 7 | +import { formatApiError, type ClassGroup, type PersonRef } from "@/api/client"; | ||
| 8 | +import { RouteGuard } from "@/components/layout/route-guard"; | ||
| 9 | +import { RosterPersonCell } from "@/components/users/roster-person-cell"; | ||
| 10 | +import { Button } from "@/components/ui/button"; | ||
| 11 | +import { ComingSoonBadge, ComingSoonValue } from "@/components/ui/coming-soon"; | ||
| 12 | +import { DataTable, DataTableSkeleton } from "@/components/ui/data-table"; | ||
| 13 | +import { ErrorAlert } from "@/components/ui/error-alert"; | ||
| 14 | +import { IconEye, IconPlus, IconUploadCloud } from "@/components/ui/icons"; | ||
| 15 | +import { Select } from "@/components/ui/select"; | ||
| 16 | +import { TableRowActions } from "@/components/ui/table-row-actions"; | ||
| 17 | +import { Tabs, TabsList, TabsTrigger } from "@/components/ui/tabs"; | ||
| 18 | +import { useT } from "@/stores/preferences-context"; | ||
| 19 | + | ||
| 20 | +const ROSTER_PAGE_SIZE = 10; | ||
| 21 | + | ||
| 22 | +type StudentRow = { person: PersonRef; classes: ClassGroup[] }; | ||
| 23 | + | ||
| 24 | +export default function StudentsRosterPage() { | ||
| 25 | + return ( | ||
| 26 | + <RouteGuard minRole="manager"> | ||
| 27 | + <StudentsRosterContent /> | ||
| 28 | + </RouteGuard> | ||
| 29 | + ); | ||
| 30 | +} | ||
| 31 | + | ||
| 32 | +// ADM-02. The roster, class and term are real; topic mastery, plan adherence | ||
| 33 | +// and the risk status are AI/analytics fields no endpoint serves, so their | ||
| 34 | +// columns keep the design's slot and say "yakında" instead of a number. | ||
| 35 | +function StudentsRosterContent() { | ||
| 36 | + const t = useT(); | ||
| 37 | + const navigate = useNavigate(); | ||
| 38 | + const [classFilter, setClassFilter] = createSignal(""); | ||
| 39 | + const [termFilter, setTermFilter] = createSignal(""); | ||
| 40 | + | ||
| 41 | + const [data, { refetch }] = createResource(async () => { | ||
| 42 | + const [students, classes, terms] = await Promise.all([ | ||
| 43 | + getUserSearch("", undefined, "student"), | ||
| 44 | + getClasses(), | ||
| 45 | + getTerms().catch(() => ({ items: [] })), | ||
| 46 | + ]); | ||
| 47 | + // No endpoint maps students to classes in bulk; one members read per class | ||
| 48 | + // is bounded by the class count, not the student count. | ||
| 49 | + const memberships = await Promise.all( | ||
| 50 | + classes.items.map(async (cls) => ({ cls, members: (await getClassMembers(cls.id)).items })), | ||
| 51 | + ); | ||
| 52 | + const byStudent = new Map<string, ClassGroup[]>(); | ||
| 53 | + for (const { cls, members } of memberships) { | ||
| 54 | + for (const member of members) byStudent.set(member.user.id, [...(byStudent.get(member.user.id) ?? []), cls]); | ||
| 55 | + } | ||
| 56 | + const rows: StudentRow[] = students.items.map((person) => ({ person, classes: byStudent.get(person.id) ?? [] })); | ||
| 57 | + return { rows, classes: classes.items, terms: terms.items }; | ||
| 58 | + }); | ||
| 59 | + | ||
| 60 | + const rows = createMemo(() => | ||
| 61 | + (data()?.rows ?? []).filter((row) => { | ||
| 62 | + if (classFilter() && !row.classes.some((cls) => cls.id === classFilter())) return false; | ||
| 63 | + if (termFilter() && !row.classes.some((cls) => cls.term === termFilter())) return false; | ||
| 64 | + return true; | ||
| 65 | + }), | ||
| 66 | + ); | ||
| 67 | + | ||
| 68 | + const open = (row: StudentRow) => void navigate({ to: "/profile/$userId", params: { userId: row.person.id } }); | ||
| 69 | + | ||
| 70 | + const columns = createMemo<ColumnDef<StudentRow>[]>(() => [ | ||
| 71 | + { | ||
| 72 | + id: "student", size: 220, | ||
| 73 | + header: t("roster.student"), | ||
| 74 | + cell: (cell) => <RosterPersonCell person={cell.row.original.person} />, | ||
| 75 | + }, | ||
| 76 | + { | ||
| 77 | + id: "class", | ||
| 78 | + size: 90, | ||
| 79 | + header: t("roster.class"), | ||
| 80 | + cell: (cell) => ( | ||
| 81 | + <span class="truncate text-sm">{cell.row.original.classes.map((cls) => cls.name).join(", ") || "—"}</span> | ||
| 82 | + ), | ||
| 83 | + }, | ||
| 84 | + { id: "mastery", size: 130, header: t("roster.mastery"), enableSorting: false, cell: () => <ComingSoonValue /> }, | ||
| 85 | + { id: "attendance", size: 130, header: t("roster.attendance"), enableSorting: false, cell: () => <ComingSoonValue /> }, | ||
| 86 | + { id: "plan", size: 130, header: t("roster.planAdherence"), enableSorting: false, cell: () => <ComingSoonValue /> }, | ||
| 87 | + { id: "status", size: 130, header: t("roster.status"), enableSorting: false, cell: () => <ComingSoonValue /> }, | ||
| 88 | + { | ||
| 89 | + id: "actions", | ||
| 90 | + header: t("common.actions"), | ||
| 91 | + meta: { headerClass: "w-[110px] min-w-[110px] max-w-[110px] h-[45px] text-center whitespace-nowrap" }, | ||
| 92 | + cell: (cell) => ( | ||
| 93 | + <TableRowActions | ||
| 94 | + label={t("common.actions")} | ||
| 95 | + actions={[{ label: t("common.view"), icon: <IconEye class="h-4 w-4" />, onSelect: () => open(cell.row.original) }]} | ||
| 96 | + /> | ||
| 97 | + ), | ||
| 98 | + }, | ||
| 99 | + ]); | ||
| 100 | + | ||
| 101 | + return ( | ||
| 102 | + <div class="space-y-5"> | ||
| 103 | + <Tabs value="all"> | ||
| 104 | + <TabsList> | ||
| 105 | + <TabsTrigger value="all">{t("roster.tabAll")}</TabsTrigger> | ||
| 106 | + <For each={["roster.tabActive", "roster.tabNew", "roster.tabAtRisk", "roster.tabLeft"] as const}> | ||
| 107 | + {(key) => ( | ||
| 108 | + <TabsTrigger value={key} disabled title={t("comingSoon.title")}> | ||
| 109 | + {t(key)} | ||
| 110 | + <ComingSoonBadge class="ml-1.5" /> | ||
| 111 | + </TabsTrigger> | ||
| 112 | + )} | ||
| 113 | + </For> | ||
| 114 | + </TabsList> | ||
| 115 | + </Tabs> | ||
| 116 | + | ||
| 117 | + <div class="flex flex-wrap items-start justify-between gap-3"> | ||
| 118 | + <div class="space-y-1"> | ||
| 119 | + <h1 class="text-2xl font-semibold tracking-tight text-text-strong">{t("nav.studentsRoster")}</h1> | ||
| 120 | + <p class="text-sm text-text-subtle">{t("roster.studentsSubtitle")}</p> | ||
| 121 | + </div> | ||
| 122 | + <div class="flex flex-wrap gap-2"> | ||
| 123 | + <Button size="sm" variant="outline" class="min-w-[7.5rem] rounded-lg" disabled title={t("comingSoon.title")}> | ||
| 124 | + <IconUploadCloud class="h-4 w-4" /> | ||
| 125 | + {t("roster.import")} | ||
| 126 | + <ComingSoonBadge class="ml-1.5" /> | ||
| 127 | + </Button> | ||
| 128 | + <Button size="sm" class="min-w-[7.5rem] rounded-lg" disabled title={t("comingSoon.title")}> | ||
| 129 | + <IconPlus class="h-4 w-4" /> | ||
| 130 | + {t("roster.addStudent")} | ||
| 131 | + <ComingSoonBadge class="ml-1.5" /> | ||
| 132 | + </Button> | ||
| 133 | + </div> | ||
| 134 | + </div> | ||
| 135 | + | ||
| 136 | + <Suspense fallback={<DataTableSkeleton columns={6} rows={8} />}> | ||
| 137 | + <Show when={data.error}> | ||
| 138 | + <ErrorAlert message={formatApiError(data.error)} onRetry={() => void refetch()} /> | ||
| 139 | + </Show> | ||
| 140 | + <Show when={!data.error && data()}> | ||
| 141 | + {(value) => ( | ||
| 142 | + <DataTable | ||
| 143 | + columns={columns()} | ||
| 144 | + data={rows()} | ||
| 145 | + tableClass="min-w-[940px]" | ||
| 146 | + empty={t("form.noStudents")} | ||
| 147 | + filterPlaceholder={t("roster.searchStudents")} | ||
| 148 | + searchPredicate={(row, query) => | ||
| 149 | + [row.person.username, row.person.display_name ?? ""].join(" ").toLocaleLowerCase().includes(query.toLocaleLowerCase()) | ||
| 150 | + } | ||
| 151 | + filters={ | ||
| 152 | + <> | ||
| 153 | + <Select aria-label={t("roster.class")} value={classFilter()} onChange={(e) => setClassFilter(e.currentTarget.value)} wrapperClass="w-auto"> | ||
| 154 | + <option value="">{t("roster.classAll")}</option> | ||
| 155 | + <For each={value().classes}>{(cls) => <option value={cls.id}>{cls.name}</option>}</For> | ||
| 156 | + </Select> | ||
| 157 | + <Select aria-label={t("roster.term")} value={termFilter()} onChange={(e) => setTermFilter(e.currentTarget.value)} wrapperClass="w-auto"> | ||
| 158 | + <option value="">{t("roster.termAll")}</option> | ||
| 159 | + <For each={value().terms}>{(term) => <option value={term.id}>{term.name}</option>}</For> | ||
| 160 | + </Select> | ||
| 161 | + </> | ||
| 162 | + } | ||
| 163 | + enablePagination | ||
| 164 | + pageSize={ROSTER_PAGE_SIZE} | ||
| 165 | + storageKey="students-roster" | ||
| 166 | + onRowClick={open} | ||
| 167 | + /> | ||
| 168 | + )} | ||
| 169 | + </Show> | ||
| 170 | + </Suspense> | ||
| 171 | + </div> | ||
| 172 | + ); | ||
| 173 | +} | ||
src/pages/teachers-roster-page.tsxadded+134 -0
| @@ -0,0 +1,134 @@ | |||
| 1 | +import { useNavigate } from "@tanstack/solid-router"; | ||
| 2 | +import type { ColumnDef } from "@tanstack/solid-table"; | ||
| 3 | +import { For, Show, Suspense, createMemo, createResource } from "solid-js"; | ||
| 4 | +import { getClasses } from "@/api/classes"; | ||
| 5 | +import { getUserSearch } from "@/api/users"; | ||
| 6 | +import { formatApiError, type PersonRef } from "@/api/client"; | ||
| 7 | +import { RouteGuard } from "@/components/layout/route-guard"; | ||
| 8 | +import { RosterPersonCell } from "@/components/users/roster-person-cell"; | ||
| 9 | +import { Button } from "@/components/ui/button"; | ||
| 10 | +import { ComingSoonBadge, ComingSoonValue } from "@/components/ui/coming-soon"; | ||
| 11 | +import { DataTable, DataTableSkeleton } from "@/components/ui/data-table"; | ||
| 12 | +import { ErrorAlert } from "@/components/ui/error-alert"; | ||
| 13 | +import { IconEye, IconPlus, IconUploadCloud } from "@/components/ui/icons"; | ||
| 14 | +import { TableRowActions } from "@/components/ui/table-row-actions"; | ||
| 15 | +import { Tabs, TabsList, TabsTrigger } from "@/components/ui/tabs"; | ||
| 16 | +import { useT } from "@/stores/preferences-context"; | ||
| 17 | + | ||
| 18 | +const ROSTER_PAGE_SIZE = 10; | ||
| 19 | + | ||
| 20 | +type TeacherRow = { person: PersonRef; homeroomClasses: number }; | ||
| 21 | + | ||
| 22 | +export default function TeachersRosterPage() { | ||
| 23 | + return ( | ||
| 24 | + <RouteGuard minRole="manager"> | ||
| 25 | + <TeachersRosterContent /> | ||
| 26 | + </RouteGuard> | ||
| 27 | + ); | ||
| 28 | +} | ||
| 29 | + | ||
| 30 | +// ADM-08. "Sınıf" is the number of classes the teacher is homeroom teacher of | ||
| 31 | +// (ClassGroup.teacher); branch, weekly load, AI acceptance and employment | ||
| 32 | +// status have no field anywhere, so they stay "yakında". | ||
| 33 | +function TeachersRosterContent() { | ||
| 34 | + const t = useT(); | ||
| 35 | + const navigate = useNavigate(); | ||
| 36 | + | ||
| 37 | + const [data, { refetch }] = createResource(async () => { | ||
| 38 | + const [teachers, classes] = await Promise.all([getUserSearch("", undefined, "teacher"), getClasses()]); | ||
| 39 | + const homeroom = new Map<string, number>(); | ||
| 40 | + for (const cls of classes.items) { | ||
| 41 | + if (cls.teacher) homeroom.set(cls.teacher.id, (homeroom.get(cls.teacher.id) ?? 0) + 1); | ||
| 42 | + } | ||
| 43 | + return teachers.items.map<TeacherRow>((person) => ({ person, homeroomClasses: homeroom.get(person.id) ?? 0 })); | ||
| 44 | + }); | ||
| 45 | + | ||
| 46 | + const open = (row: TeacherRow) => void navigate({ to: "/profile/$userId", params: { userId: row.person.id } }); | ||
| 47 | + | ||
| 48 | + const columns = createMemo<ColumnDef<TeacherRow>[]>(() => [ | ||
| 49 | + { id: "teacher", size: 220, header: t("roster.teacher"), cell: (cell) => <RosterPersonCell person={cell.row.original.person} /> }, | ||
| 50 | + { id: "branch", size: 130, header: t("roster.branch"), enableSorting: false, cell: () => <ComingSoonValue /> }, | ||
| 51 | + { | ||
| 52 | + accessorKey: "homeroomClasses", | ||
| 53 | + size: 90, | ||
| 54 | + header: t("roster.class"), | ||
| 55 | + meta: { cellClass: "mono tabular-nums" }, | ||
| 56 | + cell: (cell) => (cell.row.original.homeroomClasses > 0 ? cell.row.original.homeroomClasses : "—"), | ||
| 57 | + }, | ||
| 58 | + { id: "weekly", size: 130, header: t("roster.weeklyLessons"), enableSorting: false, cell: () => <ComingSoonValue /> }, | ||
| 59 | + { id: "acceptance", size: 130, header: t("roster.suggestionAcceptance"), enableSorting: false, cell: () => <ComingSoonValue /> }, | ||
| 60 | + { id: "status", size: 130, header: t("roster.status"), enableSorting: false, cell: () => <ComingSoonValue /> }, | ||
| 61 | + { | ||
| 62 | + id: "actions", | ||
| 63 | + header: t("common.actions"), | ||
| 64 | + meta: { headerClass: "w-[110px] min-w-[110px] max-w-[110px] h-[45px] text-center whitespace-nowrap" }, | ||
| 65 | + cell: (cell) => ( | ||
| 66 | + <TableRowActions | ||
| 67 | + label={t("common.actions")} | ||
| 68 | + actions={[{ label: t("common.view"), icon: <IconEye class="h-4 w-4" />, onSelect: () => open(cell.row.original) }]} | ||
| 69 | + /> | ||
| 70 | + ), | ||
| 71 | + }, | ||
| 72 | + ]); | ||
| 73 | + | ||
| 74 | + return ( | ||
| 75 | + <div class="space-y-5"> | ||
| 76 | + <Tabs value="all"> | ||
| 77 | + <TabsList> | ||
| 78 | + <TabsTrigger value="all">{t("roster.tabAll")}</TabsTrigger> | ||
| 79 | + <For each={["roster.tabPermanent", "roster.tabContract", "roster.tabAdvisor"] as const}> | ||
| 80 | + {(key) => ( | ||
| 81 | + <TabsTrigger value={key} disabled title={t("comingSoon.title")}> | ||
| 82 | + {t(key)} | ||
| 83 | + <ComingSoonBadge class="ml-1.5" /> | ||
| 84 | + </TabsTrigger> | ||
| 85 | + )} | ||
| 86 | + </For> | ||
| 87 | + </TabsList> | ||
| 88 | + </Tabs> | ||
| 89 | + | ||
| 90 | + <div class="flex flex-wrap items-start justify-between gap-3"> | ||
| 91 | + <div class="space-y-1"> | ||
| 92 | + <h1 class="text-2xl font-semibold tracking-tight text-text-strong">{t("nav.teachersRoster")}</h1> | ||
| 93 | + <p class="text-sm text-text-subtle">{t("roster.teachersSubtitle")}</p> | ||
| 94 | + </div> | ||
| 95 | + <div class="flex flex-wrap gap-2"> | ||
| 96 | + <Button size="sm" variant="outline" class="min-w-[7.5rem] rounded-lg" disabled title={t("comingSoon.title")}> | ||
| 97 | + <IconUploadCloud class="h-4 w-4" /> | ||
| 98 | + {t("roster.import")} | ||
| 99 | + <ComingSoonBadge class="ml-1.5" /> | ||
| 100 | + </Button> | ||
| 101 | + <Button size="sm" class="min-w-[7.5rem] rounded-lg" disabled title={t("comingSoon.title")}> | ||
| 102 | + <IconPlus class="h-4 w-4" /> | ||
| 103 | + {t("roster.addTeacher")} | ||
| 104 | + <ComingSoonBadge class="ml-1.5" /> | ||
| 105 | + </Button> | ||
| 106 | + </div> | ||
| 107 | + </div> | ||
| 108 | + | ||
| 109 | + <Suspense fallback={<DataTableSkeleton columns={6} rows={8} />}> | ||
| 110 | + <Show when={data.error}> | ||
| 111 | + <ErrorAlert message={formatApiError(data.error)} onRetry={() => void refetch()} /> | ||
| 112 | + </Show> | ||
| 113 | + <Show when={!data.error && data()}> | ||
| 114 | + {(rows) => ( | ||
| 115 | + <DataTable | ||
| 116 | + columns={columns()} | ||
| 117 | + data={rows()} | ||
| 118 | + tableClass="min-w-[940px]" | ||
| 119 | + empty={t("roster.noTeachers")} | ||
| 120 | + filterPlaceholder={t("roster.searchTeachers")} | ||
| 121 | + searchPredicate={(row, query) => | ||
| 122 | + [row.person.username, row.person.display_name ?? ""].join(" ").toLocaleLowerCase().includes(query.toLocaleLowerCase()) | ||
| 123 | + } | ||
| 124 | + enablePagination | ||
| 125 | + pageSize={ROSTER_PAGE_SIZE} | ||
| 126 | + storageKey="teachers-roster" | ||
| 127 | + onRowClick={open} | ||
| 128 | + /> | ||
| 129 | + )} | ||
| 130 | + </Show> | ||
| 131 | + </Suspense> | ||
| 132 | + </div> | ||
| 133 | + ); | ||
| 134 | +} | ||
src/routes/router.tsxmodified+16 -2
| @@ -68,6 +68,8 @@ const PaymentStatementPage = lazyRoute(() => import("@/pages/payment-statement-p | |||
| 68 | const WhiteboardsPage = lazyRoute(() => import("@/pages/whiteboards-page")); | 68 | const WhiteboardsPage = lazyRoute(() => import("@/pages/whiteboards-page")); |
| 69 | const WhiteboardPage = lazyRoute(() => import("@/pages/whiteboard-page")); | 69 | const WhiteboardPage = lazyRoute(() => import("@/pages/whiteboard-page")); |
| 70 | const ComingSoonPage = lazyRoute(() => import("@/pages/coming-soon-page")); | 70 | const ComingSoonPage = lazyRoute(() => import("@/pages/coming-soon-page")); |
| 71 | +const StudentsRosterPage = lazyRoute(() => import("@/pages/students-roster-page")); | ||
| 72 | +const TeachersRosterPage = lazyRoute(() => import("@/pages/teachers-roster-page")); | ||
| 71 | const LicenseModulesPage = lazyRoute(() => import("@/pages/license-modules-page")); | 73 | const LicenseModulesPage = lazyRoute(() => import("@/pages/license-modules-page")); |
| 72 | const BuilderLoginPage = lazyRoute(() => import("@/pages/builder-login-page")); | 74 | const BuilderLoginPage = lazyRoute(() => import("@/pages/builder-login-page")); |
| 73 | const BuilderSchoolsPage = lazyRoute(() => import("@/pages/builder-schools-page")); | 75 | const BuilderSchoolsPage = lazyRoute(() => import("@/pages/builder-schools-page")); |
| @@ -413,6 +415,18 @@ const whiteboardRoute = createRoute({ | |||
| 413 | component: WhiteboardPage, | 415 | component: WhiteboardPage, |
| 414 | }); | 416 | }); |
| 415 | 417 | ||
| 418 | +const studentsRosterRoute = createRoute({ | ||
| 419 | + getParentRoute: () => rootRoute, | ||
| 420 | + path: "/management/students", | ||
| 421 | + component: StudentsRosterPage, | ||
| 422 | +}); | ||
| 423 | + | ||
| 424 | +const teachersRosterRoute = createRoute({ | ||
| 425 | + getParentRoute: () => rootRoute, | ||
| 426 | + path: "/management/teachers", | ||
| 427 | + component: TeachersRosterPage, | ||
| 428 | +}); | ||
| 429 | + | ||
| 416 | const licenseModulesRoute = createRoute({ | 430 | const licenseModulesRoute = createRoute({ |
| 417 | getParentRoute: () => rootRoute, | 431 | getParentRoute: () => rootRoute, |
| 418 | path: "/management/modules", | 432 | path: "/management/modules", |
| @@ -449,8 +463,6 @@ const COMING_SOON_SLUGS = [ | |||
| 449 | "optik-okuma", | 463 | "optik-okuma", |
| 450 | "raporlar", | 464 | "raporlar", |
| 451 | "kvkk-denetim", | 465 | "kvkk-denetim", |
| 452 | - "ogrenciler", | ||
| 453 | - "ogretmenler", | ||
| 454 | "ogrenci-analizi", | 466 | "ogrenci-analizi", |
| 455 | "bekleyen-onaylar", | 467 | "bekleyen-onaylar", |
| 456 | "soru-uretimi", | 468 | "soru-uretimi", |
| @@ -515,6 +527,8 @@ const routeTree = rootRoute.addChildren([ | |||
| 515 | paymentStatementRoute, | 527 | paymentStatementRoute, |
| 516 | whiteboardsRoute, | 528 | whiteboardsRoute, |
| 517 | whiteboardRoute, | 529 | whiteboardRoute, |
| 530 | + studentsRosterRoute, | ||
| 531 | + teachersRosterRoute, | ||
| 518 | licenseModulesRoute, | 532 | licenseModulesRoute, |
| 519 | builderLoginRoute, | 533 | builderLoginRoute, |
| 520 | builderSchoolsRoute, | 534 | builderSchoolsRoute, |