✨ event roster roll call, record search, draft-first exams
Browse files at this commit691fcf8166510dbb9a3db96057d21e8cb7de0fceParent: 37148ac- feat
- ✨ event roster roll call, record search, draft-first exams
59 changed files +2079 -672
- docs/backend/attendance-pomodoro-summary-request.md +179 -0
- docs/frontend/sitemap.md +98 -86
- src/components/events/attendance-status-picker.tsx +0 -50
- src/components/events/attendance-table.tsx +6 -3
- src/components/events/event-roll-call.test.tsx +68 -0
- src/components/events/event-roll-call.tsx +336 -0
- src/components/exams/exam-form.tsx +26 -3
- src/components/insights/insight-student-analysis-tabs.tsx +6 -3
- src/components/insights/insight-students-table.tsx +6 -6
- src/components/layout/command-palette.test.tsx +26 -0
- src/components/layout/command-palette.tsx +112 -7
- src/components/layout/floating-action-button.tsx +2 -1
- src/components/layout/notification-center.tsx +8 -3
- src/components/layout/notification-list.tsx +25 -33
- src/components/layout/shell-unread-badge.test.tsx +36 -2
- src/components/meals/meal-menu-card.tsx +1 -7
- src/components/messages/gmail-compose-box.test.tsx +40 -0
- src/components/messages/gmail-compose-box.tsx +33 -15
- src/components/ui/chart-bar.tsx +6 -3
- src/components/ui/chart-line.tsx +16 -8
- src/components/ui/chart-progress-ring.tsx +7 -4
- src/components/ui/combobox.tsx +24 -1
- src/components/ui/coming-soon.tsx +0 -45
- src/components/ui/data-table.test.tsx +2 -2
- src/components/ui/data-table.tsx +15 -6
- src/components/ui/data-toolbar.tsx +1 -1
- src/components/ui/dialog.tsx +10 -7
- src/components/whiteboard/whiteboard-canvas.tsx +24 -8
- src/i18n/locales/en.ts +52 -4
- src/i18n/locales/tr.ts +52 -4
- src/i18n/messages.ts +49 -1
- src/index.css +18 -0
- src/lib/command-search.test.ts +113 -0
- src/lib/command-search.ts +163 -0
- src/lib/event-roll-call.test.ts +65 -0
- src/lib/event-roll-call.ts +83 -0
- src/lib/exam-publish.test.ts +35 -0
- src/lib/exam-publish.ts +19 -0
- src/lib/format.ts +9 -0
- src/lib/notifications.ts +14 -1
- src/lib/student-directory.test.ts +35 -0
- src/lib/student-directory.ts +31 -1
- src/pages/admin-users-page.tsx +4 -15
- src/pages/ai-insight-student-page.tsx +1 -5
- src/pages/bank-question-detail-page.tsx +0 -13
- src/pages/classes-page.tsx +0 -5
- src/pages/dashboard-page.tsx +16 -39
- src/pages/event-detail-page.tsx +30 -33
- src/pages/exams-page.tsx +28 -2
- src/pages/license-modules-page.tsx +2 -31
- src/pages/meals-page.tsx +1 -1
- src/pages/messages-page.tsx +60 -111
- src/pages/payments-page.tsx +0 -7
- src/pages/question-bank-page.tsx +0 -14
- src/pages/register-page.tsx +76 -15
- src/pages/staff-work-page.tsx +0 -13
- src/pages/students-roster-page.tsx +5 -26
- src/pages/teachers-roster-page.tsx +3 -25
- src/pages/whiteboards-page.tsx +2 -2
docs/backend/attendance-pomodoro-summary-request.mdadded+179 -0
| @@ -0,0 +1,179 @@ | |||
| 1 | +# Feature request: list-level attendance and pomodoro summaries | ||
| 2 | + | ||
| 3 | +Status: requested by frontend · Date: 2026-09-22 | ||
| 4 | +Contract checked: live OpenAPI at `https://hezarfen-backend.dizey.sh/api-docs/openapi.json` | ||
| 5 | +(`info.version` 0.1.0, fetched 2026-09-22). | ||
| 6 | + | ||
| 7 | +## Problem | ||
| 8 | + | ||
| 9 | +Two management lists can only show a roster of students, not the numbers a | ||
| 10 | +manager opens them for: | ||
| 11 | + | ||
| 12 | +| Page | What it shows today | What it should show | | ||
| 13 | +| --- | --- | --- | | ||
| 14 | +| `/management/student-attendance` | Student directory; a row opens that one student's report in a side panel | Per-student present / absent / late / excused counts and attendance rate, sortable, filterable by class and term | | ||
| 15 | +| `/management/pomodoros` | Student directory; a row opens that one student's log | Per-student session count and focus minutes for a period, sortable, filterable by class | | ||
| 16 | + | ||
| 17 | +The API only offers these numbers one student at a time: | ||
| 18 | + | ||
| 19 | +- `GET /attendance/{user}` → `AttendanceReport` (`events`, `sessions`, | ||
| 20 | + `courses[]`, `devamsizlik[]`), teacher+ or linked parent. | ||
| 21 | +- `GET /pomodoro/{user}` → `PomodoroLog` (paged sessions + unpaged | ||
| 22 | + `total_focus_ms`), teacher+ or linked parent. | ||
| 23 | + | ||
| 24 | +Filling a list of N students would take N requests per page view (and per | ||
| 25 | +filter change). For a school of several hundred students that is not | ||
| 26 | +acceptable, so the frontend deliberately does not do it: it shows no numbers | ||
| 27 | +rather than firing a request storm, and it never shows made-up figures. | ||
| 28 | + | ||
| 29 | +## Verified: no such endpoint exists yet | ||
| 30 | + | ||
| 31 | +Every path in the live contract was checked. Nothing returns attendance or | ||
| 32 | +pomodoro figures for more than one user: | ||
| 33 | + | ||
| 34 | +- Attendance paths: `/attendance/me`, `/attendance/{user}`, | ||
| 35 | + `/events/{id}/attendance[/{user}]`, `/events/{id}/roster`, | ||
| 36 | + `/sessions/{id}/attendance[/{user}]`, `/meals/attendance/{user}`, | ||
| 37 | + `/meals/menus/{id}/attendance`. The event/session ones are per-event or | ||
| 38 | + per-lesson rosters, not per-student totals. | ||
| 39 | +- Pomodoro paths: `/pomodoro/me`, `/pomodoro/{user}`, `/pomodoro/start`, | ||
| 40 | + `/pomodoro/finish`. | ||
| 41 | +- No `summary`, `stats` or `report` path covers either domain. The nearest | ||
| 42 | + ones are unrelated: `/exams/{id}/statistics`, `/homework/report/{user}` | ||
| 43 | + (per user), `/insights/*` (AI insight runs), `/marks/karne[/{user}]`. | ||
| 44 | + | ||
| 45 | +## Proposal | ||
| 46 | + | ||
| 47 | +Two read-only endpoints. Both page with the standard `?limit=&offset=` and | ||
| 48 | +return the standard `{items, total, limit, offset}` envelope; `total` counts | ||
| 49 | +students, not attendance rows. | ||
| 50 | + | ||
| 51 | +Naming follows the existing contract: filters are named after the resource | ||
| 52 | +without an `_id` suffix (`term`, `course`, as on `/marks/karne` and | ||
| 53 | +`/course-notes`), and times are UTC unix milliseconds. | ||
| 54 | + | ||
| 55 | +### 1. `GET /attendance/summary` | ||
| 56 | + | ||
| 57 | +Per-student attendance tallies for a set of students. | ||
| 58 | + | ||
| 59 | +Query parameters: | ||
| 60 | + | ||
| 61 | +| Name | Type | Required | Meaning | | ||
| 62 | +| --- | --- | --- | --- | | ||
| 63 | +| `class` | string | no | Only students currently in this class section (`GET /classes/{id}/members`). Omit for every student the caller may see. | | ||
| 64 | +| `term` | string | no | Count only rows dated inside this term (`GET /terms/{id}`). Omit for the newest term, like `/marks/karne`. | | ||
| 65 | +| `q` | string | no | Name / username / student number search, as on the existing `q` filters. | | ||
| 66 | +| `sort` | string | no | `name` (default), `rate`, `absent`, `late`; prefix `-` for descending. | | ||
| 67 | +| `limit`, `offset` | int | no | Standard paging; same bounds as every other list (`1..500`). | | ||
| 68 | + | ||
| 69 | +Response `200` — `Page_AttendanceSummaryEntry`: | ||
| 70 | + | ||
| 71 | +```json | ||
| 72 | +{ | ||
| 73 | + "items": [ | ||
| 74 | + { | ||
| 75 | + "user": { "id": "0192…", "username": "ada.y", "display_name": "Ada Yılmaz", "student_number": "1043" }, | ||
| 76 | + "sessions": { "present": 118, "absent": 4, "late": 3, "excused": 2, "custom": {}, "total": 127, "rate": 0.968 }, | ||
| 77 | + "events": { "present": 6, "absent": 1, "late": 0, "excused": 0, "custom": {}, "total": 7, "rate": 0.857 }, | ||
| 78 | + "absence": { | ||
| 79 | + "term": "0191…", | ||
| 80 | + "name": "2026-2027 1. Dönem", | ||
| 81 | + "absent_days": 3, | ||
| 82 | + "excused_days": 1, | ||
| 83 | + "unexcused_days": 3, | ||
| 84 | + "over_limit": false | ||
| 85 | + } | ||
| 86 | + } | ||
| 87 | + ], | ||
| 88 | + "total": 32, | ||
| 89 | + "limit": 50, | ||
| 90 | + "offset": 0 | ||
| 91 | +} | ||
| 92 | +``` | ||
| 93 | + | ||
| 94 | +- `sessions` / `events` reuse the existing `StatusCounts` schema unchanged | ||
| 95 | + (same `rate` formula: `(present + late) / (present + absent + late)`, | ||
| 96 | + `null` when there is nothing to rate). | ||
| 97 | +- `absence` is the requested term's `TermAbsence` row (the same object as one | ||
| 98 | + entry of `AttendanceReport.devamsizlik`; `limits` may be dropped here since | ||
| 99 | + it is school-wide), or `null` when the student has no rows in that term. | ||
| 100 | +- A student with no attendance rows at all still appears, with zero counts — | ||
| 101 | + the list is a roster first. | ||
| 102 | + | ||
| 103 | +### 2. `GET /pomodoro/summary` | ||
| 104 | + | ||
| 105 | +Per-student pomodoro totals for a period. | ||
| 106 | + | ||
| 107 | +Query parameters: | ||
| 108 | + | ||
| 109 | +| Name | Type | Required | Meaning | | ||
| 110 | +| --- | --- | --- | --- | | ||
| 111 | +| `class` | string | no | Only students currently in this class section. Omit for every student the caller may see. | | ||
| 112 | +| `from` | int (ms) | no | Count sessions that started at or after this instant. | | ||
| 113 | +| `to` | int (ms) | no | Count sessions that started before this instant. | | ||
| 114 | +| `q` | string | no | Name / username / student number search. | | ||
| 115 | +| `sort` | string | no | `name` (default), `focus`, `sessions`, `last`; prefix `-` for descending. | | ||
| 116 | +| `limit`, `offset` | int | no | Standard paging. | | ||
| 117 | + | ||
| 118 | +Omitting both `from` and `to` means the whole log, matching what | ||
| 119 | +`GET /pomodoro/{user}` sums today. | ||
| 120 | + | ||
| 121 | +Response `200` — `Page_PomodoroSummaryEntry`: | ||
| 122 | + | ||
| 123 | +```json | ||
| 124 | +{ | ||
| 125 | + "items": [ | ||
| 126 | + { | ||
| 127 | + "user": { "id": "0192…", "username": "ada.y", "display_name": "Ada Yılmaz", "student_number": "1043" }, | ||
| 128 | + "sessions": 14, | ||
| 129 | + "counted_sessions": 12, | ||
| 130 | + "total_focus_ms": 20400000, | ||
| 131 | + "last_started_at": 1758540000000 | ||
| 132 | + } | ||
| 133 | + ], | ||
| 134 | + "total": 32, | ||
| 135 | + "limit": 50, | ||
| 136 | + "offset": 0 | ||
| 137 | +} | ||
| 138 | +``` | ||
| 139 | + | ||
| 140 | +- `sessions`: finished sessions in the window. A running session is not | ||
| 141 | + counted, as in `PomodoroLog.total_focus_ms`. | ||
| 142 | +- `counted_sessions`: of those, how many had `counted = true` (moved the | ||
| 143 | + badge / streak counters). Optional; useful for oversight, not required. | ||
| 144 | +- `total_focus_ms`: sum of `duration_ms` over those sessions. Milliseconds, | ||
| 145 | + like every other duration in the contract; the UI converts to minutes. | ||
| 146 | +- `last_started_at`: newest session start in the window, `null` if none. | ||
| 147 | +- Students with no sessions appear with zeros. | ||
| 148 | + | ||
| 149 | +## Role scoping | ||
| 150 | + | ||
| 151 | +Same rules as the per-student endpoints they summarise, applied per row: | ||
| 152 | + | ||
| 153 | +| Caller | `class` omitted | `class` given | | ||
| 154 | +| --- | --- | --- | | ||
| 155 | +| admin, manager | every student | that class | | ||
| 156 | +| teacher | students of the classes they are homeroom teacher of (`ClassResponse.teacher`) or teach an instance in | allowed only if they are that class's homeroom teacher or teach an instance of it; otherwise `403` | | ||
| 157 | +| student, parent | `403` (they already have `/attendance/me`, `/pomodoro/me` and the per-child endpoints) | `403` | | ||
| 158 | + | ||
| 159 | +For `/attendance/summary`, a teacher's `sessions` tally should follow the | ||
| 160 | +`GET /attendance/{user}` rule: only the roll-call rows of instances the | ||
| 161 | +teacher runs, plus event tallies. Managers and admins see every instance. | ||
| 162 | + | ||
| 163 | +## Errors | ||
| 164 | + | ||
| 165 | +- `400` — invalid `limit`/`offset`/`sort`, `from > to`, unknown `term`. | ||
| 166 | +- `401` — not authenticated. | ||
| 167 | +- `403` — role not allowed, or a teacher asking for a class outside their scope. | ||
| 168 | +- `404` — `class` or `term` does not exist. | ||
| 169 | + | ||
| 170 | +## Frontend plan once available | ||
| 171 | + | ||
| 172 | +- `src/api/reports/getAttendanceSummary.ts` and | ||
| 173 | + `src/api/reports/getPomodoroSummary.ts`, with tests in | ||
| 174 | + `src/api/__tests__/reports/`. | ||
| 175 | +- `/management/student-attendance`: server-paged `DataTable` with rate, | ||
| 176 | + absent, late, excused and unexcused-days columns, class and term filters; | ||
| 177 | + the row action keeps opening the full per-student report. | ||
| 178 | +- `/management/pomodoros`: server-paged `DataTable` with session count, focus | ||
| 179 | + minutes and last session, class filter and a period picker. | ||
docs/frontend/sitemap.mdmodified+98 -86
| @@ -6,7 +6,8 @@ Every route in the app, how it is reached, and who may enter it. | |||
| 6 | same commit when either changes: | 6 | same commit when either changes: |
| 7 | 7 | ||
| 8 | - `src/routes/router.tsx` — the route table (paths, params, redirects) | 8 | - `src/routes/router.tsx` — the route table (paths, params, redirects) |
| 9 | -- `src/components/layout/nav-items.ts` — sidebar grouping and per-role visibility | 9 | +- `src/components/layout/nav-items.ts` — sidebar groups per role, module gates, |
| 10 | + the mobile tab bar | ||
| 10 | - `src/pages/*.tsx` — the `<RouteGuard>` each page wraps itself in | 11 | - `src/pages/*.tsx` — the `<RouteGuard>` each page wraps itself in |
| 11 | 12 | ||
| 12 | Role rank (`src/lib/roles.ts`): `parent (-1) < student (0) < teacher (1) < manager (2) < admin (3)`. | 13 | Role rank (`src/lib/roles.ts`): `parent (-1) < student (0) < teacher (1) < manager (2) < admin (3)`. |
| @@ -22,73 +23,73 @@ flowchart LR | |||
| 22 | Login -- "no account" --> Register["/register"] | 23 | Login -- "no account" --> Register["/register"] |
| 23 | Register --> Login | 24 | Register --> Login |
| 24 | Login --> Home | 25 | Login --> Home |
| 26 | + Builder(["Platform operator"]) --> BLogin["/builder/login"] --> BHome["/builder"] --> BSchool["/builder/schools/$slug"] | ||
| 25 | ``` | 27 | ``` |
| 26 | 28 | ||
| 27 | `RouteGuard` sends any unauthenticated visitor to `/login`; `guest-guard.tsx` does | 29 | `RouteGuard` sends any unauthenticated visitor to `/login`; `guest-guard.tsx` does |
| 28 | -the reverse for `/login` and `/register`. Neither auth page is in the sidebar. | 30 | +the reverse for `/login`, `/register` and `/builder/login`. The `/builder/*` |
| 31 | +pages sit behind `BuilderGuard` (the platform-operator session), not a school | ||
| 32 | +role. None of these are in the sidebar. | ||
| 29 | 33 | ||
| 30 | -## Main sitemap | 34 | +## Sidebar per role |
| 31 | 35 | ||
| 32 | -Grouped exactly as the sidebar groups them. Bracketed labels are the role gate — | 36 | +Each role has its own tree in `nav-items.ts` (`GROUPS_BY_ROLE`); manager and |
| 33 | -unmarked entries are visible to every signed-in role except `parent` (see | 37 | +admin share one tree and the manager simply qualifies for fewer items. An item |
| 34 | -[Parent visibility](#parent-visibility)). | 38 | +with a `module` is also hidden when the school has that module switched off |
| 39 | +(`moduleVisible`). The Çelebi and "Ayarlar" rows open shell panels instead of | ||
| 40 | +navigating, so they have no route. | ||
| 35 | 41 | ||
| 36 | -```mermaid | 42 | +### Admin / manager |
| 37 | -flowchart TD | 43 | + |
| 38 | - Home["/ — Dashboard"] | 44 | +| Group | Entries | |
| 39 | - | 45 | +| --- | --- | |
| 40 | - Home --> Classes["Dersler"] | 46 | +| Yapay zekâ | `/ai/studio` · `/ai/study` · `/ai/insights` · Çelebi | |
| 41 | - Home --> Planning["Planlama"] | 47 | +| Okul yönetimi | `/management/students` (manager+) · `/management/teachers` (manager+) · `/management/classes` · `/management/academic-years` (manager+) · `/management/terms` (manager+) · `/calendar` | |
| 42 | - Home --> Workspace["Çalışma alanı"] | 48 | +| Eğitim ve içerik | `/courses` · `/homework` · `/exams` · `/question-bank` · `/questions` · `/notes` · `/whiteboards` | |
| 43 | - Home --> Students["Öğrenciler"] | 49 | +| Öğrenci takibi | `/management/student-attendance` · `/management/student-marks` · `/management/pomodoros` | |
| 44 | - Home --> Services["Hizmetler"] | 50 | +| Okul hizmetleri | `/events` · `/appointments` · `/meals` | |
| 45 | - Home --> Community["Topluluk"] | 51 | +| Kurum | `/management/payments` · `/management/staff-work` · `/work` · `/admin/users` (admin) · `/management/modules` (admin) · `/management/settings` | |
| 46 | - Home --> School["Okul"] | 52 | +| Yakında (folded) | `/coming-soon/deneme-sinavlari` · `/coming-soon/optik-okuma` · `/coming-soon/raporlar` · `/coming-soon/kvkk-denetim` (admin) | |
| 47 | - | ||
| 48 | - Classes --> C1["/courses"] | ||
| 49 | - Classes --> C2["/homework"] | ||
| 50 | - Classes --> C3["/exams"] | ||
| 51 | - Classes --> C4["/question-bank<br/>teacher+"] | ||
| 52 | - Classes --> C5["/marks<br/>student only"] | ||
| 53 | - | ||
| 54 | - Planning --> P1["/events"] | ||
| 55 | - Planning --> P2["/calendar"] | ||
| 56 | - Planning --> P3["/appointments"] | ||
| 57 | - | ||
| 58 | - Workspace --> W1["/notes"] | ||
| 59 | - Workspace --> W2["/whiteboards<br/>student+"] | ||
| 60 | - Workspace --> W3["/pomodoro<br/>student only"] | ||
| 61 | - | ||
| 62 | - Students --> S1["/students<br/>parent only"] | ||
| 63 | - Students --> S2["/management/classes<br/>teacher+"] | ||
| 64 | - Students --> S3["/management/student-marks<br/>teacher+"] | ||
| 65 | - Students --> S4["/management/student-attendance<br/>teacher+"] | ||
| 66 | - Students --> S5["/management/pomodoros<br/>teacher+"] | ||
| 67 | - | ||
| 68 | - Services --> V1["/meals"] | ||
| 69 | - Services --> V2["/payments<br/>parent + student"] | ||
| 70 | - | ||
| 71 | - Community --> M1["/messages"] | ||
| 72 | - Community --> M2["/questions<br/>student+"] | ||
| 73 | - Community --> M3["/work<br/>teacher..manager"] | ||
| 74 | - | ||
| 75 | - School --> K1["/management/staff-work<br/>manager+"] | ||
| 76 | - School --> K2["/management/settings<br/>manager+"] | ||
| 77 | - School --> K3["/management/terms<br/>manager+"] | ||
| 78 | - School --> K4["/management/payments<br/>manager+"] | ||
| 79 | - School --> K5["/admin/users<br/>admin"] | ||
| 80 | -``` | ||
| 81 | 53 | ||
| 82 | -### Primary strip | 54 | +### Teacher |
| 83 | 55 | ||
| 84 | -`PRIMARY_BY_ROLE` lifts a few of the above into the top strip / mobile tab bar | 56 | +| Group | Entries | |
| 85 | -instead of the grouped sidebar: | 57 | +| --- | --- | |
| 58 | +| Yapay zekâ | `/ai/studio` · `/ai/study` · Çelebi | | ||
| 59 | +| Sınıfım | `/management/classes` · `/calendar` · `/courses` | | ||
| 60 | +| Öğrenci takibi | `/management/student-attendance` · `/management/student-marks` · `/management/pomodoros` · `/ai/insights` ("Öğrenci analizi") | | ||
| 61 | +| Eğitim ve içerik | `/homework` · `/exams` · `/question-bank` · `/ai/question-generation` · `/questions` · `/questions?status=pending` · `/notes` · `/whiteboards` | | ||
| 62 | +| Diğer | `/messages` · `/appointments` · `/events` · `/meals` · `/work` · Ayarlar | | ||
| 63 | + | ||
| 64 | +### Student | ||
| 86 | 65 | ||
| 87 | -| Role | Primary items | | 66 | +| Group | Entries | |
| 88 | | --- | --- | | 67 | | --- | --- | |
| 89 | -| student | `/` · `/courses` · `/calendar` · `/marks` | | 68 | +| Yapay zekâ | `/ai/studio` · `/ai/study` · `/ai/insights` · Çelebi | |
| 90 | -| teacher, manager, admin | `/` · `/courses` · `/calendar` | | 69 | +| Çalışma | `/marks` · `/exams` · `/homework` · `/pomodoro` | |
| 91 | -| parent | `/` · `/students` · `/calendar` | | 70 | +| Eğitim ve içerik | `/courses` · `/notes` · `/questions` · `/whiteboards` | |
| 71 | +| Diğer | `/calendar` · `/events` · `/messages` · `/appointments` · `/meals` · Ayarlar | | ||
| 72 | +| Yakında (folded) | `/coming-soon/calisma-programim` | | ||
| 73 | + | ||
| 74 | +### Parent | ||
| 75 | + | ||
| 76 | +| Group | Entries | | ||
| 77 | +| --- | --- | | ||
| 78 | +| Yapay zekâ | `/ai/insights` | | ||
| 79 | +| Öğrencim | `/students` · `/students/attendance` · `/students/exams` · `/students/study` | | ||
| 80 | +| Kurum | `/payments` · `/appointments` · `/messages` · `/calendar` · `/events` · `/meals` · Ayarlar | | ||
| 81 | + | ||
| 82 | +### Mobile tab bar | ||
| 83 | + | ||
| 84 | +`PRIMARY_IDS_BY_ROLE` picks Home plus two entries from the role's own tree for | ||
| 85 | +the phone tab bar (then the bar's own Search and Menu buttons): | ||
| 86 | + | ||
| 87 | +| Role | Tabs | | ||
| 88 | +| --- | --- | | ||
| 89 | +| student | `/` · `/homework` · `/exams` | | ||
| 90 | +| teacher | `/` · `/management/classes` · `/management/student-attendance` | | ||
| 91 | +| manager, admin | `/` · `/management/students` · `/management/classes` | | ||
| 92 | +| parent | `/` · `/students` · `/appointments` | | ||
| 92 | 93 | ||
| 93 | ## Detail and nested routes | 94 | ## Detail and nested routes |
| 94 | 95 | ||
| @@ -103,16 +104,29 @@ flowchart LR | |||
| 103 | C1 --> C3["/exam-room/$id<br/>student only"] | 104 | C1 --> C3["/exam-room/$id<br/>student only"] |
| 104 | D["/question-bank<br/>teacher+"] --> D1["/question-bank/$id<br/>teacher+"] | 105 | D["/question-bank<br/>teacher+"] --> D1["/question-bank/$id<br/>teacher+"] |
| 105 | E["/courses"] --> E1["/courses/$id"] | 106 | E["/courses"] --> E1["/courses/$id"] |
| 107 | + E1 --> E2["/instances/$id"] | ||
| 106 | F["/questions<br/>student+"] --> F1["/questions/$id<br/>student+"] | 108 | F["/questions<br/>student+"] --> F1["/questions/$id<br/>student+"] |
| 107 | G["/meals"] --> G1["/meals/$id"] | 109 | G["/meals"] --> G1["/meals/$id"] |
| 108 | - H["/management/classes<br/>teacher+"] --> H1["/management/classes/$id"] | 110 | + H["/management/classes<br/>teacher+"] --> H1["/management/classes/$id<br/>teacher+"] |
| 109 | I["/admin/users<br/>admin"] --> I1["/admin/users/$id<br/>admin"] | 111 | I["/admin/users<br/>admin"] --> I1["/admin/users/$id<br/>admin"] |
| 110 | J["/whiteboards<br/>student+"] --> J1["/whiteboards/$id<br/>student+"] | 112 | J["/whiteboards<br/>student+"] --> J1["/whiteboards/$id<br/>student+"] |
| 111 | K["/management/payments<br/>manager+"] --> K1["/management/payments/$userId<br/>manager+"] | 113 | K["/management/payments<br/>manager+"] --> K1["/management/payments/$userId<br/>manager+"] |
| 114 | + L["/notes"] --> L1["/notes/new"] | ||
| 115 | + L --> L2["/notes/$id"] | ||
| 116 | + M["/ai/insights"] --> M1["/ai/insights/$userId"] | ||
| 117 | + N["/builder"] --> N1["/builder/schools/$slug"] | ||
| 112 | ``` | 118 | ``` |
| 113 | 119 | ||
| 114 | -`/management/payments/$userId` renders the same `PaymentsPage` component as the | 120 | +- `/courses/$id` is the catalog row; `/instances/$id` is a şube×ders instance |
| 115 | -list route — the param only deep-links a selected student. | 121 | + (enrollments, exams, homework, sessions, roll call), reached from a course or |
| 122 | + a class. | ||
| 123 | +- `/management/payments/$userId` renders the same `PaymentsPage` component as | ||
| 124 | + the list route — the param only deep-links a selected student. | ||
| 125 | +- `/students/attendance`, `/students/exams` and `/students/study` render the | ||
| 126 | + same `MyStudentsPage` as `/students`, each on its own tab. | ||
| 127 | +- `/notes/new` and `/notes/$id` share `NoteEditorPage`. | ||
| 128 | +- `/profile/me` and `/profile/$userId` share `ProfilePage`; `/profile/me` is | ||
| 129 | + opened from the account menu, `/profile/$userId` from a person link. | ||
| 116 | 130 | ||
| 117 | ## Redirects | 131 | ## Redirects |
| 118 | 132 | ||
| @@ -120,40 +134,38 @@ list route — the param only deep-links a selected student. | |||
| 120 | | --- | --- | --- | | 134 | | --- | --- | --- | |
| 121 | | `/studies` | `/courses?kind=study` | Courses page filters by `kind` | | 135 | | `/studies` | `/courses?kind=study` | Courses page filters by `kind` | |
| 122 | | `/clubs` | `/courses?kind=club` | same | | 136 | | `/clubs` | `/courses?kind=club` | same | |
| 123 | -| `/attendance` | `/marks?tab=attendance` | attendance is a tab on the marks page | | 137 | +| `/ai` | `/ai/studio` | the old AI hub; each AI module has its own page now | |
| 138 | +| `/sound-studio` | `/ai/studio` | the audio studio moved into AI Studio | | ||
| 139 | +| `/attendance` | per role: student → `/marks?tab=attendance`, parent → `/students/attendance`, staff → `/management/student-attendance` | old link every role may still hold | | ||
| 124 | 140 | ||
| 125 | -All three are `beforeLoad` redirects with no component of their own. | 141 | +The first four are `beforeLoad` redirects with no component of their own; |
| 142 | +`/attendance` waits for the session (`AttendanceRedirect`) because the target | ||
| 143 | +depends on the role. | ||
| 126 | 144 | ||
| 127 | ## Route guards at a glance | 145 | ## Route guards at a glance |
| 128 | 146 | ||
| 129 | -Route-level enforcement only — the sidebar hides more than this table blocks. | 147 | +Route-level enforcement only — the sidebar hides more than this table blocks, |
| 148 | +and the backend still scopes every read. | ||
| 130 | 149 | ||
| 131 | | Guard | Routes | | 150 | | Guard | Routes | |
| 132 | | --- | --- | | 151 | | --- | --- | |
| 133 | -| `admin` | `/admin/users`, `/admin/users/$id` | | 152 | +| `admin` | `/admin/users`, `/admin/users/$id`, `/management/modules` | |
| 134 | -| `manager+` | `/management/settings`, `/management/terms`, `/management/staff-work`, `/management/payments`, `/management/payments/$userId` | | 153 | +| `manager+` | `/management/students`, `/management/teachers`, `/management/academic-years`, `/management/terms`, `/management/settings`, `/management/staff-work`, `/management/payments`, `/management/payments/$userId` | |
| 135 | -| `teacher+` | `/question-bank`, `/question-bank/$id`, `/management/student-marks`, `/management/student-attendance`, `/management/pomodoros`, `/exams/$id/live` | | 154 | +| `teacher+` | `/management/classes`, `/management/classes/$id`, `/management/student-marks`, `/management/student-attendance`, `/management/pomodoros`, `/question-bank`, `/question-bank/$id`, `/ai/question-generation`, `/exams/$id/live`, `/work` | |
| 136 | -| `teacher..manager` | `/work` | | 155 | +| `student+` | `/questions`, `/questions/$id`, `/whiteboards`, `/whiteboards/$id`, `/ai/studio`, `/ai/study` | |
| 137 | -| `student+` | `/questions`, `/questions/$id`, `/whiteboards`, `/whiteboards/$id` | | ||
| 138 | | `student` only | `/marks`, `/pomodoro`, `/exam-room/$id` | | 156 | | `student` only | `/marks`, `/pomodoro`, `/exam-room/$id` | |
| 139 | -| `parent` only | `/students` | | 157 | +| `parent` only | `/students`, `/students/attendance`, `/students/exams`, `/students/study` | |
| 140 | -| signed-in, no role gate | `/`, `/notes`, `/events`, `/events/$id`, `/homework`, `/homework/$id`, `/exams`, `/exams/$id`, `/courses`, `/courses/$id`, `/management/classes`, `/management/classes/$id`, `/calendar`, `/appointments`, `/meals`, `/meals/$id`, `/messages`, `/payments`, `/guide` | | 158 | +| signed-in, no role gate | `/`, `/notes`, `/notes/new`, `/notes/$id`, `/events`, `/events/$id`, `/homework`, `/homework/$id`, `/exams`, `/exams/$id`, `/courses`, `/courses/$id`, `/instances/$id`, `/calendar`, `/appointments`, `/meals`, `/meals/$id`, `/messages`, `/payments`, `/ai/insights`, `/ai/insights/$userId`, `/profile/me`, `/profile/$userId`, `/guide`, `/coming-soon/*` | |
| 141 | - | 159 | +| builder session | `/builder`, `/builder/schools/$slug` | |
| 142 | -### Parent visibility | 160 | +| guest only | `/login`, `/register`, `/builder/login` | |
| 143 | - | ||
| 144 | -`itemVisible()` in `nav-items.ts` ends with an allowlist: a `parent` sees an | ||
| 145 | -otherwise-ungated item only when its path is `/`, `/calendar`, `/appointments`, | ||
| 146 | -`/meals` or `/messages`. Every other ungated route above is hidden from a parent's | ||
| 147 | -sidebar but has no `RouteGuard`, so it stays reachable by typing the URL — the | ||
| 148 | -data those pages show is scoped by the backend, not by the router. | ||
| 149 | 161 | ||
| 150 | -The same gap applies to `/payments` (the personal statement page): the sidebar | 162 | +Ungated routes that a role's sidebar does not list (a parent typing `/notes`, |
| 151 | -shows it at `maxRole: "student"` (parent and student), while the route itself is | 163 | +say) stay reachable by URL — the data those pages show is scoped by the |
| 152 | -ungated. | 164 | +backend, not by the router. |
| 153 | 165 | ||
| 154 | -## Not in the sitemap | 166 | +## Not in the sidebar |
| 155 | 167 | ||
| 156 | -- `/guide` — the in-app help page, reached from the account dropdown at the foot | 168 | +- `/guide` and `/profile/me` — opened from the account menu (`account-menu.ts`), |
| 157 | - of the sidebar (`sidebar-account.tsx`), not from a nav group. | 169 | + shared by the desktop dropdown and the phone menu sheet. |
| 158 | -- `/login`, `/register` — pre-auth, covered in [Entry flow](#entry-flow). | 170 | +- `/login`, `/register`, `/builder/*` — covered in [Entry flow](#entry-flow). |
| 159 | - 404 — `notFoundComponent` on the root route, links back to `/`. | 171 | - 404 — `notFoundComponent` on the root route, links back to `/`. |
src/components/events/attendance-status-picker.tsxdeleted+0 -50
| @@ -1,50 +0,0 @@ | |||
| 1 | -import { For, Show, createMemo } from "solid-js"; | ||
| 2 | -import { createResource } from "@/lib/create-resource"; | ||
| 3 | -import { getSettings } from "@/api/settings"; | ||
| 4 | -import type { AttendanceStatus } from "@/api/client"; | ||
| 5 | -import { Label } from "@/components/ui/label"; | ||
| 6 | -import { Select } from "@/components/ui/select"; | ||
| 7 | -import { ATTENDANCE_STATUSES, getAttendanceStatusMeta } from "@/lib/attendance-status"; | ||
| 8 | -import { useT } from "@/stores/preferences-context"; | ||
| 9 | - | ||
| 10 | -export function AttendanceStatusPicker(props: { | ||
| 11 | - id?: string; | ||
| 12 | - value: AttendanceStatus; | ||
| 13 | - onChange: (status: AttendanceStatus) => void; | ||
| 14 | - label?: string; | ||
| 15 | - hideLabel?: boolean; | ||
| 16 | - hideDetail?: boolean; | ||
| 17 | -}) { | ||
| 18 | - const t = useT(); | ||
| 19 | - const [settings] = createResource(() => getSettings()); | ||
| 20 | - const statuses = createMemo(() => { | ||
| 21 | - const values = settings()?.attendance_statuses ?? ATTENDANCE_STATUSES.map((item) => item.value); | ||
| 22 | - return values.includes(props.value) ? values : [props.value, ...values]; | ||
| 23 | - }); | ||
| 24 | - const selectedMeta = createMemo(() => getAttendanceStatusMeta(props.value)); | ||
| 25 | - return ( | ||
| 26 | - <div class="space-y-1.5"> | ||
| 27 | - <Show when={!props.hideLabel}> | ||
| 28 | - <Label for={props.id ?? "attendance-status"}>{props.label ?? t("events.status")}</Label> | ||
| 29 | - </Show> | ||
| 30 | - <Select | ||
| 31 | - id={props.id ?? "attendance-status"} | ||
| 32 | - class="h-10 rounded-lg bg-background/80" | ||
| 33 | - value={props.value} | ||
| 34 | - onChange={(e) => props.onChange(e.currentTarget.value as AttendanceStatus)} | ||
| 35 | - > | ||
| 36 | - <For each={statuses()}> | ||
| 37 | - {(status) => { | ||
| 38 | - const meta = getAttendanceStatusMeta(status); | ||
| 39 | - return <option value={status}>{meta ? `${t(meta.key)} - ${t(meta.detailKey)}` : status}</option>; | ||
| 40 | - }} | ||
| 41 | - </For> | ||
| 42 | - </Select> | ||
| 43 | - <Show when={!props.hideDetail}> | ||
| 44 | - <p class="text-xs text-muted-foreground"> | ||
| 45 | - {selectedMeta() ? `${t(selectedMeta()!.key)}: ${t(selectedMeta()!.detailKey)}` : props.value} | ||
| 46 | - </p> | ||
| 47 | - </Show> | ||
| 48 | - </div> | ||
| 49 | - ); | ||
| 50 | -} | ||
src/components/events/attendance-table.tsxmodified+6 -3
| @@ -8,6 +8,7 @@ import { TableRowActions } from "@/components/ui/table-row-actions"; | |||
| 8 | import { Badge } from "@/components/ui/badge"; | 8 | import { Badge } from "@/components/ui/badge"; |
| 9 | import { getAttendanceStatusMeta } from "@/lib/attendance-status"; | 9 | import { getAttendanceStatusMeta } from "@/lib/attendance-status"; |
| 10 | import { cn } from "@/lib/cn"; | 10 | import { cn } from "@/lib/cn"; |
| 11 | +import { eventStatusLabelKey } from "@/lib/event-roll-call"; | ||
| 11 | import { personId, personLabel } from "@/lib/person"; | 12 | import { personId, personLabel } from "@/lib/person"; |
| 12 | import { useT } from "@/stores/preferences-context"; | 13 | import { useT } from "@/stores/preferences-context"; |
| 13 | 14 | ||
| @@ -30,11 +31,13 @@ export function AttendanceTable(props: { | |||
| 30 | accessorKey: "status", | 31 | accessorKey: "status", |
| 31 | header: t("events.status"), | 32 | header: t("events.status"), |
| 32 | cell: (cell) => { | 33 | cell: (cell) => { |
| 33 | - const meta = getAttendanceStatusMeta(cell.row.original.status); | 34 | + const status = cell.row.original.status; |
| 35 | + const meta = getAttendanceStatusMeta(status); | ||
| 36 | + // Event wording ("Katıldı"), not the lesson one ("Var · Derste"). | ||
| 37 | + const key = eventStatusLabelKey(status) ?? meta?.key; | ||
| 34 | return ( | 38 | return ( |
| 35 | <Badge variant="outline" class={cn("gap-1 rounded-full border px-2.5 py-1 normal-case", meta?.class)}> | 39 | <Badge variant="outline" class={cn("gap-1 rounded-full border px-2.5 py-1 normal-case", meta?.class)}> |
| 36 | - <span>{meta ? t(meta.key) : cell.row.original.status}</span> | 40 | + {key ? t(key) : status} |
| 37 | - <Show when={meta}>{(known) => <span class="font-normal opacity-75">· {t(known().detailKey)}</span>}</Show> | ||
| 38 | </Badge> | 41 | </Badge> |
| 39 | ); | 42 | ); |
| 40 | }, | 43 | }, |
src/components/events/event-roll-call.test.tsxadded+68 -0
| @@ -0,0 +1,68 @@ | |||
| 1 | +import { fireEvent, render, screen, waitFor, within } from "@solidjs/testing-library"; | ||
| 2 | +import { EventRollCall } from "@/components/events/event-roll-call"; | ||
| 3 | +import { PreferencesProvider } from "@/stores/preferences-context"; | ||
| 4 | + | ||
| 5 | +const { postEventAttendance } = vi.hoisted(() => ({ | ||
| 6 | + postEventAttendance: vi.fn(async (_eventId: string, body: { user_id: string; status: string }) => { | ||
| 7 | + if (body.user_id === "s-3") throw new Error("outside audience"); | ||
| 8 | + return { id: `a-${body.user_id}`, event: "event-1", user: { id: body.user_id, username: body.user_id, display_name: null }, status: body.status, marked_by: { id: "t", username: "t", display_name: null } }; | ||
| 9 | + }), | ||
| 10 | +})); | ||
| 11 | + | ||
| 12 | +vi.mock("@/api/events", () => ({ postEventAttendance })); | ||
| 13 | +vi.mock("@/api/settings", () => ({ | ||
| 14 | + getSettings: async () => ({ attendance_statuses: ["present", "absent", "late", "excused"] }), | ||
| 15 | +})); | ||
| 16 | + | ||
| 17 | +const person = (id: string, name: string) => ({ id, username: id, display_name: name }); | ||
| 18 | +const roster = [ | ||
| 19 | + { user: person("s-1", "Ada"), status: "present", marked_by: person("t", "Öğretmen") }, | ||
| 20 | + { user: person("s-2", "Bora"), status: null, marked_by: null }, | ||
| 21 | + { user: person("s-3", "Cem"), status: null, marked_by: null }, | ||
| 22 | +]; | ||
| 23 | + | ||
| 24 | +afterEach(() => { | ||
| 25 | + vi.clearAllMocks(); | ||
| 26 | +}); | ||
| 27 | + | ||
| 28 | +const mount = (open = true, onSaved = vi.fn()) => | ||
| 29 | + render(() => ( | ||
| 30 | + <PreferencesProvider> | ||
| 31 | + <EventRollCall eventId="event-1" roster={roster} open={open} onSaved={onSaved} /> | ||
| 32 | + </PreferencesProvider> | ||
| 33 | + )); | ||
| 34 | +const row = (name: string) => within(screen.getByRole("radiogroup", { name })); | ||
| 35 | +const saveButton = () => screen.getByRole("button", { name: /Yoklamayı kaydet|Save roll call|Save attendance/ }); | ||
| 36 | + | ||
| 37 | +test("lists the whole audience with recorded statuses and nothing sent on pick", async () => { | ||
| 38 | + mount(); | ||
| 39 | + expect(await screen.findByText("Ada")).toBeTruthy(); | ||
| 40 | + expect(row("Ada").getByRole("radio", { name: /Katıldı|Attended/ }).getAttribute("aria-checked")).toBe("true"); | ||
| 41 | + fireEvent.click(row("Bora").getByRole("radio", { name: /Katılmadı|Did not attend/ })); | ||
| 42 | + expect(postEventAttendance).not.toHaveBeenCalled(); | ||
| 43 | +}); | ||
| 44 | + | ||
| 45 | +test("saves only changed rows and reports a failed row on that row", async () => { | ||
| 46 | + const onSaved = vi.fn(); | ||
| 47 | + mount(true, onSaved); | ||
| 48 | + await screen.findByText("Ada"); | ||
| 49 | + fireEvent.click(row("Ada").getByRole("radio", { name: /Katıldı|Attended/ })); // unchanged: no-op | ||
| 50 | + fireEvent.click(row("Bora").getByRole("radio", { name: /Katılmadı|Did not attend/ })); | ||
| 51 | + fireEvent.click(row("Cem").getByRole("radio", { name: /Geç geldi|Arrived late/ })); | ||
| 52 | + fireEvent.click(saveButton()); | ||
| 53 | + | ||
| 54 | + await waitFor(() => expect(postEventAttendance).toHaveBeenCalledTimes(2)); | ||
| 55 | + expect(postEventAttendance).toHaveBeenNthCalledWith(1, "event-1", { user_id: "s-2", status: "absent" }); | ||
| 56 | + expect(postEventAttendance).toHaveBeenNthCalledWith(2, "event-1", { user_id: "s-3", status: "late" }); | ||
| 57 | + // The failed row keeps its pick and carries its own error line. | ||
| 58 | + expect(await screen.findByText(/İşlem tamamlanamadı|Something went wrong/)).toBeTruthy(); | ||
| 59 | + expect(screen.getByText(/1 of 2 rows|2 satırdan 1/)).toBeTruthy(); | ||
| 60 | + expect(onSaved).toHaveBeenCalledTimes(1); | ||
| 61 | +}); | ||
| 62 | + | ||
| 63 | +test("before the event starts nothing can be picked or saved", async () => { | ||
| 64 | + mount(false); | ||
| 65 | + await screen.findByText("Ada"); | ||
| 66 | + expect((row("Bora").getByRole("radio", { name: /Katıldı|Attended/ }) as HTMLButtonElement).disabled).toBe(true); | ||
| 67 | + expect((saveButton() as HTMLButtonElement).disabled).toBe(true); | ||
| 68 | +}); | ||
src/components/events/event-roll-call.tsxadded+336 -0
| @@ -0,0 +1,336 @@ | |||
| 1 | +import { For, Show, createEffect, createMemo, createSignal, on } from "solid-js"; | ||
| 2 | +import { createResource } from "@/lib/create-resource"; | ||
| 3 | +import { postEventAttendance } from "@/api/events"; | ||
| 4 | +import { getSettings } from "@/api/settings"; | ||
| 5 | +import { formatApiError } from "@/api/client"; | ||
| 6 | +import type { AttendanceStatus, EventRosterEntry } from "@/api/client"; | ||
| 7 | +import { Alert } from "@/components/ui/alert"; | ||
| 8 | +import { Button } from "@/components/ui/button"; | ||
| 9 | +import { DataTableSearch } from "@/components/ui/data-table-search"; | ||
| 10 | +import { EmptyState } from "@/components/ui/empty-state"; | ||
| 11 | +import { IconCheck } from "@/components/ui/icons"; | ||
| 12 | +import { TablePagination } from "@/components/ui/table-pagination"; | ||
| 13 | +import { ATTENDANCE_STATUSES, getAttendanceStatusMeta } from "@/lib/attendance-status"; | ||
| 14 | +import { cn } from "@/lib/cn"; | ||
| 15 | +import { | ||
| 16 | + eventStatusLabelKey, | ||
| 17 | + orderRollCallStatuses, | ||
| 18 | + rollCallChanges, | ||
| 19 | + saveRollCallChanges, | ||
| 20 | +} from "@/lib/event-roll-call"; | ||
| 21 | +import { personLabel } from "@/lib/person"; | ||
| 22 | +import { matchesSearch } from "@/lib/search-text"; | ||
| 23 | +import { useT } from "@/stores/preferences-context"; | ||
| 24 | + | ||
| 25 | +const PAGE_SIZE = 20; | ||
| 26 | + | ||
| 27 | +/** | ||
| 28 | + * Event roll call as one roster: every expected attendee (resolved by the | ||
| 29 | + * backend from the event's audience) with a status row. Picks stay local | ||
| 30 | + * until "Yoklamayı kaydet" sends the changed rows — the API marks one user per | ||
| 31 | + * call, so rows go one at a time with progress, and a row that fails keeps its | ||
| 32 | + * pick and shows its own error. | ||
| 33 | + */ | ||
| 34 | +export function EventRollCall(props: { | ||
| 35 | + eventId: string; | ||
| 36 | + roster: EventRosterEntry[]; | ||
| 37 | + /** False before the event starts: statuses show, nothing can be picked. */ | ||
| 38 | + open: boolean; | ||
| 39 | + closedReason?: string; | ||
| 40 | + onSaved: () => void | Promise<unknown>; | ||
| 41 | +}) { | ||
| 42 | + const t = useT(); | ||
| 43 | + const [settings] = createResource(() => getSettings()); | ||
| 44 | + const statuses = createMemo<AttendanceStatus[]>(() => | ||
| 45 | + orderRollCallStatuses(settings.latest?.attendance_statuses ?? ATTENDANCE_STATUSES.map((item) => item.value)), | ||
| 46 | + ); | ||
| 47 | + | ||
| 48 | + // Marks this component saved, shown until the refetched roster carries them. | ||
| 49 | + const [savedLocal, setSavedLocal] = createSignal<Record<string, AttendanceStatus>>({}); | ||
| 50 | + createEffect(on(() => props.roster, () => setSavedLocal({}), { defer: true })); | ||
| 51 | + const saved = createMemo<Record<string, AttendanceStatus | null>>(() => { | ||
| 52 | + const map: Record<string, AttendanceStatus | null> = {}; | ||
| 53 | + for (const row of props.roster) map[row.user.id] = row.status; | ||
| 54 | + return { ...map, ...savedLocal() }; | ||
| 55 | + }); | ||
| 56 | + | ||
| 57 | + const [draft, setDraft] = createSignal<Record<string, AttendanceStatus | undefined>>({}); | ||
| 58 | + const [rowErrors, setRowErrors] = createSignal<Record<string, string>>({}); | ||
| 59 | + const [progress, setProgress] = createSignal<{ done: number; total: number } | null>(null); | ||
| 60 | + const [summary, setSummary] = createSignal<{ kind: "success" | "destructive"; text: string } | null>(null); | ||
| 61 | + const [query, setQuery] = createSignal(""); | ||
| 62 | + const [onlyUnmarked, setOnlyUnmarked] = createSignal(false); | ||
| 63 | + const [page, setPage] = createSignal(0); | ||
| 64 | + | ||
| 65 | + const effective = (userId: string) => draft()[userId] ?? saved()[userId] ?? undefined; | ||
| 66 | + const changes = createMemo(() => rollCallChanges(saved(), draft())); | ||
| 67 | + const markedCount = createMemo(() => props.roster.filter((row) => effective(row.user.id) != null).length); | ||
| 68 | + const counts = createMemo(() => { | ||
| 69 | + const tally: Record<string, number> = {}; | ||
| 70 | + for (const row of props.roster) { | ||
| 71 | + const status = effective(row.user.id); | ||
| 72 | + if (status) tally[status] = (tally[status] ?? 0) + 1; | ||
| 73 | + } | ||
| 74 | + return tally; | ||
| 75 | + }); | ||
| 76 | + const unmarkedIds = createMemo(() => props.roster.filter((row) => effective(row.user.id) == null).map((row) => row.user.id)); | ||
| 77 | + | ||
| 78 | + const visible = createMemo(() => { | ||
| 79 | + const q = query().trim(); | ||
| 80 | + return props.roster.filter((row) => { | ||
| 81 | + if (onlyUnmarked() && effective(row.user.id) != null) return false; | ||
| 82 | + return !q || matchesSearch(q, personLabel(row.user), row.user.username, row.user.student_number); | ||
| 83 | + }); | ||
| 84 | + }); | ||
| 85 | + const pageCount = () => Math.max(1, Math.ceil(visible().length / PAGE_SIZE)); | ||
| 86 | + createEffect(on([query, onlyUnmarked], () => setPage(0), { defer: true })); | ||
| 87 | + createEffect(() => { | ||
| 88 | + if (page() >= pageCount()) setPage(pageCount() - 1); | ||
| 89 | + }); | ||
| 90 | + const pageRows = createMemo(() => visible().slice(page() * PAGE_SIZE, (page() + 1) * PAGE_SIZE)); | ||
| 91 | + | ||
| 92 | + const busy = () => progress() != null; | ||
| 93 | + const locked = () => !props.open || busy(); | ||
| 94 | + | ||
| 95 | + const statusLabel = (status: AttendanceStatus) => { | ||
| 96 | + const key = eventStatusLabelKey(status); | ||
| 97 | + if (key) return t(key); | ||
| 98 | + const meta = getAttendanceStatusMeta(status); | ||
| 99 | + return meta ? t(meta.key) : status; | ||
| 100 | + }; | ||
| 101 | + | ||
| 102 | + const pick = (userId: string, status: AttendanceStatus) => { | ||
| 103 | + if (locked()) return; | ||
| 104 | + setSummary(null); | ||
| 105 | + setDraft((current) => { | ||
| 106 | + const next = { ...current }; | ||
| 107 | + // Tapping the drafted status again drops the pick back to the saved one. | ||
| 108 | + if (current[userId] === status || saved()[userId] === status) delete next[userId]; | ||
| 109 | + else next[userId] = status; | ||
| 110 | + return next; | ||
| 111 | + }); | ||
| 112 | + setRowErrors((current) => { | ||
| 113 | + if (!(userId in current)) return current; | ||
| 114 | + const next = { ...current }; | ||
| 115 | + delete next[userId]; | ||
| 116 | + return next; | ||
| 117 | + }); | ||
| 118 | + }; | ||
| 119 | + | ||
| 120 | + const markRestPresent = () => { | ||
| 121 | + if (locked()) return; | ||
| 122 | + setSummary(null); | ||
| 123 | + setDraft((current) => { | ||
| 124 | + const next = { ...current }; | ||
| 125 | + for (const userId of unmarkedIds()) next[userId] = "present"; | ||
| 126 | + return next; | ||
| 127 | + }); | ||
| 128 | + }; | ||
| 129 | + | ||
| 130 | + const save = async () => { | ||
| 131 | + const queue = changes(); | ||
| 132 | + if (queue.length === 0 || locked()) return; | ||
| 133 | + setSummary(null); | ||
| 134 | + setRowErrors({}); | ||
| 135 | + setProgress({ done: 0, total: queue.length }); | ||
| 136 | + const result = await saveRollCallChanges( | ||
| 137 | + queue, | ||
| 138 | + (change) => postEventAttendance(props.eventId, { user_id: change.userId, status: change.status }), | ||
| 139 | + (done, total) => setProgress({ done, total }), | ||
| 140 | + ); | ||
| 141 | + setProgress(null); | ||
| 142 | + if (result.saved.length > 0) { | ||
| 143 | + setSavedLocal((current) => ({ | ||
| 144 | + ...current, | ||
| 145 | + ...Object.fromEntries(result.saved.map((change) => [change.userId, change.status])), | ||
| 146 | + })); | ||
| 147 | + setDraft((current) => { | ||
| 148 | + const next = { ...current }; | ||
| 149 | + for (const change of result.saved) delete next[change.userId]; | ||
| 150 | + return next; | ||
| 151 | + }); | ||
| 152 | + } | ||
| 153 | + setRowErrors(Object.fromEntries(result.failed.map((item) => [item.change.userId, formatApiError(item.error)]))); | ||
| 154 | + if (result.failed.length > 0) { | ||
| 155 | + setSummary({ | ||
| 156 | + kind: "destructive", | ||
| 157 | + text: t("events.rollCall.saveFailed", { failed: result.failed.length, total: queue.length }), | ||
| 158 | + }); | ||
| 159 | + } else { | ||
| 160 | + setSummary({ kind: "success", text: t("events.rollCall.saved", { count: result.saved.length }) }); | ||
| 161 | + } | ||
| 162 | + if (result.saved.length > 0) await props.onSaved(); | ||
| 163 | + }; | ||
| 164 | + | ||
| 165 | + return ( | ||
| 166 | + <div class="space-y-3"> | ||
| 167 | + <Show when={!props.open}> | ||
| 168 | + <Alert variant="info">{props.closedReason ?? t("events.rollCall.notStarted")}</Alert> | ||
| 169 | + </Show> | ||
| 170 | + <Show | ||
| 171 | + when={props.roster.length > 0} | ||
| 172 | + fallback={<EmptyState kind="people" title={t("events.rollCall.emptyRoster")} />} | ||
| 173 | + > | ||
| 174 | + <div class="space-y-2.5 rounded-xl border border-border-line bg-surface-base p-3 shadow-xs sm:p-4"> | ||
| 175 | + <div class="flex flex-wrap items-center justify-between gap-3"> | ||
| 176 | + <p class="text-sm font-semibold text-text-strong" role="status"> | ||
| 177 | + {t("rollCall.progress", { marked: markedCount(), total: props.roster.length })} | ||
| 178 | + </p> | ||
| 179 | + <div class="flex flex-wrap justify-end gap-1.5"> | ||
| 180 | + <For each={statuses()}> | ||
| 181 | + {(status) => ( | ||
| 182 | + <Show when={counts()[status]}> | ||
| 183 | + <span class={cn("rounded-full border px-2 py-0.5 text-xs font-medium", getAttendanceStatusMeta(status)?.class)}> | ||
| 184 | + {statusLabel(status)} {counts()[status]} | ||
| 185 | + </span> | ||
| 186 | + </Show> | ||
| 187 | + )} | ||
| 188 | + </For> | ||
| 189 | + </div> | ||
| 190 | + </div> | ||
| 191 | + <div class="h-1.5 overflow-hidden rounded-full bg-surface-tint" aria-hidden="true"> | ||
| 192 | + <div | ||
| 193 | + class="h-full rounded-full bg-success transition-[width] duration-200" | ||
| 194 | + style={{ width: `${props.roster.length ? (markedCount() / props.roster.length) * 100 : 0}%` }} | ||
| 195 | + /> | ||
| 196 | + </div> | ||
| 197 | + <div class="flex flex-wrap items-center gap-2"> | ||
| 198 | + <DataTableSearch | ||
| 199 | + value={query()} | ||
| 200 | + onChange={setQuery} | ||
| 201 | + placeholder={t("events.selectAttendee")} | ||
| 202 | + hint={t("events.rollCall.searchHint")} | ||
| 203 | + class="sm:max-w-60" | ||
| 204 | + /> | ||
| 205 | + <Button | ||
| 206 | + type="button" | ||
| 207 | + size="sm" | ||
| 208 | + variant="outline" | ||
| 209 | + class="h-8 rounded-lg" | ||
| 210 | + disabled={locked() || unmarkedIds().length === 0} | ||
| 211 | + onClick={markRestPresent} | ||
| 212 | + > | ||
| 213 | + <IconCheck class="h-4 w-4" /> | ||
| 214 | + {t("events.rollCall.markRestPresent")} | ||
| 215 | + </Button> | ||
| 216 | + <Button | ||
| 217 | + type="button" | ||
| 218 | + size="sm" | ||
| 219 | + variant="outline" | ||
| 220 | + class="h-8 rounded-lg" | ||
| 221 | + aria-pressed={onlyUnmarked()} | ||
| 222 | + onClick={() => setOnlyUnmarked((value) => !value)} | ||
| 223 | + > | ||
| 224 | + {t("rollCall.onlyUnmarked")} | ||
| 225 | + </Button> | ||
| 226 | + </div> | ||
| 227 | + </div> | ||
| 228 | + | ||
| 229 | + <Show | ||
| 230 | + when={pageRows().length > 0} | ||
| 231 | + fallback={ | ||
| 232 | + <p class="py-6 text-center text-sm text-muted-foreground"> | ||
| 233 | + {query().trim() ? t("events.noAttendees") : t("rollCall.allMarked")} | ||
| 234 | + </p> | ||
| 235 | + } | ||
| 236 | + > | ||
| 237 | + <ul class="divide-y divide-border-hairline rounded-xl border border-border-line bg-surface-base px-3 shadow-xs sm:px-4"> | ||
| 238 | + <For each={pageRows()}> | ||
| 239 | + {(row) => { | ||
| 240 | + const userId = row.user.id; | ||
| 241 | + const current = () => effective(userId); | ||
| 242 | + const pending = () => draft()[userId] != null && draft()[userId] !== saved()[userId]; | ||
| 243 | + const rowError = () => rowErrors()[userId]; | ||
| 244 | + const name = () => personLabel(row.user); | ||
| 245 | + return ( | ||
| 246 | + <li class="flex flex-col gap-2 py-2.5 sm:flex-row sm:items-center"> | ||
| 247 | + <div class="flex min-w-0 flex-1 items-center gap-2"> | ||
| 248 | + <span | ||
| 249 | + class={cn( | ||
| 250 | + "h-2 w-2 shrink-0 rounded-full", | ||
| 251 | + rowError() ? "bg-destructive" : pending() ? "bg-warning" : current() ? "bg-success" : "bg-border-line", | ||
| 252 | + )} | ||
| 253 | + aria-hidden="true" | ||
| 254 | + /> | ||
| 255 | + <div class="min-w-0"> | ||
| 256 | + <p class="truncate text-sm font-medium">{name()}</p> | ||
| 257 | + <p class={cn("truncate text-xs", rowError() ? "text-destructive-text" : "text-muted-foreground")}> | ||
| 258 | + {rowError() | ||
| 259 | + ? rowError() | ||
| 260 | + : pending() | ||
| 261 | + ? t("events.rollCall.unsaved", { status: statusLabel(current()!) }) | ||
| 262 | + : current() | ||
| 263 | + ? statusLabel(current()!) | ||
| 264 | + : t("rollCall.unmarked")} | ||
| 265 | + </p> | ||
| 266 | + </div> | ||
| 267 | + </div> | ||
| 268 | + <div role="radiogroup" aria-label={name()} class="grid grid-cols-4 gap-1 sm:flex"> | ||
| 269 | + <For each={statuses()}> | ||
| 270 | + {(status) => { | ||
| 271 | + const selected = () => current() === status; | ||
| 272 | + return ( | ||
| 273 | + <button | ||
| 274 | + type="button" | ||
| 275 | + role="radio" | ||
| 276 | + aria-checked={selected()} | ||
| 277 | + disabled={locked()} | ||
| 278 | + class={cn( | ||
| 279 | + "h-9 min-w-0 rounded-lg border px-2.5 text-xs font-semibold transition-colors outline-hidden focus-visible:ring-2 focus-visible:ring-ring disabled:opacity-60", | ||
| 280 | + selected() | ||
| 281 | + ? getAttendanceStatusMeta(status)?.class ?? "border-primary bg-primary/10 text-primary-text" | ||
| 282 | + : "border-border-line bg-surface-base text-muted-foreground hover:bg-muted/60 hover:text-foreground", | ||
| 283 | + )} | ||
| 284 | + onClick={() => pick(userId, status)} | ||
| 285 | + > | ||
| 286 | + {statusLabel(status)} | ||
| 287 | + </button> | ||
| 288 | + ); | ||
| 289 | + }} | ||
| 290 | + </For> | ||
| 291 | + </div> | ||
| 292 | + </li> | ||
| 293 | + ); | ||
| 294 | + }} | ||
| 295 | + </For> | ||
| 296 | + </ul> | ||
| 297 | + </Show> | ||
| 298 | + <TablePagination | ||
| 299 | + pageIndex={page()} | ||
| 300 | + pageCount={pageCount()} | ||
| 301 | + pageSize={PAGE_SIZE} | ||
| 302 | + total={visible().length} | ||
| 303 | + onPageChange={setPage} | ||
| 304 | + /> | ||
| 305 | + | ||
| 306 | + <Show when={summary()}> | ||
| 307 | + {(item) => <Alert variant={item().kind}>{item().text}</Alert>} | ||
| 308 | + </Show> | ||
| 309 | + | ||
| 310 | + <div class="sticky bottom-0 z-10 flex flex-wrap items-center justify-end gap-3 rounded-xl border border-border-line bg-surface-base px-3 py-2.5 shadow-xs sm:px-4"> | ||
| 311 | + <p class="mr-auto text-xs text-muted-foreground" aria-live="polite"> | ||
| 312 | + {progress() | ||
| 313 | + ? t("rollCall.marking", { done: progress()!.done, total: progress()!.total }) | ||
| 314 | + : changes().length > 0 | ||
| 315 | + ? t("events.rollCall.pendingChanges", { count: changes().length }) | ||
| 316 | + : t("events.rollCall.noChanges")} | ||
| 317 | + </p> | ||
| 318 | + <Show when={changes().length > 0 && !busy()}> | ||
| 319 | + <Button type="button" variant="ghost" size="sm" class="h-9 rounded-lg" onClick={() => { setDraft({}); setRowErrors({}); setSummary(null); }}> | ||
| 320 | + {t("events.rollCall.discard")} | ||
| 321 | + </Button> | ||
| 322 | + </Show> | ||
| 323 | + <Button | ||
| 324 | + type="button" | ||
| 325 | + size="sm" | ||
| 326 | + class="h-9 min-w-[7.5rem] rounded-lg" | ||
| 327 | + disabled={locked() || changes().length === 0} | ||
| 328 | + onClick={() => void save()} | ||
| 329 | + > | ||
| 330 | + {t("events.saveStudentAttendance")} | ||
| 331 | + </Button> | ||
| 332 | + </div> | ||
| 333 | + </Show> | ||
| 334 | + </div> | ||
| 335 | + ); | ||
| 336 | +} | ||
src/components/exams/exam-form.tsxmodified+26 -3
| @@ -16,6 +16,7 @@ import { Select } from "@/components/ui/select"; | |||
| 16 | import { Textarea } from "@/components/ui/textarea"; | 16 | import { Textarea } from "@/components/ui/textarea"; |
| 17 | import { examKindLabel } from "@/lib/exam-labels"; | 17 | import { examKindLabel } from "@/lib/exam-labels"; |
| 18 | import { pickCurrentTerm } from "@/lib/terms"; | 18 | import { pickCurrentTerm } from "@/lib/terms"; |
| 19 | +import { countExamQuestions, isPublishing } from "@/lib/exam-publish"; | ||
| 19 | import { useT } from "@/stores/preferences-context"; | 20 | import { useT } from "@/stores/preferences-context"; |
| 20 | 21 | ||
| 21 | function dateInputFromMs(ms: number | null | undefined): string { | 22 | function dateInputFromMs(ms: number | null | undefined): string { |
| @@ -87,7 +88,9 @@ export function ExamForm(props: { | |||
| 87 | const [maxAttempts, setMaxAttempts] = createSignal(String(props.initial?.max_attempts ?? 1)); | 88 | const [maxAttempts, setMaxAttempts] = createSignal(String(props.initial?.max_attempts ?? 1)); |
| 88 | const [allowRejoin, setAllowRejoin] = createSignal(props.initial?.allow_rejoin ?? true); | 89 | const [allowRejoin, setAllowRejoin] = createSignal(props.initial?.allow_rejoin ?? true); |
| 89 | const [allowReview, setAllowReview] = createSignal(props.initial?.allow_review ?? false); | 90 | const [allowReview, setAllowReview] = createSignal(props.initial?.allow_review ?? false); |
| 90 | - const [draft, setDraft] = createSignal(props.initial?.draft ?? false); | 91 | + // A new exam starts as a draft: its questions are only added in step 2, so |
| 92 | + // publishing on create would put an empty exam in front of students. | ||
| 93 | + const [draft, setDraft] = createSignal(props.initial?.draft ?? true); | ||
| 91 | const [startsDate, setStartsDate] = createSignal(dateInputFromMs(props.initial?.starts_at)); | 94 | const [startsDate, setStartsDate] = createSignal(dateInputFromMs(props.initial?.starts_at)); |
| 92 | const [startsTime, setStartsTime] = createSignal(timeInputFromMs(props.initial?.starts_at)); | 95 | const [startsTime, setStartsTime] = createSignal(timeInputFromMs(props.initial?.starts_at)); |
| 93 | const [endsDate, setEndsDate] = createSignal(dateInputFromMs(props.initial?.ends_at)); | 96 | const [endsDate, setEndsDate] = createSignal(dateInputFromMs(props.initial?.ends_at)); |
| @@ -103,6 +106,8 @@ export function ExamForm(props: { | |||
| 103 | const [pending, setPending] = createSignal(false); | 106 | const [pending, setPending] = createSignal(false); |
| 104 | const [confirmOpen, setConfirmOpen] = createSignal(false); | 107 | const [confirmOpen, setConfirmOpen] = createSignal(false); |
| 105 | const [pendingValues, setPendingValues] = createSignal<ExamFormValues | null>(null); | 108 | const [pendingValues, setPendingValues] = createSignal<ExamFormValues | null>(null); |
| 109 | + /** Set when the pending update would publish an exam that has no questions. */ | ||
| 110 | + const [publishingEmpty, setPublishingEmpty] = createSignal(false); | ||
| 106 | const isEdit = () => !!props.initial?.id; | 111 | const isEdit = () => !!props.initial?.id; |
| 107 | const [settings] = createResource(() => getSettings()); | 112 | const [settings] = createResource(() => getSettings()); |
| 108 | const [serverTime] = createResource(() => getTime().catch(() => ({ now: Date.now() }))); | 113 | const [serverTime] = createResource(() => getTime().catch(() => ({ now: Date.now() }))); |
| @@ -160,7 +165,7 @@ export function ExamForm(props: { | |||
| 160 | setHasRetakes(false); | 165 | setHasRetakes(false); |
| 161 | setMaxAttempts("1"); | 166 | setMaxAttempts("1"); |
| 162 | setAllowRejoin(true); | 167 | setAllowRejoin(true); |
| 163 | - setDraft(false); | 168 | + setDraft(true); |
| 164 | setStartsDate(""); | 169 | setStartsDate(""); |
| 165 | setStartsTime(""); | 170 | setStartsTime(""); |
| 166 | setEndsDate(""); | 171 | setEndsDate(""); |
| @@ -212,6 +217,16 @@ export function ExamForm(props: { | |||
| 212 | } satisfies ExamFormValues; | 217 | } satisfies ExamFormValues; |
| 213 | 218 | ||
| 214 | if (isEdit()) { | 219 | if (isEdit()) { |
| 220 | + let empty = false; | ||
| 221 | + const examId = props.initial?.id; | ||
| 222 | + if (examId && isPublishing(props.initial, values.draft)) { | ||
| 223 | + try { | ||
| 224 | + empty = (await countExamQuestions(examId)) === 0; | ||
| 225 | + } catch { | ||
| 226 | + // The count is advisory; the update confirmation still guards the save. | ||
| 227 | + } | ||
| 228 | + } | ||
| 229 | + setPublishingEmpty(empty); | ||
| 215 | setPendingValues(values); | 230 | setPendingValues(values); |
| 216 | setConfirmOpen(true); | 231 | setConfirmOpen(true); |
| 217 | return; | 232 | return; |
| @@ -448,6 +463,9 @@ export function ExamForm(props: { | |||
| 448 | <div> | 463 | <div> |
| 449 | <span class="font-medium">{t("exams.draft")}</span> | 464 | <span class="font-medium">{t("exams.draft")}</span> |
| 450 | <p class="text-xs font-normal text-muted-foreground">{t("exams.draftHelp")}</p> | 465 | <p class="text-xs font-normal text-muted-foreground">{t("exams.draftHelp")}</p> |
| 466 | + <Show when={!isEdit() && !draft()}> | ||
| 467 | + <p class="mt-1 text-xs font-medium text-warning-text">{t("exams.publishOnCreateWarning")}</p> | ||
| 468 | + </Show> | ||
| 451 | </div> | 469 | </div> |
| 452 | </label> | 470 | </label> |
| 453 | </div> | 471 | </div> |
| @@ -470,7 +488,12 @@ export function ExamForm(props: { | |||
| 470 | open={confirmOpen()} | 488 | open={confirmOpen()} |
| 471 | onOpenChange={setConfirmOpen} | 489 | onOpenChange={setConfirmOpen} |
| 472 | title={t("confirm.updateTitle")} | 490 | title={t("confirm.updateTitle")} |
| 473 | - summary={t("confirm.updateExam", { title: pendingValues()?.title ?? "" })} | 491 | + summary={ |
| 492 | + <Show when={publishingEmpty()} fallback={t("confirm.updateExam", { title: pendingValues()?.title ?? "" })}> | ||
| 493 | + <span class="block">{t("confirm.updateExam", { title: pendingValues()?.title ?? "" })}</span> | ||
| 494 | + <span class="mt-2 block font-medium text-warning-text">{t("exams.publishEmptyWarning")}</span> | ||
| 495 | + </Show> | ||
| 496 | + } | ||
| 474 | onConfirm={async () => { | 497 | onConfirm={async () => { |
| 475 | const values = pendingValues(); | 498 | const values = pendingValues(); |
| 476 | if (!values) return; | 499 | if (!values) return; |
src/components/insights/insight-student-analysis-tabs.tsxmodified+6 -3
| @@ -7,6 +7,7 @@ import { ChartProgressRing, type ProgressRingSegment } from "@/components/ui/cha | |||
| 7 | import { EmptyInline } from "@/components/ui/empty-inline"; | 7 | import { EmptyInline } from "@/components/ui/empty-inline"; |
| 8 | import { IconAlert, IconChevronDown } from "@/components/ui/icons"; | 8 | import { IconAlert, IconChevronDown } from "@/components/ui/icons"; |
| 9 | import { Tabs, TabsContent, TabsList, TabsTrigger } from "@/components/ui/tabs"; | 9 | import { Tabs, TabsContent, TabsList, TabsTrigger } from "@/components/ui/tabs"; |
| 10 | +import { formatNumber } from "@/lib/format"; | ||
| 10 | import { isRecord, type UnknownRecord } from "@/lib/is-record"; | 11 | import { isRecord, type UnknownRecord } from "@/lib/is-record"; |
| 11 | import { usePreferences } from "@/stores/preferences-context"; | 12 | import { usePreferences } from "@/stores/preferences-context"; |
| 12 | 13 | ||
| @@ -38,6 +39,7 @@ function AttendanceChart(props: { value: unknown; t: (key: string) => string }) | |||
| 38 | } | 39 | } |
| 39 | 40 | ||
| 40 | function MarksChart(props: { value: unknown; t: (key: string) => string }) { | 41 | function MarksChart(props: { value: unknown; t: (key: string) => string }) { |
| 42 | + const { locale } = usePreferences(); | ||
| 41 | const courses = () => Object.entries(obj(obj(props.value).courses)); | 43 | const courses = () => Object.entries(obj(obj(props.value).courses)); |
| 42 | const items = (): ChartBarItem[] => courses().flatMap(([id, raw]) => { | 44 | const items = (): ChartBarItem[] => courses().flatMap(([id, raw]) => { |
| 43 | const stat = obj(raw); | 45 | const stat = obj(raw); |
| @@ -47,7 +49,7 @@ function MarksChart(props: { value: unknown; t: (key: string) => string }) { | |||
| 47 | label: String(stat.course_title ?? id).slice(0, 32), | 49 | label: String(stat.course_title ?? id).slice(0, 32), |
| 48 | value, | 50 | value, |
| 49 | max: 100, | 51 | max: 100, |
| 50 | - formattedValue: value.toLocaleString("tr-TR", { maximumFractionDigits: 1 }), | 52 | + formattedValue: formatNumber(value, locale()), |
| 51 | }]; | 53 | }]; |
| 52 | }); | 54 | }); |
| 53 | return ( | 55 | return ( |
| @@ -62,6 +64,7 @@ function MarksChart(props: { value: unknown; t: (key: string) => string }) { | |||
| 62 | } | 64 | } |
| 63 | 65 | ||
| 64 | function StudyChart(props: { value: unknown; t: (key: string) => string }) { | 66 | function StudyChart(props: { value: unknown; t: (key: string) => string }) { |
| 67 | + const { locale } = usePreferences(); | ||
| 65 | const recent = () => obj(obj(props.value).recent_28d); | 68 | const recent = () => obj(obj(props.value).recent_28d); |
| 66 | const hours = () => { | 69 | const hours = () => { |
| 67 | const milliseconds = num(recent().total_focus_ms); | 70 | const milliseconds = num(recent().total_focus_ms); |
| @@ -78,7 +81,7 @@ function StudyChart(props: { value: unknown; t: (key: string) => string }) { | |||
| 78 | id: "current", | 81 | id: "current", |
| 79 | label: props.t("insights.analysis.currentPeriod"), | 82 | label: props.t("insights.analysis.currentPeriod"), |
| 80 | value: currentHours, | 83 | value: currentHours, |
| 81 | - formattedValue: currentHours.toLocaleString("tr-TR", { maximumFractionDigits: 1 }), | 84 | + formattedValue: formatNumber(currentHours, locale()), |
| 82 | colorClass: "bg-primary", | 85 | colorClass: "bg-primary", |
| 83 | }); | 86 | }); |
| 84 | } | 87 | } |
| @@ -87,7 +90,7 @@ function StudyChart(props: { value: unknown; t: (key: string) => string }) { | |||
| 87 | id: "previous", | 90 | id: "previous", |
| 88 | label: props.t("insights.analysis.previousPeriod"), | 91 | label: props.t("insights.analysis.previousPeriod"), |
| 89 | value: previousHours, | 92 | value: previousHours, |
| 90 | - formattedValue: previousHours.toLocaleString("tr-TR", { maximumFractionDigits: 1 }), | 93 | + formattedValue: formatNumber(previousHours, locale()), |
| 91 | colorClass: "bg-info", | 94 | colorClass: "bg-info", |
| 92 | }); | 95 | }); |
| 93 | } | 96 | } |
src/components/insights/insight-students-table.tsxmodified+6 -6
| @@ -63,7 +63,7 @@ export function InsightStudentsTable(props: { | |||
| 63 | id: "student", | 63 | id: "student", |
| 64 | accessorFn: (row) => row.name, | 64 | accessorFn: (row) => row.name, |
| 65 | header: rt("student"), | 65 | header: rt("student"), |
| 66 | - size: 130, | 66 | + size: 120, |
| 67 | meta: { align: "center" }, | 67 | meta: { align: "center" }, |
| 68 | cell: (cell) => ( | 68 | cell: (cell) => ( |
| 69 | <Link to="/ai/insights/$userId" params={{ userId: cell.row.original.id }} class="font-medium text-text-default hover:text-primary-text hover:underline"> | 69 | <Link to="/ai/insights/$userId" params={{ userId: cell.row.original.id }} class="font-medium text-text-default hover:text-primary-text hover:underline"> |
| @@ -73,7 +73,7 @@ export function InsightStudentsTable(props: { | |||
| 73 | }, | 73 | }, |
| 74 | { | 74 | { |
| 75 | id: "status", | 75 | id: "status", |
| 76 | - size: 110, | 76 | + size: 108, |
| 77 | accessorFn: (row) => row.state, | 77 | accessorFn: (row) => row.state, |
| 78 | header: rt("status" as never), | 78 | header: rt("status" as never), |
| 79 | meta: { align: "center" }, | 79 | meta: { align: "center" }, |
| @@ -117,7 +117,7 @@ export function InsightStudentsTable(props: { | |||
| 117 | }, | 117 | }, |
| 118 | { | 118 | { |
| 119 | id: "marks", | 119 | id: "marks", |
| 120 | - size: 135, | 120 | + size: 148, |
| 121 | accessorFn: (row) => row.marks.average ?? -1, | 121 | accessorFn: (row) => row.marks.average ?? -1, |
| 122 | header: rt("marksAverage"), | 122 | header: rt("marksAverage"), |
| 123 | meta: { align: "center" }, | 123 | meta: { align: "center" }, |
| @@ -125,7 +125,7 @@ export function InsightStudentsTable(props: { | |||
| 125 | }, | 125 | }, |
| 126 | { | 126 | { |
| 127 | id: "attendance", | 127 | id: "attendance", |
| 128 | - size: 125, | 128 | + size: 133, |
| 129 | accessorFn: (row) => (row.attendance.observed > 0 ? row.attendance.rate ?? -1 : -1), | 129 | accessorFn: (row) => (row.attendance.observed > 0 ? row.attendance.rate ?? -1 : -1), |
| 130 | header: rt("attendanceRate"), | 130 | header: rt("attendanceRate"), |
| 131 | meta: { align: "center" }, | 131 | meta: { align: "center" }, |
| @@ -145,7 +145,7 @@ export function InsightStudentsTable(props: { | |||
| 145 | }, | 145 | }, |
| 146 | { | 146 | { |
| 147 | id: "confidence", | 147 | id: "confidence", |
| 148 | - size: 105, | 148 | + size: 97, |
| 149 | accessorFn: (row) => row.confidence ?? "", | 149 | accessorFn: (row) => row.confidence ?? "", |
| 150 | header: rt("confidence"), | 150 | header: rt("confidence"), |
| 151 | meta: { align: "center" }, | 151 | meta: { align: "center" }, |
| @@ -153,7 +153,7 @@ export function InsightStudentsTable(props: { | |||
| 153 | }, | 153 | }, |
| 154 | { | 154 | { |
| 155 | id: "computedAt", | 155 | id: "computedAt", |
| 156 | - size: 95, | 156 | + size: 100, |
| 157 | accessorFn: (row) => row.computed_at ?? 0, | 157 | accessorFn: (row) => row.computed_at ?? 0, |
| 158 | header: t("insights.computedAt"), | 158 | header: t("insights.computedAt"), |
| 159 | meta: { align: "center", cellClass: "text-xs text-muted-foreground whitespace-nowrap" }, | 159 | meta: { align: "center", cellClass: "text-xs text-muted-foreground whitespace-nowrap" }, |
src/components/layout/command-palette.test.tsxmodified+26 -0
| @@ -16,6 +16,14 @@ vi.mock("@/stores/modules-context", () => ({ | |||
| 16 | })); | 16 | })); |
| 17 | vi.mock("@/api/users", () => ({ getUserSearch: vi.fn(async () => ({ items: [], total: 0, limit: 10, offset: 0 })) })); | 17 | vi.mock("@/api/users", () => ({ getUserSearch: vi.fn(async () => ({ items: [], total: 0, limit: 10, offset: 0 })) })); |
| 18 | vi.mock("@/api/classes", () => ({ getMyClasses: vi.fn(async () => ({ items: [], total: 0, limit: 10, offset: 0 })) })); | 18 | vi.mock("@/api/classes", () => ({ getMyClasses: vi.fn(async () => ({ items: [], total: 0, limit: 10, offset: 0 })) })); |
| 19 | +vi.mock("@/lib/command-search", async (importOriginal) => ({ | ||
| 20 | + ...(await importOriginal<typeof import("@/lib/command-search")>()), | ||
| 21 | + loadCommandRecords: vi.fn(async () => [ | ||
| 22 | + { kind: "course", id: "c1", title: "Biyoloji", context: null, description: null, courseKind: "course", at: null }, | ||
| 23 | + { kind: "exam", id: "e1", title: "1. Yazılı", context: "Biyoloji — 10-B", description: null, at: null }, | ||
| 24 | + { kind: "course", id: "c2", title: "Kimya", context: null, description: null, courseKind: "course", at: null }, | ||
| 25 | + ]), | ||
| 26 | +})); | ||
| 19 | 27 | ||
| 20 | beforeEach(() => { | 28 | beforeEach(() => { |
| 21 | vi.spyOn(window, "scrollTo").mockImplementation(() => {}); | 29 | vi.spyOn(window, "scrollTo").mockImplementation(() => {}); |
| @@ -46,3 +54,21 @@ test("the palette is a combobox whose active option follows the arrow keys", asy | |||
| 46 | expect(field.getAttribute("aria-activedescendant")).toBe(options[1].id); | 54 | expect(field.getAttribute("aria-activedescendant")).toBe(options[1].id); |
| 47 | expect(options[1].getAttribute("aria-selected")).toBe("true"); | 55 | expect(options[1].getAttribute("aria-selected")).toBe("true"); |
| 48 | }); | 56 | }); |
| 57 | + | ||
| 58 | +test("typing a course name lists matching courses and exams as their own groups", async () => { | ||
| 59 | + render(() => ( | ||
| 60 | + <PreferencesProvider> | ||
| 61 | + <CommandPalette open onOpenChange={() => {}} /> | ||
| 62 | + </PreferencesProvider> | ||
| 63 | + )); | ||
| 64 | + | ||
| 65 | + const field = await screen.findByRole("combobox"); | ||
| 66 | + fireEvent.input(field, { target: { value: "biyoloji" } }); | ||
| 67 | + | ||
| 68 | + const courseOption = await screen.findByRole("option", { name: /^Biyoloji/ }); | ||
| 69 | + expect(courseOption).toBeTruthy(); | ||
| 70 | + expect(screen.getByRole("option", { name: /1\. Yazılı/ })).toBeTruthy(); | ||
| 71 | + expect(screen.queryByRole("option", { name: /Kimya/ })).toBeNull(); | ||
| 72 | + expect(screen.getByText("Courses")).toBeTruthy(); | ||
| 73 | + expect(screen.getByText("Exams")).toBeTruthy(); | ||
| 74 | +}); | ||
src/components/layout/command-palette.tsxmodified+112 -7
| @@ -19,6 +19,18 @@ import { | |||
| 19 | IconX, | 19 | IconX, |
| 20 | } from "@/components/ui/icons"; | 20 | } from "@/components/ui/icons"; |
| 21 | import { getUserSearch } from "@/api/users"; | 21 | import { getUserSearch } from "@/api/users"; |
| 22 | +import { | ||
| 23 | + COMMAND_RECORD_KINDS, | ||
| 24 | + COMMAND_RECORD_MIN_QUERY, | ||
| 25 | + COMMAND_RECORD_ROUTES, | ||
| 26 | + filterCommandRecords, | ||
| 27 | + loadCommandRecords, | ||
| 28 | + type CommandRecord, | ||
| 29 | + type CommandRecordKind, | ||
| 30 | +} from "@/lib/command-search"; | ||
| 31 | +import { courseKindLabel } from "@/lib/course-kind"; | ||
| 32 | +import { formatDate, formatDateTime } from "@/lib/format"; | ||
| 33 | +import type { MessageKey } from "@/i18n/messages"; | ||
| 22 | import { HOME_ITEM, visibleNavGroups } from "@/components/layout/nav-items"; | 34 | import { HOME_ITEM, visibleNavGroups } from "@/components/layout/nav-items"; |
| 23 | import { createStudentClassLabels } from "@/lib/student-classes"; | 35 | import { createStudentClassLabels } from "@/lib/student-classes"; |
| 24 | import { hasMinRole } from "@/lib/roles"; | 36 | import { hasMinRole } from "@/lib/roles"; |
| @@ -35,7 +47,21 @@ export type CommandPaletteProps = { | |||
| 35 | onOpenProfile?: () => void; | 47 | onOpenProfile?: () => void; |
| 36 | }; | 48 | }; |
| 37 | 49 | ||
| 38 | -type CommandCategory = "people" | "actions" | "pages" | "system"; | 50 | +type CommandCategory = "people" | CommandRecordKind | "actions" | "pages" | "system"; |
| 51 | + | ||
| 52 | +const RECORD_GROUP_KEY: Record<CommandRecordKind, MessageKey> = { | ||
| 53 | + course: "command.group.courses", | ||
| 54 | + exam: "command.group.exams", | ||
| 55 | + homework: "command.group.homework", | ||
| 56 | + event: "command.group.events", | ||
| 57 | +}; | ||
| 58 | + | ||
| 59 | +const RECORD_ICON: Record<CommandRecordKind, typeof IconSearch> = { | ||
| 60 | + course: IconBook, | ||
| 61 | + exam: IconExam, | ||
| 62 | + homework: IconHomework, | ||
| 63 | + event: IconCalendar, | ||
| 64 | +}; | ||
| 39 | 65 | ||
| 40 | type CommandItem = { | 66 | type CommandItem = { |
| 41 | id: string; | 67 | id: string; |
| @@ -83,6 +109,48 @@ export function CommandPalette(props: CommandPaletteProps) { | |||
| 83 | // each visible match is resolved to one (see `student-classes`). | 109 | // each visible match is resolved to one (see `student-classes`). |
| 84 | const classLabels = createStudentClassLabels(() => (people.latest?.items ?? []).map((person) => person.id)); | 110 | const classLabels = createStudentClassLabels(() => (people.latest?.items ?? []).map((person) => person.id)); |
| 85 | 111 | ||
| 112 | + // Courses, exams, homework and events the user's own list pages show. Only | ||
| 113 | + // kinds whose list page is in this user's nav are searched, read once per | ||
| 114 | + // open (cached briefly across reopens) and filtered client-side per keystroke. | ||
| 115 | + const recordKinds = createMemo<CommandRecordKind[]>(() => { | ||
| 116 | + const routes = new Set( | ||
| 117 | + visibleNavGroups(role(), modules.enabled()).flatMap((group) => group.items.map((item) => item.to)), | ||
| 118 | + ); | ||
| 119 | + return COMMAND_RECORD_KINDS.filter((kind) => routes.has(COMMAND_RECORD_ROUTES[kind])); | ||
| 120 | + }); | ||
| 121 | + const [records] = createResource( | ||
| 122 | + () => { | ||
| 123 | + const userRole = role(); | ||
| 124 | + const kinds = recordKinds(); | ||
| 125 | + return props.open && userRole && kinds.length > 0 ? { role: userRole, kinds } : null; | ||
| 126 | + }, | ||
| 127 | + (source) => loadCommandRecords(source.role, source.kinds), | ||
| 128 | + ); | ||
| 129 | + const recordDescription = (record: CommandRecord): string | undefined => { | ||
| 130 | + const locale = prefs.locale(); | ||
| 131 | + switch (record.kind) { | ||
| 132 | + case "course": | ||
| 133 | + return record.courseKind ? courseKindLabel(record.courseKind, t) : undefined; | ||
| 134 | + case "exam": | ||
| 135 | + return [record.context, record.at != null ? formatDateTime(record.at, locale) : null].filter(Boolean).join(" · ") || undefined; | ||
| 136 | + case "homework": | ||
| 137 | + return [record.context, record.at != null ? t("command.homeworkDue", { date: formatDate(record.at, locale) }) : null] | ||
| 138 | + .filter(Boolean) | ||
| 139 | + .join(" · ") || undefined; | ||
| 140 | + case "event": | ||
| 141 | + return record.at != null ? formatDateTime(record.at, locale) : undefined; | ||
| 142 | + } | ||
| 143 | + }; | ||
| 144 | + const openRecord = (record: CommandRecord) => { | ||
| 145 | + const params = { id: record.id }; | ||
| 146 | + if (record.kind === "course") void navigate({ to: "/courses/$id", params }); | ||
| 147 | + else if (record.kind === "exam") void navigate({ to: "/exams/$id", params }); | ||
| 148 | + else if (record.kind === "homework") void navigate({ to: "/homework/$id", params }); | ||
| 149 | + else void navigate({ to: "/events/$id", params }); | ||
| 150 | + }; | ||
| 151 | + const recordsLoading = () => | ||
| 152 | + records.loading && query().trim().length >= COMMAND_RECORD_MIN_QUERY && records.latest === undefined; | ||
| 153 | + | ||
| 86 | const items = createMemo<CommandItem[]>(() => { | 154 | const items = createMemo<CommandItem[]>(() => { |
| 87 | const list: CommandItem[] = []; | 155 | const list: CommandItem[] = []; |
| 88 | const userRole = role(); | 156 | const userRole = role(); |
| @@ -300,9 +368,19 @@ export function CommandPalette(props: CommandPaletteProps) { | |||
| 300 | title: person.display_name || person.username, | 368 | title: person.display_name || person.username, |
| 301 | description: classLabels()[person.id] ? `${classLabels()[person.id]} · ${person.username}` : person.username, | 369 | description: classLabels()[person.id] ? `${classLabels()[person.id]} · ${person.username}` : person.username, |
| 302 | icon: IconUsers, | 370 | icon: IconUsers, |
| 303 | - onSelect: () => void navigate({ to: "/admin/users/$id", params: { id: person.id } }), | 371 | + // Same destination as a row on the students list. |
| 372 | + onSelect: () => void navigate({ to: "/profile/$userId", params: { userId: person.id } }), | ||
| 373 | + })); | ||
| 374 | + const matchedRecords: CommandItem[] = filterCommandRecords(records.latest ?? [], q).map((record) => ({ | ||
| 375 | + id: `${record.kind}-${record.id}`, | ||
| 376 | + category: record.kind, | ||
| 377 | + categoryLabel: t(RECORD_GROUP_KEY[record.kind]), | ||
| 378 | + title: record.title, | ||
| 379 | + description: recordDescription(record), | ||
| 380 | + icon: RECORD_ICON[record.kind], | ||
| 381 | + onSelect: () => openRecord(record), | ||
| 304 | })); | 382 | })); |
| 305 | - return [...found, ...items().filter((item) => | 383 | + return [...found, ...matchedRecords, ...items().filter((item) => |
| 306 | matchesSearch(q, item.title, item.description, item.keywords, item.categoryLabel), | 384 | matchesSearch(q, item.title, item.description, item.keywords, item.categoryLabel), |
| 307 | )]; | 385 | )]; |
| 308 | }); | 386 | }); |
| @@ -321,7 +399,7 @@ export function CommandPalette(props: CommandPaletteProps) { | |||
| 321 | map.get(item.category)!.push({ item, globalIndex: idx }); | 399 | map.get(item.category)!.push({ item, globalIndex: idx }); |
| 322 | }); | 400 | }); |
| 323 | 401 | ||
| 324 | - const order: CommandCategory[] = ["people", "actions", "pages", "system"]; | 402 | + const order: CommandCategory[] = ["people", ...COMMAND_RECORD_KINDS, "actions", "pages", "system"]; |
| 325 | for (const cat of order) { | 403 | for (const cat of order) { |
| 326 | const itemsInCat = map.get(cat); | 404 | const itemsInCat = map.get(cat); |
| 327 | if (itemsInCat && itemsInCat.length > 0) { | 405 | if (itemsInCat && itemsInCat.length > 0) { |
| @@ -396,6 +474,9 @@ export function CommandPalette(props: CommandPaletteProps) { | |||
| 396 | <Dialog open={props.open} onOpenChange={props.onOpenChange}> | 474 | <Dialog open={props.open} onOpenChange={props.onOpenChange}> |
| 397 | <DialogContent | 475 | <DialogContent |
| 398 | class="max-h-[min(85vh,38rem)] max-w-2xl overflow-hidden rounded-lg p-0 shadow-2xl border border-black/8 dark:border-white/12 bg-popover" | 476 | class="max-h-[min(85vh,38rem)] max-w-2xl overflow-hidden rounded-lg p-0 shadow-2xl border border-black/8 dark:border-white/12 bg-popover" |
| 477 | + // The palette draws its own labelled close control: the dialog's | ||
| 478 | + // icon-only × sat beside the clear-search × and read as the same button. | ||
| 479 | + closeButton={false} | ||
| 399 | // The dialog's focus trap parks focus on the panel itself when it | 480 | // The dialog's focus trap parks focus on the panel itself when it |
| 400 | // opens, which used to swallow a focus() queued from an effect — the | 481 | // opens, which used to swallow a focus() queued from an effect — the |
| 401 | // palette opened with nothing focused and the first keystroke went | 482 | // palette opened with nothing focused and the first keystroke went |
| @@ -409,7 +490,7 @@ export function CommandPalette(props: CommandPaletteProps) { | |||
| 409 | <DialogDescription class="sr-only">{t("common.searchPlaceholder")}</DialogDescription> | 490 | <DialogDescription class="sr-only">{t("common.searchPlaceholder")}</DialogDescription> |
| 410 | 491 | ||
| 411 | {/* Search Bar Header */} | 492 | {/* Search Bar Header */} |
| 412 | - <div class="flex items-center gap-2.5 border-b border-border/80 px-4 py-3 pr-16 bg-muted/20"> | 493 | + <div class="flex items-center gap-2.5 border-b border-border/80 px-4 py-3 bg-muted/20"> |
| 413 | <IconSearch class="h-4 w-4 text-muted-foreground shrink-0" /> | 494 | <IconSearch class="h-4 w-4 text-muted-foreground shrink-0" /> |
| 414 | <input | 495 | <input |
| 415 | ref={inputRef} | 496 | ref={inputRef} |
| @@ -441,10 +522,21 @@ export function CommandPalette(props: CommandPaletteProps) { | |||
| 441 | > | 522 | > |
| 442 | <IconX class="h-3.5 w-3.5" /> | 523 | <IconX class="h-3.5 w-3.5" /> |
| 443 | </button> | 524 | </button> |
| 444 | - <span role="status" class="rounded-md bg-secondary px-2 py-0.5 text-xs font-semibold text-muted-foreground shrink-0 font-mono"> | 525 | + <span role="status" class="shrink-0 whitespace-nowrap rounded-md bg-secondary px-2 py-0.5 text-xs font-semibold text-muted-foreground"> |
| 445 | - {filteredItems().length} {t("dashboard.ready").toLowerCase()} | 526 | + {t("command.resultCount", { count: filteredItems().length })} |
| 446 | </span> | 527 | </span> |
| 447 | </Show> | 528 | </Show> |
| 529 | + <button | ||
| 530 | + type="button" | ||
| 531 | + class="ml-1 inline-flex h-7 shrink-0 items-center gap-1.5 rounded-md border border-border/80 bg-background px-2 text-xs font-medium text-muted-foreground transition-colors hover:bg-muted hover:text-foreground" | ||
| 532 | + onClick={() => props.onOpenChange(false)} | ||
| 533 | + aria-label={t("common.close")} | ||
| 534 | + title={t("common.close")} | ||
| 535 | + > | ||
| 536 | + {/* Keyboards get the key to press, touch screens the word. */} | ||
| 537 | + <kbd class="hidden font-mono text-[11px] font-semibold sm:inline">Esc</kbd> | ||
| 538 | + <span class="sm:hidden">{t("common.close")}</span> | ||
| 539 | + </button> | ||
| 448 | </div> | 540 | </div> |
| 449 | 541 | ||
| 450 | {/* What the field accepts — the palette takes names, pages and | 542 | {/* What the field accepts — the palette takes names, pages and |
| @@ -452,6 +544,19 @@ export function CommandPalette(props: CommandPaletteProps) { | |||
| 452 | <Show when={!query()}> | 544 | <Show when={!query()}> |
| 453 | <p class="border-b border-border/60 bg-muted/10 px-4 py-2 text-[11px] leading-snug text-muted-foreground"> | 545 | <p class="border-b border-border/60 bg-muted/10 px-4 py-2 text-[11px] leading-snug text-muted-foreground"> |
| 454 | {role() === "admin" ? t("search.hint.commandAdmin") : t("search.hint.command")} | 546 | {role() === "admin" ? t("search.hint.commandAdmin") : t("search.hint.command")} |
| 547 | + <Show when={recordKinds().length > 0}> | ||
| 548 | + {" "} | ||
| 549 | + {t("search.hint.commandRecords", { | ||
| 550 | + kinds: recordKinds() | ||
| 551 | + .map((kind) => t(RECORD_GROUP_KEY[kind]).toLocaleLowerCase(prefs.locale() === "tr" ? "tr-TR" : "en-US")) | ||
| 552 | + .join(", "), | ||
| 553 | + })} | ||
| 554 | + </Show> | ||
| 555 | + </p> | ||
| 556 | + </Show> | ||
| 557 | + <Show when={recordsLoading()}> | ||
| 558 | + <p role="status" class="border-b border-border/60 px-4 py-2 text-[11px] text-muted-foreground"> | ||
| 559 | + {t("command.recordsLoading")} | ||
| 455 | </p> | 560 | </p> |
| 456 | </Show> | 561 | </Show> |
| 457 | 562 | ||
src/components/layout/floating-action-button.tsxmodified+2 -1
| @@ -1,6 +1,7 @@ | |||
| 1 | import { Index, Show, createEffect, createSignal, onCleanup, onMount, type Component } from "solid-js"; | 1 | import { Index, Show, createEffect, createSignal, onCleanup, onMount, type Component } from "solid-js"; |
| 2 | import { IconChevronLeft, IconChevronRight, IconPlus, IconX } from "@/components/ui/icons"; | 2 | import { IconChevronLeft, IconChevronRight, IconPlus, IconX } from "@/components/ui/icons"; |
| 3 | import { cn } from "@/lib/cn"; | 3 | import { cn } from "@/lib/cn"; |
| 4 | +import { formatUnreadCount } from "@/lib/notifications"; | ||
| 4 | import { clamp01, radialOffsets, readFloatingButton, writeFloatingButton } from "@/lib/floating-button"; | 5 | import { clamp01, radialOffsets, readFloatingButton, writeFloatingButton } from "@/lib/floating-button"; |
| 5 | import { useT } from "@/stores/preferences-context"; | 6 | import { useT } from "@/stores/preferences-context"; |
| 6 | 7 | ||
| @@ -25,7 +26,7 @@ const TAP_SLOP = 8; | |||
| 25 | /** How close the button centre has to come to the hide target to snap into it. */ | 26 | /** How close the button centre has to come to the hide target to snap into it. */ |
| 26 | const HIDE_REACH = 64; | 27 | const HIDE_REACH = 64; |
| 27 | 28 | ||
| 28 | -const badgeText = (count: number) => (count > 9 ? "9+" : String(count)); | 29 | +const badgeText = formatUnreadCount; |
| 29 | const clamp = (value: number, min: number, max: number) => Math.min(max, Math.max(min, value)); | 30 | const clamp = (value: number, min: number, max: number) => Math.min(max, Math.max(min, value)); |
| 30 | 31 | ||
| 31 | /** | 32 | /** |
src/components/layout/notification-center.tsxmodified+8 -3
| @@ -3,6 +3,7 @@ import { useNavigate } from "@tanstack/solid-router"; | |||
| 3 | import { Popover, PopoverContent, PopoverTrigger } from "@/components/ui/popover"; | 3 | import { Popover, PopoverContent, PopoverTrigger } from "@/components/ui/popover"; |
| 4 | import { IconBell } from "@/components/ui/icons"; | 4 | import { IconBell } from "@/components/ui/icons"; |
| 5 | import { cn } from "@/lib/cn"; | 5 | import { cn } from "@/lib/cn"; |
| 6 | +import { formatUnreadCount } from "@/lib/notifications"; | ||
| 6 | import { createNotificationFeed } from "@/components/layout/notification-feed"; | 7 | import { createNotificationFeed } from "@/components/layout/notification-feed"; |
| 7 | import { NotificationList } from "@/components/layout/notification-list"; | 8 | import { NotificationList } from "@/components/layout/notification-list"; |
| 8 | import { useT } from "@/stores/preferences-context"; | 9 | import { useT } from "@/stores/preferences-context"; |
| @@ -34,12 +35,16 @@ export function NotificationCenter() { | |||
| 34 | open() && "bg-muted text-foreground" | 35 | open() && "bg-muted text-foreground" |
| 35 | )} | 36 | )} |
| 36 | title={t("notifications.title")} | 37 | title={t("notifications.title")} |
| 37 | - aria-label={t("notifications.title")} | 38 | + aria-label={ |
| 39 | + unreadCount() > 0 | ||
| 40 | + ? `${t("notifications.title")} — ${t("notifications.unreadCount", { count: unreadCount() })}` | ||
| 41 | + : t("notifications.title") | ||
| 42 | + } | ||
| 38 | > | 43 | > |
| 39 | <IconBell class="h-4 w-4" /> | 44 | <IconBell class="h-4 w-4" /> |
| 40 | <Show when={unreadCount() > 0}> | 45 | <Show when={unreadCount() > 0}> |
| 41 | - <span class="absolute -top-1 -right-1 flex h-5 min-w-5 items-center justify-center rounded-full bg-destructive px-1 text-[11px] font-bold text-destructive-foreground ring-2 ring-background"> | 46 | + <span class="absolute -top-1 -right-1 flex h-5 min-w-5 items-center justify-center rounded-full bg-destructive px-1 text-[11px] font-bold text-destructive-foreground ring-2 ring-background" aria-hidden="true"> |
| 42 | - {unreadCount() > 9 ? "9+" : unreadCount()} | 47 | + {formatUnreadCount(unreadCount())} |
| 43 | </span> | 48 | </span> |
| 44 | </Show> | 49 | </Show> |
| 45 | </PopoverTrigger> | 50 | </PopoverTrigger> |
src/components/layout/notification-list.tsxmodified+25 -33
| @@ -1,21 +1,18 @@ | |||
| 1 | import { For, Show, Suspense, createSignal } from "solid-js"; | 1 | import { For, Show, Suspense, createSignal } from "solid-js"; |
| 2 | import { Button } from "@/components/ui/button"; | 2 | import { Button } from "@/components/ui/button"; |
| 3 | -import { ComingSoonPanel } from "@/components/ui/coming-soon"; | ||
| 4 | import { ConfirmDialog } from "@/components/ui/confirm-dialog"; | 3 | import { ConfirmDialog } from "@/components/ui/confirm-dialog"; |
| 5 | -import { Tabs, TabsContent, TabsList, TabsTrigger } from "@/components/ui/tabs"; | ||
| 6 | import { | 4 | import { |
| 7 | IconBell, | 5 | IconBell, |
| 8 | IconCalendar, | 6 | IconCalendar, |
| 9 | IconChevronLeft, | 7 | IconChevronLeft, |
| 10 | IconExam, | 8 | IconExam, |
| 11 | - IconExternalLink, | ||
| 12 | IconHomework, | 9 | IconHomework, |
| 13 | IconMessage, | 10 | IconMessage, |
| 14 | IconTrash, | 11 | IconTrash, |
| 15 | IconX, | 12 | IconX, |
| 16 | } from "@/components/ui/icons"; | 13 | } from "@/components/ui/icons"; |
| 17 | import { cn } from "@/lib/cn"; | 14 | import { cn } from "@/lib/cn"; |
| 18 | -import type { NotificationItem, NotificationType } from "@/lib/notifications"; | 15 | +import { formatUnreadCount, type NotificationItem, type NotificationType } from "@/lib/notifications"; |
| 19 | import type { NotificationFeed } from "@/components/layout/notification-feed"; | 16 | import type { NotificationFeed } from "@/components/layout/notification-feed"; |
| 20 | import { useT } from "@/stores/preferences-context"; | 17 | import { useT } from "@/stores/preferences-context"; |
| 21 | 18 | ||
| @@ -63,16 +60,12 @@ export function NotificationList(props: { | |||
| 63 | props.feed.dismiss(id); | 60 | props.feed.dismiss(id); |
| 64 | }; | 61 | }; |
| 65 | 62 | ||
| 66 | - const select = async (item: NotificationItem) => { | 63 | + // A row with a target page goes straight there (marked read on the way); |
| 67 | - await props.feed.markRead(item); | 64 | + // only a row with nowhere to go opens the in-list preview. |
| 68 | - setPreviewNotification(item); | 65 | + const select = (item: NotificationItem) => { |
| 69 | - }; | 66 | + void props.feed.markRead(item); |
| 70 | - | 67 | + if (item.targetUrl) props.onNavigate(item.targetUrl); |
| 71 | - const goTo = () => { | 68 | + else setPreviewNotification(item); |
| 72 | - const item = previewNotification(); | ||
| 73 | - if (!item) return; | ||
| 74 | - setPreviewNotification(null); | ||
| 75 | - props.onNavigate(item.targetUrl); | ||
| 76 | }; | 69 | }; |
| 77 | 70 | ||
| 78 | return ( | 71 | return ( |
| @@ -86,8 +79,11 @@ export function NotificationList(props: { | |||
| 86 | <h3 class="text-sm font-semibold text-text-strong">{t("notifications.title")}</h3> | 79 | <h3 class="text-sm font-semibold text-text-strong">{t("notifications.title")}</h3> |
| 87 | </Show> | 80 | </Show> |
| 88 | <Show when={props.feed.unreadCount() > 0}> | 81 | <Show when={props.feed.unreadCount() > 0}> |
| 89 | - <span class="rounded-full bg-primary/15 px-2 py-0.5 font-mono text-[11px] font-bold text-primary-text"> | 82 | + <span |
| 90 | - {props.feed.unreadCount()} | 83 | + class="rounded-full bg-primary/15 px-2 py-0.5 font-mono text-[11px] font-bold text-primary-text" |
| 84 | + aria-label={t("notifications.unreadCount", { count: props.feed.unreadCount() })} | ||
| 85 | + > | ||
| 86 | + {formatUnreadCount(props.feed.unreadCount())} | ||
| 91 | </span> | 87 | </span> |
| 92 | </Show> | 88 | </Show> |
| 93 | </div> | 89 | </div> |
| @@ -111,13 +107,8 @@ export function NotificationList(props: { | |||
| 111 | <Show | 107 | <Show |
| 112 | when={previewNotification()} | 108 | when={previewNotification()} |
| 113 | fallback={ | 109 | fallback={ |
| 114 | - <Tabs defaultValue="all" class="p-2"> | 110 | + <div class="p-2"> |
| 115 | - <TabsList class="mx-auto mb-2 h-8 w-fit min-w-[180px] p-0.5"> | 111 | + <div class={cn("mt-0 space-y-1 overflow-y-auto", props.scrollClass ?? "max-h-80")}> |
| 116 | - <TabsTrigger value="all" class="h-7 flex-1 px-3 text-[11px]">{t("notifications.tabAll")}</TabsTrigger> | ||
| 117 | - <TabsTrigger value="system" class="h-7 flex-1 px-3 text-[11px]">{t("notifications.tabSystem")}</TabsTrigger> | ||
| 118 | - </TabsList> | ||
| 119 | - | ||
| 120 | - <TabsContent value="all" class={cn("mt-0 space-y-1 overflow-y-auto", props.scrollClass ?? "max-h-80")}> | ||
| 121 | <Suspense | 112 | <Suspense |
| 122 | fallback={ | 113 | fallback={ |
| 123 | <div class="p-8 text-center text-xs text-text-subtle"> | 114 | <div class="p-8 text-center text-xs text-text-subtle"> |
| @@ -171,7 +162,16 @@ export function NotificationList(props: { | |||
| 171 | <For each={group.items}> | 162 | <For each={group.items}> |
| 172 | {(item) => ( | 163 | {(item) => ( |
| 173 | <div | 164 | <div |
| 165 | + role="button" | ||
| 166 | + tabIndex={0} | ||
| 174 | onClick={() => select(item)} | 167 | onClick={() => select(item)} |
| 168 | + onKeyDown={(event) => { | ||
| 169 | + if (event.target !== event.currentTarget) return; | ||
| 170 | + if (event.key === "Enter" || event.key === " ") { | ||
| 171 | + event.preventDefault(); | ||
| 172 | + select(item); | ||
| 173 | + } | ||
| 174 | + }} | ||
| 175 | class="group relative flex cursor-pointer select-none items-start gap-3 rounded-lg p-2 text-xs transition-colors hover:bg-background/70" | 175 | class="group relative flex cursor-pointer select-none items-start gap-3 rounded-lg p-2 text-xs transition-colors hover:bg-background/70" |
| 176 | > | 176 | > |
| 177 | <div class="mt-0.5 flex h-8 w-8 shrink-0 items-center justify-center rounded-lg bg-background/75 text-text-subtle transition-colors group-hover:bg-primary group-hover:text-primary-foreground"> | 177 | <div class="mt-0.5 flex h-8 w-8 shrink-0 items-center justify-center rounded-lg bg-background/75 text-text-subtle transition-colors group-hover:bg-primary group-hover:text-primary-foreground"> |
| @@ -219,12 +219,8 @@ export function NotificationList(props: { | |||
| 219 | </div> | 219 | </div> |
| 220 | </Show> | 220 | </Show> |
| 221 | </Suspense> | 221 | </Suspense> |
| 222 | - </TabsContent> | 222 | + </div> |
| 223 | - | 223 | + </div> |
| 224 | - <TabsContent value="system" class="mt-0"> | ||
| 225 | - <ComingSoonPanel title={t("notifications.tabSystem")} class="border-0 p-3" /> | ||
| 226 | - </TabsContent> | ||
| 227 | - </Tabs> | ||
| 228 | } | 224 | } |
| 229 | > | 225 | > |
| 230 | {(item) => ( | 226 | {(item) => ( |
| @@ -267,10 +263,6 @@ export function NotificationList(props: { | |||
| 267 | </div> | 263 | </div> |
| 268 | </div> | 264 | </div> |
| 269 | 265 | ||
| 270 | - <Button type="button" size="sm" class="w-full rounded-lg" onClick={goTo}> | ||
| 271 | - <IconExternalLink class="mr-1.5 h-3.5 w-3.5" /> | ||
| 272 | - {t("notifications.goToPage")} | ||
| 273 | - </Button> | ||
| 274 | </div> | 266 | </div> |
| 275 | )} | 267 | )} |
| 276 | </Show> | 268 | </Show> |
src/components/layout/shell-unread-badge.test.tsxmodified+36 -2
| @@ -6,13 +6,14 @@ import { PreferencesProvider } from "@/stores/preferences-context"; | |||
| 6 | 6 | ||
| 7 | // The shell feed is the single source of truth for both badges; the test drives | 7 | // The shell feed is the single source of truth for both badges; the test drives |
| 8 | // it through signals so a refetch (new message arriving) is reproducible. | 8 | // it through signals so a refetch (new message arriving) is reproducible. |
| 9 | -const h = vi.hoisted(() => ({ feed: null as never })); | 9 | +const h = vi.hoisted(() => ({ feed: null as never, navigate: vi.fn() })); |
| 10 | 10 | ||
| 11 | vi.mock("@/stores/shell-feed-context", () => ({ useShellFeed: () => h.feed })); | 11 | vi.mock("@/stores/shell-feed-context", () => ({ useShellFeed: () => h.feed })); |
| 12 | +vi.mock("@/api/messages", () => ({ patchMessageById: vi.fn(async () => ({})) })); | ||
| 12 | vi.mock("@/stores/auth-context", () => ({ useAuth: () => ({ user: () => ({ id: "u-1" }) }) })); | 13 | vi.mock("@/stores/auth-context", () => ({ useAuth: () => ({ user: () => ({ id: "u-1" }) }) })); |
| 13 | vi.mock("@tanstack/solid-router", () => ({ | 14 | vi.mock("@tanstack/solid-router", () => ({ |
| 14 | Link: (props: never) => <a href={(props as { to: string }).to}>{(props as { children: unknown }).children}</a>, | 15 | Link: (props: never) => <a href={(props as { to: string }).to}>{(props as { children: unknown }).children}</a>, |
| 15 | - useNavigate: () => () => undefined, | 16 | + useNavigate: () => h.navigate, |
| 16 | })); | 17 | })); |
| 17 | // Kobalte's popover keeps its content unmounted in jsdom; the badge and the | 18 | // Kobalte's popover keeps its content unmounted in jsdom; the badge and the |
| 18 | // "dismiss all" button are the surfaces under test, so render both inline. | 19 | // "dismiss all" button are the surfaces under test, so render both inline. |
| @@ -95,3 +96,36 @@ test("dismiss all clears the badge, a later message raises it again", async () = | |||
| 95 | setUnreadMessages({ ...emptyPage, items: [msg("new"), ...listed.slice(0, 9)], total: 12 }); | 96 | setUnreadMessages({ ...emptyPage, items: [msg("new"), ...listed.slice(0, 9)], total: 12 }); |
| 96 | expect(badges()).toEqual(["1"]); | 97 | expect(badges()).toEqual(["1"]); |
| 97 | }); | 98 | }); |
| 99 | + | ||
| 100 | +test("the bell badge and the list header show the same capped unread count", () => { | ||
| 101 | + const listed = Array.from({ length: 10 }, (_, i) => msg(`m${i}`)); | ||
| 102 | + mountFeed([], { items: listed, total: 20 }); | ||
| 103 | + | ||
| 104 | + render(() => ( | ||
| 105 | + <PreferencesProvider> | ||
| 106 | + <NotificationCenter /> | ||
| 107 | + </PreferencesProvider> | ||
| 108 | + )); | ||
| 109 | + | ||
| 110 | + expect(badges()).toEqual(["9+"]); | ||
| 111 | + const header = screen.getByLabelText("20 unread"); | ||
| 112 | + expect(header.textContent).toBe("9+"); | ||
| 113 | +}); | ||
| 114 | + | ||
| 115 | +test("a notification with a target page opens it directly and is marked read", async () => { | ||
| 116 | + h.navigate.mockClear(); | ||
| 117 | + mountFeed([], { items: [msg("m1")], total: 1 }); | ||
| 118 | + | ||
| 119 | + render(() => ( | ||
| 120 | + <PreferencesProvider> | ||
| 121 | + <NotificationCenter /> | ||
| 122 | + </PreferencesProvider> | ||
| 123 | + )); | ||
| 124 | + | ||
| 125 | + expect(badges()).toEqual(["1"]); | ||
| 126 | + fireEvent.click(screen.getByText("subject m1")); | ||
| 127 | + expect(h.navigate).toHaveBeenCalledWith({ to: "/messages" }); | ||
| 128 | + // No intermediate "go to page" step. | ||
| 129 | + expect(screen.queryByText("Go to page")).toBeNull(); | ||
| 130 | + await vi.waitFor(() => expect(badges()).toEqual([])); | ||
| 131 | +}); | ||
src/components/meals/meal-menu-card.tsxmodified+1 -7
| @@ -2,7 +2,6 @@ import { For, Show } from "solid-js"; | |||
| 2 | import { Link } from "@tanstack/solid-router"; | 2 | import { Link } from "@tanstack/solid-router"; |
| 3 | import type { MealMenu } from "@/api/client"; | 3 | import type { MealMenu } from "@/api/client"; |
| 4 | import { Badge } from "@/components/ui/badge"; | 4 | import { Badge } from "@/components/ui/badge"; |
| 5 | -import { ComingSoonBadge, ComingSoonValue } from "@/components/ui/coming-soon"; | ||
| 6 | import { IconAlert, IconUtensils } from "@/components/ui/icons"; | 5 | import { IconAlert, IconUtensils } from "@/components/ui/icons"; |
| 7 | import { dietaryTagLabel, formatTry, mealSlotLabel } from "@/lib/meals"; | 6 | import { dietaryTagLabel, formatTry, mealSlotLabel } from "@/lib/meals"; |
| 8 | import { useT } from "@/stores/preferences-context"; | 7 | import { useT } from "@/stores/preferences-context"; |
| @@ -10,7 +9,7 @@ import { useT } from "@/stores/preferences-context"; | |||
| 10 | export function MealMenuCard(props: { | 9 | export function MealMenuCard(props: { |
| 11 | menu: MealMenu; | 10 | menu: MealMenu; |
| 12 | locale: string; | 11 | locale: string; |
| 13 | - labels: { dishes: string; capacity: string; conflict: string; reservations?: string; topPick: string }; | 12 | + labels: { dishes: string; capacity: string; conflict: string; reservations?: string }; |
| 14 | /** | 13 | /** |
| 15 | * Confirmed booking count for this menu (`getMealMenuBookings(...).total`), | 14 | * Confirmed booking count for this menu (`getMealMenuBookings(...).total`), |
| 16 | * manager+ only per the backend's booking-audit scope. Undefined for | 15 | * manager+ only per the backend's booking-audit scope. Undefined for |
| @@ -37,7 +36,6 @@ export function MealMenuCard(props: { | |||
| 37 | </div> | 36 | </div> |
| 38 | <span class="shrink-0 font-semibold tabular-nums">{formatTry(total(), props.locale)}</span> | 37 | <span class="shrink-0 font-semibold tabular-nums">{formatTry(total(), props.locale)}</span> |
| 39 | </div> | 38 | </div> |
| 40 | - <div class="mt-2 flex justify-end"><ComingSoonBadge /></div> | ||
| 41 | <div class="mt-4 flex flex-wrap gap-1.5"><For each={props.menu.dishes}>{(dish) => <Badge variant="outline">{dish.name}</Badge>}</For></div> | 39 | <div class="mt-4 flex flex-wrap gap-1.5"><For each={props.menu.dishes}>{(dish) => <Badge variant="outline">{dish.name}</Badge>}</For></div> |
| 42 | <Show when={conflicts().length > 0}> | 40 | <Show when={conflicts().length > 0}> |
| 43 | <div class="mt-3 flex items-start gap-2 rounded-xl border border-warning/50 bg-warning/10 p-2 text-xs text-warning-text"> | 41 | <div class="mt-3 flex items-start gap-2 rounded-xl border border-warning/50 bg-warning/10 p-2 text-xs text-warning-text"> |
| @@ -59,10 +57,6 @@ export function MealMenuCard(props: { | |||
| 59 | <span>{props.menu.dishes.length} {props.labels.dishes}</span> | 57 | <span>{props.menu.dishes.length} {props.labels.dishes}</span> |
| 60 | <span>{props.labels.capacity}: <span>{props.menu.capacity ?? "∞"}</span></span> | 58 | <span>{props.labels.capacity}: <span>{props.menu.capacity ?? "∞"}</span></span> |
| 61 | </div> | 59 | </div> |
| 62 | - <div class="mt-2 flex items-center justify-between text-xs text-text-subtle"> | ||
| 63 | - <span>{props.labels.topPick}</span> | ||
| 64 | - <ComingSoonValue /> | ||
| 65 | - </div> | ||
| 66 | </Link> | 60 | </Link> |
| 67 | ); | 61 | ); |
| 68 | } | 62 | } |
src/components/messages/gmail-compose-box.test.tsxadded+40 -0
| @@ -0,0 +1,40 @@ | |||
| 1 | +import { cleanup, fireEvent, render, screen } from "@solidjs/testing-library"; | ||
| 2 | +import { GmailComposeBox } from "@/components/messages/gmail-compose-box"; | ||
| 3 | +import { PreferencesProvider } from "@/stores/preferences-context"; | ||
| 4 | + | ||
| 5 | +vi.mock("@/stores/auth-context", () => ({ | ||
| 6 | + useAuth: () => ({ user: () => ({ id: "user-1", username: "teacher", role: "teacher" }) }), | ||
| 7 | +})); | ||
| 8 | +vi.mock("@/api/messages", () => ({ postMessage: vi.fn() })); | ||
| 9 | +// The real picker searches the API; a plain button stands in for choosing someone. | ||
| 10 | +vi.mock("@/components/users/user-search-select", () => ({ | ||
| 11 | + UserSearchSelect: (props: { onChange: (id: string) => void }) => ( | ||
| 12 | + <button type="button" onClick={() => props.onChange("user-2")}>pick recipient</button> | ||
| 13 | + ), | ||
| 14 | +})); | ||
| 15 | +vi.mock("@/components/ui/rich-text-editor", () => ({ RichTextEditor: () => <div /> })); | ||
| 16 | + | ||
| 17 | +afterEach(cleanup); | ||
| 18 | + | ||
| 19 | +test("send stays disabled until there is a recipient and a subject, and says what is missing", () => { | ||
| 20 | + render(() => ( | ||
| 21 | + <PreferencesProvider> | ||
| 22 | + <GmailComposeBox open onClose={() => {}} onSuccess={() => {}} /> | ||
| 23 | + </PreferencesProvider> | ||
| 24 | + )); | ||
| 25 | + | ||
| 26 | + const send = screen.getByRole("button", { name: "Send" }) as HTMLButtonElement; | ||
| 27 | + expect(send.disabled).toBe(true); | ||
| 28 | + expect(screen.getByText("Choose a recipient to send.")).toBeTruthy(); | ||
| 29 | + | ||
| 30 | + fireEvent.click(screen.getByText("pick recipient")); | ||
| 31 | + expect(send.disabled).toBe(true); | ||
| 32 | + expect(screen.getByText("Add a subject to send.")).toBeTruthy(); | ||
| 33 | + | ||
| 34 | + fireEvent.input(screen.getByLabelText("Subject"), { target: { value: " " } }); | ||
| 35 | + expect(send.disabled).toBe(true); | ||
| 36 | + | ||
| 37 | + fireEvent.input(screen.getByLabelText("Subject"), { target: { value: "Veli toplantısı" } }); | ||
| 38 | + expect(send.disabled).toBe(false); | ||
| 39 | + expect(screen.queryByText("Add a subject to send.")).toBeNull(); | ||
| 40 | +}); | ||
src/components/messages/gmail-compose-box.tsxmodified+33 -15
| @@ -70,10 +70,18 @@ export function GmailComposeBox(props: GmailComposeBoxProps) { | |||
| 70 | else handleClose(); | 70 | else handleClose(); |
| 71 | }; | 71 | }; |
| 72 | 72 | ||
| 73 | + // The backend needs a recipient and a subject (the body is optional), so | ||
| 74 | + // "Gönder" stays off until both are there and says which one is missing. | ||
| 75 | + const sendBlocker = () => { | ||
| 76 | + if (!recipient()) return t("messages.sendHintRecipient"); | ||
| 77 | + if (!subject().trim()) return t("messages.sendHintSubject"); | ||
| 78 | + return ""; | ||
| 79 | + }; | ||
| 80 | + | ||
| 73 | const handleSend = async (e: SubmitEvent) => { | 81 | const handleSend = async (e: SubmitEvent) => { |
| 74 | e.preventDefault(); | 82 | e.preventDefault(); |
| 75 | - if (!recipient()) { | 83 | + if (sendBlocker()) { |
| 76 | - setError(t("messages.selectRecipient")); | 84 | + setError(sendBlocker()); |
| 77 | return; | 85 | return; |
| 78 | } | 86 | } |
| 79 | setError(""); | 87 | setError(""); |
| @@ -154,12 +162,13 @@ export function GmailComposeBox(props: GmailComposeBoxProps) { | |||
| 154 | {/* Subject Line */} | 162 | {/* Subject Line */} |
| 155 | <div class="flex items-center border-b border-border-hairline px-3 py-1 gap-2 text-xs"> | 163 | <div class="flex items-center border-b border-border-hairline px-3 py-1 gap-2 text-xs"> |
| 156 | <span class="w-12 font-medium text-muted-foreground shrink-0"> | 164 | <span class="w-12 font-medium text-muted-foreground shrink-0"> |
| 157 | - {t("form.title")}: | 165 | + {t("messages.subject")}: |
| 158 | </span> | 166 | </span> |
| 159 | <Input | 167 | <Input |
| 160 | required | 168 | required |
| 161 | maxlength={200} | 169 | maxlength={200} |
| 162 | - placeholder="Konu" | 170 | + aria-label={t("messages.subject")} |
| 171 | + placeholder={t("messages.subjectPlaceholder")} | ||
| 163 | class="h-8 border-none bg-transparent shadow-none focus-visible:ring-0 text-xs flex-1" | 172 | class="h-8 border-none bg-transparent shadow-none focus-visible:ring-0 text-xs flex-1" |
| 164 | value={subject()} | 173 | value={subject()} |
| 165 | onInput={(e) => setSubject(e.currentTarget.value)} | 174 | onInput={(e) => setSubject(e.currentTarget.value)} |
| @@ -169,10 +178,11 @@ export function GmailComposeBox(props: GmailComposeBoxProps) { | |||
| 169 | {/* Optional Label Tag Line */} | 178 | {/* Optional Label Tag Line */} |
| 170 | <div class="flex items-center border-b border-border-hairline px-3 py-1 gap-2 text-xs"> | 179 | <div class="flex items-center border-b border-border-hairline px-3 py-1 gap-2 text-xs"> |
| 171 | <span class="w-12 font-medium text-muted-foreground shrink-0"> | 180 | <span class="w-12 font-medium text-muted-foreground shrink-0"> |
| 172 | - Etiket: | 181 | + {t("messages.label")}: |
| 173 | </span> | 182 | </span> |
| 174 | <Input | 183 | <Input |
| 175 | maxlength={50} | 184 | maxlength={50} |
| 185 | + aria-label={t("messages.label")} | ||
| 176 | placeholder={t("messages.labelsPlaceholder")} | 186 | placeholder={t("messages.labelsPlaceholder")} |
| 177 | class="h-8 border-none bg-transparent shadow-none focus-visible:ring-0 text-xs flex-1" | 187 | class="h-8 border-none bg-transparent shadow-none focus-visible:ring-0 text-xs flex-1" |
| 178 | value={label()} | 188 | value={label()} |
| @@ -195,16 +205,24 @@ export function GmailComposeBox(props: GmailComposeBoxProps) { | |||
| 195 | </Show> | 205 | </Show> |
| 196 | 206 | ||
| 197 | {/* Gmail Bottom Action Toolbar */} | 207 | {/* Gmail Bottom Action Toolbar */} |
| 198 | - <div class="flex items-center justify-between border-t border-border-hairline bg-surface-tint px-3 py-2.5"> | 208 | + <div class="flex items-center justify-between gap-3 border-t border-border-hairline bg-surface-tint px-3 py-2.5"> |
| 199 | - <Button | 209 | + <div class="flex min-w-0 items-center gap-3"> |
| 200 | - type="submit" | 210 | + <Button |
| 201 | - size="sm" | 211 | + type="submit" |
| 202 | - class="h-9 rounded-lg px-5 font-semibold" | 212 | + size="sm" |
| 203 | - disabled={pending()} | 213 | + class="h-9 shrink-0 rounded-lg px-5 font-semibold" |
| 204 | - > | 214 | + disabled={pending() || !!sendBlocker()} |
| 205 | - <IconSend class="mr-2 h-4 w-4" /> | 215 | + aria-describedby={sendBlocker() ? "gmail-compose-send-hint" : undefined} |
| 206 | - {t("messages.send")} | 216 | + > |
| 207 | - </Button> | 217 | + <IconSend class="mr-2 h-4 w-4" /> |
| 218 | + {t("messages.send")} | ||
| 219 | + </Button> | ||
| 220 | + <Show when={sendBlocker() && !error()}> | ||
| 221 | + <p id="gmail-compose-send-hint" class="min-w-0 text-[11px] leading-snug text-muted-foreground"> | ||
| 222 | + {sendBlocker()} | ||
| 223 | + </p> | ||
| 224 | + </Show> | ||
| 225 | + </div> | ||
| 208 | 226 | ||
| 209 | <button | 227 | <button |
| 210 | type="button" | 228 | type="button" |
src/components/ui/chart-bar.tsxmodified+6 -3
| @@ -2,7 +2,8 @@ import { For, Show, createEffect, createMemo, createSignal, type Component } fro | |||
| 2 | import { cn } from "@/lib/cn"; | 2 | import { cn } from "@/lib/cn"; |
| 3 | import { EmptyInline } from "@/components/ui/empty-inline"; | 3 | import { EmptyInline } from "@/components/ui/empty-inline"; |
| 4 | import { TablePagination } from "@/components/ui/table-pagination"; | 4 | import { TablePagination } from "@/components/ui/table-pagination"; |
| 5 | -import { useT } from "@/stores/preferences-context"; | 5 | +import { formatNumber } from "@/lib/format"; |
| 6 | +import { usePreferences, useT } from "@/stores/preferences-context"; | ||
| 6 | 7 | ||
| 7 | export type ChartBarItem = { | 8 | export type ChartBarItem = { |
| 8 | id: string; | 9 | id: string; |
| @@ -26,6 +27,8 @@ export type ChartBarProps = { | |||
| 26 | export const ChartBar: Component<ChartBarProps> = (props) => { | 27 | export const ChartBar: Component<ChartBarProps> = (props) => { |
| 27 | const [pageIndex, setPageIndex] = createSignal(0); | 28 | const [pageIndex, setPageIndex] = createSignal(0); |
| 28 | const t = useT(); | 29 | const t = useT(); |
| 30 | + const { locale } = usePreferences(); | ||
| 31 | + const display = (item: ChartBarItem) => item.formattedValue ?? formatNumber(item.value, locale()); | ||
| 29 | 32 | ||
| 30 | // The scale is computed off every item, not just the visible page, so bars | 33 | // The scale is computed off every item, not just the visible page, so bars |
| 31 | // don't rescale as the reader pages through them. | 34 | // don't rescale as the reader pages through them. |
| @@ -85,7 +88,7 @@ export const ChartBar: Component<ChartBarProps> = (props) => { | |||
| 85 | {item.label} | 88 | {item.label} |
| 86 | </span> | 89 | </span> |
| 87 | <span class="font-mono text-xs font-semibold tabular-nums text-foreground"> | 90 | <span class="font-mono text-xs font-semibold tabular-nums text-foreground"> |
| 88 | - {item.formattedValue ?? item.value} | 91 | + {display(item)} |
| 89 | </span> | 92 | </span> |
| 90 | </div> | 93 | </div> |
| 91 | 94 | ||
| @@ -102,7 +105,7 @@ export const ChartBar: Component<ChartBarProps> = (props) => { | |||
| 102 | </div> | 105 | </div> |
| 103 | 106 | ||
| 104 | <div class="pointer-events-none absolute -top-7 right-0 z-20 rounded-lg bg-popover px-2.5 py-1 text-[11px] font-medium text-popover-foreground opacity-0 shadow-md border border-border transition-opacity group-hover:opacity-100"> | 107 | <div class="pointer-events-none absolute -top-7 right-0 z-20 rounded-lg bg-popover px-2.5 py-1 text-[11px] font-medium text-popover-foreground opacity-0 shadow-md border border-border transition-opacity group-hover:opacity-100"> |
| 105 | - {item.label}: {item.formattedValue ?? item.value} ({Math.round(pct())}%) | 108 | + {item.label}: {display(item)} ({Math.round(pct())}%) |
| 106 | </div> | 109 | </div> |
| 107 | </div> | 110 | </div> |
| 108 | ); | 111 | ); |
src/components/ui/chart-line.tsxmodified+16 -8
| @@ -1,6 +1,7 @@ | |||
| 1 | import { For, Show, createMemo, type Component } from "solid-js"; | 1 | import { For, Show, createMemo, type Component } from "solid-js"; |
| 2 | import { cn } from "@/lib/cn"; | 2 | import { cn } from "@/lib/cn"; |
| 3 | -import { useT } from "@/stores/preferences-context"; | 3 | +import { usePreferences } from "@/stores/preferences-context"; |
| 4 | +import { formatDecimal } from "@/lib/format"; | ||
| 4 | import { EmptyInline } from "@/components/ui/empty-inline"; | 5 | import { EmptyInline } from "@/components/ui/empty-inline"; |
| 5 | 6 | ||
| 6 | export type ChartLineItem = { | 7 | export type ChartLineItem = { |
| @@ -25,9 +26,11 @@ const PADDING = { top: 18, right: 18, bottom: 34, left: 38 }; | |||
| 25 | const Y_TICKS = [0, 25, 50, 75, 100]; | 26 | const Y_TICKS = [0, 25, 50, 75, 100]; |
| 26 | const TOOLTIP_WIDTH = 190; | 27 | const TOOLTIP_WIDTH = 190; |
| 27 | const TOOLTIP_HEIGHT = 62; | 28 | const TOOLTIP_HEIGHT = 62; |
| 29 | +const TICK_MAX_CHARS = 14; | ||
| 28 | 30 | ||
| 29 | export const ChartLine: Component<ChartLineProps> = (props) => { | 31 | export const ChartLine: Component<ChartLineProps> = (props) => { |
| 30 | - const t = useT(); | 32 | + const { t, locale } = usePreferences(); |
| 33 | + const decimal = (value: number) => formatDecimal(value, locale()); | ||
| 31 | const maxValue = () => props.maxScale != null && props.maxScale > 0 | 34 | const maxValue = () => props.maxScale != null && props.maxScale > 0 |
| 32 | ? props.maxScale | 35 | ? props.maxScale |
| 33 | : Math.max(...props.items.map((item) => item.value), 1); | 36 | : Math.max(...props.items.map((item) => item.value), 1); |
| @@ -67,6 +70,14 @@ export const ChartLine: Component<ChartLineProps> = (props) => { | |||
| 67 | if (indexes[indexes.length - 1] !== props.items.length - 1) indexes.push(props.items.length - 1); | 70 | if (indexes[indexes.length - 1] !== props.items.length - 1) indexes.push(props.items.length - 1); |
| 68 | return indexes; | 71 | return indexes; |
| 69 | }); | 72 | }); |
| 73 | + // An axis tick has ~1/6 of the width, so it carries the item's caption (a | ||
| 74 | + // short date) or, when there is none, its position. Full labels overlap | ||
| 75 | + // each other and are already in the tooltip and the "latest" line. | ||
| 76 | + const tickLabel = (index: number) => { | ||
| 77 | + const caption = props.items[index].caption; | ||
| 78 | + if (!caption) return String(index + 1); | ||
| 79 | + return caption.length > TICK_MAX_CHARS ? `${caption.slice(0, TICK_MAX_CHARS - 1)}…` : caption; | ||
| 80 | + }; | ||
| 70 | const averageY = () => PADDING.top + (1 - Math.min(1, summary()!.average / maxValue())) * plotHeight; | 81 | const averageY = () => PADDING.top + (1 - Math.min(1, summary()!.average / maxValue())) * plotHeight; |
| 71 | 82 | ||
| 72 | return ( | 83 | return ( |
| @@ -99,11 +110,11 @@ export const ChartLine: Component<ChartLineProps> = (props) => { | |||
| 99 | </div> | 110 | </div> |
| 100 | <div class="rounded-lg bg-surface-overlay px-2.5 py-2"> | 111 | <div class="rounded-lg bg-surface-overlay px-2.5 py-2"> |
| 101 | <dt class="text-[11px] text-muted-foreground">{t("dashboard.chartAverage")}</dt> | 112 | <dt class="text-[11px] text-muted-foreground">{t("dashboard.chartAverage")}</dt> |
| 102 | - <dd class="mt-0.5 font-mono text-sm font-semibold tabular-nums">{stats().average.toFixed(1)}</dd> | 113 | + <dd class="mt-0.5 font-mono text-sm font-semibold tabular-nums">{decimal(stats().average)}</dd> |
| 103 | </div> | 114 | </div> |
| 104 | <div class="rounded-lg bg-surface-overlay px-2.5 py-2"> | 115 | <div class="rounded-lg bg-surface-overlay px-2.5 py-2"> |
| 105 | <dt class="text-[11px] text-muted-foreground">{t("dashboard.chartRange")}</dt> | 116 | <dt class="text-[11px] text-muted-foreground">{t("dashboard.chartRange")}</dt> |
| 106 | - <dd class="mt-0.5 font-mono text-sm font-semibold tabular-nums">{stats().minimum.toFixed(1)}–{stats().maximum.toFixed(1)}</dd> | 117 | + <dd class="mt-0.5 font-mono text-sm font-semibold tabular-nums">{decimal(stats().minimum)}–{decimal(stats().maximum)}</dd> |
| 107 | </div> | 118 | </div> |
| 108 | </dl> | 119 | </dl> |
| 109 | 120 | ||
| @@ -137,9 +148,6 @@ export const ChartLine: Component<ChartLineProps> = (props) => { | |||
| 137 | stroke-width="1" | 148 | stroke-width="1" |
| 138 | stroke-dasharray="4 4" | 149 | stroke-dasharray="4 4" |
| 139 | /> | 150 | /> |
| 140 | - <text x={PADDING.left + 5} y={averageY() - 5} class="fill-muted-foreground text-[11px]"> | ||
| 141 | - {t("dashboard.chartAverage")}: {stats().average.toFixed(1)} | ||
| 142 | - </text> | ||
| 143 | <polyline points={points()} fill="none" class="stroke-primary" stroke-width="3" stroke-linecap="round" stroke-linejoin="round" /> | 151 | <polyline points={points()} fill="none" class="stroke-primary" stroke-width="3" stroke-linecap="round" stroke-linejoin="round" /> |
| 144 | </Show> | 152 | </Show> |
| 145 | 153 | ||
| @@ -198,7 +206,7 @@ export const ChartLine: Component<ChartLineProps> = (props) => { | |||
| 198 | text-anchor={index === 0 ? "start" : index === props.items.length - 1 ? "end" : "middle"} | 206 | text-anchor={index === 0 ? "start" : index === props.items.length - 1 ? "end" : "middle"} |
| 199 | class="fill-muted-foreground text-[11px]" | 207 | class="fill-muted-foreground text-[11px]" |
| 200 | > | 208 | > |
| 201 | - {props.items[index].caption ?? props.items[index].label} | 209 | + {tickLabel(index)} |
| 202 | </text> | 210 | </text> |
| 203 | ); | 211 | ); |
| 204 | }} | 212 | }} |
src/components/ui/chart-progress-ring.tsxmodified+7 -4
| @@ -2,7 +2,8 @@ import { For, Show, createEffect, createMemo, createSignal, type Component } fro | |||
| 2 | import { cn } from "@/lib/cn"; | 2 | import { cn } from "@/lib/cn"; |
| 3 | import { EmptyInline } from "@/components/ui/empty-inline"; | 3 | import { EmptyInline } from "@/components/ui/empty-inline"; |
| 4 | import { TablePagination } from "@/components/ui/table-pagination"; | 4 | import { TablePagination } from "@/components/ui/table-pagination"; |
| 5 | -import { useT } from "@/stores/preferences-context"; | 5 | +import { formatNumber } from "@/lib/format"; |
| 6 | +import { usePreferences, useT } from "@/stores/preferences-context"; | ||
| 6 | 7 | ||
| 7 | export type ProgressRingSegment = { | 8 | export type ProgressRingSegment = { |
| 8 | id: string; | 9 | id: string; |
| @@ -25,6 +26,8 @@ export type ChartProgressRingProps = { | |||
| 25 | 26 | ||
| 26 | export const ChartProgressRing: Component<ChartProgressRingProps> = (props) => { | 27 | export const ChartProgressRing: Component<ChartProgressRingProps> = (props) => { |
| 27 | const t = useT(); | 28 | const t = useT(); |
| 29 | + const { locale } = usePreferences(); | ||
| 30 | + const num = (value: number) => formatNumber(value, locale()); | ||
| 28 | const [pageIndex, setPageIndex] = createSignal(0); | 31 | const [pageIndex, setPageIndex] = createSignal(0); |
| 29 | // The gauge bar above always renders every segment's share of the total — | 32 | // The gauge bar above always renders every segment's share of the total — |
| 30 | // only the legend cards below it are paged. | 33 | // only the legend cards below it are paged. |
| @@ -65,7 +68,7 @@ export const ChartProgressRing: Component<ChartProgressRingProps> = (props) => { | |||
| 65 | {/* Total Stat Highlight */} | 68 | {/* Total Stat Highlight */} |
| 66 | <div class="flex items-baseline gap-2"> | 69 | <div class="flex items-baseline gap-2"> |
| 67 | <span class="font-mono text-3xl font-bold tracking-tight text-foreground"> | 70 | <span class="font-mono text-3xl font-bold tracking-tight text-foreground"> |
| 68 | - {props.valueText ?? calculatedTotal()} | 71 | + {props.valueText ?? num(calculatedTotal())} |
| 69 | </span> | 72 | </span> |
| 70 | <Show when={props.subtext}> | 73 | <Show when={props.subtext}> |
| 71 | <span class="text-xs font-medium text-muted-foreground">{props.subtext}</span> | 74 | <span class="text-xs font-medium text-muted-foreground">{props.subtext}</span> |
| @@ -82,7 +85,7 @@ export const ChartProgressRing: Component<ChartProgressRingProps> = (props) => { | |||
| 82 | <div | 85 | <div |
| 83 | class={cn("h-full rounded-full transition-all duration-500 ease-out", segment.colorClass)} | 86 | class={cn("h-full rounded-full transition-all duration-500 ease-out", segment.colorClass)} |
| 84 | style={{ width: `${pct()}%` }} | 87 | style={{ width: `${pct()}%` }} |
| 85 | - title={`${segment.label}: ${segment.value} (${Math.round(pct())}%)`} | 88 | + title={`${segment.label}: ${num(segment.value)} (${Math.round(pct())}%)`} |
| 86 | /> | 89 | /> |
| 87 | </Show> | 90 | </Show> |
| 88 | ); | 91 | ); |
| @@ -99,7 +102,7 @@ export const ChartProgressRing: Component<ChartProgressRingProps> = (props) => { | |||
| 99 | <span class={cn("h-2.5 w-2.5 shrink-0 rounded-full", segment.colorClass)} /> | 102 | <span class={cn("h-2.5 w-2.5 shrink-0 rounded-full", segment.colorClass)} /> |
| 100 | <span class="truncate font-medium text-muted-foreground">{segment.label}</span> | 103 | <span class="truncate font-medium text-muted-foreground">{segment.label}</span> |
| 101 | </div> | 104 | </div> |
| 102 | - <span class="font-mono font-semibold text-foreground ml-2">{segment.value}</span> | 105 | + <span class="font-mono font-semibold text-foreground ml-2">{num(segment.value)}</span> |
| 103 | </div> | 106 | </div> |
| 104 | )} | 107 | )} |
| 105 | </For> | 108 | </For> |
src/components/ui/combobox.tsxmodified+24 -1
| @@ -5,7 +5,30 @@ import { IconCheck, IconChevronDown } from "@/components/ui/icons"; | |||
| 5 | import { cn } from "@/lib/cn"; | 5 | import { cn } from "@/lib/cn"; |
| 6 | import { useT } from "@/stores/preferences-context"; | 6 | import { useT } from "@/stores/preferences-context"; |
| 7 | 7 | ||
| 8 | -export const Combobox = ComboboxPrimitive; | 8 | +/** |
| 9 | + * Kobalte's Combobox root with its screen-reader strings (listbox name, | ||
| 10 | + * trigger name, focus/selection/count announcements) in the app language — | ||
| 11 | + * Kobalte ships them in English only. A call site can still pass its own | ||
| 12 | + * `translations`, which wins. | ||
| 13 | + */ | ||
| 14 | +function ComboboxRoot(props: ComponentProps<typeof ComboboxPrimitive>) { | ||
| 15 | + const t = useT(); | ||
| 16 | + const translations = () => ({ | ||
| 17 | + focusAnnouncement: (optionText: string, isSelected: boolean) => | ||
| 18 | + isSelected ? t("combobox.optionSelected", { option: optionText }) : optionText, | ||
| 19 | + // Kobalte's type narrows this to its own English literal; the runtime | ||
| 20 | + // only needs a string (or undefined for "say nothing"). | ||
| 21 | + countAnnouncement: ((optionCount: number) => t("combobox.optionCount", { count: optionCount })) as unknown as ( | ||
| 22 | + optionCount: number, | ||
| 23 | + ) => "one option available" | undefined, | ||
| 24 | + selectedAnnouncement: (optionText: string) => t("combobox.optionSelected", { option: optionText }), | ||
| 25 | + triggerLabel: t("combobox.showSuggestions"), | ||
| 26 | + listboxLabel: t("combobox.suggestions"), | ||
| 27 | + }); | ||
| 28 | + return <ComboboxPrimitive translations={translations()} {...props} />; | ||
| 29 | +} | ||
| 30 | + | ||
| 31 | +export const Combobox = Object.assign(ComboboxRoot, ComboboxPrimitive) as unknown as typeof ComboboxPrimitive; | ||
| 9 | export const ComboboxItemLabel = ComboboxPrimitive.ItemLabel; | 32 | export const ComboboxItemLabel = ComboboxPrimitive.ItemLabel; |
| 10 | export const ComboboxHiddenSelect = ComboboxPrimitive.HiddenSelect; | 33 | export const ComboboxHiddenSelect = ComboboxPrimitive.HiddenSelect; |
| 11 | 34 | ||
src/components/ui/coming-soon.tsxdeleted+0 -45
| @@ -1,45 +0,0 @@ | |||
| 1 | -import type { ParentProps } from "solid-js"; | ||
| 2 | -import { Badge } from "@/components/ui/badge"; | ||
| 3 | -import { cn } from "@/lib/cn"; | ||
| 4 | -import { useT } from "@/stores/preferences-context"; | ||
| 5 | - | ||
| 6 | -export function ComingSoonBadge(props: { class?: string }) { | ||
| 7 | - const t = useT(); | ||
| 8 | - return ( | ||
| 9 | - // `data-coming-soon` lets a toolbar find the control carrying it — phones | ||
| 10 | - // drop a button that can only say "not yet" (see DataTable's toolbar). | ||
| 11 | - <Badge variant="secondary" data-coming-soon class={cn("bg-surface-tint text-text-subtle", props.class)}> | ||
| 12 | - {t("comingSoon.title")} | ||
| 13 | - </Badge> | ||
| 14 | - ); | ||
| 15 | -} | ||
| 16 | - | ||
| 17 | -/** | ||
| 18 | - * Stands in for a value the design shows but no endpoint can fill yet. Renders | ||
| 19 | - * the slot the design allots so the layout keeps its shape, and says plainly | ||
| 20 | - * that the number is not here rather than printing a placeholder digit a | ||
| 21 | - * reader would take for real. | ||
| 22 | - */ | ||
| 23 | -export function ComingSoonValue(props: { class?: string }) { | ||
| 24 | - const t = useT(); | ||
| 25 | - return ( | ||
| 26 | - <span class={cn("inline-flex items-center gap-2 text-text-subtle", props.class)}> | ||
| 27 | - <span aria-hidden="true" class="text-lg leading-none">—</span> | ||
| 28 | - <span class="text-xs font-medium">{t("comingSoon.title")}</span> | ||
| 29 | - </span> | ||
| 30 | - ); | ||
| 31 | -} | ||
| 32 | - | ||
| 33 | -export function ComingSoonPanel(props: ParentProps<{ title: string; class?: string }>) { | ||
| 34 | - const t = useT(); | ||
| 35 | - return ( | ||
| 36 | - <section class={cn("data-shell space-y-2 p-4", props.class)}> | ||
| 37 | - <div class="flex items-center justify-between gap-2"> | ||
| 38 | - <h2 class="truncate text-sm font-semibold text-text-strong">{props.title}</h2> | ||
| 39 | - <ComingSoonBadge /> | ||
| 40 | - </div> | ||
| 41 | - <p class="text-sm text-text-subtle">{t("comingSoon.description")}</p> | ||
| 42 | - {props.children} | ||
| 43 | - </section> | ||
| 44 | - ); | ||
| 45 | -} | ||
src/components/ui/data-table.test.tsxmodified+2 -2
| @@ -58,7 +58,7 @@ test("keeps only the rightmost action column sticky and fixed at 110x45", () => | |||
| 58 | expect(roleHeader?.classList).not.toContain("table-sticky-head-right"); | 58 | expect(roleHeader?.classList).not.toContain("table-sticky-head-right"); |
| 59 | }); | 59 | }); |
| 60 | 60 | ||
| 61 | -test("freezes the meta.stickyLeft column and keeps the table centered", () => { | 61 | +test("freezes the meta.stickyLeft column and centres headers and left-aligns cells", () => { |
| 62 | const alignedColumns: ColumnDef<Row>[] = [ | 62 | const alignedColumns: ColumnDef<Row>[] = [ |
| 63 | { accessorKey: "name", header: "Name", meta: { stickyLeft: true } }, | 63 | { accessorKey: "name", header: "Name", meta: { stickyLeft: true } }, |
| 64 | { accessorKey: "role", header: "Role", meta: { align: "right" } }, | 64 | { accessorKey: "role", header: "Role", meta: { align: "right" } }, |
| @@ -78,7 +78,7 @@ test("freezes the meta.stickyLeft column and keeps the table centered", () => { | |||
| 78 | const roleCell = screen.getByRole("cell", { name: "Admin" }); | 78 | const roleCell = screen.getByRole("cell", { name: "Admin" }); |
| 79 | // List tables use one consistent centered alignment, including numeric columns. | 79 | // List tables use one consistent centered alignment, including numeric columns. |
| 80 | expect(roleHeader?.classList).toContain("text-center"); | 80 | expect(roleHeader?.classList).toContain("text-center"); |
| 81 | - expect(roleCell.classList).toContain("text-center"); | 81 | + expect(roleCell.classList).toContain("text-left"); |
| 82 | }); | 82 | }); |
| 83 | 83 | ||
| 84 | test("paginates tables by default", () => { | 84 | test("paginates tables by default", () => { |
src/components/ui/data-table.tsxmodified+15 -6
| @@ -40,7 +40,7 @@ declare module "@tanstack/solid-table" { | |||
| 40 | stickyLeft?: boolean; | 40 | stickyLeft?: boolean; |
| 41 | /** Vertical divider on the given edge — separates frozen label from metric columns. */ | 41 | /** Vertical divider on the given edge — separates frozen label from metric columns. */ |
| 42 | divider?: "left" | "right"; | 42 | divider?: "left" | "right"; |
| 43 | - /** Leave this column out of the phone card layout (e.g. a "yakında" placeholder). */ | 43 | + /** Leave this column out of the phone card layout (e.g. a column that only matters on a wide table). */ |
| 44 | hideInCards?: boolean; | 44 | hideInCards?: boolean; |
| 45 | } | 45 | } |
| 46 | } | 46 | } |
| @@ -220,7 +220,17 @@ export function DataTable<TData, TValue = unknown>(props: DataTableProps<TData, | |||
| 220 | const stickyRightLocked = (columnId: string) => | 220 | const stickyRightLocked = (columnId: string) => |
| 221 | columnId === "actions" || (columnId === "update" && table.getColumn("actions") == null); | 221 | columnId === "actions" || (columnId === "update" && table.getColumn("actions") == null); |
| 222 | const isStickyLeft = (column: Column<TData, unknown>) => column.columnDef.meta?.stickyLeft === true; | 222 | const isStickyLeft = (column: Column<TData, unknown>) => column.columnDef.meta?.stickyLeft === true; |
| 223 | - const alignOf = (_column: Column<TData, unknown>) => "center" as const; | 223 | + // Headers stay centred; body cells read from the left edge. System columns |
| 224 | + // (row actions, checkboxes) keep their controls centred under the header. | ||
| 225 | + const isSystemColumnId = (columnId: string) => ["actions", "update", "select"].includes(columnId); | ||
| 226 | + const alignOf = (column: Column<TData, unknown>) => isSystemColumnId(column.id) ? "center" as const : "left" as const; | ||
| 227 | + // Cell renderers written for the old centred layout carry their own | ||
| 228 | + // mx-auto / justify-center / text-center on their root; pull those to the | ||
| 229 | + // start. Direct children only: deeper centring (avatar initials, icon | ||
| 230 | + // buttons) is the widget's own layout, not the column's. | ||
| 231 | + const leftCellClass = (column: Column<TData, unknown>) => isSystemColumnId(column.id) | ||
| 232 | + ? undefined | ||
| 233 | + : "[&>.mx-auto]:mx-0 [&>.justify-center]:justify-start [&>.text-center]:text-left"; | ||
| 224 | const dividerClass = (column: Column<TData, unknown>) => { | 234 | const dividerClass = (column: Column<TData, unknown>) => { |
| 225 | const divider = column.columnDef.meta?.divider; | 235 | const divider = column.columnDef.meta?.divider; |
| 226 | return divider === "left" ? "border-l border-border/70" : divider === "right" ? "border-r border-border/70" : undefined; | 236 | return divider === "left" ? "border-l border-border/70" : divider === "right" ? "border-r border-border/70" : undefined; |
| @@ -438,9 +448,7 @@ export function DataTable<TData, TValue = unknown>(props: DataTableProps<TData, | |||
| 438 | the button stretches instead of hanging off the right edge. */} | 448 | the button stretches instead of hanging off the right edge. */} |
| 439 | <div class="order-2 ml-auto flex shrink-0 grow flex-wrap items-center justify-end gap-2 sm:grow-0 lg:order-3"> | 449 | <div class="order-2 ml-auto flex shrink-0 grow flex-wrap items-center justify-end gap-2 sm:grow-0 lg:order-3"> |
| 440 | <Show when={props.actions}> | 450 | <Show when={props.actions}> |
| 441 | - {/* A "yakında" button does nothing yet; on a phone it only | 451 | + <div class="flex min-w-0 flex-wrap items-center gap-2 [&_button]:rounded-md max-sm:flex-1 touch:[&_button]:h-10 max-sm:[&_button]:flex-1">{props.actions}</div> |
| 442 | - pushes the working action off the search row. */} | ||
| 443 | - <div class="flex min-w-0 flex-wrap items-center gap-2 [&_button]:rounded-md max-sm:flex-1 touch:[&_button]:h-10 max-sm:[&_button]:flex-1 max-sm:[&_button:has([data-coming-soon])]:hidden">{props.actions}</div> | ||
| 444 | </Show> | 452 | </Show> |
| 445 | <Show when={showColumnMenu()}> | 453 | <Show when={showColumnMenu()}> |
| 446 | <DataTableViewMenu columns={viewMenuColumns()} /> | 454 | <DataTableViewMenu columns={viewMenuColumns()} /> |
| @@ -610,6 +618,7 @@ export function DataTable<TData, TValue = unknown>(props: DataTableProps<TData, | |||
| 610 | <TableCell | 618 | <TableCell |
| 611 | class={cn( | 619 | class={cn( |
| 612 | alignClass[alignOf(cell.column)], | 620 | alignClass[alignOf(cell.column)], |
| 621 | + leftCellClass(cell.column), | ||
| 613 | dividerClass(cell.column), | 622 | dividerClass(cell.column), |
| 614 | stickyCellClass(cell.column), | 623 | stickyCellClass(cell.column), |
| 615 | cell.column.columnDef.meta?.cellClass, | 624 | cell.column.columnDef.meta?.cellClass, |
| @@ -662,7 +671,7 @@ export function DataTableFrame(props: ParentProps<{ class?: string }>) { | |||
| 662 | // frame's bottom edge it covered the last row's action button. | 671 | // frame's bottom edge it covered the last row's action button. |
| 663 | return ( | 672 | return ( |
| 664 | <div class="space-y-1"> | 673 | <div class="space-y-1"> |
| 665 | - <div ref={frame} class={cn("data-table-wrap relative", props.class)}> | 674 | + <div ref={frame} class={cn("data-table-wrap relative", props.class)} data-scrollable={scrollable() ? "" : undefined}> |
| 666 | {props.children} | 675 | {props.children} |
| 667 | </div> | 676 | </div> |
| 668 | <Show when={scrollable()}> | 677 | <Show when={scrollable()}> |
src/components/ui/data-toolbar.tsxmodified+1 -1
| @@ -36,7 +36,7 @@ export function DataToolbar(props: { | |||
| 36 | <div class="order-3 flex w-full flex-wrap items-center gap-2 sm:order-2 sm:w-auto">{props.filters}</div> | 36 | <div class="order-3 flex w-full flex-wrap items-center gap-2 sm:order-2 sm:w-auto">{props.filters}</div> |
| 37 | </Show> | 37 | </Show> |
| 38 | <Show when={props.actions}> | 38 | <Show when={props.actions}> |
| 39 | - <div class="order-2 ml-auto flex shrink-0 grow items-center justify-end gap-2 sm:order-3 sm:grow-0 touch:[&_button]:h-10 max-sm:[&_button]:flex-1 max-sm:[&_button:has([data-coming-soon])]:hidden">{props.actions}</div> | 39 | + <div class="order-2 ml-auto flex shrink-0 grow items-center justify-end gap-2 sm:order-3 sm:grow-0 touch:[&_button]:h-10 max-sm:[&_button]:flex-1">{props.actions}</div> |
| 40 | </Show> | 40 | </Show> |
| 41 | </div> | 41 | </div> |
| 42 | ); | 42 | ); |
src/components/ui/dialog.tsxmodified+10 -7
| @@ -1,6 +1,6 @@ | |||
| 1 | import { Dialog as DialogPrimitive } from "@kobalte/core/dialog"; | 1 | import { Dialog as DialogPrimitive } from "@kobalte/core/dialog"; |
| 2 | import type { ComponentProps, ParentProps, ValidComponent } from "solid-js"; | 2 | import type { ComponentProps, ParentProps, ValidComponent } from "solid-js"; |
| 3 | -import { splitProps } from "solid-js"; | 3 | +import { Show, splitProps } from "solid-js"; |
| 4 | import { IconX } from "@/components/ui/icons"; | 4 | import { IconX } from "@/components/ui/icons"; |
| 5 | import { cn } from "@/lib/cn"; | 5 | import { cn } from "@/lib/cn"; |
| 6 | 6 | ||
| @@ -9,13 +9,12 @@ export const DialogTrigger = DialogPrimitive.Trigger; | |||
| 9 | export const DialogClose = DialogPrimitive.CloseButton; | 9 | export const DialogClose = DialogPrimitive.CloseButton; |
| 10 | 10 | ||
| 11 | export function DialogContent<T extends ValidComponent = "div">( | 11 | export function DialogContent<T extends ValidComponent = "div">( |
| 12 | - props: ComponentProps<typeof DialogPrimitive.Content<T>> & { dismissable?: boolean }, | 12 | + props: ComponentProps<typeof DialogPrimitive.Content<T>> & { dismissable?: boolean; closeButton?: boolean }, |
| 13 | ) { | 13 | ) { |
| 14 | - const [local, rest] = splitProps(props as ComponentProps<typeof DialogPrimitive.Content> & { dismissable?: boolean }, [ | 14 | + const [local, rest] = splitProps( |
| 15 | - "class", | 15 | + props as ComponentProps<typeof DialogPrimitive.Content> & { dismissable?: boolean; closeButton?: boolean }, |
| 16 | - "children", | 16 | + ["class", "children", "dismissable", "closeButton"], |
| 17 | - "dismissable", | 17 | + ); |
| 18 | - ]); | ||
| 19 | return ( | 18 | return ( |
| 20 | <DialogPrimitive.Portal> | 19 | <DialogPrimitive.Portal> |
| 21 | {/* z-[70]: above the mobile nav sheet (z-60) and tab bar (z-40). */} | 20 | {/* z-[70]: above the mobile nav sheet (z-60) and tab bar (z-40). */} |
| @@ -39,6 +38,9 @@ export function DialogContent<T extends ValidComponent = "div">( | |||
| 39 | onEscapeKeyDown={local.dismissable === false ? (e) => e.preventDefault() : undefined} | 38 | onEscapeKeyDown={local.dismissable === false ? (e) => e.preventDefault() : undefined} |
| 40 | {...rest} | 39 | {...rest} |
| 41 | > | 40 | > |
| 41 | + {/* `closeButton={false}` lets a dialog draw its own close control | ||
| 42 | + (the command palette labels it, beside its clear-search ×). */} | ||
| 43 | + <Show when={local.closeButton !== false}> | ||
| 42 | <DialogPrimitive.CloseButton | 44 | <DialogPrimitive.CloseButton |
| 43 | type="button" | 45 | type="button" |
| 44 | class="absolute right-4 top-4 z-10 inline-flex h-8 w-8 items-center justify-center rounded-sm text-muted-foreground transition-all hover:bg-accent hover:text-foreground focus-visible:outline-hidden focus-visible:ring-2 focus-visible:ring-ring focus-visible:ring-offset-2" | 46 | class="absolute right-4 top-4 z-10 inline-flex h-8 w-8 items-center justify-center rounded-sm text-muted-foreground transition-all hover:bg-accent hover:text-foreground focus-visible:outline-hidden focus-visible:ring-2 focus-visible:ring-ring focus-visible:ring-offset-2" |
| @@ -46,6 +48,7 @@ export function DialogContent<T extends ValidComponent = "div">( | |||
| 46 | > | 48 | > |
| 47 | <IconX class="h-4 w-4" /> | 49 | <IconX class="h-4 w-4" /> |
| 48 | </DialogPrimitive.CloseButton> | 50 | </DialogPrimitive.CloseButton> |
| 51 | + </Show> | ||
| 49 | {local.children} | 52 | {local.children} |
| 50 | </DialogPrimitive.Content> | 53 | </DialogPrimitive.Content> |
| 51 | </div> | 54 | </div> |
src/components/whiteboard/whiteboard-canvas.tsxmodified+24 -8
| @@ -9,9 +9,18 @@ import { | |||
| 9 | type Point, | 9 | type Point, |
| 10 | type Stroke, | 10 | type Stroke, |
| 11 | } from "@/lib/draw-stroke"; | 11 | } from "@/lib/draw-stroke"; |
| 12 | +import type { MessageKey } from "@/i18n/messages"; | ||
| 12 | import { useT } from "@/stores/preferences-context"; | 13 | import { useT } from "@/stores/preferences-context"; |
| 13 | 14 | ||
| 14 | const COLORS = ["#1f2937", "#dc2626", "#2563eb", "#16a34a", "#ca8a04"]; | 15 | const COLORS = ["#1f2937", "#dc2626", "#2563eb", "#16a34a", "#ca8a04"]; |
| 16 | +/** Spoken name of each swatch — a hex code is no accessible name. */ | ||
| 17 | +const COLOR_NAMES: Record<string, MessageKey> = { | ||
| 18 | + "#1f2937": "draw.colorName.black", | ||
| 19 | + "#dc2626": "draw.colorName.red", | ||
| 20 | + "#2563eb": "draw.colorName.blue", | ||
| 21 | + "#16a34a": "draw.colorName.green", | ||
| 22 | + "#ca8a04": "draw.colorName.yellow", | ||
| 23 | +}; | ||
| 15 | const WIDTHS = [2, 6, 14]; | 24 | const WIDTHS = [2, 6, 14]; |
| 16 | const ZOOM_MIN = 0.25; | 25 | const ZOOM_MIN = 0.25; |
| 17 | const ZOOM_MAX = 4; | 26 | const ZOOM_MAX = 4; |
| @@ -55,7 +64,10 @@ export function WhiteboardCanvas(props: { | |||
| 55 | const [color, setColor] = createSignal(COLORS[0]); | 64 | const [color, setColor] = createSignal(COLORS[0]); |
| 56 | const [width, setWidth] = createSignal(WIDTHS[1]); | 65 | const [width, setWidth] = createSignal(WIDTHS[1]); |
| 57 | const [erasing, setErasing] = createSignal(false); | 66 | const [erasing, setErasing] = createSignal(false); |
| 58 | - const [hand, setHand] = createSignal(false); | 67 | + // The board opens on the hand tool: it is a shared live canvas, so a stray |
| 68 | + // tap or scroll must not leave a mark for everyone — drawing starts only | ||
| 69 | + // once the pen (or a colour) is picked. | ||
| 70 | + const [hand, setHand] = createSignal(true); | ||
| 59 | const [override, setOverride] = createSignal<null | "pan" | "erase">(null); | 71 | const [override, setOverride] = createSignal<null | "pan" | "erase">(null); |
| 60 | const [pan, setPan] = createSignal({ x: 0, y: 0 }); | 72 | const [pan, setPan] = createSignal({ x: 0, y: 0 }); |
| 61 | const [panning, setPanning] = createSignal(false); | 73 | const [panning, setPanning] = createSignal(false); |
| @@ -238,6 +250,7 @@ export function WhiteboardCanvas(props: { | |||
| 238 | type="button" | 250 | type="button" |
| 239 | class={toolClass(activeTool() === "pen")} | 251 | class={toolClass(activeTool() === "pen")} |
| 240 | title={t("draw.pen")} | 252 | title={t("draw.pen")} |
| 253 | + aria-pressed={activeTool() === "pen"} | ||
| 241 | onClick={() => { | 254 | onClick={() => { |
| 242 | setErasing(false); | 255 | setErasing(false); |
| 243 | setHand(false); | 256 | setHand(false); |
| @@ -250,6 +263,7 @@ export function WhiteboardCanvas(props: { | |||
| 250 | type="button" | 263 | type="button" |
| 251 | class={toolClass(activeTool() === "erase")} | 264 | class={toolClass(activeTool() === "erase")} |
| 252 | title={t("draw.eraser")} | 265 | title={t("draw.eraser")} |
| 266 | + aria-pressed={activeTool() === "erase"} | ||
| 253 | onClick={() => { | 267 | onClick={() => { |
| 254 | setErasing(true); | 268 | setErasing(true); |
| 255 | setHand(false); | 269 | setHand(false); |
| @@ -262,6 +276,7 @@ export function WhiteboardCanvas(props: { | |||
| 262 | type="button" | 276 | type="button" |
| 263 | class={toolClass(activeTool() === "pan")} | 277 | class={toolClass(activeTool() === "pan")} |
| 264 | title={t("draw.pan")} | 278 | title={t("draw.pan")} |
| 279 | + aria-pressed={activeTool() === "pan"} | ||
| 265 | onClick={() => setHand(true)} | 280 | onClick={() => setHand(true)} |
| 266 | > | 281 | > |
| 267 | <IconMove class="h-5 w-5" /> | 282 | <IconMove class="h-5 w-5" /> |
| @@ -275,7 +290,9 @@ export function WhiteboardCanvas(props: { | |||
| 275 | {(swatch) => ( | 290 | {(swatch) => ( |
| 276 | <button | 291 | <button |
| 277 | type="button" | 292 | type="button" |
| 278 | - title={t("draw.color")} | 293 | + title={`${t("draw.color")}: ${t(COLOR_NAMES[swatch])}`} |
| 294 | + aria-label={`${t("draw.color")}: ${t(COLOR_NAMES[swatch])}`} | ||
| 295 | + aria-pressed={color() === swatch && activeTool() === "pen"} | ||
| 279 | class={cn( | 296 | class={cn( |
| 280 | "h-9 w-9 sm:h-11 sm:w-11 rounded-lg border-2 transition-transform", | 297 | "h-9 w-9 sm:h-11 sm:w-11 rounded-lg border-2 transition-transform", |
| 281 | color() === swatch && activeTool() === "pen" | 298 | color() === swatch && activeTool() === "pen" |
| @@ -288,9 +305,7 @@ export function WhiteboardCanvas(props: { | |||
| 288 | setErasing(false); | 305 | setErasing(false); |
| 289 | setHand(false); | 306 | setHand(false); |
| 290 | }} | 307 | }} |
| 291 | - > | 308 | + /> |
| 292 | - <span class="sr-only">{swatch}</span> | ||
| 293 | - </button> | ||
| 294 | )} | 309 | )} |
| 295 | </For> | 310 | </For> |
| 296 | ); | 311 | ); |
| @@ -300,12 +315,13 @@ export function WhiteboardCanvas(props: { | |||
| 300 | {(size) => ( | 315 | {(size) => ( |
| 301 | <button | 316 | <button |
| 302 | type="button" | 317 | type="button" |
| 303 | - title={t("draw.width")} | 318 | + title={`${t("draw.width")}: ${size}`} |
| 319 | + aria-label={`${t("draw.width")}: ${size}`} | ||
| 320 | + aria-pressed={width() === size} | ||
| 304 | class={toolClass(width() === size)} | 321 | class={toolClass(width() === size)} |
| 305 | onClick={() => setWidth(size)} | 322 | onClick={() => setWidth(size)} |
| 306 | > | 323 | > |
| 307 | <span class="rounded-full bg-current" style={{ width: `${size + 2}px`, height: `${size + 2}px` }} /> | 324 | <span class="rounded-full bg-current" style={{ width: `${size + 2}px`, height: `${size + 2}px` }} /> |
| 308 | - <span class="sr-only">{size}</span> | ||
| 309 | </button> | 325 | </button> |
| 310 | )} | 326 | )} |
| 311 | </For> | 327 | </For> |
| @@ -347,7 +363,7 @@ export function WhiteboardCanvas(props: { | |||
| 347 | /> | 363 | /> |
| 348 | <Show when={empty() && !current}> | 364 | <Show when={empty() && !current}> |
| 349 | <p class="pointer-events-none absolute inset-0 flex items-center justify-center text-sm text-slate-400"> | 365 | <p class="pointer-events-none absolute inset-0 flex items-center justify-center text-sm text-slate-400"> |
| 350 | - {t("whiteboard.canvasHint")} | 366 | + {activeTool() === "pan" && !props.disabled ? t("whiteboard.canvasHintPickPen") : t("whiteboard.canvasHint")} |
| 351 | </p> | 367 | </p> |
| 352 | </Show> | 368 | </Show> |
| 353 | 369 | ||
src/i18n/locales/en.tsmodified+52 -4
| @@ -377,7 +377,7 @@ export const en: Dict = { | |||
| 377 | "notifications.empty": "No new notifications yet.", | 377 | "notifications.empty": "No new notifications yet.", |
| 378 | "notifications.tabAll": "All", | 378 | "notifications.tabAll": "All", |
| 379 | "notifications.tabSystem": "System", | 379 | "notifications.tabSystem": "System", |
| 380 | - "notifications.goToPage": "Go to page", | 380 | + "notifications.unreadCount": "{count} unread", |
| 381 | "errors.notFoundDescription": "The page you're looking for may have moved or been deleted.", | 381 | "errors.notFoundDescription": "The page you're looking for may have moved or been deleted.", |
| 382 | "errors.accessDeniedDescription": "Your role can't view this section. Ask an administrator if you need access.", | 382 | "errors.accessDeniedDescription": "Your role can't view this section. Ask an administrator if you need access.", |
| 383 | "network.offlineTitle": "You're offline", | 383 | "network.offlineTitle": "You're offline", |
| @@ -801,6 +801,11 @@ export const en: Dict = { | |||
| 801 | "auth.passwordHint": "6–128 characters", | 801 | "auth.passwordHint": "6–128 characters", |
| 802 | "auth.showPassword": "Show password", | 802 | "auth.showPassword": "Show password", |
| 803 | "auth.hidePassword": "Hide password", | 803 | "auth.hidePassword": "Hide password", |
| 804 | + "auth.showConfirmPassword": "Show password confirmation", | ||
| 805 | + "auth.hideConfirmPassword": "Hide password confirmation", | ||
| 806 | + "auth.schoolCodeHint": "The school code your school gave you (not the school's name): lowercase letters, digits and hyphens, {min}–{max} characters.", | ||
| 807 | + "auth.passwordMinHint": "At least {min} characters.", | ||
| 808 | + "auth.passwordTooShort": "The password needs at least {min} characters.", | ||
| 804 | "auth.welcomeBack": "Good to see you again", | 809 | "auth.welcomeBack": "Good to see you again", |
| 805 | "auth.createStudent": "Create student account", | 810 | "auth.createStudent": "Create student account", |
| 806 | "dashboard.greeting": "Hello, {name}", | 811 | "dashboard.greeting": "Hello, {name}", |
| @@ -841,11 +846,11 @@ export const en: Dict = { | |||
| 841 | "command.action.createExamDesc": "Prepare new exam for students", | 846 | "command.action.createExamDesc": "Prepare new exam for students", |
| 842 | "command.action.createNote": "Create note", | 847 | "command.action.createNote": "Create note", |
| 843 | "command.action.createNoteDesc": "Save a personal or class note", | 848 | "command.action.createNoteDesc": "Save a personal or class note", |
| 844 | - "command.action.importNote": "Import note assistant", | 849 | + "command.action.importNote": "Note import assistant", |
| 845 | "command.action.importNoteDesc": "Convert PDF or text files to note", | 850 | "command.action.importNoteDesc": "Convert PDF or text files to note", |
| 846 | "command.action.askQuestion": "Ask / add question", | 851 | "command.action.askQuestion": "Ask / add question", |
| 847 | "command.action.askQuestionDesc": "Ask question or add to community pool", | 852 | "command.action.askQuestionDesc": "Ask question or add to community pool", |
| 848 | - "command.action.askCelebi": "Ask Çelebi AI", | 853 | + "command.action.askCelebi": "Chat with Çelebi", |
| 849 | "command.action.askCelebiDesc": "Chat with smart AI assistant", | 854 | "command.action.askCelebiDesc": "Chat with smart AI assistant", |
| 850 | "command.action.myProfile": "My profile", | 855 | "command.action.myProfile": "My profile", |
| 851 | "command.action.myProfileDesc": "User account and profile details", | 856 | "command.action.myProfileDesc": "User account and profile details", |
| @@ -860,6 +865,14 @@ export const en: Dict = { | |||
| 860 | "command.key.navigate": "navigate", | 865 | "command.key.navigate": "navigate", |
| 861 | "command.key.select": "select", | 866 | "command.key.select": "select", |
| 862 | "command.key.close": "close", | 867 | "command.key.close": "close", |
| 868 | + "command.group.courses": "Courses", | ||
| 869 | + "command.group.exams": "Exams", | ||
| 870 | + "command.group.homework": "Homework", | ||
| 871 | + "command.group.events": "Events", | ||
| 872 | + "command.recordsLoading": "Loading courses, exams and other records…", | ||
| 873 | + "command.resultCount": "{count} results", | ||
| 874 | + "command.homeworkDue": "Due {date}", | ||
| 875 | + "search.hint.commandRecords": "You can also search by name: {kinds}.", | ||
| 863 | "command.action.themeDarkDesc": "Switch to dark mode", | 876 | "command.action.themeDarkDesc": "Switch to dark mode", |
| 864 | "command.action.themeLightDesc": "Switch to light mode", | 877 | "command.action.themeLightDesc": "Switch to light mode", |
| 865 | "command.action.langTrDesc": "Switch to Turkish", | 878 | "command.action.langTrDesc": "Switch to Turkish", |
| @@ -1180,6 +1193,32 @@ export const en: Dict = { | |||
| 1180 | "draw.bgNone": "Plain", | 1193 | "draw.bgNone": "Plain", |
| 1181 | "draw.bgLines": "Lines", | 1194 | "draw.bgLines": "Lines", |
| 1182 | "draw.bgGrid": "Grid", | 1195 | "draw.bgGrid": "Grid", |
| 1196 | + "draw.colorName.black": "Black", | ||
| 1197 | + "draw.colorName.red": "Red", | ||
| 1198 | + "draw.colorName.blue": "Blue", | ||
| 1199 | + "draw.colorName.green": "Green", | ||
| 1200 | + "draw.colorName.yellow": "Yellow", | ||
| 1201 | + "whiteboard.canvasHintPickPen": "Pick the pen to draw — everyone on the board sees it live.", | ||
| 1202 | + "exams.publishOnCreateWarning": "Not a draft: the exam opens to students before any question is added.", | ||
| 1203 | + "exams.publishEmptyTitle": "Publish without questions?", | ||
| 1204 | + "exams.publishEmptyWarning": "This exam has no questions. If you publish it, students will see an empty exam.", | ||
| 1205 | + "exams.publishAnyway": "Publish anyway", | ||
| 1206 | + "exams.savedAsDraftHint": "The exam is saved as a draft; publish it from the list when it is ready.", | ||
| 1207 | + "events.status.present": "Attended", | ||
| 1208 | + "events.status.absent": "Did not attend", | ||
| 1209 | + "events.status.late": "Arrived late", | ||
| 1210 | + "events.status.excused": "Excused", | ||
| 1211 | + "events.rollCall.notStarted": "Roll call opens when the event starts.", | ||
| 1212 | + "events.rollCall.opensAt": "Roll call opens when the event starts ({date}). Recorded statuses are shown below.", | ||
| 1213 | + "events.rollCall.emptyRoster": "Nobody is in this event's audience.", | ||
| 1214 | + "events.rollCall.searchHint": "Searches name, username or student number.", | ||
| 1215 | + "events.rollCall.markRestPresent": "Mark the rest Attended", | ||
| 1216 | + "events.rollCall.unsaved": "{status} · not saved", | ||
| 1217 | + "events.rollCall.saveFailed": "{failed} of {total} rows could not be saved. The errors are shown on those rows.", | ||
| 1218 | + "events.rollCall.saved": "{count} attendance marks saved.", | ||
| 1219 | + "events.rollCall.pendingChanges": "{count} unsaved changes", | ||
| 1220 | + "events.rollCall.noChanges": "No unsaved changes", | ||
| 1221 | + "events.rollCall.discard": "Discard changes", | ||
| 1183 | "notes.downloadFile": "Download", | 1222 | "notes.downloadFile": "Download", |
| 1184 | "notes.noFiles": "No files attached.", | 1223 | "notes.noFiles": "No files attached.", |
| 1185 | "notes.fileLimit": "This note already has 10 files.", | 1224 | "notes.fileLimit": "This note already has 10 files.", |
| @@ -1201,7 +1240,7 @@ export const en: Dict = { | |||
| 1201 | "events.myAttendance": "My attendance", | 1240 | "events.myAttendance": "My attendance", |
| 1202 | "events.myAttendanceHelp": "Choose your event status and save it.", | 1241 | "events.myAttendanceHelp": "Choose your event status and save it.", |
| 1203 | "events.studentAttendance": "Student attendance", | 1242 | "events.studentAttendance": "Student attendance", |
| 1204 | - "events.studentAttendanceHelp": "Select a student, choose a status, then save the record.", | 1243 | + "events.studentAttendanceHelp": "Everyone in the event's audience is listed. Pick a status on each row, then save them all at once.", |
| 1205 | "events.saveStudentAttendance": "Save attendance", | 1244 | "events.saveStudentAttendance": "Save attendance", |
| 1206 | "events.attendance": "Attendance roster", | 1245 | "events.attendance": "Attendance roster", |
| 1207 | "events.attendanceRecords": "Attendance records", | 1246 | "events.attendanceRecords": "Attendance records", |
| @@ -2346,6 +2385,9 @@ export const en: Dict = { | |||
| 2346 | "homework.gradeStatusPlaceholder": "Choose a status", | 2385 | "homework.gradeStatusPlaceholder": "Choose a status", |
| 2347 | "homework.gradeStatusRequired": "Choose a status before saving.", | 2386 | "homework.gradeStatusRequired": "Choose a status before saving.", |
| 2348 | "combobox.showSuggestions": "Show suggestions", | 2387 | "combobox.showSuggestions": "Show suggestions", |
| 2388 | + "combobox.suggestions": "Suggestions", | ||
| 2389 | + "combobox.optionSelected": "{option}, selected", | ||
| 2390 | + "combobox.optionCount": "Options available: {count}", | ||
| 2349 | "course.removeStudentTitle": "Remove the student from this course?", | 2391 | "course.removeStudentTitle": "Remove the student from this course?", |
| 2350 | "course.removeStudentHint": "Their enrollment in this class's course is removed; the account itself is not deleted.", | 2392 | "course.removeStudentHint": "Their enrollment in this class's course is removed; the account itself is not deleted.", |
| 2351 | "course.removeStudentAction": "Remove from course", | 2393 | "course.removeStudentAction": "Remove from course", |
| @@ -2359,6 +2401,12 @@ export const en: Dict = { | |||
| 2359 | "instances.karneTurnOff": "Stop counting", | 2401 | "instances.karneTurnOff": "Stop counting", |
| 2360 | "messages.discardDraftTitle": "Discard this draft?", | 2402 | "messages.discardDraftTitle": "Discard this draft?", |
| 2361 | "messages.discardDraftHint": "What you wrote in this message has not been sent and will be lost.", | 2403 | "messages.discardDraftHint": "What you wrote in this message has not been sent and will be lost.", |
| 2404 | + "messages.folders": "Folders", | ||
| 2405 | + "messages.subject": "Subject", | ||
| 2406 | + "messages.subjectPlaceholder": "What the message is about", | ||
| 2407 | + "messages.label": "Label", | ||
| 2408 | + "messages.sendHintRecipient": "Choose a recipient to send.", | ||
| 2409 | + "messages.sendHintSubject": "Add a subject to send.", | ||
| 2362 | "errors.studentOnlyTitle": "This page is for students", | 2410 | "errors.studentOnlyTitle": "This page is for students", |
| 2363 | "errors.parentOnlyTitle": "This page is for parents", | 2411 | "errors.parentOnlyTitle": "This page is for parents", |
| 2364 | "errors.audienceOnlyDescription": "This view is shown only to the student or parent signed in to their own account; staff accounts do not open it.", | 2412 | "errors.audienceOnlyDescription": "This view is shown only to the student or parent signed in to their own account; staff accounts do not open it.", |
src/i18n/locales/tr.tsmodified+52 -4
| @@ -373,7 +373,7 @@ export const tr: Dict = { | |||
| 373 | "notifications.empty": "Henüz yeni bir bildiriminiz yok.", | 373 | "notifications.empty": "Henüz yeni bir bildiriminiz yok.", |
| 374 | "notifications.tabAll": "Tümü", | 374 | "notifications.tabAll": "Tümü", |
| 375 | "notifications.tabSystem": "Sistem", | 375 | "notifications.tabSystem": "Sistem", |
| 376 | - "notifications.goToPage": "Sayfaya git", | 376 | + "notifications.unreadCount": "{count} okunmamış", |
| 377 | "errors.notFoundDescription": "Aradığın sayfa taşınmış ya da silinmiş olabilir.", | 377 | "errors.notFoundDescription": "Aradığın sayfa taşınmış ya da silinmiş olabilir.", |
| 378 | "errors.accessDeniedDescription": "Rolün bu bölümü görüntülemeye yetkili değil. Gerekliyse kurum yöneticinden yetki iste.", | 378 | "errors.accessDeniedDescription": "Rolün bu bölümü görüntülemeye yetkili değil. Gerekliyse kurum yöneticinden yetki iste.", |
| 379 | "network.offlineTitle": "Bağlantın koptu", | 379 | "network.offlineTitle": "Bağlantın koptu", |
| @@ -797,6 +797,11 @@ export const tr: Dict = { | |||
| 797 | "auth.passwordHint": "6–128 karakter", | 797 | "auth.passwordHint": "6–128 karakter", |
| 798 | "auth.showPassword": "Şifreyi göster", | 798 | "auth.showPassword": "Şifreyi göster", |
| 799 | "auth.hidePassword": "Şifreyi gizle", | 799 | "auth.hidePassword": "Şifreyi gizle", |
| 800 | + "auth.showConfirmPassword": "Şifre onayını göster", | ||
| 801 | + "auth.hideConfirmPassword": "Şifre onayını gizle", | ||
| 802 | + "auth.schoolCodeHint": "Okulunun sana ilettiği okul kodu (okul adı değil): küçük harf, rakam ve tire, {min}–{max} karakter.", | ||
| 803 | + "auth.passwordMinHint": "En az {min} karakter.", | ||
| 804 | + "auth.passwordTooShort": "Şifre en az {min} karakter olmalı.", | ||
| 800 | "auth.welcomeBack": "Seni yeniden görmek güzel", | 805 | "auth.welcomeBack": "Seni yeniden görmek güzel", |
| 801 | "auth.createStudent": "Öğrenci hesabı oluştur", | 806 | "auth.createStudent": "Öğrenci hesabı oluştur", |
| 802 | "dashboard.greeting": "Merhaba, {name}", | 807 | "dashboard.greeting": "Merhaba, {name}", |
| @@ -837,11 +842,11 @@ export const tr: Dict = { | |||
| 837 | "command.action.createExamDesc": "Öğrenciler için yeni sınav tanımla", | 842 | "command.action.createExamDesc": "Öğrenciler için yeni sınav tanımla", |
| 838 | "command.action.createNote": "Ders notu ekle", | 843 | "command.action.createNote": "Ders notu ekle", |
| 839 | "command.action.createNoteDesc": "Kişisel veya ders notu kaydet", | 844 | "command.action.createNoteDesc": "Kişisel veya ders notu kaydet", |
| 840 | - "command.action.importNote": "Not içe aktar assistant", | 845 | + "command.action.importNote": "Not içe aktarma yardımcısı", |
| 841 | "command.action.importNoteDesc": "PDF veya metin belgesini not haline getir", | 846 | "command.action.importNoteDesc": "PDF veya metin belgesini not haline getir", |
| 842 | "command.action.askQuestion": "Soru sor / havuza ekle", | 847 | "command.action.askQuestion": "Soru sor / havuza ekle", |
| 843 | "command.action.askQuestionDesc": "Soru havuzuna yeni soru ekle", | 848 | "command.action.askQuestionDesc": "Soru havuzuna yeni soru ekle", |
| 844 | - "command.action.askCelebi": "Çelebi AI ile konuş", | 849 | + "command.action.askCelebi": "Çelebi ile sohbet et", |
| 845 | "command.action.askCelebiDesc": "Yapay zeka asistanı ile sohbet et", | 850 | "command.action.askCelebiDesc": "Yapay zeka asistanı ile sohbet et", |
| 846 | "command.action.myProfile": "Profil bilgilerim", | 851 | "command.action.myProfile": "Profil bilgilerim", |
| 847 | "command.action.myProfileDesc": "Kullanıcı hesabı ve profil detayları", | 852 | "command.action.myProfileDesc": "Kullanıcı hesabı ve profil detayları", |
| @@ -856,6 +861,14 @@ export const tr: Dict = { | |||
| 856 | "command.key.navigate": "gezin", | 861 | "command.key.navigate": "gezin", |
| 857 | "command.key.select": "seç", | 862 | "command.key.select": "seç", |
| 858 | "command.key.close": "kapat", | 863 | "command.key.close": "kapat", |
| 864 | + "command.group.courses": "Dersler", | ||
| 865 | + "command.group.exams": "Sınavlar", | ||
| 866 | + "command.group.homework": "Ödevler", | ||
| 867 | + "command.group.events": "Etkinlikler", | ||
| 868 | + "command.recordsLoading": "Dersler, sınavlar ve diğer kayıtlar yükleniyor…", | ||
| 869 | + "command.resultCount": "{count} sonuç", | ||
| 870 | + "command.homeworkDue": "Teslim: {date}", | ||
| 871 | + "search.hint.commandRecords": "Adıyla da arayabilirsiniz: {kinds}.", | ||
| 859 | "command.action.themeDarkDesc": "Koyu moda geç", | 872 | "command.action.themeDarkDesc": "Koyu moda geç", |
| 860 | "command.action.themeLightDesc": "Açık moda geç", | 873 | "command.action.themeLightDesc": "Açık moda geç", |
| 861 | "command.action.langTrDesc": "Türkçe diline geç", | 874 | "command.action.langTrDesc": "Türkçe diline geç", |
| @@ -1176,6 +1189,32 @@ export const tr: Dict = { | |||
| 1176 | "draw.bgNone": "Düz", | 1189 | "draw.bgNone": "Düz", |
| 1177 | "draw.bgLines": "Çizgili", | 1190 | "draw.bgLines": "Çizgili", |
| 1178 | "draw.bgGrid": "Kareli", | 1191 | "draw.bgGrid": "Kareli", |
| 1192 | + "draw.colorName.black": "Siyah", | ||
| 1193 | + "draw.colorName.red": "Kırmızı", | ||
| 1194 | + "draw.colorName.blue": "Mavi", | ||
| 1195 | + "draw.colorName.green": "Yeşil", | ||
| 1196 | + "draw.colorName.yellow": "Sarı", | ||
| 1197 | + "whiteboard.canvasHintPickPen": "Çizmek için kalemi seç — tahtadaki herkes anlık görür.", | ||
| 1198 | + "exams.publishOnCreateWarning": "Taslak işaretli değil: sınav, soru eklenmeden öğrencilere açılır.", | ||
| 1199 | + "exams.publishEmptyTitle": "Soru olmadan yayınlansın mı?", | ||
| 1200 | + "exams.publishEmptyWarning": "Bu sınavda hiç soru yok. Yayınlarsan öğrenciler boş bir sınav görür.", | ||
| 1201 | + "exams.publishAnyway": "Yine de yayınla", | ||
| 1202 | + "exams.savedAsDraftHint": "Sınav taslak olarak kaydedildi; hazır olduğunda listeden yayınla.", | ||
| 1203 | + "events.status.present": "Katıldı", | ||
| 1204 | + "events.status.absent": "Katılmadı", | ||
| 1205 | + "events.status.late": "Geç geldi", | ||
| 1206 | + "events.status.excused": "Mazeretli", | ||
| 1207 | + "events.rollCall.notStarted": "Yoklama etkinlik başladığında açılır.", | ||
| 1208 | + "events.rollCall.opensAt": "Yoklama etkinlik başladığında açılır ({date}). Kayıtlı durumlar aşağıda görünür.", | ||
| 1209 | + "events.rollCall.emptyRoster": "Bu etkinliğin hedef kitlesinde kimse yok.", | ||
| 1210 | + "events.rollCall.searchHint": "Ad, kullanıcı adı veya öğrenci numarasında arar.", | ||
| 1211 | + "events.rollCall.markRestPresent": "Kalanları Katıldı işaretle", | ||
| 1212 | + "events.rollCall.unsaved": "{status} · kaydedilmedi", | ||
| 1213 | + "events.rollCall.saveFailed": "{total} satırdan {failed} tanesi kaydedilemedi. Hatalar ilgili satırlarda.", | ||
| 1214 | + "events.rollCall.saved": "{count} yoklama kaydedildi.", | ||
| 1215 | + "events.rollCall.pendingChanges": "{count} değişiklik kaydedilmedi", | ||
| 1216 | + "events.rollCall.noChanges": "Kaydedilmemiş değişiklik yok", | ||
| 1217 | + "events.rollCall.discard": "Değişiklikleri at", | ||
| 1179 | "notes.downloadFile": "İndir", | 1218 | "notes.downloadFile": "İndir", |
| 1180 | "notes.noFiles": "Henüz dosya eklenmemiş.", | 1219 | "notes.noFiles": "Henüz dosya eklenmemiş.", |
| 1181 | "notes.fileLimit": "Bu notta zaten 10 dosya var.", | 1220 | "notes.fileLimit": "Bu notta zaten 10 dosya var.", |
| @@ -1197,7 +1236,7 @@ export const tr: Dict = { | |||
| 1197 | "events.myAttendance": "Katılım durumum", | 1236 | "events.myAttendance": "Katılım durumum", |
| 1198 | "events.myAttendanceHelp": "Etkinlik durumunu seç ve kaydet.", | 1237 | "events.myAttendanceHelp": "Etkinlik durumunu seç ve kaydet.", |
| 1199 | "events.studentAttendance": "Öğrenci yoklaması", | 1238 | "events.studentAttendance": "Öğrenci yoklaması", |
| 1200 | - "events.studentAttendanceHelp": "Öğrenciyi seç, durumunu belirle, kaydı kaydet.", | 1239 | + "events.studentAttendanceHelp": "Etkinliğin hedef kitlesindeki herkes listede. Her satırda durumu seç, sonra tek seferde kaydet.", |
| 1201 | "events.saveStudentAttendance": "Yoklamayı kaydet", | 1240 | "events.saveStudentAttendance": "Yoklamayı kaydet", |
| 1202 | "events.attendance": "Yoklama listesi", | 1241 | "events.attendance": "Yoklama listesi", |
| 1203 | "events.attendanceRecords": "Yoklama kayıtları", | 1242 | "events.attendanceRecords": "Yoklama kayıtları", |
| @@ -2342,6 +2381,9 @@ export const tr: Dict = { | |||
| 2342 | "homework.gradeStatusPlaceholder": "Durum seç", | 2381 | "homework.gradeStatusPlaceholder": "Durum seç", |
| 2343 | "homework.gradeStatusRequired": "Kaydetmeden önce bir durum seç.", | 2382 | "homework.gradeStatusRequired": "Kaydetmeden önce bir durum seç.", |
| 2344 | "combobox.showSuggestions": "Önerileri göster", | 2383 | "combobox.showSuggestions": "Önerileri göster", |
| 2384 | + "combobox.suggestions": "Öneriler", | ||
| 2385 | + "combobox.optionSelected": "{option}, seçili", | ||
| 2386 | + "combobox.optionCount": "Seçenek sayısı: {count}", | ||
| 2345 | "course.removeStudentTitle": "Öğrenci bu dersten çıkarılsın mı?", | 2387 | "course.removeStudentTitle": "Öğrenci bu dersten çıkarılsın mı?", |
| 2346 | "course.removeStudentHint": "Öğrencinin bu şubedeki ders kaydı kaldırılır; hesabı silinmez.", | 2388 | "course.removeStudentHint": "Öğrencinin bu şubedeki ders kaydı kaldırılır; hesabı silinmez.", |
| 2347 | "course.removeStudentAction": "Dersten çıkar", | 2389 | "course.removeStudentAction": "Dersten çıkar", |
| @@ -2355,6 +2397,12 @@ export const tr: Dict = { | |||
| 2355 | "instances.karneTurnOff": "Karneye işleme", | 2397 | "instances.karneTurnOff": "Karneye işleme", |
| 2356 | "messages.discardDraftTitle": "Taslak atılsın mı?", | 2398 | "messages.discardDraftTitle": "Taslak atılsın mı?", |
| 2357 | "messages.discardDraftHint": "Bu mesaja yazdıkların gönderilmedi ve kaybolacak.", | 2399 | "messages.discardDraftHint": "Bu mesaja yazdıkların gönderilmedi ve kaybolacak.", |
| 2400 | + "messages.folders": "Klasörler", | ||
| 2401 | + "messages.subject": "Konu", | ||
| 2402 | + "messages.subjectPlaceholder": "Mesajın konusu", | ||
| 2403 | + "messages.label": "Etiket", | ||
| 2404 | + "messages.sendHintRecipient": "Göndermek için bir alıcı seçin.", | ||
| 2405 | + "messages.sendHintSubject": "Göndermek için bir konu yazın.", | ||
| 2358 | "errors.studentOnlyTitle": "Bu sayfa öğrenciler için", | 2406 | "errors.studentOnlyTitle": "Bu sayfa öğrenciler için", |
| 2359 | "errors.parentOnlyTitle": "Bu sayfa veliler için", | 2407 | "errors.parentOnlyTitle": "Bu sayfa veliler için", |
| 2360 | "errors.audienceOnlyDescription": "Bu görünüm yalnızca kendi hesabıyla giriş yapan öğrenci ya da veliye gösterilir; personel hesaplarında açılmaz.", | 2408 | "errors.audienceOnlyDescription": "Bu görünüm yalnızca kendi hesabıyla giriş yapan öğrenci ya da veliye gösterilir; personel hesaplarında açılmaz.", |
src/i18n/messages.tsmodified+49 -1
| @@ -581,7 +581,7 @@ export type MessageKey = | |||
| 581 | | "notifications.empty" | 581 | | "notifications.empty" |
| 582 | | "notifications.tabAll" | 582 | | "notifications.tabAll" |
| 583 | | "notifications.tabSystem" | 583 | | "notifications.tabSystem" |
| 584 | - | "notifications.goToPage" | 584 | + | "notifications.unreadCount" |
| 585 | | "errors.notFoundDescription" | 585 | | "errors.notFoundDescription" |
| 586 | | "errors.accessDeniedDescription" | 586 | | "errors.accessDeniedDescription" |
| 587 | | "network.offlineTitle" | 587 | | "network.offlineTitle" |
| @@ -788,6 +788,11 @@ export type MessageKey = | |||
| 788 | | "auth.passwordHint" | 788 | | "auth.passwordHint" |
| 789 | | "auth.showPassword" | 789 | | "auth.showPassword" |
| 790 | | "auth.hidePassword" | 790 | | "auth.hidePassword" |
| 791 | + | "auth.showConfirmPassword" | ||
| 792 | + | "auth.hideConfirmPassword" | ||
| 793 | + | "auth.schoolCodeHint" | ||
| 794 | + | "auth.passwordMinHint" | ||
| 795 | + | "auth.passwordTooShort" | ||
| 791 | | "auth.welcomeBack" | 796 | | "auth.welcomeBack" |
| 792 | | "auth.createStudent" | 797 | | "auth.createStudent" |
| 793 | | "dashboard.greeting" | 798 | | "dashboard.greeting" |
| @@ -851,6 +856,14 @@ export type MessageKey = | |||
| 851 | | "command.key.navigate" | 856 | | "command.key.navigate" |
| 852 | | "command.key.select" | 857 | | "command.key.select" |
| 853 | | "command.key.close" | 858 | | "command.key.close" |
| 859 | + | "command.group.courses" | ||
| 860 | + | "command.group.exams" | ||
| 861 | + | "command.group.homework" | ||
| 862 | + | "command.group.events" | ||
| 863 | + | "command.recordsLoading" | ||
| 864 | + | "command.resultCount" | ||
| 865 | + | "command.homeworkDue" | ||
| 866 | + | "search.hint.commandRecords" | ||
| 854 | | "dashboard.observationOnly" | 867 | | "dashboard.observationOnly" |
| 855 | | "dashboard.today" | 868 | | "dashboard.today" |
| 856 | | "dashboard.reportCard" | 869 | | "dashboard.reportCard" |
| @@ -1167,6 +1180,32 @@ export type MessageKey = | |||
| 1167 | | "draw.bgNone" | 1180 | | "draw.bgNone" |
| 1168 | | "draw.bgLines" | 1181 | | "draw.bgLines" |
| 1169 | | "draw.bgGrid" | 1182 | | "draw.bgGrid" |
| 1183 | + | "draw.colorName.black" | ||
| 1184 | + | "draw.colorName.red" | ||
| 1185 | + | "draw.colorName.blue" | ||
| 1186 | + | "draw.colorName.green" | ||
| 1187 | + | "draw.colorName.yellow" | ||
| 1188 | + | "whiteboard.canvasHintPickPen" | ||
| 1189 | + | "exams.publishOnCreateWarning" | ||
| 1190 | + | "exams.publishEmptyTitle" | ||
| 1191 | + | "exams.publishEmptyWarning" | ||
| 1192 | + | "exams.publishAnyway" | ||
| 1193 | + | "exams.savedAsDraftHint" | ||
| 1194 | + | "events.status.present" | ||
| 1195 | + | "events.status.absent" | ||
| 1196 | + | "events.status.late" | ||
| 1197 | + | "events.status.excused" | ||
| 1198 | + | "events.rollCall.notStarted" | ||
| 1199 | + | "events.rollCall.opensAt" | ||
| 1200 | + | "events.rollCall.emptyRoster" | ||
| 1201 | + | "events.rollCall.searchHint" | ||
| 1202 | + | "events.rollCall.markRestPresent" | ||
| 1203 | + | "events.rollCall.unsaved" | ||
| 1204 | + | "events.rollCall.saveFailed" | ||
| 1205 | + | "events.rollCall.saved" | ||
| 1206 | + | "events.rollCall.pendingChanges" | ||
| 1207 | + | "events.rollCall.noChanges" | ||
| 1208 | + | "events.rollCall.discard" | ||
| 1170 | | "notes.downloadFile" | 1209 | | "notes.downloadFile" |
| 1171 | | "notes.noFiles" | 1210 | | "notes.noFiles" |
| 1172 | | "notes.fileLimit" | 1211 | | "notes.fileLimit" |
| @@ -2326,6 +2365,9 @@ export type MessageKey = | |||
| 2326 | | "homework.gradeStatusPlaceholder" | 2365 | | "homework.gradeStatusPlaceholder" |
| 2327 | | "homework.gradeStatusRequired" | 2366 | | "homework.gradeStatusRequired" |
| 2328 | | "combobox.showSuggestions" | 2367 | | "combobox.showSuggestions" |
| 2368 | + | "combobox.suggestions" | ||
| 2369 | + | "combobox.optionSelected" | ||
| 2370 | + | "combobox.optionCount" | ||
| 2329 | | "course.removeStudentTitle" | 2371 | | "course.removeStudentTitle" |
| 2330 | | "course.removeStudentHint" | 2372 | | "course.removeStudentHint" |
| 2331 | | "course.removeStudentAction" | 2373 | | "course.removeStudentAction" |
| @@ -2339,6 +2381,12 @@ export type MessageKey = | |||
| 2339 | | "instances.karneTurnOff" | 2381 | | "instances.karneTurnOff" |
| 2340 | | "messages.discardDraftTitle" | 2382 | | "messages.discardDraftTitle" |
| 2341 | | "messages.discardDraftHint" | 2383 | | "messages.discardDraftHint" |
| 2384 | + | "messages.folders" | ||
| 2385 | + | "messages.subject" | ||
| 2386 | + | "messages.subjectPlaceholder" | ||
| 2387 | + | "messages.label" | ||
| 2388 | + | "messages.sendHintRecipient" | ||
| 2389 | + | "messages.sendHintSubject" | ||
| 2342 | | "errors.studentOnlyTitle" | 2390 | | "errors.studentOnlyTitle" |
| 2343 | | "errors.parentOnlyTitle" | 2391 | | "errors.parentOnlyTitle" |
| 2344 | | "errors.audienceOnlyDescription" | 2392 | | "errors.audienceOnlyDescription" |
src/index.cssmodified+18 -0
| @@ -242,6 +242,19 @@ | |||
| 242 | box-shadow: -4px 0 6px -6px color-mix(in srgb, hsl(var(--foreground)) 12%, transparent); | 242 | box-shadow: -4px 0 6px -6px color-mix(in srgb, hsl(var(--foreground)) 12%, transparent); |
| 243 | } | 243 | } |
| 244 | 244 | ||
| 245 | +/* Frozen columns only cast their seam when something can slide under them. | ||
| 246 | + * On a table that fits, the shadow and heavier rule read as "more content to | ||
| 247 | + * the side" and invite a scroll that goes nowhere. */ | ||
| 248 | +.data-table-wrap:not([data-scrollable]) :is(.table-sticky-left, .table-sticky-right, .table-sticky-head-left, .table-sticky-head-right) { | ||
| 249 | + box-shadow: none; | ||
| 250 | +} | ||
| 251 | +.data-table-wrap:not([data-scrollable]) :is(.table-sticky-right, .table-sticky-head-right) { | ||
| 252 | + border-left-color: transparent; | ||
| 253 | +} | ||
| 254 | +.data-table-wrap:not([data-scrollable]) :is(.table-sticky-left, .table-sticky-head-left) { | ||
| 255 | + border-right-color: var(--color-border-hairline); | ||
| 256 | +} | ||
| 257 | + | ||
| 245 | /* İşlemler sütunu: sabit 110x45. */ | 258 | /* İşlemler sütunu: sabit 110x45. */ |
| 246 | .data-table td.table-action-cell, | 259 | .data-table td.table-action-cell, |
| 247 | .data-table th.table-action-cell { | 260 | .data-table th.table-action-cell { |
| @@ -261,6 +274,11 @@ | |||
| 261 | text-align: center; | 274 | text-align: center; |
| 262 | } | 275 | } |
| 263 | 276 | ||
| 277 | +/* Headers centred, values from the left edge, as on every other table. */ | ||
| 278 | +.insight-grid-table td:not(.table-action-cell) { | ||
| 279 | + text-align: left; | ||
| 280 | +} | ||
| 281 | + | ||
| 264 | .insight-grid-table th:last-child, | 282 | .insight-grid-table th:last-child, |
| 265 | .insight-grid-table td:last-child { | 283 | .insight-grid-table td:last-child { |
| 266 | border-right: 0; | 284 | border-right: 0; |
src/lib/command-search.test.tsadded+113 -0
| @@ -0,0 +1,113 @@ | |||
| 1 | +import { afterEach, beforeEach, describe, expect, test, vi } from "vitest"; | ||
| 2 | + | ||
| 3 | +const api = vi.hoisted(() => ({ | ||
| 4 | + getCourses: vi.fn(), | ||
| 5 | + getMyCourses: vi.fn(), | ||
| 6 | + getExams: vi.fn(), | ||
| 7 | + getHomework: vi.fn(), | ||
| 8 | + getEvents: vi.fn(), | ||
| 9 | + getMyInstances: vi.fn(), | ||
| 10 | + loadInstanceLabels: vi.fn(), | ||
| 11 | +})); | ||
| 12 | + | ||
| 13 | +vi.mock("@/api/courses", () => ({ getCourses: api.getCourses })); | ||
| 14 | +vi.mock("@/api/reports", () => ({ getMyCourses: api.getMyCourses })); | ||
| 15 | +vi.mock("@/api/exams", () => ({ getExams: api.getExams })); | ||
| 16 | +vi.mock("@/api/homework", () => ({ getHomework: api.getHomework })); | ||
| 17 | +vi.mock("@/api/events", () => ({ getEvents: api.getEvents })); | ||
| 18 | +vi.mock("@/api/instances", () => ({ getMyInstances: api.getMyInstances })); | ||
| 19 | +vi.mock("@/lib/instance-labels", () => ({ loadInstanceLabels: api.loadInstanceLabels })); | ||
| 20 | + | ||
| 21 | +import { | ||
| 22 | + filterCommandRecords, | ||
| 23 | + loadCommandRecords, | ||
| 24 | + resetCommandRecordCache, | ||
| 25 | + type CommandRecord, | ||
| 26 | +} from "@/lib/command-search"; | ||
| 27 | + | ||
| 28 | +const page = <T,>(items: T[]) => ({ items, total: items.length, limit: 100, offset: 0 }); | ||
| 29 | +const record = (kind: CommandRecord["kind"], id: string, title: string, context: string | null = null): CommandRecord => ({ | ||
| 30 | + kind, | ||
| 31 | + id, | ||
| 32 | + title, | ||
| 33 | + context, | ||
| 34 | + description: null, | ||
| 35 | + at: null, | ||
| 36 | +}); | ||
| 37 | + | ||
| 38 | +describe("filterCommandRecords", () => { | ||
| 39 | + const records = [ | ||
| 40 | + record("event", "ev1", "Biyoloji gezisi"), | ||
| 41 | + record("course", "c1", "Biyoloji"), | ||
| 42 | + record("course", "c2", "Kimya"), | ||
| 43 | + record("exam", "e1", "1. Yazılı", "Biyoloji — 10-B"), | ||
| 44 | + record("homework", "h1", "Hücre ödevi", "Biyoloji — 9-A"), | ||
| 45 | + ]; | ||
| 46 | + | ||
| 47 | + test("matches titles and section labels, Turkish-folded, grouped in kind order", () => { | ||
| 48 | + expect(filterCommandRecords(records, "biyoloji").map((r) => r.id)).toEqual(["c1", "e1", "h1", "ev1"]); | ||
| 49 | + expect(filterCommandRecords(records, "BİYOLOJİ").map((r) => r.id)).toEqual(["c1", "e1", "h1", "ev1"]); | ||
| 50 | + expect(filterCommandRecords(records, "yazili").map((r) => r.id)).toEqual(["e1"]); | ||
| 51 | + expect(filterCommandRecords(records, "hucre 9a").map((r) => r.id)).toEqual(["h1"]); | ||
| 52 | + }); | ||
| 53 | + | ||
| 54 | + test("a one-letter query matches nothing", () => { | ||
| 55 | + expect(filterCommandRecords(records, "b")).toEqual([]); | ||
| 56 | + expect(filterCommandRecords(records, " ")).toEqual([]); | ||
| 57 | + }); | ||
| 58 | + | ||
| 59 | + test("caps each kind", () => { | ||
| 60 | + const many = Array.from({ length: 8 }, (_, i) => record("course", `c${i}`, `Matematik ${i}`)); | ||
| 61 | + expect(filterCommandRecords(many, "matematik", 3).map((r) => r.id)).toEqual(["c0", "c1", "c2"]); | ||
| 62 | + }); | ||
| 63 | +}); | ||
| 64 | + | ||
| 65 | +describe("loadCommandRecords", () => { | ||
| 66 | + beforeEach(() => { | ||
| 67 | + resetCommandRecordCache(); | ||
| 68 | + api.getCourses.mockResolvedValue(page([{ id: "c1", title: "Biyoloji", description: "", kind: "course" }])); | ||
| 69 | + api.getMyCourses.mockResolvedValue(page([{ id: "c9", title: "Fizik", description: "", kind: "course" }])); | ||
| 70 | + api.getExams.mockResolvedValue( | ||
| 71 | + page([ | ||
| 72 | + { id: "e1", title: "Yazılı", description: "", class_course: "i1", starts_at: 5 }, | ||
| 73 | + { id: "e2", title: "Quiz", description: "", class_course: "i2", starts_at: null }, | ||
| 74 | + ]), | ||
| 75 | + ); | ||
| 76 | + api.getHomework.mockResolvedValue(page([{ id: "h1", title: "Ödev", description: null, class_course: "i1", due_at: 7 }])); | ||
| 77 | + api.getEvents.mockResolvedValue(page([{ id: "ev1", title: "Gezi", description: "", starts_at: 9 }])); | ||
| 78 | + api.getMyInstances.mockResolvedValue(page([{ id: "i1" }])); | ||
| 79 | + api.loadInstanceLabels.mockResolvedValue(new Map([["i1", { label: "Biyoloji — 10-B" }]])); | ||
| 80 | + }); | ||
| 81 | + afterEach(() => vi.clearAllMocks()); | ||
| 82 | + | ||
| 83 | + test("a student reads their own courses and only exams in their own sections", async () => { | ||
| 84 | + const out = await loadCommandRecords("student", ["course", "exam"]); | ||
| 85 | + expect(api.getMyCourses).toHaveBeenCalled(); | ||
| 86 | + expect(api.getCourses).not.toHaveBeenCalled(); | ||
| 87 | + expect(out.map((r) => r.id)).toEqual(["c9", "e1"]); | ||
| 88 | + expect(out[1].context).toBe("Biyoloji — 10-B"); | ||
| 89 | + }); | ||
| 90 | + | ||
| 91 | + test("staff read the full catalog and every exam the backend returns", async () => { | ||
| 92 | + const out = await loadCommandRecords("teacher", ["course", "exam"]); | ||
| 93 | + expect(api.getCourses).toHaveBeenCalled(); | ||
| 94 | + expect(api.getMyInstances).not.toHaveBeenCalled(); | ||
| 95 | + expect(out.map((r) => r.id)).toEqual(["c1", "e1", "e2"]); | ||
| 96 | + }); | ||
| 97 | + | ||
| 98 | + test("only the requested kinds are read, and a failing kind leaves the others", async () => { | ||
| 99 | + api.getEvents.mockRejectedValue(new Error("boom")); | ||
| 100 | + const out = await loadCommandRecords("parent", ["event", "homework"]); | ||
| 101 | + expect(api.getCourses).not.toHaveBeenCalled(); | ||
| 102 | + expect(api.getExams).not.toHaveBeenCalled(); | ||
| 103 | + expect(out.map((r) => r.id)).toEqual(["h1"]); | ||
| 104 | + }); | ||
| 105 | + | ||
| 106 | + test("reopening within the cache window reuses the last read", async () => { | ||
| 107 | + await loadCommandRecords("teacher", ["course"], 1_000); | ||
| 108 | + await loadCommandRecords("teacher", ["course"], 30_000); | ||
| 109 | + expect(api.getCourses).toHaveBeenCalledTimes(1); | ||
| 110 | + await loadCommandRecords("teacher", ["course"], 120_000); | ||
| 111 | + expect(api.getCourses).toHaveBeenCalledTimes(2); | ||
| 112 | + }); | ||
| 113 | +}); | ||
src/lib/command-search.tsadded+163 -0
| @@ -0,0 +1,163 @@ | |||
| 1 | +import { getCourses } from "@/api/courses"; | ||
| 2 | +import { getExams } from "@/api/exams"; | ||
| 3 | +import { getEvents } from "@/api/events"; | ||
| 4 | +import { getHomework } from "@/api/homework"; | ||
| 5 | +import { getMyInstances } from "@/api/instances"; | ||
| 6 | +import { getMyCourses } from "@/api/reports"; | ||
| 7 | +import type { Role } from "@/api/client"; | ||
| 8 | +import { LIST_CAP, loadCappedList } from "@/lib/capped-list"; | ||
| 9 | +import { loadInstanceLabels } from "@/lib/instance-labels"; | ||
| 10 | +import { matchesSearch } from "@/lib/search-text"; | ||
| 11 | + | ||
| 12 | +/** | ||
| 13 | + * Records the command palette can search besides pages and actions: the | ||
| 14 | + * courses, exams, homework and events the user's own list pages show. | ||
| 15 | + * | ||
| 16 | + * Each kind is read the way its list page reads it (same endpoint, same cap, | ||
| 17 | + * same role scoping), once when the palette opens — never per keystroke — and | ||
| 18 | + * the typed query is matched client-side with the app's Turkish folding. | ||
| 19 | + */ | ||
| 20 | +export type CommandRecordKind = "course" | "exam" | "homework" | "event"; | ||
| 21 | + | ||
| 22 | +export const COMMAND_RECORD_KINDS: readonly CommandRecordKind[] = ["course", "exam", "homework", "event"]; | ||
| 23 | + | ||
| 24 | +/** The list route each kind lives under; a kind is searched only when its route is in the user's nav. */ | ||
| 25 | +export const COMMAND_RECORD_ROUTES: Record<CommandRecordKind, string> = { | ||
| 26 | + course: "/courses", | ||
| 27 | + exam: "/exams", | ||
| 28 | + homework: "/homework", | ||
| 29 | + event: "/events", | ||
| 30 | +}; | ||
| 31 | + | ||
| 32 | +export type CommandRecord = { | ||
| 33 | + kind: CommandRecordKind; | ||
| 34 | + id: string; | ||
| 35 | + title: string; | ||
| 36 | + /** "<ders> — <şube>" for exams and homework; null when it could not be read. */ | ||
| 37 | + context: string | null; | ||
| 38 | + description: string | null; | ||
| 39 | + /** Course kind (course / study / club) for catalog rows. */ | ||
| 40 | + courseKind?: string; | ||
| 41 | + /** Start time (exam, event) or due time (homework). */ | ||
| 42 | + at: number | null; | ||
| 43 | +}; | ||
| 44 | + | ||
| 45 | +/** Below this many characters a query would match nearly every record. */ | ||
| 46 | +export const COMMAND_RECORD_MIN_QUERY = 2; | ||
| 47 | +export const COMMAND_RECORDS_PER_KIND = 5; | ||
| 48 | + | ||
| 49 | +/** | ||
| 50 | + * Records matching `query`, in kind order, at most `perKind` of each — the | ||
| 51 | + * palette is a jump list, not a results page, and the list page holds the rest. | ||
| 52 | + */ | ||
| 53 | +export function filterCommandRecords( | ||
| 54 | + records: readonly CommandRecord[], | ||
| 55 | + query: string, | ||
| 56 | + perKind = COMMAND_RECORDS_PER_KIND, | ||
| 57 | +): CommandRecord[] { | ||
| 58 | + const q = query.trim(); | ||
| 59 | + if (q.length < COMMAND_RECORD_MIN_QUERY) return []; | ||
| 60 | + const counts = new Map<CommandRecordKind, number>(); | ||
| 61 | + const out: CommandRecord[] = []; | ||
| 62 | + for (const kind of COMMAND_RECORD_KINDS) { | ||
| 63 | + for (const record of records) { | ||
| 64 | + if (record.kind !== kind) continue; | ||
| 65 | + if ((counts.get(kind) ?? 0) >= perKind) break; | ||
| 66 | + if (!matchesSearch(q, record.title, record.context, record.description)) continue; | ||
| 67 | + counts.set(kind, (counts.get(kind) ?? 0) + 1); | ||
| 68 | + out.push(record); | ||
| 69 | + } | ||
| 70 | + } | ||
| 71 | + return out; | ||
| 72 | +} | ||
| 73 | + | ||
| 74 | +async function loadCourses(role: Role): Promise<CommandRecord[]> { | ||
| 75 | + // As on /courses: a student's list is their own enrolments. | ||
| 76 | + const page = role === "student" ? await getMyCourses() : await getCourses(); | ||
| 77 | + return page.items.map((course) => ({ | ||
| 78 | + kind: "course", | ||
| 79 | + id: course.id, | ||
| 80 | + title: course.title, | ||
| 81 | + context: null, | ||
| 82 | + description: course.description || null, | ||
| 83 | + courseKind: course.kind, | ||
| 84 | + at: null, | ||
| 85 | + })); | ||
| 86 | +} | ||
| 87 | + | ||
| 88 | +async function loadExams(role: Role): Promise<CommandRecord[]> { | ||
| 89 | + const [page, mine] = await Promise.all([ | ||
| 90 | + loadCappedList(getExams, LIST_CAP, false), | ||
| 91 | + // As on /exams: a student only sees exams set in their own sections. | ||
| 92 | + role === "student" ? getMyInstances({ limit: 200 }).then((p) => new Set(p.items.map((i) => i.id))) : null, | ||
| 93 | + ]); | ||
| 94 | + const items = mine ? page.items.filter((exam) => mine.has(exam.class_course)) : page.items; | ||
| 95 | + const labels = await loadInstanceLabels(items.map((exam) => exam.class_course), role).catch(() => new Map()); | ||
| 96 | + return items.map((exam) => ({ | ||
| 97 | + kind: "exam", | ||
| 98 | + id: exam.id, | ||
| 99 | + title: exam.title, | ||
| 100 | + context: labels.get(exam.class_course)?.label ?? null, | ||
| 101 | + description: exam.description || null, | ||
| 102 | + at: exam.starts_at, | ||
| 103 | + })); | ||
| 104 | +} | ||
| 105 | + | ||
| 106 | +async function loadHomework(role: Role): Promise<CommandRecord[]> { | ||
| 107 | + const items = (await getHomework({ limit: LIST_CAP })).items; | ||
| 108 | + const labels = await loadInstanceLabels(items.map((item) => item.class_course), role).catch(() => new Map()); | ||
| 109 | + return items.map((item) => ({ | ||
| 110 | + kind: "homework", | ||
| 111 | + id: item.id, | ||
| 112 | + title: item.title, | ||
| 113 | + context: labels.get(item.class_course)?.label ?? null, | ||
| 114 | + description: item.description || null, | ||
| 115 | + at: item.due_at, | ||
| 116 | + })); | ||
| 117 | +} | ||
| 118 | + | ||
| 119 | +async function loadEvents(): Promise<CommandRecord[]> { | ||
| 120 | + const page = await loadCappedList(getEvents, LIST_CAP, false); | ||
| 121 | + return page.items.map((event) => ({ | ||
| 122 | + kind: "event", | ||
| 123 | + id: event.id, | ||
| 124 | + title: event.title, | ||
| 125 | + context: null, | ||
| 126 | + description: event.description || null, | ||
| 127 | + at: event.starts_at, | ||
| 128 | + })); | ||
| 129 | +} | ||
| 130 | + | ||
| 131 | +const LOADERS: Record<CommandRecordKind, (role: Role) => Promise<CommandRecord[]>> = { | ||
| 132 | + course: loadCourses, | ||
| 133 | + exam: loadExams, | ||
| 134 | + homework: loadHomework, | ||
| 135 | + event: loadEvents, | ||
| 136 | +}; | ||
| 137 | + | ||
| 138 | +/** Reopening the palette within this window reuses the last read. */ | ||
| 139 | +const CACHE_MS = 60_000; | ||
| 140 | +let cache: { key: string; at: number; records: Promise<CommandRecord[]> } | null = null; | ||
| 141 | + | ||
| 142 | +/** | ||
| 143 | + * Every searchable record for `role`, limited to `kinds`. A kind that fails to | ||
| 144 | + * load is left out rather than emptying the others. | ||
| 145 | + */ | ||
| 146 | +export function loadCommandRecords( | ||
| 147 | + role: Role, | ||
| 148 | + kinds: readonly CommandRecordKind[], | ||
| 149 | + now: number = Date.now(), | ||
| 150 | +): Promise<CommandRecord[]> { | ||
| 151 | + const key = `${role}|${[...kinds].sort().join(",")}`; | ||
| 152 | + if (cache && cache.key === key && now - cache.at < CACHE_MS) return cache.records; | ||
| 153 | + const records = Promise.allSettled(kinds.map((kind) => LOADERS[kind](role))).then((results) => | ||
| 154 | + results.flatMap((result) => (result.status === "fulfilled" ? result.value : [])), | ||
| 155 | + ); | ||
| 156 | + cache = { key, at: now, records }; | ||
| 157 | + return records; | ||
| 158 | +} | ||
| 159 | + | ||
| 160 | +/** Test hook: forget the last read. */ | ||
| 161 | +export function resetCommandRecordCache(): void { | ||
| 162 | + cache = null; | ||
| 163 | +} | ||
src/lib/event-roll-call.test.tsadded+65 -0
| @@ -0,0 +1,65 @@ | |||
| 1 | +import { | ||
| 2 | + eventStatusLabelKey, | ||
| 3 | + isRollCallOpen, | ||
| 4 | + orderRollCallStatuses, | ||
| 5 | + rollCallChanges, | ||
| 6 | + saveRollCallChanges, | ||
| 7 | +} from "@/lib/event-roll-call"; | ||
| 8 | + | ||
| 9 | +test("core statuses get event wording, school-defined ones do not", () => { | ||
| 10 | + expect(eventStatusLabelKey("present")).toBe("events.status.present"); | ||
| 11 | + expect(eventStatusLabelKey("absent")).toBe("events.status.absent"); | ||
| 12 | + expect(eventStatusLabelKey("late")).toBe("events.status.late"); | ||
| 13 | + expect(eventStatusLabelKey("excused")).toBe("events.status.excused"); | ||
| 14 | + expect(eventStatusLabelKey("medical")).toBeNull(); | ||
| 15 | +}); | ||
| 16 | + | ||
| 17 | +test("present leads the status list, the rest keep the school's order", () => { | ||
| 18 | + expect(orderRollCallStatuses(["absent", "late", "present", "excused"])).toEqual(["present", "absent", "late", "excused"]); | ||
| 19 | + expect(orderRollCallStatuses(["absent", "late"])).toEqual(["absent", "late"]); | ||
| 20 | +}); | ||
| 21 | + | ||
| 22 | +test("only drafted statuses that differ from the saved mark are sent", () => { | ||
| 23 | + const saved = { a: "present", b: null, c: "late" }; | ||
| 24 | + const draft = { a: "present", b: "absent", c: "excused", d: "present" }; | ||
| 25 | + expect(rollCallChanges(saved, draft)).toEqual([ | ||
| 26 | + { userId: "b", status: "absent" }, | ||
| 27 | + { userId: "c", status: "excused" }, | ||
| 28 | + { userId: "d", status: "present" }, | ||
| 29 | + ]); | ||
| 30 | +}); | ||
| 31 | + | ||
| 32 | +test("an empty draft has nothing to save", () => { | ||
| 33 | + expect(rollCallChanges({ a: "present" }, {})).toEqual([]); | ||
| 34 | + expect(rollCallChanges({ a: "present" }, { a: undefined })).toEqual([]); | ||
| 35 | +}); | ||
| 36 | + | ||
| 37 | +test("roll call opens at the start time, or at once without one", () => { | ||
| 38 | + expect(isRollCallOpen(2000, 1000)).toBe(false); | ||
| 39 | + expect(isRollCallOpen(1000, 1000)).toBe(true); | ||
| 40 | + expect(isRollCallOpen(1000, 2000)).toBe(true); | ||
| 41 | + expect(isRollCallOpen(null, 0)).toBe(true); | ||
| 42 | + expect(isRollCallOpen(undefined, 0)).toBe(true); | ||
| 43 | +}); | ||
| 44 | + | ||
| 45 | +test("saving sends rows in order, keeps going past a failure and reports progress", async () => { | ||
| 46 | + const sent: string[] = []; | ||
| 47 | + const progress: [number, number][] = []; | ||
| 48 | + const boom = new Error("outside audience"); | ||
| 49 | + const result = await saveRollCallChanges( | ||
| 50 | + [ | ||
| 51 | + { userId: "a", status: "present" }, | ||
| 52 | + { userId: "b", status: "absent" }, | ||
| 53 | + { userId: "c", status: "late" }, | ||
| 54 | + ], | ||
| 55 | + async (change) => { | ||
| 56 | + sent.push(change.userId); | ||
| 57 | + if (change.userId === "b") throw boom; | ||
| 58 | + }, | ||
| 59 | + (done, total) => progress.push([done, total]), | ||
| 60 | + ); | ||
| 61 | + expect(sent).toEqual(["a", "b", "c"]); | ||
| 62 | + expect(result.saved.map((change) => change.userId)).toEqual(["a", "c"]); | ||
| 63 | + expect(result.failed).toEqual([{ change: { userId: "b", status: "absent" }, error: boom }]); | ||
| 64 | + expect(progress).toEqual([[1, 3], [2, 3], [3, 3]]); | ||
| 65 | +}); | ||
src/lib/event-roll-call.tsadded+83 -0
| @@ -0,0 +1,83 @@ | |||
| 1 | +import type { AttendanceStatus } from "@/api/client"; | ||
| 2 | +import type { MessageKey } from "@/i18n/messages"; | ||
| 3 | + | ||
| 4 | +/** | ||
| 5 | + * Event wording for the core attendance statuses. The backend knows the same | ||
| 6 | + * status values for lessons and events; only the label changes ("Var" reads | ||
| 7 | + * as "in class" — at an event the student "attended"). Unknown school-defined | ||
| 8 | + * statuses have no entry and fall back to the shared lesson label or the raw | ||
| 9 | + * value. | ||
| 10 | + */ | ||
| 11 | +const EVENT_STATUS_KEYS: Record<string, MessageKey> = { | ||
| 12 | + present: "events.status.present", | ||
| 13 | + absent: "events.status.absent", | ||
| 14 | + late: "events.status.late", | ||
| 15 | + excused: "events.status.excused", | ||
| 16 | +}; | ||
| 17 | + | ||
| 18 | +export function eventStatusLabelKey(status: AttendanceStatus): MessageKey | null { | ||
| 19 | + return EVENT_STATUS_KEYS[status] ?? null; | ||
| 20 | +} | ||
| 21 | + | ||
| 22 | +/** | ||
| 23 | + * The school's statuses in its own order, except "present" leads — it is the | ||
| 24 | + * status taken most, so it sits first on every row (as in lesson roll call). | ||
| 25 | + */ | ||
| 26 | +export function orderRollCallStatuses(list: readonly AttendanceStatus[]): AttendanceStatus[] { | ||
| 27 | + return list.includes("present") ? ["present", ...list.filter((status) => status !== "present")] : [...list]; | ||
| 28 | +} | ||
| 29 | + | ||
| 30 | +export type RollCallChange = { userId: string; status: AttendanceStatus }; | ||
| 31 | + | ||
| 32 | +/** | ||
| 33 | + * The rows a save has to send: every drafted status that differs from what | ||
| 34 | + * the server already holds. A draft equal to the saved mark is a no-op. | ||
| 35 | + */ | ||
| 36 | +export function rollCallChanges( | ||
| 37 | + saved: Readonly<Record<string, AttendanceStatus | null | undefined>>, | ||
| 38 | + draft: Readonly<Record<string, AttendanceStatus | undefined>>, | ||
| 39 | +): RollCallChange[] { | ||
| 40 | + const changes: RollCallChange[] = []; | ||
| 41 | + for (const [userId, status] of Object.entries(draft)) { | ||
| 42 | + if (status && saved[userId] !== status) changes.push({ userId, status }); | ||
| 43 | + } | ||
| 44 | + return changes; | ||
| 45 | +} | ||
| 46 | + | ||
| 47 | +/** | ||
| 48 | + * Roll call opens once the event has started. An event with no start time | ||
| 49 | + * has nothing to wait for and is always open. | ||
| 50 | + */ | ||
| 51 | +export function isRollCallOpen(startsAt: number | null | undefined, now: number): boolean { | ||
| 52 | + return startsAt == null || startsAt <= now; | ||
| 53 | +} | ||
| 54 | + | ||
| 55 | +export type RollCallSaveResult = { | ||
| 56 | + saved: RollCallChange[]; | ||
| 57 | + failed: { change: RollCallChange; error: unknown }[]; | ||
| 58 | +}; | ||
| 59 | + | ||
| 60 | +/** | ||
| 61 | + * Sends the changes one at a time — the API marks a single user per call and | ||
| 62 | + * has no bulk endpoint. A failed row does not stop the rest; each outcome is | ||
| 63 | + * reported so the caller can show per-row errors. | ||
| 64 | + */ | ||
| 65 | +export async function saveRollCallChanges( | ||
| 66 | + changes: readonly RollCallChange[], | ||
| 67 | + send: (change: RollCallChange) => Promise<unknown>, | ||
| 68 | + onProgress?: (done: number, total: number) => void, | ||
| 69 | +): Promise<RollCallSaveResult> { | ||
| 70 | + const result: RollCallSaveResult = { saved: [], failed: [] }; | ||
| 71 | + let done = 0; | ||
| 72 | + for (const change of changes) { | ||
| 73 | + try { | ||
| 74 | + await send(change); | ||
| 75 | + result.saved.push(change); | ||
| 76 | + } catch (error) { | ||
| 77 | + result.failed.push({ change, error }); | ||
| 78 | + } | ||
| 79 | + done += 1; | ||
| 80 | + onProgress?.(done, changes.length); | ||
| 81 | + } | ||
| 82 | + return result; | ||
| 83 | +} | ||
src/lib/exam-publish.test.tsadded+35 -0
| @@ -0,0 +1,35 @@ | |||
| 1 | +import { countExamQuestions, isPublishing } from "@/lib/exam-publish"; | ||
| 2 | + | ||
| 3 | +const { getExamQuestions } = vi.hoisted(() => ({ | ||
| 4 | + getExamQuestions: vi.fn(async () => ({ items: [], total: 3, limit: 1, offset: 0 })), | ||
| 5 | +})); | ||
| 6 | + | ||
| 7 | +vi.mock("@/api/exams", () => ({ getExamQuestions })); | ||
| 8 | + | ||
| 9 | +afterEach(() => { | ||
| 10 | + vi.clearAllMocks(); | ||
| 11 | +}); | ||
| 12 | + | ||
| 13 | +test("clearing the draft flag on a draft exam publishes it", () => { | ||
| 14 | + expect(isPublishing({ draft: true }, false)).toBe(true); | ||
| 15 | +}); | ||
| 16 | + | ||
| 17 | +test("creating an exam without the draft flag publishes it", () => { | ||
| 18 | + expect(isPublishing(null, false)).toBe(true); | ||
| 19 | + expect(isPublishing(undefined, false)).toBe(true); | ||
| 20 | +}); | ||
| 21 | + | ||
| 22 | +test("an exam that stays or becomes a draft is not published", () => { | ||
| 23 | + expect(isPublishing({ draft: true }, true)).toBe(false); | ||
| 24 | + expect(isPublishing({ draft: false }, true)).toBe(false); | ||
| 25 | + expect(isPublishing(null, true)).toBe(false); | ||
| 26 | +}); | ||
| 27 | + | ||
| 28 | +test("editing an exam that is already live is not a publish", () => { | ||
| 29 | + expect(isPublishing({ draft: false }, false)).toBe(false); | ||
| 30 | +}); | ||
| 31 | + | ||
| 32 | +test("countExamQuestions reads the total of a one-row page", async () => { | ||
| 33 | + await expect(countExamQuestions("exam-1")).resolves.toBe(3); | ||
| 34 | + expect(getExamQuestions).toHaveBeenCalledWith("exam-1", { limit: 1 }); | ||
| 35 | +}); | ||
src/lib/exam-publish.tsadded+19 -0
| @@ -0,0 +1,19 @@ | |||
| 1 | +import { getExamQuestions } from "@/api/exams"; | ||
| 2 | + | ||
| 3 | +/** | ||
| 4 | + * True when a save takes a draft exam live: it was a draft before and the | ||
| 5 | + * new values clear the flag. Creating straight into live (no `before`) also | ||
| 6 | + * counts — a brand-new exam never has questions yet. | ||
| 7 | + */ | ||
| 8 | +export function isPublishing(before: { draft?: boolean } | null | undefined, nextDraft: boolean): boolean { | ||
| 9 | + if (nextDraft) return false; | ||
| 10 | + return before == null || before.draft === true; | ||
| 11 | +} | ||
| 12 | + | ||
| 13 | +/** | ||
| 14 | + * How many questions an exam holds. The exam row carries no count, so this | ||
| 15 | + * asks the questions list for a one-row page and reads its `total`. | ||
| 16 | + */ | ||
| 17 | +export async function countExamQuestions(examId: string): Promise<number> { | ||
| 18 | + return (await getExamQuestions(examId, { limit: 1 })).total; | ||
| 19 | +} | ||
src/lib/format.tsmodified+9 -0
| @@ -61,3 +61,12 @@ export function formatDecimal(value: number | null | undefined, locale: Locale = | |||
| 61 | maximumFractionDigits: digits, | 61 | maximumFractionDigits: digits, |
| 62 | }).format(value); | 62 | }).format(value); |
| 63 | } | 63 | } |
| 64 | + | ||
| 65 | +/** | ||
| 66 | + * A chart or count value in the reader's locale with up to `maxDigits` | ||
| 67 | + * decimals: "1.234,5" in Turkish, "1,234.5" in English. Whole numbers stay whole. | ||
| 68 | + */ | ||
| 69 | +export function formatNumber(value: number | null | undefined, locale: Locale = "en", maxDigits = 1): string { | ||
| 70 | + if (value == null || !Number.isFinite(value)) return "—"; | ||
| 71 | + return new Intl.NumberFormat(locale === "tr" ? "tr-TR" : "en-US", { maximumFractionDigits: maxDigits }).format(value); | ||
| 72 | +} | ||
src/lib/notifications.tsmodified+14 -1
| @@ -6,10 +6,23 @@ export interface NotificationItem { | |||
| 6 | title: string; | 6 | title: string; |
| 7 | description: string; | 7 | description: string; |
| 8 | preview?: string; | 8 | preview?: string; |
| 9 | - targetUrl: string; | 9 | + /** Where a click goes; a row without one opens the in-list preview instead. */ |
| 10 | + targetUrl?: string; | ||
| 10 | timestamp: number; | 11 | timestamp: number; |
| 11 | } | 12 | } |
| 12 | 13 | ||
| 14 | +/** | ||
| 15 | + * An unread count as every shell surface shows it — the bell and messages | ||
| 16 | + * badges, the phone action button and the notification list header share one | ||
| 17 | + * cap, so a badge never reads "9+" over a header that says "20". The exact | ||
| 18 | + * number goes in the accessible label. | ||
| 19 | + */ | ||
| 20 | +export const UNREAD_DISPLAY_CAP = 9; | ||
| 21 | + | ||
| 22 | +export function formatUnreadCount(count: number): string { | ||
| 23 | + return count > UNREAD_DISPLAY_CAP ? `${UNREAD_DISPLAY_CAP}+` : String(Math.max(0, count)); | ||
| 24 | +} | ||
| 25 | + | ||
| 13 | const STORAGE_KEY = "hezarfen.dismissedNotifications"; | 26 | const STORAGE_KEY = "hezarfen.dismissedNotifications"; |
| 14 | const READ_STORAGE_KEY = "hezarfen.readNotifications"; | 27 | const READ_STORAGE_KEY = "hezarfen.readNotifications"; |
| 15 | 28 | ||
src/lib/student-directory.test.tsadded+35 -0
| @@ -0,0 +1,35 @@ | |||
| 1 | +import { describe, expect, test } from "vitest"; | ||
| 2 | +import type { ClassGroup, PersonRef } from "@/api/client"; | ||
| 3 | +import { sortByClass } from "@/lib/student-directory"; | ||
| 4 | + | ||
| 5 | +const cls = (name: string, grade: string | null): ClassGroup => ({ | ||
| 6 | + id: name, creator: null, name, grade, year: null, teacher: null, | ||
| 7 | +}); | ||
| 8 | +const person = (name: string): PersonRef => ({ | ||
| 9 | + id: name, username: name.toLowerCase(), display_name: name, student_number: null, | ||
| 10 | +} as PersonRef); | ||
| 11 | + | ||
| 12 | +describe("sortByClass", () => { | ||
| 13 | + test("orders by grade, then şube, then name; classless students last", () => { | ||
| 14 | + const rows = [ | ||
| 15 | + { person: person("Zeynep"), classes: [cls("10-B", "10")] }, | ||
| 16 | + { person: person("Ali"), classes: [] }, | ||
| 17 | + { person: person("Can"), classes: [cls("9-A", "9")] }, | ||
| 18 | + { person: person("Ayşe"), classes: [cls("10-A", "10")] }, | ||
| 19 | + { person: person("Burak"), classes: [cls("10-B", "10")] }, | ||
| 20 | + { person: person("Deniz"), classes: [cls("9-B", "9")] }, | ||
| 21 | + ]; | ||
| 22 | + expect(sortByClass(rows).map((row) => row.person.display_name)) | ||
| 23 | + .toEqual(["Can", "Deniz", "Ayşe", "Burak", "Zeynep", "Ali"]); | ||
| 24 | + }); | ||
| 25 | + | ||
| 26 | + test("files a student in several classes under the earliest one", () => { | ||
| 27 | + const rows = [ | ||
| 28 | + { person: person("Ece"), classes: [cls("10-B", "10"), cls("9-A", "9")] }, | ||
| 29 | + { person: person("Mert"), classes: [cls("9-B", "9")] }, | ||
| 30 | + ]; | ||
| 31 | + const sorted = sortByClass(rows); | ||
| 32 | + expect(sorted.map((row) => row.person.display_name)).toEqual(["Ece", "Mert"]); | ||
| 33 | + expect(sorted[0].classes.map((c) => c.name)).toEqual(["9-A", "10-B"]); | ||
| 34 | + }); | ||
| 35 | +}); | ||
src/lib/student-directory.tsmodified+31 -1
| @@ -22,5 +22,35 @@ export async function getStudentDirectory(): Promise<StudentDirectoryRow[]> { | |||
| 22 | byStudent.set(member.user.id, [...(byStudent.get(member.user.id) ?? []), cls]); | 22 | byStudent.set(member.user.id, [...(byStudent.get(member.user.id) ?? []), cls]); |
| 23 | } | 23 | } |
| 24 | } | 24 | } |
| 25 | - return students.items.map((person) => ({ person, classes: byStudent.get(person.id) ?? [] })); | 25 | + return sortByClass(students.items.map((person) => ({ person, classes: byStudent.get(person.id) ?? [] }))); |
| 26 | +} | ||
| 27 | + | ||
| 28 | +const collator = new Intl.Collator("tr", { numeric: true, sensitivity: "base" }); | ||
| 29 | + | ||
| 30 | +/** Class order a school reads rosters in: grade (9 before 10), then the şube name. */ | ||
| 31 | +export function compareClasses(a: ClassGroup, b: ClassGroup): number { | ||
| 32 | + const gradeA = Number.parseInt(a.grade ?? a.name, 10); | ||
| 33 | + const gradeB = Number.parseInt(b.grade ?? b.name, 10); | ||
| 34 | + if (Number.isFinite(gradeA) && Number.isFinite(gradeB) && gradeA !== gradeB) return gradeA - gradeB; | ||
| 35 | + return collator.compare(a.name, b.name); | ||
| 36 | +} | ||
| 37 | + | ||
| 38 | +/** | ||
| 39 | + * Rows ordered class by class (9-A, 9-B, 10-A…) and by name inside a class. | ||
| 40 | + * A student in several classes files under the first of them; students with | ||
| 41 | + * no class come last. The row's own `classes` are put in the same order. | ||
| 42 | + */ | ||
| 43 | +export function sortByClass<Row extends { person: PersonRef; classes: ClassGroup[] }>(rows: Row[]): Row[] { | ||
| 44 | + const ordered = rows.map((row) => ({ ...row, classes: [...row.classes].sort(compareClasses) })); | ||
| 45 | + return ordered.sort((a, b) => { | ||
| 46 | + const classA = a.classes[0]; | ||
| 47 | + const classB = b.classes[0]; | ||
| 48 | + if (classA && !classB) return -1; | ||
| 49 | + if (!classA && classB) return 1; | ||
| 50 | + if (classA && classB) { | ||
| 51 | + const byClass = compareClasses(classA, classB); | ||
| 52 | + if (byClass !== 0) return byClass; | ||
| 53 | + } | ||
| 54 | + return collator.compare(a.person.display_name || a.person.username, b.person.display_name || b.person.username); | ||
| 55 | + }); | ||
| 26 | } | 56 | } |
src/pages/admin-users-page.tsxmodified+4 -15
| @@ -11,7 +11,6 @@ import { CreateUserPanel } from "@/components/users/create-user-panel"; | |||
| 11 | import { ParentStudentsPanel } from "@/components/users/parent-students-panel"; | 11 | import { ParentStudentsPanel } from "@/components/users/parent-students-panel"; |
| 12 | import { Alert } from "@/components/ui/alert"; | 12 | import { Alert } from "@/components/ui/alert"; |
| 13 | import { Button } from "@/components/ui/button"; | 13 | import { Button } from "@/components/ui/button"; |
| 14 | -import { ComingSoonBadge } from "@/components/ui/coming-soon"; | ||
| 15 | import { DataTableSkeleton } from "@/components/ui/data-table"; | 14 | import { DataTableSkeleton } from "@/components/ui/data-table"; |
| 16 | import { IconPlus } from "@/components/ui/icons"; | 15 | import { IconPlus } from "@/components/ui/icons"; |
| 17 | import { Tabs, TabsList, TabsTrigger } from "@/components/ui/tabs"; | 16 | import { Tabs, TabsList, TabsTrigger } from "@/components/ui/tabs"; |
| @@ -83,10 +82,6 @@ function AdminUsersContent() { | |||
| 83 | <TabsTrigger value="teacher">{t("admin.tabTeachers")}</TabsTrigger> | 82 | <TabsTrigger value="teacher">{t("admin.tabTeachers")}</TabsTrigger> |
| 84 | <TabsTrigger value="parent">{t("admin.tabParents")}</TabsTrigger> | 83 | <TabsTrigger value="parent">{t("admin.tabParents")}</TabsTrigger> |
| 85 | <TabsTrigger value="student">{t("admin.tabStudents")}</TabsTrigger> | 84 | <TabsTrigger value="student">{t("admin.tabStudents")}</TabsTrigger> |
| 86 | - <TabsTrigger value="invites" disabled title={t("comingSoon.title")}> | ||
| 87 | - {t("admin.tabInvites")} | ||
| 88 | - <ComingSoonBadge class="ml-1.5" /> | ||
| 89 | - </TabsTrigger> | ||
| 90 | </TabsList> | 85 | </TabsList> |
| 91 | </Tabs> | 86 | </Tabs> |
| 92 | 87 | ||
| @@ -103,16 +98,10 @@ function AdminUsersContent() { | |||
| 103 | title={t("admin.title")} | 98 | title={t("admin.title")} |
| 104 | description={t("admin.subtitle")} | 99 | description={t("admin.subtitle")} |
| 105 | actions={ | 100 | actions={ |
| 106 | - <> | 101 | + <Button size="sm" class="min-w-[7.5rem] rounded-lg" onClick={() => setCreating(true)}> |
| 107 | - <Button size="sm" variant="outline" class="min-w-[7.5rem] rounded-lg" disabled title={t("comingSoon.title")}> | 102 | + <IconPlus class="mr-1.5 h-4 w-4" /> |
| 108 | - {t("admin.inviteUser")} | 103 | + {t("admin.createUser")} |
| 109 | - <ComingSoonBadge class="ml-1.5" /> | 104 | + </Button> |
| 110 | - </Button> | ||
| 111 | - <Button size="sm" class="min-w-[7.5rem] rounded-lg" onClick={() => setCreating(true)}> | ||
| 112 | - <IconPlus class="mr-1.5 h-4 w-4" /> | ||
| 113 | - {t("admin.createUser")} | ||
| 114 | - </Button> | ||
| 115 | - </> | ||
| 116 | } | 105 | } |
| 117 | users={visibleUsers() as User[]} | 106 | users={visibleUsers() as User[]} |
| 118 | currentUserId={auth.user()!.id} | 107 | currentUserId={auth.user()!.id} |
src/pages/ai-insight-student-page.tsxmodified+1 -5
| @@ -10,7 +10,7 @@ import { Alert } from "@/components/ui/alert"; | |||
| 10 | import { Button } from "@/components/ui/button"; | 10 | import { Button } from "@/components/ui/button"; |
| 11 | import { ErrorAlert } from "@/components/ui/error-alert"; | 11 | import { ErrorAlert } from "@/components/ui/error-alert"; |
| 12 | import { Badge } from "@/components/ui/badge"; | 12 | import { Badge } from "@/components/ui/badge"; |
| 13 | -import { IconDownload, IconSparkles } from "@/components/ui/icons"; | 13 | +import { IconSparkles } from "@/components/ui/icons"; |
| 14 | import { PageSpinner } from "@/components/ui/page-spinner"; | 14 | import { PageSpinner } from "@/components/ui/page-spinner"; |
| 15 | import { createFlash } from "@/lib/flash"; | 15 | import { createFlash } from "@/lib/flash"; |
| 16 | import { loadInsightStudents } from "@/lib/insight-students"; | 16 | import { loadInsightStudents } from "@/lib/insight-students"; |
| @@ -135,10 +135,6 @@ function AiInsightStudentContent() { | |||
| 135 | </div> | 135 | </div> |
| 136 | </div> | 136 | </div> |
| 137 | <div class="flex flex-wrap items-center gap-2"> | 137 | <div class="flex flex-wrap items-center gap-2"> |
| 138 | - <Button variant="outline" size="sm" class="rounded-lg" disabled title={t("comingSoon.title")}> | ||
| 139 | - <IconDownload class="h-4 w-4" /> | ||
| 140 | - {t("common.export")} | ||
| 141 | - </Button> | ||
| 142 | <Show when={canRecompute()}> | 138 | <Show when={canRecompute()}> |
| 143 | <Button size="sm" class="rounded-lg" disabled={queuing()} onClick={() => void recompute()}> | 139 | <Button size="sm" class="rounded-lg" disabled={queuing()} onClick={() => void recompute()}> |
| 144 | <IconSparkles class="h-4 w-4" /> | 140 | <IconSparkles class="h-4 w-4" /> |
src/pages/bank-question-detail-page.tsxmodified+0 -13
| @@ -16,7 +16,6 @@ import { RouteGuard } from "@/components/layout/route-guard"; | |||
| 16 | import { Alert } from "@/components/ui/alert"; | 16 | import { Alert } from "@/components/ui/alert"; |
| 17 | import { Badge } from "@/components/ui/badge"; | 17 | import { Badge } from "@/components/ui/badge"; |
| 18 | import { Button } from "@/components/ui/button"; | 18 | import { Button } from "@/components/ui/button"; |
| 19 | -import { ComingSoonValue } from "@/components/ui/coming-soon"; | ||
| 20 | import { ConfirmDialog } from "@/components/ui/confirm-dialog"; | 19 | import { ConfirmDialog } from "@/components/ui/confirm-dialog"; |
| 21 | import { DetailField } from "@/components/ui/detail-field"; | 20 | import { DetailField } from "@/components/ui/detail-field"; |
| 22 | import { IconEdit, IconTrash } from "@/components/ui/icons"; | 21 | import { IconEdit, IconTrash } from "@/components/ui/icons"; |
| @@ -126,18 +125,6 @@ function BankQuestionDetailContent() { | |||
| 126 | <DetailField label={t("bank.whoCanSee")} value={current().visibility === "school" ? t("bank.sharedWithSchool") : t("bank.onlyMe")} /> | 125 | <DetailField label={t("bank.whoCanSee")} value={current().visibility === "school" ? t("bank.sharedWithSchool") : t("bank.onlyMe")} /> |
| 127 | <DetailField label={t("exams.title")} value={current().source_exam || "—"} mono /> | 126 | <DetailField label={t("exams.title")} value={current().source_exam || "—"} mono /> |
| 128 | <DetailField label={t("admin.id")} value={current().id} mono /> | 127 | <DetailField label={t("admin.id")} value={current().id} mono /> |
| 129 | - <div class="min-w-0 space-y-1"> | ||
| 130 | - <p class="text-xs font-medium text-muted-foreground">{t("bank.difficulty")}</p> | ||
| 131 | - <ComingSoonValue /> | ||
| 132 | - </div> | ||
| 133 | - <div class="min-w-0 space-y-1"> | ||
| 134 | - <p class="text-xs font-medium text-muted-foreground">{t("bank.correctRate")}</p> | ||
| 135 | - <ComingSoonValue /> | ||
| 136 | - </div> | ||
| 137 | - <div class="min-w-0 space-y-1"> | ||
| 138 | - <p class="text-xs font-medium text-muted-foreground">{t("bank.objective")}</p> | ||
| 139 | - <ComingSoonValue /> | ||
| 140 | - </div> | ||
| 141 | </div> | 128 | </div> |
| 142 | 129 | ||
| 143 | <Show when={current().image}> | 130 | <Show when={current().image}> |
src/pages/classes-page.tsxmodified+0 -5
| @@ -22,7 +22,6 @@ import { Label } from "@/components/ui/label"; | |||
| 22 | import { SidePanel } from "@/components/ui/side-panel"; | 22 | import { SidePanel } from "@/components/ui/side-panel"; |
| 23 | import { Tabs, TabsContent, TabsList, TabsTrigger } from "@/components/ui/tabs"; | 23 | import { Tabs, TabsContent, TabsList, TabsTrigger } from "@/components/ui/tabs"; |
| 24 | import { BlueprintsTab } from "@/components/classes/blueprints-tab"; | 24 | import { BlueprintsTab } from "@/components/classes/blueprints-tab"; |
| 25 | -import { ComingSoonBadge } from "@/components/ui/coming-soon"; | ||
| 26 | import { UserSearchSelect } from "@/components/users/user-search-select"; | 25 | import { UserSearchSelect } from "@/components/users/user-search-select"; |
| 27 | import { createFlash } from "@/lib/flash"; | 26 | import { createFlash } from "@/lib/flash"; |
| 28 | import { matchesSearch } from "@/lib/search-text"; | 27 | import { matchesSearch } from "@/lib/search-text"; |
| @@ -241,10 +240,6 @@ function ClassesContent() { | |||
| 241 | } | 240 | } |
| 242 | actions={ | 241 | actions={ |
| 243 | <Show when={canManage()}> | 242 | <Show when={canManage()}> |
| 244 | - <Button type="button" size="sm" variant="outline" class="rounded-lg" disabled title={t("comingSoon.title")}> | ||
| 245 | - {t("classGroups.mergeClasses")} | ||
| 246 | - <ComingSoonBadge class="ml-1.5" /> | ||
| 247 | - </Button> | ||
| 248 | <Button type="button" size="sm" class="rounded-lg" onClick={() => setShowForm(true)}> | 243 | <Button type="button" size="sm" class="rounded-lg" onClick={() => setShowForm(true)}> |
| 249 | <IconPlus class="h-4 w-4" /> | 244 | <IconPlus class="h-4 w-4" /> |
| 250 | {t("classGroups.newClass")} | 245 | {t("classGroups.newClass")} |
src/pages/dashboard-page.tsxmodified+16 -39
| @@ -23,7 +23,6 @@ import { Button } from "@/components/ui/button"; | |||
| 23 | import { EmptyInline } from "@/components/ui/empty-inline"; | 23 | import { EmptyInline } from "@/components/ui/empty-inline"; |
| 24 | import { Select } from "@/components/ui/select"; | 24 | import { Select } from "@/components/ui/select"; |
| 25 | import { Badge } from "@/components/ui/badge"; | 25 | import { Badge } from "@/components/ui/badge"; |
| 26 | -import { ComingSoonBadge, ComingSoonPanel } from "@/components/ui/coming-soon"; | ||
| 27 | import { ChartBar } from "@/components/ui/chart-bar"; | 26 | import { ChartBar } from "@/components/ui/chart-bar"; |
| 28 | import { ChartHeatmap, type HeatmapEntry } from "@/components/ui/chart-heatmap"; | 27 | import { ChartHeatmap, type HeatmapEntry } from "@/components/ui/chart-heatmap"; |
| 29 | import { ChartLine } from "@/components/ui/chart-line"; | 28 | import { ChartLine } from "@/components/ui/chart-line"; |
| @@ -832,17 +831,7 @@ function DashboardContent() { | |||
| 832 | 831 | ||
| 833 | <Suspense fallback={<PanelSkeleton />}> | 832 | <Suspense fallback={<PanelSkeleton />}> |
| 834 | <section class="space-y-3" aria-labelledby="highlights-heading"> | 833 | <section class="space-y-3" aria-labelledby="highlights-heading"> |
| 835 | - <div class="flex flex-wrap items-center justify-between gap-2"> | 834 | + <h2 id="highlights-heading" class="text-base font-semibold tracking-tight text-text-strong">{t("dashboard.analytics")}</h2> |
| 836 | - <h2 id="highlights-heading" class="text-base font-semibold tracking-tight text-text-strong">{t("dashboard.analytics")}</h2> | ||
| 837 | - <Show when={isAdminHome()}> | ||
| 838 | - <div class="flex items-center gap-2"> | ||
| 839 | - <Select disabled wrapperClass="w-auto" class="h-8" aria-label={t("dashboard.admin.rangeThisMonth")}> | ||
| 840 | - <option>{t("dashboard.admin.rangeThisMonth")}</option> | ||
| 841 | - </Select> | ||
| 842 | - <ComingSoonBadge /> | ||
| 843 | - </div> | ||
| 844 | - </Show> | ||
| 845 | - </div> | ||
| 846 | <div class="grid grid-cols-1 gap-3 sm:grid-cols-2 lg:grid-cols-4"> | 835 | <div class="grid grid-cols-1 gap-3 sm:grid-cols-2 lg:grid-cols-4"> |
| 847 | <For each={stats()}> | 836 | <For each={stats()}> |
| 848 | {(stat) => <StatTile label={t(stat.labelKey)} value={stat.value} Icon={stat.Icon} />} | 837 | {(stat) => <StatTile label={t(stat.labelKey)} value={stat.value} Icon={stat.Icon} />} |
| @@ -853,10 +842,9 @@ function DashboardContent() { | |||
| 853 | 842 | ||
| 854 | <Suspense fallback={<PanelSkeleton />}> | 843 | <Suspense fallback={<PanelSkeleton />}> |
| 855 | <Show when={role() === "student"}> | 844 | <Show when={role() === "student"}> |
| 856 | - {/* STU-01's own "Bugünün Planı" and "Konu Yetkinliğim" main-column | 845 | + {/* STU-01's "Konu Yetkinliğim" and "Ses Atölyesi" cards need a |
| 857 | - cards need a study-plan/mastery API this app doesn't have, and | 846 | + mastery / audio backend this app doesn't have, so they are left |
| 858 | - "Ses Atölyesi" has no backend concept at all — all three keep | 847 | + out rather than shown as placeholders. "Bu Hafta" is real |
| 859 | - their design slot as a ComingSoonPanel. "Bu Hafta" is real | ||
| 860 | (this week's pomodoro minutes), so it gets the rail slot the | 848 | (this week's pomodoro minutes), so it gets the rail slot the |
| 861 | design reserves for that kind of card. */} | 849 | design reserves for that kind of card. */} |
| 862 | <div class="grid grid-cols-1 gap-3 lg:grid-cols-4"> | 850 | <div class="grid grid-cols-1 gap-3 lg:grid-cols-4"> |
| @@ -911,13 +899,9 @@ function DashboardContent() { | |||
| 911 | </div> | 899 | </div> |
| 912 | </Show> | 900 | </Show> |
| 913 | </div> | 901 | </div> |
| 914 | - <div class="grid grid-cols-1 gap-3 lg:grid-cols-3"> | 902 | + <Show when={on("sessions") && clock()}> |
| 915 | - <Show when={on("sessions") && clock()} fallback={<ComingSoonPanel title={t("dashboard.student.todayPlan")} />}> | 903 | + {(ready) => <TodayLessonsPanel audience="student" now={ready().now} courseTitle={courseTitleOf} />} |
| 916 | - {(ready) => <TodayLessonsPanel audience="student" now={ready().now} courseTitle={courseTitleOf} />} | 904 | + </Show> |
| 917 | - </Show> | ||
| 918 | - <ComingSoonPanel title={t("dashboard.student.mastery")} /> | ||
| 919 | - <ComingSoonPanel title={t("dashboard.student.audioWorkshop")} /> | ||
| 920 | - </div> | ||
| 921 | </Show> | 905 | </Show> |
| 922 | </Suspense> | 906 | </Suspense> |
| 923 | 907 | ||
| @@ -928,7 +912,7 @@ function DashboardContent() { | |||
| 928 | each started lesson's roll-call count — it leads the board | 912 | each started lesson's roll-call count — it leads the board |
| 929 | because an untaken roll call is the one thing that cannot wait. | 913 | because an untaken roll call is the one thing that cannot wait. |
| 930 | "Sınıf Performansı" needs per-class topic mastery, which is | 914 | "Sınıf Performansı" needs per-class topic mastery, which is |
| 931 | - out, so it keeps its ComingSoonPanel slot. The AI suggestion | 915 | + out, so it is left off the board. The AI suggestion |
| 932 | queue has no backend at all. The one real rail item behind that | 916 | queue has no backend at all. The one real rail item behind that |
| 933 | queue — a pending appointment request — gets the rail. */} | 917 | queue — a pending appointment request — gets the rail. */} |
| 934 | <div class="grid grid-cols-1 gap-3 lg:grid-cols-2"> | 918 | <div class="grid grid-cols-1 gap-3 lg:grid-cols-2"> |
| @@ -987,7 +971,6 @@ function DashboardContent() { | |||
| 987 | </div> | 971 | </div> |
| 988 | </Show> | 972 | </Show> |
| 989 | </div> | 973 | </div> |
| 990 | - <ComingSoonPanel title={t("dashboard.teacher.classPerformance")} /> | ||
| 991 | </Show> | 974 | </Show> |
| 992 | </Suspense> | 975 | </Suspense> |
| 993 | 976 | ||
| @@ -1016,8 +999,8 @@ function DashboardContent() { | |||
| 1016 | <Show when={role() === "parent"}> | 999 | <Show when={role() === "parent"}> |
| 1017 | {/* PAR-01's "Gelişim" (topic-mastery trend) needs mastery data this | 1000 | {/* PAR-01's "Gelişim" (topic-mastery trend) needs mastery data this |
| 1018 | app doesn't have, and "Öğretmen Notları" has no backend concept | 1001 | app doesn't have, and "Öğretmen Notları" has no backend concept |
| 1019 | - distinct from `/messages` — both keep their design slot as a | 1002 | + distinct from `/messages` — both are left off the board. |
| 1020 | - ComingSoonPanel. "Devamsızlık" and "Ödeme" are both real, | 1003 | + "Devamsızlık" and "Ödeme" are both real, |
| 1021 | per-child reads already used elsewhere in the app (`/students` | 1004 | per-child reads already used elsewhere in the app (`/students` |
| 1022 | child detail, `/payments`). */} | 1005 | child detail, `/payments`). */} |
| 1023 | <Show when={(children()?.items.length ?? 0) > 1}> | 1006 | <Show when={(children()?.items.length ?? 0) > 1}> |
| @@ -1100,18 +1083,12 @@ function DashboardContent() { | |||
| 1100 | </div> | 1083 | </div> |
| 1101 | </Show> | 1084 | </Show> |
| 1102 | </div> | 1085 | </div> |
| 1103 | - <div class="grid grid-cols-1 gap-3 lg:grid-cols-3"> | 1086 | + {/* PAR progress: the child's homework report (a parent-readable |
| 1104 | - {/* PAR progress: the child's homework report (a parent-readable | 1087 | + route) as overdue / due-this-week; marks-based progress still |
| 1105 | - route) as overdue / due-this-week, in place of the coming-soon | 1088 | + has no parent-facing trend. */} |
| 1106 | - slot; marks-based progress still has no parent-facing trend. */} | 1089 | + <Show when={on("homework") && selectedChildId() && clock()}> |
| 1107 | - <Show | 1090 | + <ChildHomeworkPanel childId={selectedChildId()} now={clock()!.now} /> |
| 1108 | - when={on("homework") && selectedChildId() && clock()} | 1091 | + </Show> |
| 1109 | - fallback={<ComingSoonPanel class="lg:col-span-2" title={t("dashboard.parent.progress")} />} | ||
| 1110 | - > | ||
| 1111 | - <ChildHomeworkPanel class="lg:col-span-2" childId={selectedChildId()} now={clock()!.now} /> | ||
| 1112 | - </Show> | ||
| 1113 | - <ComingSoonPanel title={t("dashboard.parent.teacherNotes")} /> | ||
| 1114 | - </div> | ||
| 1115 | </Show> | 1092 | </Show> |
| 1116 | </Suspense> | 1093 | </Suspense> |
| 1117 | 1094 | ||
src/pages/event-detail-page.tsxmodified+30 -33
| @@ -9,14 +9,13 @@ import { getEventAttendance } from "@/api/events"; | |||
| 9 | import { getEventById } from "@/api/events"; | 9 | import { getEventById } from "@/api/events"; |
| 10 | import { getEventRoster } from "@/api/events"; | 10 | import { getEventRoster } from "@/api/events"; |
| 11 | import { patchEventById } from "@/api/events"; | 11 | import { patchEventById } from "@/api/events"; |
| 12 | -import { postEventAttendance } from "@/api/events"; | ||
| 13 | import { postEventRegister } from "@/api/events"; | 12 | import { postEventRegister } from "@/api/events"; |
| 14 | import { formatApiError } from "@/api/client"; | 13 | import { formatApiError } from "@/api/client"; |
| 15 | -import type { AttendanceStatus, EventAudience, EventRosterEntry } from "@/api/client"; | 14 | +import type { EventAudience, EventRosterEntry } from "@/api/client"; |
| 16 | import type { MessageKey } from "@/i18n/messages"; | 15 | import type { MessageKey } from "@/i18n/messages"; |
| 17 | -import { AttendanceStatusPicker } from "@/components/events/attendance-status-picker"; | ||
| 18 | import { AttendanceTable } from "@/components/events/attendance-table"; | 16 | import { AttendanceTable } from "@/components/events/attendance-table"; |
| 19 | import { EventForm } from "@/components/events/event-form"; | 17 | import { EventForm } from "@/components/events/event-form"; |
| 18 | +import { EventRollCall } from "@/components/events/event-roll-call"; | ||
| 20 | import { RouteGuard } from "@/components/layout/route-guard"; | 19 | import { RouteGuard } from "@/components/layout/route-guard"; |
| 21 | import { PageHeader } from "@/components/layout/page-header"; | 20 | import { PageHeader } from "@/components/layout/page-header"; |
| 22 | import { Breadcrumbs } from "@/components/layout/breadcrumbs"; | 21 | import { Breadcrumbs } from "@/components/layout/breadcrumbs"; |
| @@ -35,6 +34,8 @@ import { TableRowActions } from "@/components/ui/table-row-actions"; | |||
| 35 | import { UserSearchSelect } from "@/components/users/user-search-select"; | 34 | import { UserSearchSelect } from "@/components/users/user-search-select"; |
| 36 | import { getAttendanceStatusMeta } from "@/lib/attendance-status"; | 35 | import { getAttendanceStatusMeta } from "@/lib/attendance-status"; |
| 37 | import { cn } from "@/lib/cn"; | 36 | import { cn } from "@/lib/cn"; |
| 37 | +import { createNow } from "@/lib/create-now"; | ||
| 38 | +import { eventStatusLabelKey, isRollCallOpen } from "@/lib/event-roll-call"; | ||
| 38 | import { createFlash } from "@/lib/flash"; | 39 | import { createFlash } from "@/lib/flash"; |
| 39 | import { formatDateTime } from "@/lib/format"; | 40 | import { formatDateTime } from "@/lib/format"; |
| 40 | import { personId, personLabel } from "@/lib/person"; | 41 | import { personId, personLabel } from "@/lib/person"; |
| @@ -71,8 +72,6 @@ function EventDetailContent() { | |||
| 71 | return params().id; | 72 | return params().id; |
| 72 | }); | 73 | }); |
| 73 | 74 | ||
| 74 | - const [status, setStatus] = createSignal<AttendanceStatus>("present"); | ||
| 75 | - const [otherUserId, setOtherUserId] = createSignal(""); | ||
| 76 | const [registrationUserId, setRegistrationUserId] = createSignal(""); | 75 | const [registrationUserId, setRegistrationUserId] = createSignal(""); |
| 77 | const [editing, setEditing] = createSignal(false); | 76 | const [editing, setEditing] = createSignal(false); |
| 78 | const [deleteOpen, setDeleteOpen] = createSignal(false); | 77 | const [deleteOpen, setDeleteOpen] = createSignal(false); |
| @@ -85,8 +84,11 @@ function EventDetailContent() { | |||
| 85 | const isTeacherPlus = () => hasMinRole(auth.user()?.role, "teacher"); | 84 | const isTeacherPlus = () => hasMinRole(auth.user()?.role, "teacher"); |
| 86 | 85 | ||
| 87 | const [event, { refetch: refetchEvent }] = createResource(id, (eventId) => getEventById(eventId)); | 86 | const [event, { refetch: refetchEvent }] = createResource(id, (eventId) => getEventById(eventId)); |
| 87 | + // The expected-attendee roster, resolved by the backend from the event's | ||
| 88 | + // audience (whole school, a role, a course, or the signup list) and joined | ||
| 89 | + // with each person's recorded mark. It feeds both the signup list and roll call. | ||
| 88 | const [roster, { refetch: refetchRoster }] = createResource( | 90 | const [roster, { refetch: refetchRoster }] = createResource( |
| 89 | - () => (isTeacherPlus() && event()?.audience.kind === "registration" ? id() : null), | 91 | + () => (isTeacherPlus() && event() ? id() : null), |
| 90 | async (eventId) => (eventId ? (await getEventRoster(eventId)).items : []), | 92 | async (eventId) => (eventId ? (await getEventRoster(eventId)).items : []), |
| 91 | ); | 93 | ); |
| 92 | const [attendance, { refetch: refetchAttendance }] = createResource( | 94 | const [attendance, { refetch: refetchAttendance }] = createResource( |
| @@ -106,6 +108,8 @@ function EventDetailContent() { | |||
| 106 | return e.creator === u.id || hasMinRole(u.role, "manager"); | 108 | return e.creator === u.id || hasMinRole(u.role, "manager"); |
| 107 | }; | 109 | }; |
| 108 | const [flash, setFlash] = createFlash(); | 110 | const [flash, setFlash] = createFlash(); |
| 111 | + const now = createNow(); | ||
| 112 | + const rollCallOpen = () => isRollCallOpen(event()?.starts_at, now()); | ||
| 109 | const rosterColumns = createMemo<ColumnDef<EventRosterEntry>[]>(() => [ | 113 | const rosterColumns = createMemo<ColumnDef<EventRosterEntry>[]>(() => [ |
| 110 | { | 114 | { |
| 111 | id: "attendee", | 115 | id: "attendee", |
| @@ -120,9 +124,10 @@ function EventDetailContent() { | |||
| 120 | cell: (cell) => { | 124 | cell: (cell) => { |
| 121 | const status = cell.row.original.status; | 125 | const status = cell.row.original.status; |
| 122 | const meta = status ? getAttendanceStatusMeta(status) : null; | 126 | const meta = status ? getAttendanceStatusMeta(status) : null; |
| 127 | + const key = status ? eventStatusLabelKey(status) ?? meta?.key : null; | ||
| 123 | return status ? ( | 128 | return status ? ( |
| 124 | <Badge variant="outline" class={cn("gap-1 rounded-full border px-2.5 py-1 normal-case", meta?.class)}> | 129 | <Badge variant="outline" class={cn("gap-1 rounded-full border px-2.5 py-1 normal-case", meta?.class)}> |
| 125 | - {meta ? t(meta.key) : status} | 130 | + {key ? t(key) : status} |
| 126 | </Badge> | 131 | </Badge> |
| 127 | ) : <span class="text-sm text-muted-foreground">{t("events.notMarked")}</span>; | 132 | ) : <span class="text-sm text-muted-foreground">{t("events.notMarked")}</span>; |
| 128 | }, | 133 | }, |
| @@ -322,32 +327,24 @@ function EventDetailContent() { | |||
| 322 | </Show> | 327 | </Show> |
| 323 | 328 | ||
| 324 | <TabsContent value="studentAttendance" forceMount class="space-y-3"> | 329 | <TabsContent value="studentAttendance" forceMount class="space-y-3"> |
| 325 | - <div class="rounded-xl border border-border-line bg-surface-base p-3 shadow-xs sm:p-4"> | 330 | + <p class="text-sm text-muted-foreground">{t("events.studentAttendanceHelp")}</p> |
| 326 | - <p class="mb-3 text-sm text-muted-foreground">{t("events.studentAttendanceHelp")}</p> | 331 | + <Suspense fallback={<DataTableSkeleton columns={2} />}> |
| 327 | - <div class="grid gap-3"> | 332 | + <Show when={roster()} fallback={ |
| 328 | - <UserSearchSelect id="other-user" label={t("events.attendee")} value={otherUserId()} placeholder={t("events.selectAttendee")} emptyMessage={t("events.noAttendees")} role="student" onChange={setOtherUserId} /> | 333 | + <Show when={roster.error}> |
| 329 | - <AttendanceStatusPicker id="other-status" value={status()} onChange={setStatus} label={t("events.status")} /> | 334 | + <Alert variant="destructive">{formatApiError(roster.error)}</Alert> |
| 330 | - <Button | 335 | + </Show> |
| 331 | - type="button" | 336 | + }> |
| 332 | - class="w-full rounded-xl sm:w-auto" | 337 | + {(rows) => ( |
| 333 | - disabled={pending()} | 338 | + <EventRollCall |
| 334 | - onClick={() => { | 339 | + eventId={id()} |
| 335 | - const uid = otherUserId().trim(); | 340 | + roster={rows()} |
| 336 | - if (!uid) { | 341 | + open={rollCallOpen()} |
| 337 | - setError(t("events.userIdRequired")); | 342 | + closedReason={t("events.rollCall.opensAt", { date: formatDateTime(ev().starts_at, locale()) })} |
| 338 | - return; | 343 | + onSaved={() => Promise.all([refetchRoster(), refetchAttendance()])} |
| 339 | - } | 344 | + /> |
| 340 | - void wrap(async () => { | 345 | + )} |
| 341 | - await postEventAttendance(id(), { status: status(), user_id: uid }); | 346 | + </Show> |
| 342 | - setOtherUserId(""); | 347 | + </Suspense> |
| 343 | - await refetchAttendance(); | ||
| 344 | - }, t("common.saved")); | ||
| 345 | - }} | ||
| 346 | - > | ||
| 347 | - {t("events.saveStudentAttendance")} | ||
| 348 | - </Button> | ||
| 349 | - </div> | ||
| 350 | - </div> | ||
| 351 | </TabsContent> | 348 | </TabsContent> |
| 352 | 349 | ||
| 353 | <TabsContent value="attendanceRecords" forceMount class="space-y-3"> | 350 | <TabsContent value="attendanceRecords" forceMount class="space-y-3"> |
src/pages/exams-page.tsxmodified+28 -2
| @@ -15,6 +15,7 @@ import { RouteGuard } from "@/components/layout/route-guard"; | |||
| 15 | import { Alert } from "@/components/ui/alert"; | 15 | import { Alert } from "@/components/ui/alert"; |
| 16 | import { Badge } from "@/components/ui/badge"; | 16 | import { Badge } from "@/components/ui/badge"; |
| 17 | import { Button } from "@/components/ui/button"; | 17 | import { Button } from "@/components/ui/button"; |
| 18 | +import { ConfirmDialog } from "@/components/ui/confirm-dialog"; | ||
| 18 | import { DataTable, DataTableSkeleton } from "@/components/ui/data-table"; | 19 | import { DataTable, DataTableSkeleton } from "@/components/ui/data-table"; |
| 19 | import { IconCheck, IconEdit, IconEye, IconPlus, IconRotateCcw } from "@/components/ui/icons"; | 20 | import { IconCheck, IconEdit, IconEye, IconPlus, IconRotateCcw } from "@/components/ui/icons"; |
| 20 | import { DropdownSelect } from "@/components/ui/select"; | 21 | import { DropdownSelect } from "@/components/ui/select"; |
| @@ -29,6 +30,7 @@ import { examKindLabel } from "@/lib/exam-labels"; | |||
| 29 | import { examDisplayStatus, examStatusMessageKey, examStatusTone, type ExamDisplayStatus } from "@/lib/exam-status"; | 30 | import { examDisplayStatus, examStatusMessageKey, examStatusTone, type ExamDisplayStatus } from "@/lib/exam-status"; |
| 30 | import { LIST_CAP, loadCappedList } from "@/lib/capped-list"; | 31 | import { LIST_CAP, loadCappedList } from "@/lib/capped-list"; |
| 31 | import { createFlash } from "@/lib/flash"; | 32 | import { createFlash } from "@/lib/flash"; |
| 33 | +import { countExamQuestions } from "@/lib/exam-publish"; | ||
| 32 | import { formatDateTime } from "@/lib/format"; | 34 | import { formatDateTime } from "@/lib/format"; |
| 33 | import { hasMinRole } from "@/lib/roles"; | 35 | import { hasMinRole } from "@/lib/roles"; |
| 34 | import { matchesSearch } from "@/lib/search-text"; | 36 | import { matchesSearch } from "@/lib/search-text"; |
| @@ -92,6 +94,8 @@ function ExamsContent() { | |||
| 92 | const [flash, setFlash] = createFlash(); | 94 | const [flash, setFlash] = createFlash(); |
| 93 | const [error, setError] = createSignal(""); | 95 | const [error, setError] = createSignal(""); |
| 94 | const [pending, setPending] = createSignal(false); | 96 | const [pending, setPending] = createSignal(false); |
| 97 | + /** A draft exam with no questions, waiting on "publish anyway". */ | ||
| 98 | + const [emptyPublishTarget, setEmptyPublishTarget] = createSignal<Exam | null>(null); | ||
| 95 | 99 | ||
| 96 | const [createStep, setCreateStep] = createSignal<"details" | "questions">("details"); | 100 | const [createStep, setCreateStep] = createSignal<"details" | "questions">("details"); |
| 97 | const [createdExam, setCreatedExam] = createSignal<Exam | null>(null); | 101 | const [createdExam, setCreatedExam] = createSignal<Exam | null>(null); |
| @@ -302,10 +306,15 @@ function ExamsContent() { | |||
| 302 | setFlash(t("common.saved")); | 306 | setFlash(t("common.saved")); |
| 303 | }; | 307 | }; |
| 304 | 308 | ||
| 305 | - const publishExam = async (exam: Exam) => { | 309 | + const publishExam = async (exam: Exam, force = false) => { |
| 306 | setPending(true); | 310 | setPending(true); |
| 307 | setError(""); | 311 | setError(""); |
| 308 | try { | 312 | try { |
| 313 | + // An exam with no questions is almost always a mistake — ask first. | ||
| 314 | + if (!force && (await countExamQuestions(exam.id)) === 0) { | ||
| 315 | + setEmptyPublishTarget(exam); | ||
| 316 | + return; | ||
| 317 | + } | ||
| 309 | await patchExamById(exam.id, { draft: false }); | 318 | await patchExamById(exam.id, { draft: false }); |
| 310 | await refetchExams(); | 319 | await refetchExams(); |
| 311 | setFlash(t("exams.published")); | 320 | setFlash(t("exams.published")); |
| @@ -482,7 +491,10 @@ function ExamsContent() { | |||
| 482 | courseId={examCourseId(createdExam()!)} | 491 | courseId={examCourseId(createdExam()!)} |
| 483 | embedded | 492 | embedded |
| 484 | /> | 493 | /> |
| 485 | - <div class="flex justify-end border-t pt-3"> | 494 | + <div class="flex flex-wrap items-center justify-end gap-3 border-t pt-3"> |
| 495 | + <Show when={createdExam()!.draft}> | ||
| 496 | + <p class="mr-auto text-xs text-muted-foreground">{t("exams.savedAsDraftHint")}</p> | ||
| 497 | + </Show> | ||
| 486 | <Button type="button" variant="default" onClick={() => setCreateOpen(false)}> | 498 | <Button type="button" variant="default" onClick={() => setCreateOpen(false)}> |
| 487 | {t("exams.finishAndClose")} | 499 | {t("exams.finishAndClose")} |
| 488 | </Button> | 500 | </Button> |
| @@ -491,6 +503,20 @@ function ExamsContent() { | |||
| 491 | </Show> | 503 | </Show> |
| 492 | </SidePanel> | 504 | </SidePanel> |
| 493 | 505 | ||
| 506 | + <ConfirmDialog | ||
| 507 | + open={emptyPublishTarget() != null} | ||
| 508 | + onOpenChange={(open) => { | ||
| 509 | + if (!open) setEmptyPublishTarget(null); | ||
| 510 | + }} | ||
| 511 | + title={t("exams.publishEmptyTitle")} | ||
| 512 | + summary={t("exams.publishEmptyWarning")} | ||
| 513 | + confirmLabel={t("exams.publishAnyway")} | ||
| 514 | + onConfirm={async () => { | ||
| 515 | + const exam = emptyPublishTarget(); | ||
| 516 | + if (exam) await publishExam(exam, true); | ||
| 517 | + }} | ||
| 518 | + /> | ||
| 519 | + | ||
| 494 | <SidePanel | 520 | <SidePanel |
| 495 | open={editingExam() != null} | 521 | open={editingExam() != null} |
| 496 | onOpenChange={(open) => { | 522 | onOpenChange={(open) => { |
src/pages/license-modules-page.tsxmodified+2 -31
| @@ -1,16 +1,13 @@ | |||
| 1 | import type { ColumnDef } from "@tanstack/solid-table"; | 1 | import type { ColumnDef } from "@tanstack/solid-table"; |
| 2 | -import { For, Show, Suspense, createMemo } from "solid-js"; | 2 | +import { Show, Suspense, createMemo } from "solid-js"; |
| 3 | import { createResource } from "@/lib/create-resource"; | 3 | import { createResource } from "@/lib/create-resource"; |
| 4 | import { getModules, getModulesCatalog } from "@/api/modules"; | 4 | import { getModules, getModulesCatalog } from "@/api/modules"; |
| 5 | import { formatApiError } from "@/api/client"; | 5 | import { formatApiError } from "@/api/client"; |
| 6 | import { RouteGuard } from "@/components/layout/route-guard"; | 6 | import { RouteGuard } from "@/components/layout/route-guard"; |
| 7 | import { Badge } from "@/components/ui/badge"; | 7 | import { Badge } from "@/components/ui/badge"; |
| 8 | -import { Button } from "@/components/ui/button"; | ||
| 9 | -import { ComingSoonBadge, ComingSoonPanel } from "@/components/ui/coming-soon"; | ||
| 10 | import { DataTable, DataTableSkeleton } from "@/components/ui/data-table"; | 8 | import { DataTable, DataTableSkeleton } from "@/components/ui/data-table"; |
| 11 | import { ErrorAlert } from "@/components/ui/error-alert"; | 9 | import { ErrorAlert } from "@/components/ui/error-alert"; |
| 12 | -import { IconDownload, IconPackage, IconPlus } from "@/components/ui/icons"; | 10 | +import { IconPackage } from "@/components/ui/icons"; |
| 13 | -import { Tabs, TabsList, TabsTrigger } from "@/components/ui/tabs"; | ||
| 14 | import { moduleLabel, packageLabel } from "@/lib/module-labels"; | 11 | import { moduleLabel, packageLabel } from "@/lib/module-labels"; |
| 15 | import { useT } from "@/stores/preferences-context"; | 12 | import { useT } from "@/stores/preferences-context"; |
| 16 | 13 | ||
| @@ -86,20 +83,6 @@ function LicenseModulesContent() { | |||
| 86 | 83 | ||
| 87 | return ( | 84 | return ( |
| 88 | <div class="space-y-5"> | 85 | <div class="space-y-5"> |
| 89 | - <Tabs value="overview"> | ||
| 90 | - <TabsList> | ||
| 91 | - <TabsTrigger value="overview">{t("modules.tabOverview")}</TabsTrigger> | ||
| 92 | - <For each={["modules.tabUsage", "modules.tabInvoices", "modules.tabContract"] as const}> | ||
| 93 | - {(key) => ( | ||
| 94 | - <TabsTrigger value={key} disabled title={t("comingSoon.title")}> | ||
| 95 | - {t(key)} | ||
| 96 | - <ComingSoonBadge class="ml-1.5" /> | ||
| 97 | - </TabsTrigger> | ||
| 98 | - )} | ||
| 99 | - </For> | ||
| 100 | - </TabsList> | ||
| 101 | - </Tabs> | ||
| 102 | - | ||
| 103 | <Suspense fallback={<DataTableSkeleton columns={2} rows={8} />}> | 86 | <Suspense fallback={<DataTableSkeleton columns={2} rows={8} />}> |
| 104 | <Show when={data.error}> | 87 | <Show when={data.error}> |
| 105 | <ErrorAlert message={formatApiError(data.error)} onRetry={() => void refetch()} /> | 88 | <ErrorAlert message={formatApiError(data.error)} onRetry={() => void refetch()} /> |
| @@ -132,16 +115,6 @@ function LicenseModulesContent() { | |||
| 132 | urlState | 115 | urlState |
| 133 | title={t("nav.licenseModules")} | 116 | title={t("nav.licenseModules")} |
| 134 | description={t("modules.subtitle")} | 117 | description={t("modules.subtitle")} |
| 135 | - actions={<><Button size="sm" variant="outline" class="min-w-[7.5rem] rounded-lg" disabled title={t("comingSoon.title")}> | ||
| 136 | - <IconDownload class="h-4 w-4" /> | ||
| 137 | - {t("modules.downloadInvoices")} | ||
| 138 | - <ComingSoonBadge class="ml-1.5" /> | ||
| 139 | - </Button> | ||
| 140 | - <Button size="sm" class="min-w-[7.5rem] rounded-lg" disabled title={t("modules.readOnlyHint")}> | ||
| 141 | - <IconPlus class="h-4 w-4" /> | ||
| 142 | - {t("modules.addLicense")} | ||
| 143 | - <ComingSoonBadge class="ml-1.5" /> | ||
| 144 | - </Button></>} | ||
| 145 | columns={columns()} | 118 | columns={columns()} |
| 146 | data={value().rows} | 119 | data={value().rows} |
| 147 | tableClass="min-w-md" | 120 | tableClass="min-w-md" |
| @@ -149,8 +122,6 @@ function LicenseModulesContent() { | |||
| 149 | storageKey="license-modules" | 122 | storageKey="license-modules" |
| 150 | /> | 123 | /> |
| 151 | </section> | 124 | </section> |
| 152 | - | ||
| 153 | - <ComingSoonPanel title={t("modules.recentInvoices")} /> | ||
| 154 | </> | 125 | </> |
| 155 | )} | 126 | )} |
| 156 | </Show> | 127 | </Show> |
src/pages/meals-page.tsxmodified+1 -1
| @@ -114,7 +114,7 @@ function MealsContent() { | |||
| 114 | <Suspense fallback={<PageSpinner />}> | 114 | <Suspense fallback={<PageSpinner />}> |
| 115 | <Show when={menus.error}><ErrorAlert message={formatApiError(menus.error)} onRetry={() => void refetch()} /></Show> | 115 | <Show when={menus.error}><ErrorAlert message={formatApiError(menus.error)} onRetry={() => void refetch()} /></Show> |
| 116 | <Show when={visible().length > 0} fallback={<EmptyState kind="meals" title={t("meals.empty")} />}> | 116 | <Show when={visible().length > 0} fallback={<EmptyState kind="meals" title={t("meals.empty")} />}> |
| 117 | - <div class="grid grid-cols-1 gap-4 sm:grid-cols-2 lg:grid-cols-3 xl:grid-cols-4"><For each={visible()}>{(menu) => <MealMenuCard menu={menu} locale={locale() === "tr" ? "tr-TR" : "en-US"} labels={{ dishes: t("meals.dishes"), capacity: t("meals.capacity"), conflict: t("meals.conflict"), reservations: t("meals.reservations"), topPick: t("meals.topPick") }} reservationCount={reservationCounts()?.get(menu.id) ?? undefined} />}</For></div> | 117 | + <div class="grid grid-cols-1 gap-4 sm:grid-cols-2 lg:grid-cols-3 xl:grid-cols-4"><For each={visible()}>{(menu) => <MealMenuCard menu={menu} locale={locale() === "tr" ? "tr-TR" : "en-US"} labels={{ dishes: t("meals.dishes"), capacity: t("meals.capacity"), conflict: t("meals.conflict"), reservations: t("meals.reservations") }} reservationCount={reservationCounts()?.get(menu.id) ?? undefined} />}</For></div> |
| 118 | <TablePagination pageIndex={page()} pageCount={totalPages()} onPageChange={setPage} /> | 118 | <TablePagination pageIndex={page()} pageCount={totalPages()} onPageChange={setPage} /> |
| 119 | </Show> | 119 | </Show> |
| 120 | </Suspense> | 120 | </Suspense> |
src/pages/messages-page.tsxmodified+60 -111
| @@ -30,15 +30,22 @@ import { | |||
| 30 | deleteMessageById, | 30 | deleteMessageById, |
| 31 | } from "@/api/messages"; | 31 | } from "@/api/messages"; |
| 32 | import type { Message, MessageFolder } from "@/api/client"; | 32 | import type { Message, MessageFolder } from "@/api/client"; |
| 33 | +import type { MessageKey } from "@/i18n/messages"; | ||
| 33 | import { formatApiError } from "@/api/client"; | 34 | import { formatApiError } from "@/api/client"; |
| 34 | import { useAuth } from "@/stores/auth-context"; | 35 | import { useAuth } from "@/stores/auth-context"; |
| 35 | import { useT } from "@/stores/preferences-context"; | 36 | import { useT } from "@/stores/preferences-context"; |
| 36 | import { matchesSearch } from "@/lib/search-text"; | 37 | import { matchesSearch } from "@/lib/search-text"; |
| 37 | import { personLabel } from "@/lib/person"; | 38 | import { personLabel } from "@/lib/person"; |
| 38 | import { createFlash } from "@/lib/flash"; | 39 | import { createFlash } from "@/lib/flash"; |
| 39 | -import { Badge } from "@/components/ui/badge"; | ||
| 40 | import { ConfirmDialog } from "@/components/ui/confirm-dialog"; | 40 | import { ConfirmDialog } from "@/components/ui/confirm-dialog"; |
| 41 | 41 | ||
| 42 | +const folders: { id: MessageFolder; labelKey: MessageKey; icon: typeof IconMessage }[] = [ | ||
| 43 | + { id: "inbox", labelKey: "messages.inbox", icon: IconMessage }, | ||
| 44 | + { id: "sent", labelKey: "messages.sent", icon: IconSend }, | ||
| 45 | + { id: "archive", labelKey: "messages.archive", icon: IconArchive }, | ||
| 46 | + { id: "trash", labelKey: "messages.trash", icon: IconTrash }, | ||
| 47 | +]; | ||
| 48 | + | ||
| 42 | export default function MessagesPage() { | 49 | export default function MessagesPage() { |
| 43 | const t = useT(); | 50 | const t = useT(); |
| 44 | const auth = useAuth(); | 51 | const auth = useAuth(); |
| @@ -169,129 +176,71 @@ export default function MessagesPage() { | |||
| 169 | } | 176 | } |
| 170 | }; | 177 | }; |
| 171 | 178 | ||
| 172 | - const folderLabel = () => { | ||
| 173 | - const f = folder(); | ||
| 174 | - if (f === "sent") return t("messages.sent"); | ||
| 175 | - if (f === "archive") return t("messages.archive"); | ||
| 176 | - if (f === "trash") return t("messages.trash"); | ||
| 177 | - return t("messages.inbox"); | ||
| 178 | - }; | ||
| 179 | - | ||
| 180 | return ( | 179 | return ( |
| 181 | <RouteGuard> | 180 | <RouteGuard> |
| 182 | <div class="space-y-4"> | 181 | <div class="space-y-4"> |
| 183 | <div class="min-h-[50vh] sm:min-h-[calc(100vh-11rem)]"> | 182 | <div class="min-h-[50vh] sm:min-h-[calc(100vh-11rem)]"> |
| 184 | <section class="data-shell overflow-hidden p-0"> | 183 | <section class="data-shell overflow-hidden p-0"> |
| 185 | <div class="flex min-h-[50vh] flex-col sm:min-h-[calc(100vh-11rem)]"> | 184 | <div class="flex min-h-[50vh] flex-col sm:min-h-[calc(100vh-11rem)]"> |
| 186 | - {/* Card header — folder name + unread chip, matching Figma's "Gelen kutusu" card. */} | 185 | + {/* Card header names the page; the active folder is already the |
| 186 | + highlighted tab below, and the inbox tab carries the unread count. */} | ||
| 187 | <div class="flex items-center gap-2 border-b border-border-hairline bg-surface-base px-4 py-3"> | 187 | <div class="flex items-center gap-2 border-b border-border-hairline bg-surface-base px-4 py-3"> |
| 188 | - <p class="text-sm font-semibold text-text-strong">{folderLabel()}</p> | 188 | + <h1 class="text-sm font-semibold text-text-strong">{t("nav.messages")}</h1> |
| 189 | - <Show when={folder() === "inbox" && unreadCount() && unreadCount()! > 0}> | ||
| 190 | - <Badge variant="secondary" class="rounded-full text-[11px]"> | ||
| 191 | - {unreadCount()} {t("messages.unread")} | ||
| 192 | - </Badge> | ||
| 193 | - </Show> | ||
| 194 | </div> | 189 | </div> |
| 195 | {/* Folder toolbar — the app shell already owns the global sidebar. */} | 190 | {/* Folder toolbar — the app shell already owns the global sidebar. */} |
| 196 | <aside class="flex flex-wrap items-center justify-between gap-2 border-b border-border-hairline bg-surface-overlay px-3 py-2.5"> | 191 | <aside class="flex flex-wrap items-center justify-between gap-2 border-b border-border-hairline bg-surface-overlay px-3 py-2.5"> |
| 197 | - {/* Folder navigation stays compact, leaving the only sidebar to the app shell. */} | 192 | + {/* On a phone the four folders share one full-width row as |
| 198 | - <nav class="flex min-w-0 flex-1 items-center gap-1 overflow-x-auto"> | 193 | + icon-over-label cells, so none of them hides off screen; from |
| 199 | - <button | 194 | + sm up they sit inline beside the new-message button. */} |
| 200 | - type="button" | 195 | + <nav aria-label={t("messages.folders")} class="grid w-full grid-cols-4 gap-0.5 sm:flex sm:gap-1 sm:w-auto sm:min-w-0 sm:flex-1 sm:items-center"> |
| 201 | - class={cn( | 196 | + <For each={folders}> |
| 202 | - "flex h-8 shrink-0 items-center justify-between gap-2 rounded-lg px-3 text-xs font-semibold transition-colors", | 197 | + {(entry) => { |
| 203 | - folder() === "inbox" | 198 | + const active = () => folder() === entry.id; |
| 204 | - ? "bg-primary/10 text-primary-text" | 199 | + const Icon = entry.icon; |
| 205 | - : "text-muted-foreground hover:bg-muted/40 hover:text-foreground" | 200 | + const badge = () => (entry.id === "inbox" ? unreadCount() ?? 0 : 0); |
| 206 | - )} | 201 | + return ( |
| 207 | - onClick={() => | 202 | + <button |
| 208 | - startTransition(() => { | 203 | + type="button" |
| 209 | - setFolder("inbox"); | 204 | + aria-current={active() ? "page" : undefined} |
| 210 | - setPage(1); | 205 | + class={cn( |
| 211 | - setSelectedId(""); | 206 | + "relative flex min-w-0 flex-col items-center justify-center gap-0.5 rounded-lg px-0 py-1.5 text-[11px] font-semibold tracking-tight transition-colors sm:h-8 sm:tracking-normal sm:shrink-0 sm:flex-row sm:gap-2 sm:px-3 sm:py-0 sm:text-xs", |
| 212 | - }) | 207 | + active() |
| 213 | - } | 208 | + ? entry.id === "trash" |
| 214 | - > | 209 | + ? "bg-destructive/10 text-destructive-text" |
| 215 | - <div class="flex items-center gap-3"> | 210 | + : "bg-primary/10 text-primary-text" |
| 216 | - <IconMessage class="h-4 w-4" /> | 211 | + : "text-muted-foreground hover:bg-muted/40 hover:text-foreground", |
| 217 | - <span>{t("messages.inbox")}</span> | 212 | + )} |
| 218 | - </div> | 213 | + onClick={() => |
| 219 | - <Show when={unreadCount() ? unreadCount()! > 0 : false}> | 214 | + startTransition(() => { |
| 220 | - <span class="rounded-full bg-primary px-2 py-0.5 text-[11px] font-bold text-primary-foreground"> | 215 | + setFolder(entry.id); |
| 221 | - {unreadCount()} | 216 | + setPage(1); |
| 222 | - </span> | 217 | + setSelectedId(""); |
| 223 | - </Show> | 218 | + }) |
| 224 | - </button> | 219 | + } |
| 225 | - | 220 | + > |
| 226 | - <button | 221 | + <span class="relative flex items-center"> |
| 227 | - type="button" | 222 | + <Icon class="h-4 w-4" /> |
| 228 | - class={cn( | 223 | + {/* Phone: the count rides on the icon. */} |
| 229 | - "flex h-8 shrink-0 items-center justify-between gap-2 rounded-lg px-3 text-xs font-semibold transition-colors", | 224 | + <Show when={badge() > 0}> |
| 230 | - folder() === "sent" | 225 | + <span class="absolute -right-2.5 -top-1.5 rounded-full bg-primary px-1 text-[11px] font-bold leading-4 text-primary-foreground sm:hidden"> |
| 231 | - ? "bg-primary/10 text-primary-text" | 226 | + {badge() > 99 ? "99+" : badge()} |
| 232 | - : "text-muted-foreground hover:bg-muted/40 hover:text-foreground" | 227 | + </span> |
| 233 | - )} | 228 | + </Show> |
| 234 | - onClick={() => | 229 | + </span> |
| 235 | - startTransition(() => { | 230 | + <span class="max-w-full truncate">{t(entry.labelKey)}</span> |
| 236 | - setFolder("sent"); | 231 | + <Show when={badge() > 0}> |
| 237 | - setPage(1); | 232 | + <span class="hidden rounded-full bg-primary px-2 py-0.5 text-[11px] font-bold text-primary-foreground sm:inline"> |
| 238 | - setSelectedId(""); | 233 | + {badge()} |
| 239 | - }) | 234 | + </span> |
| 240 | - } | 235 | + </Show> |
| 241 | - > | 236 | + </button> |
| 242 | - <div class="flex items-center gap-3"> | 237 | + ); |
| 243 | - <IconSend class="h-4 w-4" /> | 238 | + }} |
| 244 | - <span>{t("messages.sent")}</span> | 239 | + </For> |
| 245 | - </div> | ||
| 246 | - </button> | ||
| 247 | - | ||
| 248 | - <button | ||
| 249 | - type="button" | ||
| 250 | - class={cn( | ||
| 251 | - "flex h-8 shrink-0 items-center justify-between gap-2 rounded-lg px-3 text-xs font-semibold transition-colors", | ||
| 252 | - folder() === "archive" | ||
| 253 | - ? "bg-primary/10 text-primary-text" | ||
| 254 | - : "text-muted-foreground hover:bg-muted/40 hover:text-foreground" | ||
| 255 | - )} | ||
| 256 | - onClick={() => | ||
| 257 | - startTransition(() => { | ||
| 258 | - setFolder("archive"); | ||
| 259 | - setPage(1); | ||
| 260 | - setSelectedId(""); | ||
| 261 | - }) | ||
| 262 | - } | ||
| 263 | - > | ||
| 264 | - <div class="flex items-center gap-3"> | ||
| 265 | - <IconArchive class="h-4 w-4" /> | ||
| 266 | - <span>{t("messages.archive")}</span> | ||
| 267 | - </div> | ||
| 268 | - </button> | ||
| 269 | - | ||
| 270 | - <button | ||
| 271 | - type="button" | ||
| 272 | - class={cn( | ||
| 273 | - "flex h-8 shrink-0 items-center justify-between gap-2 rounded-lg px-3 text-xs font-semibold transition-colors", | ||
| 274 | - folder() === "trash" | ||
| 275 | - ? "bg-destructive/10 text-destructive-text" | ||
| 276 | - : "text-muted-foreground hover:bg-muted/40 hover:text-foreground" | ||
| 277 | - )} | ||
| 278 | - onClick={() => | ||
| 279 | - startTransition(() => { | ||
| 280 | - setFolder("trash"); | ||
| 281 | - setPage(1); | ||
| 282 | - setSelectedId(""); | ||
| 283 | - }) | ||
| 284 | - } | ||
| 285 | - > | ||
| 286 | - <div class="flex items-center gap-3"> | ||
| 287 | - <IconTrash class="h-4 w-4" /> | ||
| 288 | - <span>{t("messages.trash")}</span> | ||
| 289 | - </div> | ||
| 290 | - </button> | ||
| 291 | </nav> | 240 | </nav> |
| 292 | <Button | 241 | <Button |
| 293 | size="sm" | 242 | size="sm" |
| 294 | - class="shrink-0 rounded-lg" | 243 | + class="w-full shrink-0 rounded-lg sm:w-auto" |
| 295 | onClick={() => setComposeOpen(true)} | 244 | onClick={() => setComposeOpen(true)} |
| 296 | > | 245 | > |
| 297 | <IconPlus class="h-4 w-4" /> | 246 | <IconPlus class="h-4 w-4" /> |
src/pages/payments-page.tsxmodified+0 -7
| @@ -27,7 +27,6 @@ import { RouteGuard } from "@/components/layout/route-guard"; | |||
| 27 | import { Alert } from "@/components/ui/alert"; | 27 | import { Alert } from "@/components/ui/alert"; |
| 28 | import { Badge } from "@/components/ui/badge"; | 28 | import { Badge } from "@/components/ui/badge"; |
| 29 | import { Button } from "@/components/ui/button"; | 29 | import { Button } from "@/components/ui/button"; |
| 30 | -import { ComingSoonBadge } from "@/components/ui/coming-soon"; | ||
| 31 | import { ConfirmDialog } from "@/components/ui/confirm-dialog"; | 30 | import { ConfirmDialog } from "@/components/ui/confirm-dialog"; |
| 32 | import { DataTable, DataTableSkeleton } from "@/components/ui/data-table"; | 31 | import { DataTable, DataTableSkeleton } from "@/components/ui/data-table"; |
| 33 | import { DatePicker } from "@/components/ui/date-picker"; | 32 | import { DatePicker } from "@/components/ui/date-picker"; |
| @@ -634,12 +633,6 @@ function PaymentsContent() { | |||
| 634 | title={t("payments.title")} | 633 | title={t("payments.title")} |
| 635 | description={t("payments.subtitle")} | 634 | description={t("payments.subtitle")} |
| 636 | empty={t("form.noStudents")} | 635 | empty={t("form.noStudents")} |
| 637 | - actions={ | ||
| 638 | - <Button size="sm" variant="outline" class="rounded-lg" disabled title={t("comingSoon.title")}> | ||
| 639 | - {t("payments.exportStatement")} | ||
| 640 | - <ComingSoonBadge class="ml-1.5" /> | ||
| 641 | - </Button> | ||
| 642 | - } | ||
| 643 | filters={ | 636 | filters={ |
| 644 | <Select value={planFilter()} onChange={(e) => { setPlanFilter(e.currentTarget.value); setStudentPage(0); }} wrapperClass="w-56"> | 637 | <Select value={planFilter()} onChange={(e) => { setPlanFilter(e.currentTarget.value); setStudentPage(0); }} wrapperClass="w-56"> |
| 645 | <option value="">{t("payments.allPlans")}</option> | 638 | <option value="">{t("payments.allPlans")}</option> |
src/pages/question-bank-page.tsxmodified+0 -14
| @@ -12,7 +12,6 @@ import { RouteGuard } from "@/components/layout/route-guard"; | |||
| 12 | import { Alert } from "@/components/ui/alert"; | 12 | import { Alert } from "@/components/ui/alert"; |
| 13 | import { Badge } from "@/components/ui/badge"; | 13 | import { Badge } from "@/components/ui/badge"; |
| 14 | import { Button } from "@/components/ui/button"; | 14 | import { Button } from "@/components/ui/button"; |
| 15 | -import { ComingSoonBadge } from "@/components/ui/coming-soon"; | ||
| 16 | import { ConfirmDialog } from "@/components/ui/confirm-dialog"; | 15 | import { ConfirmDialog } from "@/components/ui/confirm-dialog"; |
| 17 | import { DataTable, DataTableSkeleton } from "@/components/ui/data-table"; | 16 | import { DataTable, DataTableSkeleton } from "@/components/ui/data-table"; |
| 18 | import { IconEdit, IconEye, IconEyeOff, IconPlus, IconTrash, IconUsers } from "@/components/ui/icons"; | 17 | import { IconEdit, IconEye, IconEyeOff, IconPlus, IconTrash, IconUsers } from "@/components/ui/icons"; |
| @@ -288,19 +287,6 @@ function QuestionBankContent() { | |||
| 288 | }} | 287 | }} |
| 289 | options={subjectOptions()} | 288 | options={subjectOptions()} |
| 290 | /> | 289 | /> |
| 291 | - <DropdownSelect | ||
| 292 | - labelPrefix={t("bank.source")} | ||
| 293 | - value="all" | ||
| 294 | - disabled | ||
| 295 | - onChange={() => {}} | ||
| 296 | - options={[ | ||
| 297 | - { value: "all", label: t("common.all") }, | ||
| 298 | - { value: "institution", label: t("bank.source.institution") }, | ||
| 299 | - { value: "publisher", label: t("bank.source.publisher") }, | ||
| 300 | - { value: "ai", label: t("bank.source.ai") }, | ||
| 301 | - ]} | ||
| 302 | - /> | ||
| 303 | - <ComingSoonBadge /> | ||
| 304 | </div> | 290 | </div> |
| 305 | } | 291 | } |
| 306 | /> | 292 | /> |
src/pages/register-page.tsxmodified+76 -15
| @@ -28,11 +28,27 @@ function RegisterForm() { | |||
| 28 | const [password, setPassword] = createSignal(""); | 28 | const [password, setPassword] = createSignal(""); |
| 29 | const [confirmPassword, setConfirmPassword] = createSignal(""); | 29 | const [confirmPassword, setConfirmPassword] = createSignal(""); |
| 30 | const [showPassword, setShowPassword] = createSignal(false); | 30 | const [showPassword, setShowPassword] = createSignal(false); |
| 31 | + const [showConfirm, setShowConfirm] = createSignal(false); | ||
| 32 | + const [passwordTouched, setPasswordTouched] = createSignal(false); | ||
| 33 | + const [confirmTouched, setConfirmTouched] = createSignal(false); | ||
| 31 | const [error, setError] = createSignal(""); | 34 | const [error, setError] = createSignal(""); |
| 32 | const [pending, setPending] = createSignal(false); | 35 | const [pending, setPending] = createSignal(false); |
| 33 | const [limits] = createResource(() => getLimits().catch(() => null)); | 36 | const [limits] = createResource(() => getLimits().catch(() => null)); |
| 34 | const minSchoolSlugLength = () => limits()?.user.min_slug_len ?? 2; | 37 | const minSchoolSlugLength = () => limits()?.user.min_slug_len ?? 2; |
| 35 | const maxSchoolSlugLength = () => limits()?.user.max_slug_len ?? 32; | 38 | const maxSchoolSlugLength = () => limits()?.user.max_slug_len ?? 32; |
| 39 | + const minPasswordLength = () => limits()?.user.min_password_len ?? 6; | ||
| 40 | + // Inline checks wait until the reader has left the field (or, for the | ||
| 41 | + // confirmation, typed as many characters as the password) so they never | ||
| 42 | + // shout at a half-typed value. | ||
| 43 | + const passwordError = () => | ||
| 44 | + passwordTouched() && password().length > 0 && password().length < minPasswordLength() | ||
| 45 | + ? t("auth.passwordTooShort", { min: minPasswordLength() }) | ||
| 46 | + : undefined; | ||
| 47 | + const confirmError = () => { | ||
| 48 | + const cp = confirmPassword(); | ||
| 49 | + if (!cp || cp === password()) return undefined; | ||
| 50 | + return confirmTouched() || cp.length >= password().length ? t("auth.passwordMismatch") : undefined; | ||
| 51 | + }; | ||
| 36 | 52 | ||
| 37 | const handleSubmit = async (e: SubmitEvent) => { | 53 | const handleSubmit = async (e: SubmitEvent) => { |
| 38 | e.preventDefault(); | 54 | e.preventDefault(); |
| @@ -49,12 +65,19 @@ function RegisterForm() { | |||
| 49 | setError(t("auth.usernameHint")); | 65 | setError(t("auth.usernameHint")); |
| 50 | return; | 66 | return; |
| 51 | } | 67 | } |
| 52 | - if (userLimits && (p.length < userLimits.min_password_len || p.length > userLimits.max_password_len)) { | 68 | + if (p.length < minPasswordLength()) { |
| 69 | + // Shown inline under the field, not in the form-level banner. | ||
| 70 | + setError(""); | ||
| 71 | + setPasswordTouched(true); | ||
| 72 | + return; | ||
| 73 | + } | ||
| 74 | + if (userLimits && p.length > userLimits.max_password_len) { | ||
| 53 | setError(t("auth.passwordHint")); | 75 | setError(t("auth.passwordHint")); |
| 54 | return; | 76 | return; |
| 55 | } | 77 | } |
| 56 | if (p !== cp) { | 78 | if (p !== cp) { |
| 57 | - setError(t("auth.passwordMismatch")); | 79 | + setError(""); |
| 80 | + setConfirmTouched(true); | ||
| 58 | return; | 81 | return; |
| 59 | } | 82 | } |
| 60 | setError(""); | 83 | setError(""); |
| @@ -77,12 +100,21 @@ function RegisterForm() { | |||
| 77 | <Input | 100 | <Input |
| 78 | id="register-school" | 101 | id="register-school" |
| 79 | class="h-9" | 102 | class="h-9" |
| 103 | + autocapitalize="none" | ||
| 104 | + autocomplete="off" | ||
| 105 | + spellcheck={false} | ||
| 80 | minlength={minSchoolSlugLength()} | 106 | minlength={minSchoolSlugLength()} |
| 81 | maxlength={maxSchoolSlugLength()} | 107 | maxlength={maxSchoolSlugLength()} |
| 82 | required | 108 | required |
| 109 | + aria-describedby="register-school-hint" | ||
| 83 | value={school()} | 110 | value={school()} |
| 84 | - onInput={(e) => setSchool(e.currentTarget.value)} | 111 | + // A school code (slug) is lowercase; folding here saves a |
| 112 | + // round trip for "Ata-Koleji". | ||
| 113 | + onInput={(e) => setSchool(e.currentTarget.value.toLowerCase())} | ||
| 85 | /> | 114 | /> |
| 115 | + <p id="register-school-hint" class="text-xs text-text-subtle"> | ||
| 116 | + {t("auth.schoolCodeHint", { min: minSchoolSlugLength(), max: maxSchoolSlugLength() })} | ||
| 117 | + </p> | ||
| 86 | </div> | 118 | </div> |
| 87 | 119 | ||
| 88 | <div class="space-y-2"> | 120 | <div class="space-y-2"> |
| @@ -107,11 +139,14 @@ function RegisterForm() { | |||
| 107 | class="h-9 pr-10" | 139 | class="h-9 pr-10" |
| 108 | type={showPassword() ? "text" : "password"} | 140 | type={showPassword() ? "text" : "password"} |
| 109 | autocomplete="new-password" | 141 | autocomplete="new-password" |
| 110 | - minlength={limits()?.user.min_password_len} | 142 | + minlength={minPasswordLength()} |
| 111 | maxlength={limits()?.user.max_password_len} | 143 | maxlength={limits()?.user.max_password_len} |
| 112 | required | 144 | required |
| 145 | + aria-invalid={passwordError() ? true : undefined} | ||
| 146 | + aria-describedby="register-password-hint" | ||
| 113 | value={password()} | 147 | value={password()} |
| 114 | onInput={(e) => setPassword(e.currentTarget.value)} | 148 | onInput={(e) => setPassword(e.currentTarget.value)} |
| 149 | + onBlur={() => setPasswordTouched(true)} | ||
| 115 | /> | 150 | /> |
| 116 | <button | 151 | <button |
| 117 | type="button" | 152 | type="button" |
| @@ -124,21 +159,47 @@ function RegisterForm() { | |||
| 124 | </Show> | 159 | </Show> |
| 125 | </button> | 160 | </button> |
| 126 | </div> | 161 | </div> |
| 162 | + <p | ||
| 163 | + id="register-password-hint" | ||
| 164 | + class={passwordError() ? "text-xs font-medium text-destructive-text" : "text-xs text-text-subtle"} | ||
| 165 | + > | ||
| 166 | + {passwordError() ?? t("auth.passwordMinHint", { min: minPasswordLength() })} | ||
| 167 | + </p> | ||
| 127 | </div> | 168 | </div> |
| 128 | 169 | ||
| 129 | <div class="space-y-2"> | 170 | <div class="space-y-2"> |
| 130 | <Label for="register-confirm">{t("auth.confirmPassword")}</Label> | 171 | <Label for="register-confirm">{t("auth.confirmPassword")}</Label> |
| 131 | - <Input | 172 | + <div class="relative"> |
| 132 | - id="register-confirm" | 173 | + <Input |
| 133 | - class="h-9" | 174 | + id="register-confirm" |
| 134 | - type={showPassword() ? "text" : "password"} | 175 | + class="h-9 pr-10" |
| 135 | - autocomplete="new-password" | 176 | + type={showConfirm() ? "text" : "password"} |
| 136 | - minlength={limits()?.user.min_password_len} | 177 | + autocomplete="new-password" |
| 137 | - maxlength={limits()?.user.max_password_len} | 178 | + minlength={minPasswordLength()} |
| 138 | - required | 179 | + maxlength={limits()?.user.max_password_len} |
| 139 | - value={confirmPassword()} | 180 | + required |
| 140 | - onInput={(e) => setConfirmPassword(e.currentTarget.value)} | 181 | + aria-invalid={confirmError() ? true : undefined} |
| 141 | - /> | 182 | + aria-describedby={confirmError() ? "register-confirm-error" : undefined} |
| 183 | + value={confirmPassword()} | ||
| 184 | + onInput={(e) => setConfirmPassword(e.currentTarget.value)} | ||
| 185 | + onBlur={() => setConfirmTouched(true)} | ||
| 186 | + /> | ||
| 187 | + <button | ||
| 188 | + type="button" | ||
| 189 | + onClick={() => setShowConfirm(!showConfirm())} | ||
| 190 | + class="absolute right-3 top-1/2 -translate-y-1/2 text-muted-foreground transition-colors hover:text-foreground" | ||
| 191 | + aria-label={showConfirm() ? t("auth.hideConfirmPassword") : t("auth.showConfirmPassword")} | ||
| 192 | + > | ||
| 193 | + <Show when={showConfirm()} fallback={<IconEye class="h-4 w-4" />}> | ||
| 194 | + <IconEyeOff class="h-4 w-4" /> | ||
| 195 | + </Show> | ||
| 196 | + </button> | ||
| 197 | + </div> | ||
| 198 | + <Show when={confirmError()}> | ||
| 199 | + {(message) => ( | ||
| 200 | + <p id="register-confirm-error" role="alert" class="text-xs font-medium text-destructive-text">{message()}</p> | ||
| 201 | + )} | ||
| 202 | + </Show> | ||
| 142 | </div> | 203 | </div> |
| 143 | 204 | ||
| 144 | {error() && ( | 205 | {error() && ( |
src/pages/staff-work-page.tsxmodified+0 -13
| @@ -15,7 +15,6 @@ import { DataToolbar } from "@/components/ui/data-toolbar"; | |||
| 15 | import { Alert } from "@/components/ui/alert"; | 15 | import { Alert } from "@/components/ui/alert"; |
| 16 | import { Badge } from "@/components/ui/badge"; | 16 | import { Badge } from "@/components/ui/badge"; |
| 17 | import { Button } from "@/components/ui/button"; | 17 | import { Button } from "@/components/ui/button"; |
| 18 | -import { ComingSoonBadge } from "@/components/ui/coming-soon"; | ||
| 19 | import { ConfirmDialog } from "@/components/ui/confirm-dialog"; | 18 | import { ConfirmDialog } from "@/components/ui/confirm-dialog"; |
| 20 | import { DataTable, DataTableSkeleton } from "@/components/ui/data-table"; | 19 | import { DataTable, DataTableSkeleton } from "@/components/ui/data-table"; |
| 21 | import { EmptyState } from "@/components/ui/empty-state"; | 20 | import { EmptyState } from "@/components/ui/empty-state"; |
| @@ -296,18 +295,6 @@ function StaffWorkContent() { | |||
| 296 | searchPlaceholder={t("work.searchPlaceholder")} | 295 | searchPlaceholder={t("work.searchPlaceholder")} |
| 297 | searchHint={t("search.hint.people")} | 296 | searchHint={t("search.hint.people")} |
| 298 | onSearchInput={setStaffSearch} | 297 | onSearchInput={setStaffSearch} |
| 299 | - actions={ | ||
| 300 | - <> | ||
| 301 | - <Button type="button" size="sm" variant="outline" class="rounded-lg" disabled title={t("comingSoon.title")}> | ||
| 302 | - {t("work.addEntry")} | ||
| 303 | - <ComingSoonBadge class="ml-1.5" /> | ||
| 304 | - </Button> | ||
| 305 | - <Button type="button" size="sm" variant="outline" class="rounded-lg" disabled title={t("comingSoon.title")}> | ||
| 306 | - {t("work.planShift")} | ||
| 307 | - <ComingSoonBadge class="ml-1.5" /> | ||
| 308 | - </Button> | ||
| 309 | - </> | ||
| 310 | - } | ||
| 311 | /> | 298 | /> |
| 312 | </div> | 299 | </div> |
| 313 | 300 | ||
src/pages/students-roster-page.tsxmodified+5 -26
| @@ -1,6 +1,6 @@ | |||
| 1 | import { useNavigate } from "@tanstack/solid-router"; | 1 | import { useNavigate } from "@tanstack/solid-router"; |
| 2 | import type { ColumnDef } from "@tanstack/solid-table"; | 2 | import type { ColumnDef } from "@tanstack/solid-table"; |
| 3 | -import { For, Show, Suspense, createMemo, createSignal } from "solid-js"; | 3 | +import { Show, Suspense, createMemo, createSignal } from "solid-js"; |
| 4 | import { createResource } from "@/lib/create-resource"; | 4 | import { createResource } from "@/lib/create-resource"; |
| 5 | import { matchesSearch } from "@/lib/search-text"; | 5 | import { matchesSearch } from "@/lib/search-text"; |
| 6 | import { createUrlString } from "@/lib/url-state"; | 6 | import { createUrlString } from "@/lib/url-state"; |
| @@ -12,15 +12,14 @@ import { RouteGuard } from "@/components/layout/route-guard"; | |||
| 12 | import { CreateUserPanel } from "@/components/users/create-user-panel"; | 12 | import { CreateUserPanel } from "@/components/users/create-user-panel"; |
| 13 | import { RosterPersonCell } from "@/components/users/roster-person-cell"; | 13 | import { RosterPersonCell } from "@/components/users/roster-person-cell"; |
| 14 | import { Button } from "@/components/ui/button"; | 14 | import { Button } from "@/components/ui/button"; |
| 15 | -import { ComingSoonBadge } from "@/components/ui/coming-soon"; | ||
| 16 | import { DataTable, DataTableSkeleton } from "@/components/ui/data-table"; | 15 | import { DataTable, DataTableSkeleton } from "@/components/ui/data-table"; |
| 17 | import { ErrorAlert } from "@/components/ui/error-alert"; | 16 | import { ErrorAlert } from "@/components/ui/error-alert"; |
| 18 | -import { IconEye, IconPlus, IconUploadCloud } from "@/components/ui/icons"; | 17 | +import { IconEye, IconPlus } from "@/components/ui/icons"; |
| 19 | import { DropdownSelect } from "@/components/ui/select"; | 18 | import { DropdownSelect } from "@/components/ui/select"; |
| 20 | import { TableRowActions } from "@/components/ui/table-row-actions"; | 19 | import { TableRowActions } from "@/components/ui/table-row-actions"; |
| 21 | -import { Tabs, TabsList, TabsTrigger } from "@/components/ui/tabs"; | ||
| 22 | import { useT } from "@/stores/preferences-context"; | 20 | import { useT } from "@/stores/preferences-context"; |
| 23 | import { useAuth } from "@/stores/auth-context"; | 21 | import { useAuth } from "@/stores/auth-context"; |
| 22 | +import { sortByClass } from "@/lib/student-directory"; | ||
| 24 | 23 | ||
| 25 | const ROSTER_PAGE_SIZE = 10; | 24 | const ROSTER_PAGE_SIZE = 10; |
| 26 | 25 | ||
| @@ -61,7 +60,7 @@ function StudentsRosterContent() { | |||
| 61 | for (const { cls, members } of memberships) { | 60 | for (const { cls, members } of memberships) { |
| 62 | for (const member of members) byStudent.set(member.user.id, [...(byStudent.get(member.user.id) ?? []), cls]); | 61 | for (const member of members) byStudent.set(member.user.id, [...(byStudent.get(member.user.id) ?? []), cls]); |
| 63 | } | 62 | } |
| 64 | - const rows: StudentRow[] = students.items.map((person) => ({ person, classes: byStudent.get(person.id) ?? [] })); | 63 | + const rows: StudentRow[] = sortByClass(students.items.map((person) => ({ person, classes: byStudent.get(person.id) ?? [] }))); |
| 65 | return { rows, classes: classes.items, years: years.items }; | 64 | return { rows, classes: classes.items, years: years.items }; |
| 66 | }); | 65 | }); |
| 67 | 66 | ||
| @@ -104,21 +103,6 @@ function StudentsRosterContent() { | |||
| 104 | 103 | ||
| 105 | return ( | 104 | return ( |
| 106 | <div class="space-y-5"> | 105 | <div class="space-y-5"> |
| 107 | - <Tabs value="all"> | ||
| 108 | - <TabsList> | ||
| 109 | - <TabsTrigger value="all">{t("roster.tabAll")}</TabsTrigger> | ||
| 110 | - <For each={["roster.tabActive", "roster.tabNew", "roster.tabAtRisk", "roster.tabLeft"] as const}> | ||
| 111 | - {(key) => ( | ||
| 112 | - <TabsTrigger value={key} disabled title={t("comingSoon.title")}> | ||
| 113 | - {t(key)} | ||
| 114 | - <ComingSoonBadge class="ml-1.5" /> | ||
| 115 | - </TabsTrigger> | ||
| 116 | - )} | ||
| 117 | - </For> | ||
| 118 | - </TabsList> | ||
| 119 | - </Tabs> | ||
| 120 | - | ||
| 121 | - | ||
| 122 | <section class="space-y-4 p-0"> | 106 | <section class="space-y-4 p-0"> |
| 123 | <Suspense fallback={<DataTableSkeleton columns={3} rows={8} />}> | 107 | <Suspense fallback={<DataTableSkeleton columns={3} rows={8} />}> |
| 124 | <Show when={data.error}> | 108 | <Show when={data.error}> |
| @@ -137,12 +121,7 @@ function StudentsRosterContent() { | |||
| 137 | surfaceSections | 121 | surfaceSections |
| 138 | title={t("nav.studentsRoster")} | 122 | title={t("nav.studentsRoster")} |
| 139 | description={t("roster.studentsSubtitle")} | 123 | description={t("roster.studentsSubtitle")} |
| 140 | - actions={<><Button size="sm" variant="outline" class="min-w-[7.5rem] rounded-lg" disabled title={t("comingSoon.title")}> | 124 | + actions={<><Show when={auth.user()?.role === "admin"}> |
| 141 | - <IconUploadCloud class="h-4 w-4" /> | ||
| 142 | - {t("roster.import")} | ||
| 143 | - <ComingSoonBadge class="ml-1.5" /> | ||
| 144 | - </Button> | ||
| 145 | - <Show when={auth.user()?.role === "admin"}> | ||
| 146 | <Button size="sm" class="min-w-[7.5rem] rounded-lg" onClick={() => setCreating(true)}> | 125 | <Button size="sm" class="min-w-[7.5rem] rounded-lg" onClick={() => setCreating(true)}> |
| 147 | <IconPlus class="h-4 w-4" /> | 126 | <IconPlus class="h-4 w-4" /> |
| 148 | {t("roster.addStudent")} | 127 | {t("roster.addStudent")} |
src/pages/teachers-roster-page.tsxmodified+3 -25
| @@ -1,6 +1,6 @@ | |||
| 1 | import { useNavigate } from "@tanstack/solid-router"; | 1 | import { useNavigate } from "@tanstack/solid-router"; |
| 2 | import type { ColumnDef } from "@tanstack/solid-table"; | 2 | import type { ColumnDef } from "@tanstack/solid-table"; |
| 3 | -import { For, Show, Suspense, createMemo, createSignal } from "solid-js"; | 3 | +import { Show, Suspense, createMemo, createSignal } from "solid-js"; |
| 4 | import { createResource } from "@/lib/create-resource"; | 4 | import { createResource } from "@/lib/create-resource"; |
| 5 | import { matchesSearch } from "@/lib/search-text"; | 5 | import { matchesSearch } from "@/lib/search-text"; |
| 6 | import { getClassInstances, getClasses } from "@/api/classes"; | 6 | import { getClassInstances, getClasses } from "@/api/classes"; |
| @@ -13,12 +13,10 @@ import { RouteGuard } from "@/components/layout/route-guard"; | |||
| 13 | import { CreateUserPanel } from "@/components/users/create-user-panel"; | 13 | import { CreateUserPanel } from "@/components/users/create-user-panel"; |
| 14 | import { RosterPersonCell } from "@/components/users/roster-person-cell"; | 14 | import { RosterPersonCell } from "@/components/users/roster-person-cell"; |
| 15 | import { Button } from "@/components/ui/button"; | 15 | import { Button } from "@/components/ui/button"; |
| 16 | -import { ComingSoonBadge } from "@/components/ui/coming-soon"; | ||
| 17 | import { DataTable, DataTableSkeleton } from "@/components/ui/data-table"; | 16 | import { DataTable, DataTableSkeleton } from "@/components/ui/data-table"; |
| 18 | import { ErrorAlert } from "@/components/ui/error-alert"; | 17 | import { ErrorAlert } from "@/components/ui/error-alert"; |
| 19 | -import { IconEye, IconPlus, IconUploadCloud } from "@/components/ui/icons"; | 18 | +import { IconEye, IconPlus } from "@/components/ui/icons"; |
| 20 | import { TableRowActions } from "@/components/ui/table-row-actions"; | 19 | import { TableRowActions } from "@/components/ui/table-row-actions"; |
| 21 | -import { Tabs, TabsList, TabsTrigger } from "@/components/ui/tabs"; | ||
| 22 | import { useT } from "@/stores/preferences-context"; | 20 | import { useT } from "@/stores/preferences-context"; |
| 23 | import { useAuth } from "@/stores/auth-context"; | 21 | import { useAuth } from "@/stores/auth-context"; |
| 24 | 22 | ||
| @@ -118,21 +116,6 @@ function TeachersRosterContent() { | |||
| 118 | 116 | ||
| 119 | return ( | 117 | return ( |
| 120 | <div class="space-y-5"> | 118 | <div class="space-y-5"> |
| 121 | - <Tabs value="all"> | ||
| 122 | - <TabsList> | ||
| 123 | - <TabsTrigger value="all">{t("roster.tabAll")}</TabsTrigger> | ||
| 124 | - <For each={["roster.tabPermanent", "roster.tabContract", "roster.tabAdvisor"] as const}> | ||
| 125 | - {(key) => ( | ||
| 126 | - <TabsTrigger value={key} disabled title={t("comingSoon.title")}> | ||
| 127 | - {t(key)} | ||
| 128 | - <ComingSoonBadge class="ml-1.5" /> | ||
| 129 | - </TabsTrigger> | ||
| 130 | - )} | ||
| 131 | - </For> | ||
| 132 | - </TabsList> | ||
| 133 | - </Tabs> | ||
| 134 | - | ||
| 135 | - | ||
| 136 | <section class="space-y-4 p-0"> | 119 | <section class="space-y-4 p-0"> |
| 137 | <Suspense fallback={<DataTableSkeleton columns={4} rows={8} />}> | 120 | <Suspense fallback={<DataTableSkeleton columns={4} rows={8} />}> |
| 138 | <Show when={data.error}> | 121 | <Show when={data.error}> |
| @@ -145,12 +128,7 @@ function TeachersRosterContent() { | |||
| 145 | surfaceSections | 128 | surfaceSections |
| 146 | title={t("nav.teachersRoster")} | 129 | title={t("nav.teachersRoster")} |
| 147 | description={t("roster.teachersSubtitle")} | 130 | description={t("roster.teachersSubtitle")} |
| 148 | - actions={<><Button size="sm" variant="outline" class="min-w-[7.5rem] rounded-lg" disabled title={t("comingSoon.title")}> | 131 | + actions={<><Show when={auth.user()?.role === "admin"}> |
| 149 | - <IconUploadCloud class="h-4 w-4" /> | ||
| 150 | - {t("roster.import")} | ||
| 151 | - <ComingSoonBadge class="ml-1.5" /> | ||
| 152 | - </Button> | ||
| 153 | - <Show when={auth.user()?.role === "admin"}> | ||
| 154 | <Button size="sm" class="min-w-[7.5rem] rounded-lg" onClick={() => setCreating(true)}> | 132 | <Button size="sm" class="min-w-[7.5rem] rounded-lg" onClick={() => setCreating(true)}> |
| 155 | <IconPlus class="h-4 w-4" /> | 133 | <IconPlus class="h-4 w-4" /> |
| 156 | {t("roster.addTeacher")} | 134 | {t("roster.addTeacher")} |
src/pages/whiteboards-page.tsxmodified+2 -2
| @@ -265,8 +265,8 @@ function CreateBoardPanel(props: { | |||
| 265 | <ErrorAlert message={error()} /> | 265 | <ErrorAlert message={error()} /> |
| 266 | </Show> | 266 | </Show> |
| 267 | <div class="space-y-1.5"> | 267 | <div class="space-y-1.5"> |
| 268 | - <Label>{t("whiteboard.titleLabel")}</Label> | 268 | + <Label for="new-whiteboard-title">{t("whiteboard.titleLabel")}</Label> |
| 269 | - <Input value={title()} maxlength={200} onInput={(e) => setTitle(e.currentTarget.value)} /> | 269 | + <Input id="new-whiteboard-title" value={title()} maxlength={200} onInput={(e) => setTitle(e.currentTarget.value)} /> |
| 270 | </div> | 270 | </div> |
| 271 | 271 | ||
| 272 | <div class="space-y-1.5"> | 272 | <div class="space-y-1.5"> |