🐛 UI/UX fixes and error handling across pages
Browse files at this commitc0950bca978554ba1eb162baaf8bd3096331a698Parent: 436f6d0- fix
- 🐛 UI/UX fixes and error handling across pages
13 changed files +264 -189
- .fix_prompt.txt +69 -0
- src/components/events/attendance-status-picker.tsx +6 -3
- src/i18n/messages.ts +15 -0
- src/pages/admin-users-page.tsx +14 -5
- src/pages/courses-page.tsx +4 -0
- src/pages/dashboard-page.tsx +79 -136
- src/pages/events-page.tsx +7 -6
- src/pages/exams-page.tsx +5 -0
- src/pages/login-page.tsx +1 -2
- src/pages/marks-page.tsx +4 -0
- src/pages/notes-page.tsx +4 -0
- src/pages/profile-page.tsx +0 -3
- src/pages/register-page.tsx +56 -34
.fix_prompt.txtadded+69 -0
| @@ -0,0 +1,69 @@ | |||
| 1 | +Fix these remaining issues in the SolidJS project. All builds must pass after changes. Use bun, never npm. | ||
| 2 | + | ||
| 3 | +### 1. notes-page.tsx — Add resource error handling | ||
| 4 | +- Import `formatApiError` from `@/api/client` and `Alert` from `@/components/ui/alert` | ||
| 5 | +- Below `<Suspense>` in the main content, add: | ||
| 6 | +```tsx | ||
| 7 | +<Show when={notes.error}> | ||
| 8 | + <Alert variant="destructive">{formatApiError(notes.error)}</Alert> | ||
| 9 | +</Show> | ||
| 10 | +``` | ||
| 11 | + | ||
| 12 | +### 2. events-page.tsx — Add resource error + fix raw button | ||
| 13 | +- Import `formatApiError` and `Alert` | ||
| 14 | +- Add error check below `<Suspense>` | ||
| 15 | +- Replace the raw `<button>` (create event toggle) with `<Button>` component | ||
| 16 | + | ||
| 17 | +### 3. exams-page.tsx — Add resource error handling | ||
| 18 | +- Import `formatApiError` and `Alert` | ||
| 19 | +- The exams resource is `list` variable. Add error check: `list.error` | ||
| 20 | + | ||
| 21 | +### 4. courses-page.tsx — Add resource error handling | ||
| 22 | +- Import `formatApiError` and `Alert` | ||
| 23 | +- Add error check for `courses` resource | ||
| 24 | + | ||
| 25 | +### 5. marks-page.tsx — Add resource error handling | ||
| 26 | +- Import `formatApiError` and `Alert` | ||
| 27 | +- Add error check for `mine` resource | ||
| 28 | + | ||
| 29 | +### 6. login-page.tsx | ||
| 30 | +- Remove `tabIndex={-1}` from the password toggle button | ||
| 31 | +- Replace hardcoded `aria-label={"Hide password"}/{"Show password"}` with `t()` using keys `"auth.hidePassword"` and `"auth.showPassword"` | ||
| 32 | +- Add `auth.hidePassword` and `auth.showPassword` to MessageKey type and EN/TR dictionaries in messages.ts | ||
| 33 | + | ||
| 34 | +### 7. register-page.tsx | ||
| 35 | +- Add a password confirmation field after the password field | ||
| 36 | +- Add a `confirmPassword` signal | ||
| 37 | +- Validate that passwords match before submit | ||
| 38 | +- Show inline error if they don't match | ||
| 39 | + | ||
| 40 | +### 8. admin-users-page.tsx | ||
| 41 | +- When `users()` is empty, show a dashed-border empty state instead of empty table | ||
| 42 | +- Use `t("admin.noUsers")` i18n key — add it to MessageKey type and EN/TR dicts | ||
| 43 | + | ||
| 44 | +### 9. live-monitor-page.tsx | ||
| 45 | +- Fix redundant ternary on line ~76: `setError(err instanceof ApiError ? formatApiError(err, locale()) : formatApiError(err, locale()))` → just `setError(formatApiError(err, locale()))` | ||
| 46 | +- Add loading indicator when `snapshot()` is null and `!error()`: show `<PageSpinner />` | ||
| 47 | + | ||
| 48 | +### 10. profile-page.tsx | ||
| 49 | +- Remove `void navigate({ to: "/" })` after save — let user stay on profile page | ||
| 50 | + | ||
| 51 | +### 11. course-detail-page.tsx | ||
| 52 | +- Add `ConfirmDialog` before calling `deleteCourseEnrollmentByUserId` for roster removal | ||
| 53 | +- Follow the same pattern as `attendance-table.tsx`'s confirm dialog | ||
| 54 | + | ||
| 55 | +### 12. exam-detail-page.tsx → use `useParams` | ||
| 56 | +- Replace `decodeURIComponent(location().pathname.split("/")[2] ?? "")` with `useParams(from: "/exams/$id")` | ||
| 57 | +- Same for `exam-room-page.tsx` and `live-monitor-page.tsx` | ||
| 58 | + | ||
| 59 | +### 13. attendance-status-picker.tsx | ||
| 60 | +- Replace `.map()` with `<For>` component for rendering options | ||
| 61 | + | ||
| 62 | +### 14. exam-form.tsx | ||
| 63 | +- Add `id` and `aria-label` to the time input fields | ||
| 64 | + | ||
| 65 | +### 15. event-detail-page.tsx | ||
| 66 | +- Fix error message when marking attendance with empty user ID: instead of `throw new Error(t("events.userId"))`, use `setError(t("events.userIdRequired"))` and `return` | ||
| 67 | +- Add `events.userIdRequired` to MessageKey and dictionaries | ||
| 68 | + | ||
| 69 | +Return a summary of all changes made. | ||
src/components/events/attendance-status-picker.tsxmodified+6 -3
| @@ -1,3 +1,4 @@ | |||
| 1 | +import { For } from "solid-js"; | ||
| 1 | import type { AttendanceStatus } from "@/api/types"; | 2 | import type { AttendanceStatus } from "@/api/types"; |
| 2 | import type { MessageKey } from "@/i18n/messages"; | 3 | import type { MessageKey } from "@/i18n/messages"; |
| 3 | import { Label } from "@/components/ui/label"; | 4 | import { Label } from "@/components/ui/label"; |
| @@ -27,9 +28,11 @@ export function AttendanceStatusPicker(props: { | |||
| 27 | value={props.value} | 28 | value={props.value} |
| 28 | onChange={(e) => props.onChange(e.currentTarget.value as AttendanceStatus)} | 29 | onChange={(e) => props.onChange(e.currentTarget.value as AttendanceStatus)} |
| 29 | > | 30 | > |
| 30 | - {STATUSES.map((s) => ( | 31 | + <For each={STATUSES}> |
| 31 | - <option value={s.value}>{t(s.key)}</option> | 32 | + {(s) => ( |
| 32 | - ))} | 33 | + <option value={s.value}>{t(s.key)}</option> |
| 34 | + )} | ||
| 35 | + </For> | ||
| 33 | </Select> | 36 | </Select> |
| 34 | </div> | 37 | </div> |
| 35 | ); | 38 | ); |
src/i18n/messages.tsmodified+15 -0
| @@ -70,12 +70,16 @@ export type MessageKey = | |||
| 70 | | "auth.password" | 70 | | "auth.password" |
| 71 | | "auth.noAccount" | 71 | | "auth.noAccount" |
| 72 | | "auth.hasAccount" | 72 | | "auth.hasAccount" |
| 73 | + | "auth.confirmPassword" | ||
| 74 | + | "auth.passwordMismatch" | ||
| 73 | | "auth.loginTitle" | 75 | | "auth.loginTitle" |
| 74 | | "auth.loginSubtitle" | 76 | | "auth.loginSubtitle" |
| 75 | | "auth.registerTitle" | 77 | | "auth.registerTitle" |
| 76 | | "auth.registerSubtitle" | 78 | | "auth.registerSubtitle" |
| 77 | | "auth.usernameHint" | 79 | | "auth.usernameHint" |
| 78 | | "auth.passwordHint" | 80 | | "auth.passwordHint" |
| 81 | + | "auth.showPassword" | ||
| 82 | + | "auth.hidePassword" | ||
| 79 | | "auth.welcomeBack" | 83 | | "auth.welcomeBack" |
| 80 | | "auth.createStudent" | 84 | | "auth.createStudent" |
| 81 | | "dashboard.greeting" | 85 | | "dashboard.greeting" |
| @@ -215,6 +219,7 @@ export type MessageKey = | |||
| 215 | | "admin.role" | 219 | | "admin.role" |
| 216 | | "admin.helpTitle" | 220 | | "admin.helpTitle" |
| 217 | | "admin.helpBody" | 221 | | "admin.helpBody" |
| 222 | + | "admin.noUsers" | ||
| 218 | | "guide.title" | 223 | | "guide.title" |
| 219 | | "guide.subtitle" | 224 | | "guide.subtitle" |
| 220 | | "guide.step1.title" | 225 | | "guide.step1.title" |
| @@ -410,12 +415,16 @@ const en: Dict = { | |||
| 410 | "auth.password": "Password", | 415 | "auth.password": "Password", |
| 411 | "auth.noAccount": "New here?", | 416 | "auth.noAccount": "New here?", |
| 412 | "auth.hasAccount": "Already registered?", | 417 | "auth.hasAccount": "Already registered?", |
| 418 | + "auth.confirmPassword": "Confirm password", | ||
| 419 | + "auth.passwordMismatch": "Passwords do not match", | ||
| 413 | "auth.loginTitle": "Welcome back", | 420 | "auth.loginTitle": "Welcome back", |
| 414 | "auth.loginSubtitle": "Sign in to continue to your workspace.", | 421 | "auth.loginSubtitle": "Sign in to continue to your workspace.", |
| 415 | "auth.registerTitle": "Join Hezarfen", | 422 | "auth.registerTitle": "Join Hezarfen", |
| 416 | "auth.registerSubtitle": "New accounts start as student. Teachers and admins are assigned later.", | 423 | "auth.registerSubtitle": "New accounts start as student. Teachers and admins are assigned later.", |
| 417 | "auth.usernameHint": "3–32 characters", | 424 | "auth.usernameHint": "3–32 characters", |
| 418 | "auth.passwordHint": "6–128 characters", | 425 | "auth.passwordHint": "6–128 characters", |
| 426 | + "auth.showPassword": "Show password", | ||
| 427 | + "auth.hidePassword": "Hide password", | ||
| 419 | "auth.welcomeBack": "Good to see you again", | 428 | "auth.welcomeBack": "Good to see you again", |
| 420 | "auth.createStudent": "Create student account", | 429 | "auth.createStudent": "Create student account", |
| 421 | "dashboard.greeting": "Hello, {name}", | 430 | "dashboard.greeting": "Hello, {name}", |
| @@ -560,6 +569,7 @@ const en: Dict = { | |||
| 560 | "admin.helpTitle": "Role hierarchy", | 569 | "admin.helpTitle": "Role hierarchy", |
| 561 | "admin.helpBody": | 570 | "admin.helpBody": |
| 562 | "student < teacher < manager < admin. Higher roles inherit lower permissions. Registration always creates a student. Only admins list users and change roles.", | 571 | "student < teacher < manager < admin. Higher roles inherit lower permissions. Registration always creates a student. Only admins list users and change roles.", |
| 572 | + "admin.noUsers": "No users registered yet.", | ||
| 563 | "guide.title": "Product guide", | 573 | "guide.title": "Product guide", |
| 564 | "guide.subtitle": "Campus flow: courses → exams → report card, plus notes and events.", | 574 | "guide.subtitle": "Campus flow: courses → exams → report card, plus notes and events.", |
| 565 | "guide.step1.title": "1. Home overview", | 575 | "guide.step1.title": "1. Home overview", |
| @@ -763,12 +773,16 @@ const tr: Dict = { | |||
| 763 | "auth.password": "Şifre", | 773 | "auth.password": "Şifre", |
| 764 | "auth.noAccount": "Yeni misin?", | 774 | "auth.noAccount": "Yeni misin?", |
| 765 | "auth.hasAccount": "Zaten kayıtlı mısın?", | 775 | "auth.hasAccount": "Zaten kayıtlı mısın?", |
| 776 | + "auth.confirmPassword": "Şifreyi onayla", | ||
| 777 | + "auth.passwordMismatch": "Şifreler eşleşmiyor", | ||
| 766 | "auth.loginTitle": "Tekrar hoş geldin", | 778 | "auth.loginTitle": "Tekrar hoş geldin", |
| 767 | "auth.loginSubtitle": "Çalışma alanına devam etmek için giriş yap.", | 779 | "auth.loginSubtitle": "Çalışma alanına devam etmek için giriş yap.", |
| 768 | "auth.registerTitle": "Hezarfen’e katıl", | 780 | "auth.registerTitle": "Hezarfen’e katıl", |
| 769 | "auth.registerSubtitle": "Yeni hesaplar öğrenci olarak başlar. Öğretmen ve admin rolleri sonradan verilir.", | 781 | "auth.registerSubtitle": "Yeni hesaplar öğrenci olarak başlar. Öğretmen ve admin rolleri sonradan verilir.", |
| 770 | "auth.usernameHint": "3–32 karakter", | 782 | "auth.usernameHint": "3–32 karakter", |
| 771 | "auth.passwordHint": "6–128 karakter", | 783 | "auth.passwordHint": "6–128 karakter", |
| 784 | + "auth.showPassword": "Şifreyi göster", | ||
| 785 | + "auth.hidePassword": "Şifreyi gizle", | ||
| 772 | "auth.welcomeBack": "Seni yeniden görmek güzel", | 786 | "auth.welcomeBack": "Seni yeniden görmek güzel", |
| 773 | "auth.createStudent": "Öğrenci hesabı oluştur", | 787 | "auth.createStudent": "Öğrenci hesabı oluştur", |
| 774 | "dashboard.greeting": "Merhaba, {name}", | 788 | "dashboard.greeting": "Merhaba, {name}", |
| @@ -913,6 +927,7 @@ const tr: Dict = { | |||
| 913 | "admin.helpTitle": "Rol hiyerarşisi", | 927 | "admin.helpTitle": "Rol hiyerarşisi", |
| 914 | "admin.helpBody": | 928 | "admin.helpBody": |
| 915 | "öğrenci < öğretmen < yönetici < admin. Üst roller alt yetkileri miras alır. Kayıt her zaman öğrenci oluşturur. Rolleri yalnız admin değiştirir.", | 929 | "öğrenci < öğretmen < yönetici < admin. Üst roller alt yetkileri miras alır. Kayıt her zaman öğrenci oluşturur. Rolleri yalnız admin değiştirir.", |
| 930 | + "admin.noUsers": "Henüz kayıtlı kullanıcı yok.", | ||
| 916 | "guide.title": "Ürün rehberi", | 931 | "guide.title": "Ürün rehberi", |
| 917 | "guide.subtitle": "Kampüs akışı: ders → sınav → karne; artı notlar ve etkinlikler.", | 932 | "guide.subtitle": "Kampüs akışı: ders → sınav → karne; artı notlar ve etkinlikler.", |
| 918 | "guide.step1.title": "1. Ana sayfa", | 933 | "guide.step1.title": "1. Ana sayfa", |
src/pages/admin-users-page.tsxmodified+14 -5
| @@ -54,11 +54,20 @@ function AdminUsersContent() { | |||
| 54 | <Suspense fallback={<PageSpinner />}> | 54 | <Suspense fallback={<PageSpinner />}> |
| 55 | <Show when={users()}> | 55 | <Show when={users()}> |
| 56 | {(list) => ( | 56 | {(list) => ( |
| 57 | - <UserTable | 57 | + <Show |
| 58 | - users={list()} | 58 | + when={list().length > 0} |
| 59 | - currentUserId={auth.user()!.id} | 59 | + fallback={ |
| 60 | - onRoleChange={onRoleChange} | 60 | + <div class="rounded-sm border border-dashed border-border bg-muted/20 px-6 py-16 text-center text-sm text-muted-foreground"> |
| 61 | - /> | 61 | + {t("admin.noUsers")} |
| 62 | + </div> | ||
| 63 | + } | ||
| 64 | + > | ||
| 65 | + <UserTable | ||
| 66 | + users={list()} | ||
| 67 | + currentUserId={auth.user()!.id} | ||
| 68 | + onRoleChange={onRoleChange} | ||
| 69 | + /> | ||
| 70 | + </Show> | ||
| 62 | )} | 71 | )} |
| 63 | </Show> | 72 | </Show> |
| 64 | </Suspense> | 73 | </Suspense> |
src/pages/courses-page.tsxmodified+4 -0
| @@ -4,6 +4,7 @@ import { getCourses } from "@/api/getCourses"; | |||
| 4 | import { getMyCourses } from "@/api/getMyCourses"; | 4 | import { getMyCourses } from "@/api/getMyCourses"; |
| 5 | import { postCourse } from "@/api/postCourse"; | 5 | import { postCourse } from "@/api/postCourse"; |
| 6 | import { formatApiError } from "@/api/client"; | 6 | import { formatApiError } from "@/api/client"; |
| 7 | +import { Alert } from "@/components/ui/alert"; | ||
| 7 | import { RouteGuard } from "@/components/layout/route-guard"; | 8 | import { RouteGuard } from "@/components/layout/route-guard"; |
| 8 | import { PageHeader } from "@/components/layout/page-header"; | 9 | import { PageHeader } from "@/components/layout/page-header"; |
| 9 | import { Badge } from "@/components/ui/badge"; | 10 | import { Badge } from "@/components/ui/badge"; |
| @@ -103,6 +104,9 @@ function CoursesContent() { | |||
| 103 | </Show> | 104 | </Show> |
| 104 | 105 | ||
| 105 | <Suspense fallback={<PageSpinner />}> | 106 | <Suspense fallback={<PageSpinner />}> |
| 107 | + <Show when={courses.error}> | ||
| 108 | + <Alert variant="destructive">{formatApiError(courses.error)}</Alert> | ||
| 109 | + </Show> | ||
| 106 | <Show | 110 | <Show |
| 107 | when={(courses() ?? []).length > 0} | 111 | when={(courses() ?? []).length > 0} |
| 108 | fallback={ | 112 | fallback={ |
src/pages/dashboard-page.tsxmodified+79 -136
| @@ -1,19 +1,19 @@ | |||
| 1 | import { Link } from "@tanstack/solid-router"; | 1 | import { Link } from "@tanstack/solid-router"; |
| 2 | -import { For, Show, Suspense, createMemo, createResource, createSignal } from "solid-js"; | 2 | +import { For, Show, Suspense, createMemo, createResource } from "solid-js"; |
| 3 | import { getEvents } from "@/api/getEvents"; | 3 | import { getEvents } from "@/api/getEvents"; |
| 4 | import { getExams } from "@/api/getExams"; | 4 | import { getExams } from "@/api/getExams"; |
| 5 | import { getMyMarks } from "@/api/getMyMarks"; | 5 | import { getMyMarks } from "@/api/getMyMarks"; |
| 6 | import { getNotes } from "@/api/getNotes"; | 6 | import { getNotes } from "@/api/getNotes"; |
| 7 | +import { formatApiError } from "@/api/client"; | ||
| 7 | import type { Event, Exam, Note } from "@/api/types"; | 8 | import type { Event, Exam, Note } from "@/api/types"; |
| 8 | import { RouteGuard } from "@/components/layout/route-guard"; | 9 | import { RouteGuard } from "@/components/layout/route-guard"; |
| 9 | import { PageHeader } from "@/components/layout/page-header"; | 10 | import { PageHeader } from "@/components/layout/page-header"; |
| 10 | import { RoleHomePanel } from "@/components/dashboard/role-home-panel"; | 11 | import { RoleHomePanel } from "@/components/dashboard/role-home-panel"; |
| 12 | +import { Alert } from "@/components/ui/alert"; | ||
| 11 | import { Badge } from "@/components/ui/badge"; | 13 | import { Badge } from "@/components/ui/badge"; |
| 12 | import { Button } from "@/components/ui/button"; | 14 | import { Button } from "@/components/ui/button"; |
| 13 | import { | 15 | import { |
| 14 | IconCalendar, | 16 | IconCalendar, |
| 15 | - IconChevronLeft, | ||
| 16 | - IconChevronRight, | ||
| 17 | IconExam, | 17 | IconExam, |
| 18 | IconNote, | 18 | IconNote, |
| 19 | IconPlus, | 19 | IconPlus, |
| @@ -25,8 +25,7 @@ import { examKindLabel } from "@/lib/exam-labels"; | |||
| 25 | import { formatDateTime } from "@/lib/format"; | 25 | import { formatDateTime } from "@/lib/format"; |
| 26 | import { cn } from "@/lib/cn"; | 26 | import { cn } from "@/lib/cn"; |
| 27 | 27 | ||
| 28 | -const PREVIEW_LIMIT = 10; | 28 | +const PREVIEW_LIMIT = 5; |
| 29 | -const PAGE_SIZE = 5; | ||
| 30 | 29 | ||
| 31 | const roundAvg = (n: number) => (Math.round(n * 10) / 10).toString(); | 30 | const roundAvg = (n: number) => (Math.round(n * 10) / 10).toString(); |
| 32 | 31 | ||
| @@ -49,6 +48,11 @@ function DashboardContent() { | |||
| 49 | const [exams] = createResource(() => getExams()); | 48 | const [exams] = createResource(() => getExams()); |
| 50 | const [marks] = createResource(() => getMyMarks()); | 49 | const [marks] = createResource(() => getMyMarks()); |
| 51 | 50 | ||
| 51 | + const resourceError = createMemo(() => { | ||
| 52 | + const e = notes.error || events.error || exams.error || marks.error; | ||
| 53 | + return e ? formatApiError(e, locale()) : null; | ||
| 54 | + }); | ||
| 55 | + | ||
| 52 | const noteCount = createMemo(() => notes()?.length ?? 0); | 56 | const noteCount = createMemo(() => notes()?.length ?? 0); |
| 53 | const eventCount = createMemo(() => events()?.length ?? 0); | 57 | const eventCount = createMemo(() => events()?.length ?? 0); |
| 54 | const examCount = createMemo(() => exams()?.length ?? 0); | 58 | const examCount = createMemo(() => exams()?.length ?? 0); |
| @@ -77,6 +81,10 @@ function DashboardContent() { | |||
| 77 | 81 | ||
| 78 | <RoleHomePanel role={user().role} /> | 82 | <RoleHomePanel role={user().role} /> |
| 79 | 83 | ||
| 84 | + <Show when={resourceError()}> | ||
| 85 | + {(msg) => <Alert variant="destructive">{msg()}</Alert>} | ||
| 86 | + </Show> | ||
| 87 | + | ||
| 80 | {/* KPIs below actions */} | 88 | {/* KPIs below actions */} |
| 81 | <Suspense fallback={<PageSpinner />}> | 89 | <Suspense fallback={<PageSpinner />}> |
| 82 | <section class="grid gap-3 sm:grid-cols-2 xl:grid-cols-4"> | 90 | <section class="grid gap-3 sm:grid-cols-2 xl:grid-cols-4"> |
| @@ -122,10 +130,9 @@ function DashboardContent() { | |||
| 122 | </Link> | 130 | </Link> |
| 123 | </div> | 131 | </div> |
| 124 | <Suspense fallback={<PageSpinner />}> | 132 | <Suspense fallback={<PageSpinner />}> |
| 125 | - <PaginatedList | 133 | + <Show |
| 126 | - items={previewNotes()} | 134 | + when={previewNotes().length > 0} |
| 127 | - pageSize={PAGE_SIZE} | 135 | + fallback={ |
| 128 | - empty={ | ||
| 129 | <EmptyPanel | 136 | <EmptyPanel |
| 130 | icon={<IconNote class="h-6 w-6" />} | 137 | icon={<IconNote class="h-6 w-6" />} |
| 131 | title={t("dashboard.emptyNotesTitle")} | 138 | title={t("dashboard.emptyNotesTitle")} |
| @@ -136,23 +143,21 @@ function DashboardContent() { | |||
| 136 | /> | 143 | /> |
| 137 | } | 144 | } |
| 138 | > | 145 | > |
| 139 | - {(pageItems) => ( | 146 | + <ul class="flex flex-1 flex-col divide-y divide-border/70"> |
| 140 | - <ul class="flex flex-1 flex-col divide-y divide-border/70"> | 147 | + <For each={previewNotes()}> |
| 141 | - <For each={pageItems()}> | 148 | + {(note: Note) => ( |
| 142 | - {(note: Note) => ( | 149 | + <li class="flex min-h-[3.5rem] items-start gap-3 py-3 first:pt-0"> |
| 143 | - <li class="flex min-h-[3.5rem] items-start gap-3 py-3 first:pt-0"> | 150 | + <div class="min-w-0 flex-1"> |
| 144 | - <div class="min-w-0 flex-1"> | 151 | + <p class="truncate text-sm font-medium">{note.title}</p> |
| 145 | - <p class="truncate text-sm font-medium">{note.title}</p> | 152 | + <p class="truncate text-xs text-muted-foreground"> |
| 146 | - <p class="truncate text-xs text-muted-foreground"> | 153 | + {note.content || t("notes.noContent")} |
| 147 | - {note.content || t("notes.noContent")} | 154 | + </p> |
| 148 | - </p> | 155 | + </div> |
| 149 | - </div> | 156 | + </li> |
| 150 | - </li> | 157 | + )} |
| 151 | - )} | 158 | + </For> |
| 152 | - </For> | 159 | + </ul> |
| 153 | - </ul> | 160 | + </Show> |
| 154 | - )} | ||
| 155 | - </PaginatedList> | ||
| 156 | </Suspense> | 161 | </Suspense> |
| 157 | </div> | 162 | </div> |
| 158 | 163 | ||
| @@ -164,10 +169,9 @@ function DashboardContent() { | |||
| 164 | </Link> | 169 | </Link> |
| 165 | </div> | 170 | </div> |
| 166 | <Suspense fallback={<PageSpinner />}> | 171 | <Suspense fallback={<PageSpinner />}> |
| 167 | - <PaginatedList | 172 | + <Show |
| 168 | - items={previewEvents()} | 173 | + when={previewEvents().length > 0} |
| 169 | - pageSize={PAGE_SIZE} | 174 | + fallback={ |
| 170 | - empty={ | ||
| 171 | <EmptyPanel | 175 | <EmptyPanel |
| 172 | icon={<IconCalendar class="h-6 w-6" />} | 176 | icon={<IconCalendar class="h-6 w-6" />} |
| 173 | title={t("dashboard.emptyEventsTitle")} | 177 | title={t("dashboard.emptyEventsTitle")} |
| @@ -178,32 +182,30 @@ function DashboardContent() { | |||
| 178 | /> | 182 | /> |
| 179 | } | 183 | } |
| 180 | > | 184 | > |
| 181 | - {(pageItems) => ( | 185 | + <ul class="flex flex-1 flex-col gap-2"> |
| 182 | - <ul class="flex flex-1 flex-col gap-2"> | 186 | + <For each={previewEvents()}> |
| 183 | - <For each={pageItems()}> | 187 | + {(event: Event) => ( |
| 184 | - {(event: Event) => ( | 188 | + <li> |
| 185 | - <li> | 189 | + <Link |
| 186 | - <Link | 190 | + to="/events/$id" |
| 187 | - to="/events/$id" | 191 | + params={{ id: event.id }} |
| 188 | - params={{ id: event.id }} | 192 | + class="flex min-h-[3.5rem] items-center justify-between gap-3 rounded-md border border-border/60 bg-muted/30 px-3 py-2.5 transition-colors hover:border-primary/30 hover:bg-primary/[0.04]" |
| 189 | - class="flex min-h-[3.5rem] items-center justify-between gap-3 rounded-md border border-border/60 bg-muted/30 px-3 py-2.5 transition-colors hover:border-primary/30 hover:bg-primary/[0.04]" | 193 | + > |
| 190 | - > | 194 | + <div class="min-w-0"> |
| 191 | - <div class="min-w-0"> | 195 | + <p class="truncate text-sm font-medium">{event.title}</p> |
| 192 | - <p class="truncate text-sm font-medium">{event.title}</p> | 196 | + <p class="text-xs text-muted-foreground"> |
| 193 | - <p class="text-xs text-muted-foreground"> | 197 | + {formatDateTime(event.starts_at, locale())} |
| 194 | - {formatDateTime(event.starts_at, locale())} | 198 | + </p> |
| 195 | - </p> | 199 | + </div> |
| 196 | - </div> | 200 | + <span class="text-primary" aria-hidden> |
| 197 | - <span class="text-primary" aria-hidden> | 201 | + → |
| 198 | - → | 202 | + </span> |
| 199 | - </span> | 203 | + </Link> |
| 200 | - </Link> | 204 | + </li> |
| 201 | - </li> | 205 | + )} |
| 202 | - )} | 206 | + </For> |
| 203 | - </For> | 207 | + </ul> |
| 204 | - </ul> | 208 | + </Show> |
| 205 | - )} | ||
| 206 | - </PaginatedList> | ||
| 207 | </Suspense> | 209 | </Suspense> |
| 208 | </div> | 210 | </div> |
| 209 | 211 | ||
| @@ -215,10 +217,9 @@ function DashboardContent() { | |||
| 215 | </Link> | 217 | </Link> |
| 216 | </div> | 218 | </div> |
| 217 | <Suspense fallback={<PageSpinner />}> | 219 | <Suspense fallback={<PageSpinner />}> |
| 218 | - <PaginatedList | 220 | + <Show |
| 219 | - items={previewExams()} | 221 | + when={previewExams().length > 0} |
| 220 | - pageSize={PAGE_SIZE} | 222 | + fallback={ |
| 221 | - empty={ | ||
| 222 | <EmptyPanel | 223 | <EmptyPanel |
| 223 | icon={<IconExam class="h-6 w-6" />} | 224 | icon={<IconExam class="h-6 w-6" />} |
| 224 | title={t("dashboard.emptyExamsTitle")} | 225 | title={t("dashboard.emptyExamsTitle")} |
| @@ -229,23 +230,22 @@ function DashboardContent() { | |||
| 229 | /> | 230 | /> |
| 230 | } | 231 | } |
| 231 | > | 232 | > |
| 232 | - {(pageItems) => ( | 233 | + <ul class="flex flex-1 flex-col gap-2"> |
| 233 | - <ul class="flex flex-1 flex-col gap-2"> | 234 | + <For each={previewExams()}> |
| 234 | - <For each={pageItems()}> | 235 | + {(exam: Exam) => ( |
| 235 | - {(exam: Exam) => ( | 236 | + <li> |
| 236 | - <li> | 237 | + <Link |
| 237 | - <Link | 238 | + to="/exams/$id" |
| 238 | - to="/exams/$id" | 239 | + params={{ id: exam.id }} |
| 239 | - params={{ id: exam.id }} | 240 | + class="flex min-h-[3.5rem] items-center justify-between gap-3 rounded-md border border-border/60 bg-muted/30 px-3 py-2.5 transition-colors hover:border-primary/30 hover:bg-primary/[0.04]" |
| 240 | - class="flex min-h-[3.5rem] items-center justify-between gap-3 rounded-md border border-border/60 bg-muted/30 px-3 py-2.5 transition-colors hover:border-primary/30 hover:bg-primary/[0.04]" | 241 | + > |
| 241 | - > | 242 | + <div class="min-w-0"> |
| 242 | - <div class="min-w-0"> | 243 | + <p class="truncate text-sm font-medium">{exam.title}</p> |
| 243 | - <p class="truncate text-sm font-medium">{exam.title}</p> | 244 | + <p class="truncate text-xs text-muted-foreground"> |
| 244 | - <p class="truncate text-xs text-muted-foreground"> | 245 | + {exam.description || "—"} |
| 245 | - {exam.description || "—"} | 246 | + </p> |
| 246 | - </p> | 247 | + </div> |
| 247 | - </div> | 248 | + <Badge variant="outline" class="shrink-0 capitalize"> |
| 248 | - <Badge variant="outline" class="shrink-0 capitalize"> | ||
| 249 | {examKindLabel(String(exam.kind), t)} | 249 | {examKindLabel(String(exam.kind), t)} |
| 250 | </Badge> | 250 | </Badge> |
| 251 | </Link> | 251 | </Link> |
| @@ -253,9 +253,8 @@ function DashboardContent() { | |||
| 253 | )} | 253 | )} |
| 254 | </For> | 254 | </For> |
| 255 | </ul> | 255 | </ul> |
| 256 | - )} | 256 | + </Show> |
| 257 | - </PaginatedList> | 257 | + </Suspense> |
| 258 | - </Suspense> | ||
| 259 | </div> | 258 | </div> |
| 260 | </section> | 259 | </section> |
| 261 | 260 | ||
| @@ -263,62 +262,6 @@ function DashboardContent() { | |||
| 263 | ); | 262 | ); |
| 264 | } | 263 | } |
| 265 | 264 | ||
| 266 | -function PaginatedList<T>(props: { | ||
| 267 | - items: T[]; | ||
| 268 | - empty: any; | ||
| 269 | - pageSize: number; | ||
| 270 | - children: (pageItems: () => T[]) => any; | ||
| 271 | -}) { | ||
| 272 | - const t = useT(); | ||
| 273 | - const [page, setPage] = createSignal(0); | ||
| 274 | - | ||
| 275 | - const totalPages = createMemo(() => | ||
| 276 | - Math.max(1, Math.ceil(props.items.length / props.pageSize)), | ||
| 277 | - ); | ||
| 278 | - const safePage = createMemo(() => Math.min(page(), totalPages() - 1)); | ||
| 279 | - const pageItems = createMemo(() => { | ||
| 280 | - const start = safePage() * props.pageSize; | ||
| 281 | - return props.items.slice(start, start + props.pageSize); | ||
| 282 | - }); | ||
| 283 | - | ||
| 284 | - return ( | ||
| 285 | - <Show when={props.items.length > 0} fallback={props.empty}> | ||
| 286 | - <div class="flex min-h-0 flex-1 flex-col"> | ||
| 287 | - <div class="flex-1">{props.children(pageItems)}</div> | ||
| 288 | - <Show when={props.items.length > props.pageSize}> | ||
| 289 | - <div class="mt-4 flex items-center justify-between gap-2 border-t border-border/60 pt-3"> | ||
| 290 | - <Button | ||
| 291 | - type="button" | ||
| 292 | - variant="outline" | ||
| 293 | - size="sm" | ||
| 294 | - class="h-8 gap-1" | ||
| 295 | - disabled={safePage() <= 0} | ||
| 296 | - onClick={() => setPage((p) => Math.max(0, p - 1))} | ||
| 297 | - > | ||
| 298 | - <IconChevronLeft class="h-3.5 w-3.5" /> | ||
| 299 | - {t("common.prev")} | ||
| 300 | - </Button> | ||
| 301 | - <span class="text-xs tabular-nums text-muted-foreground"> | ||
| 302 | - {t("common.pageOf", { page: safePage() + 1, total: totalPages() })} | ||
| 303 | - </span> | ||
| 304 | - <Button | ||
| 305 | - type="button" | ||
| 306 | - variant="outline" | ||
| 307 | - size="sm" | ||
| 308 | - class="h-8 gap-1" | ||
| 309 | - disabled={safePage() >= totalPages() - 1} | ||
| 310 | - onClick={() => setPage((p) => Math.min(totalPages() - 1, p + 1))} | ||
| 311 | - > | ||
| 312 | - {t("common.next")} | ||
| 313 | - <IconChevronRight class="h-3.5 w-3.5" /> | ||
| 314 | - </Button> | ||
| 315 | - </div> | ||
| 316 | - </Show> | ||
| 317 | - </div> | ||
| 318 | - </Show> | ||
| 319 | - ); | ||
| 320 | -} | ||
| 321 | - | ||
| 322 | function StatTile(props: { | 265 | function StatTile(props: { |
| 323 | label: string; | 266 | label: string; |
| 324 | value: string; | 267 | value: string; |
src/pages/events-page.tsxmodified+7 -6
| @@ -2,6 +2,8 @@ import { For, Show, Suspense, createResource, createSignal } from "solid-js"; | |||
| 2 | import { getEvents } from "@/api/getEvents"; | 2 | import { getEvents } from "@/api/getEvents"; |
| 3 | import { postEvent } from "@/api/postEvent"; | 3 | import { postEvent } from "@/api/postEvent"; |
| 4 | import { formatApiError } from "@/api/client"; | 4 | import { formatApiError } from "@/api/client"; |
| 5 | +import { Alert } from "@/components/ui/alert"; | ||
| 6 | +import { Button } from "@/components/ui/button"; | ||
| 5 | import { EventCard } from "@/components/events/event-card"; | 7 | import { EventCard } from "@/components/events/event-card"; |
| 6 | import { EventForm } from "@/components/events/event-form"; | 8 | import { EventForm } from "@/components/events/event-form"; |
| 7 | import { RouteGuard } from "@/components/layout/route-guard"; | 9 | import { RouteGuard } from "@/components/layout/route-guard"; |
| @@ -37,13 +39,9 @@ function EventsContent() { | |||
| 37 | description={t("events.subtitle")} | 39 | description={t("events.subtitle")} |
| 38 | actions={ | 40 | actions={ |
| 39 | canCreate() ? ( | 41 | canCreate() ? ( |
| 40 | - <button | 42 | + <Button type="button" variant="outline" size="sm" onClick={() => setShowForm((v) => !v)}> |
| 41 | - type="button" | ||
| 42 | - class="rounded-sm bg-primary px-4 py-2 text-sm font-medium text-primary-foreground shadow-sm transition hover:bg-primary/90" | ||
| 43 | - onClick={() => setShowForm((v) => !v)} | ||
| 44 | - > | ||
| 45 | {showForm() ? t("common.cancel") : t("events.create")} | 43 | {showForm() ? t("common.cancel") : t("events.create")} |
| 46 | - </button> | 44 | + </Button> |
| 47 | ) : undefined | 45 | ) : undefined |
| 48 | } | 46 | } |
| 49 | /> | 47 | /> |
| @@ -82,6 +80,9 @@ function EventsContent() { | |||
| 82 | {error() && <p class="text-sm text-destructive">{error()}</p>} | 80 | {error() && <p class="text-sm text-destructive">{error()}</p>} |
| 83 | 81 | ||
| 84 | <Suspense fallback={<PageSpinner />}> | 82 | <Suspense fallback={<PageSpinner />}> |
| 83 | + <Show when={events.error}> | ||
| 84 | + <Alert variant="destructive">{formatApiError(events.error)}</Alert> | ||
| 85 | + </Show> | ||
| 85 | <Show when={events()}> | 86 | <Show when={events()}> |
| 86 | {(list) => ( | 87 | {(list) => ( |
| 87 | <Show | 88 | <Show |
src/pages/exams-page.tsxmodified+5 -0
| @@ -6,8 +6,10 @@ import { ExamCard } from "@/components/exams/exam-card"; | |||
| 6 | import { RouteGuard } from "@/components/layout/route-guard"; | 6 | import { RouteGuard } from "@/components/layout/route-guard"; |
| 7 | import { PageHeader } from "@/components/layout/page-header"; | 7 | import { PageHeader } from "@/components/layout/page-header"; |
| 8 | import { CollapsibleHelp } from "@/components/ui/collapsible-help"; | 8 | import { CollapsibleHelp } from "@/components/ui/collapsible-help"; |
| 9 | +import { Alert } from "@/components/ui/alert"; | ||
| 9 | import { Badge } from "@/components/ui/badge"; | 10 | import { Badge } from "@/components/ui/badge"; |
| 10 | import { Button } from "@/components/ui/button"; | 11 | import { Button } from "@/components/ui/button"; |
| 12 | +import { formatApiError } from "@/api/client"; | ||
| 11 | import { IconChevronRight } from "@/components/ui/icons"; | 13 | import { IconChevronRight } from "@/components/ui/icons"; |
| 12 | import { PageSpinner } from "@/components/ui/page-spinner"; | 14 | import { PageSpinner } from "@/components/ui/page-spinner"; |
| 13 | import { cn } from "@/lib/cn"; | 15 | import { cn } from "@/lib/cn"; |
| @@ -87,6 +89,9 @@ function ExamsContent() { | |||
| 87 | </Show> | 89 | </Show> |
| 88 | 90 | ||
| 89 | <Suspense fallback={<PageSpinner />}> | 91 | <Suspense fallback={<PageSpinner />}> |
| 92 | + <Show when={exams.error}> | ||
| 93 | + <Alert variant="destructive">{formatApiError(exams.error)}</Alert> | ||
| 94 | + </Show> | ||
| 90 | <Show when={exams()}> | 95 | <Show when={exams()}> |
| 91 | {(list) => ( | 96 | {(list) => ( |
| 92 | <Show | 97 | <Show |
src/pages/login-page.tsxmodified+1 -2
| @@ -94,8 +94,7 @@ function LoginForm() { | |||
| 94 | type="button" | 94 | type="button" |
| 95 | onClick={() => setShowPassword(!showPassword())} | 95 | onClick={() => setShowPassword(!showPassword())} |
| 96 | class="absolute right-3 top-1/2 -translate-y-1/2 text-muted-foreground transition-colors hover:text-foreground" | 96 | class="absolute right-3 top-1/2 -translate-y-1/2 text-muted-foreground transition-colors hover:text-foreground" |
| 97 | - tabIndex={-1} | 97 | + aria-label={showPassword() ? t("auth.hidePassword") : t("auth.showPassword")} |
| 98 | - aria-label={showPassword() ? "Hide password" : "Show password"} | ||
| 99 | > | 98 | > |
| 100 | <Show when={showPassword()} fallback={<IconEye class="h-4 w-4" />}> | 99 | <Show when={showPassword()} fallback={<IconEye class="h-4 w-4" />}> |
| 101 | <IconEyeOff class="h-4 w-4" /> | 100 | <IconEyeOff class="h-4 w-4" /> |
src/pages/marks-page.tsxmodified+4 -0
| @@ -3,6 +3,7 @@ import { Link } from "@tanstack/solid-router"; | |||
| 3 | import { getMyMarks } from "@/api/getMyMarks"; | 3 | import { getMyMarks } from "@/api/getMyMarks"; |
| 4 | import { getUserMarks } from "@/api/getUserMarks"; | 4 | import { getUserMarks } from "@/api/getUserMarks"; |
| 5 | import { formatApiError } from "@/api/client"; | 5 | import { formatApiError } from "@/api/client"; |
| 6 | +import { Alert } from "@/components/ui/alert"; | ||
| 6 | import type { MarksReport } from "@/api/types"; | 7 | import type { MarksReport } from "@/api/types"; |
| 7 | import { RouteGuard } from "@/components/layout/route-guard"; | 8 | import { RouteGuard } from "@/components/layout/route-guard"; |
| 8 | import { PageHeader } from "@/components/layout/page-header"; | 9 | import { PageHeader } from "@/components/layout/page-header"; |
| @@ -50,6 +51,9 @@ function MarksContent() { | |||
| 50 | /> | 51 | /> |
| 51 | 52 | ||
| 52 | <Suspense fallback={<PageSpinner />}> | 53 | <Suspense fallback={<PageSpinner />}> |
| 54 | + <Show when={mine.error}> | ||
| 55 | + <Alert variant="destructive">{formatApiError(mine.error)}</Alert> | ||
| 56 | + </Show> | ||
| 53 | <Show when={mine()} fallback={<p class="text-sm text-muted-foreground">{t("marks.empty")}</p>}> | 57 | <Show when={mine()} fallback={<p class="text-sm text-muted-foreground">{t("marks.empty")}</p>}> |
| 54 | {(report) => <MarksReportView report={report()} />} | 58 | {(report) => <MarksReportView report={report()} />} |
| 55 | </Show> | 59 | </Show> |
src/pages/notes-page.tsxmodified+4 -0
| @@ -4,6 +4,7 @@ import { getNotes } from "@/api/getNotes"; | |||
| 4 | import { patchNoteById } from "@/api/patchNoteById"; | 4 | import { patchNoteById } from "@/api/patchNoteById"; |
| 5 | import { postNote } from "@/api/postNote"; | 5 | import { postNote } from "@/api/postNote"; |
| 6 | import { formatApiError } from "@/api/client"; | 6 | import { formatApiError } from "@/api/client"; |
| 7 | +import { Alert } from "@/components/ui/alert"; | ||
| 7 | import { RouteGuard } from "@/components/layout/route-guard"; | 8 | import { RouteGuard } from "@/components/layout/route-guard"; |
| 8 | import { PageHeader } from "@/components/layout/page-header"; | 9 | import { PageHeader } from "@/components/layout/page-header"; |
| 9 | import { NoteForm } from "@/components/notes/note-form"; | 10 | import { NoteForm } from "@/components/notes/note-form"; |
| @@ -65,6 +66,9 @@ function NotesContent() { | |||
| 65 | 66 | ||
| 66 | <section> | 67 | <section> |
| 67 | <Suspense fallback={<PageSpinner />}> | 68 | <Suspense fallback={<PageSpinner />}> |
| 69 | + <Show when={notes.error}> | ||
| 70 | + <Alert variant="destructive">{formatApiError(notes.error)}</Alert> | ||
| 71 | + </Show> | ||
| 68 | <Show when={notes()}> | 72 | <Show when={notes()}> |
| 69 | {(list) => ( | 73 | {(list) => ( |
| 70 | <NoteList | 74 | <NoteList |
src/pages/profile-page.tsxmodified+0 -3
| @@ -1,5 +1,4 @@ | |||
| 1 | import { Show, Suspense } from "solid-js"; | 1 | import { Show, Suspense } from "solid-js"; |
| 2 | -import { useNavigate } from "@tanstack/solid-router"; | ||
| 3 | import { ProfileForm } from "@/components/users/profile-form"; | 2 | import { ProfileForm } from "@/components/users/profile-form"; |
| 4 | import { RouteGuard } from "@/components/layout/route-guard"; | 3 | import { RouteGuard } from "@/components/layout/route-guard"; |
| 5 | import { PageHeader } from "@/components/layout/page-header"; | 4 | import { PageHeader } from "@/components/layout/page-header"; |
| @@ -18,7 +17,6 @@ export default function ProfilePage() { | |||
| 18 | function ProfileContent() { | 17 | function ProfileContent() { |
| 19 | const auth = useAuth(); | 18 | const auth = useAuth(); |
| 20 | const t = useT(); | 19 | const t = useT(); |
| 21 | - const navigate = useNavigate(); | ||
| 22 | 20 | ||
| 23 | return ( | 21 | return ( |
| 24 | <Suspense fallback={<PageSpinner />}> | 22 | <Suspense fallback={<PageSpinner />}> |
| @@ -39,7 +37,6 @@ function ProfileContent() { | |||
| 39 | user={u()} | 37 | user={u()} |
| 40 | onSaved={async () => { | 38 | onSaved={async () => { |
| 41 | await auth.refresh(); | 39 | await auth.refresh(); |
| 42 | - void navigate({ to: "/" }); | ||
| 43 | }} | 40 | }} |
| 44 | /> | 41 | /> |
| 45 | </section> | 42 | </section> |
src/pages/register-page.tsxmodified+56 -34
| @@ -1,13 +1,12 @@ | |||
| 1 | import { Link, useNavigate } from "@tanstack/solid-router"; | 1 | import { Link, useNavigate } from "@tanstack/solid-router"; |
| 2 | -import { createSignal } from "solid-js"; | 2 | +import { createSignal, Show } from "solid-js"; |
| 3 | import { postRegister } from "@/api/postRegister"; | 3 | import { postRegister } from "@/api/postRegister"; |
| 4 | import { formatApiError } from "@/api/client"; | 4 | import { formatApiError } from "@/api/client"; |
| 5 | import { Button } from "@/components/ui/button"; | 5 | import { Button } from "@/components/ui/button"; |
| 6 | import { Input } from "@/components/ui/input"; | 6 | import { Input } from "@/components/ui/input"; |
| 7 | import { Label } from "@/components/ui/label"; | 7 | import { Label } from "@/components/ui/label"; |
| 8 | import { GuestGuard } from "@/components/layout/guest-guard"; | 8 | import { GuestGuard } from "@/components/layout/guest-guard"; |
| 9 | -import { LocaleSwitcher } from "@/components/layout/locale-switcher"; | 9 | +import { IconEye, IconEyeOff } from "@/components/ui/icons"; |
| 10 | -import { ThemeToggle } from "@/components/layout/theme-toggle"; | ||
| 11 | import { useAuth } from "@/stores/auth-context"; | 10 | import { useAuth } from "@/stores/auth-context"; |
| 12 | import { useT } from "@/stores/preferences-context"; | 11 | import { useT } from "@/stores/preferences-context"; |
| 13 | 12 | ||
| @@ -25,6 +24,8 @@ function RegisterForm() { | |||
| 25 | const t = useT(); | 24 | const t = useT(); |
| 26 | const [username, setUsername] = createSignal(""); | 25 | const [username, setUsername] = createSignal(""); |
| 27 | const [password, setPassword] = createSignal(""); | 26 | const [password, setPassword] = createSignal(""); |
| 27 | + const [confirmPassword, setConfirmPassword] = createSignal(""); | ||
| 28 | + const [showPassword, setShowPassword] = createSignal(false); | ||
| 28 | const [error, setError] = createSignal(""); | 29 | const [error, setError] = createSignal(""); |
| 29 | const [pending, setPending] = createSignal(false); | 30 | const [pending, setPending] = createSignal(false); |
| 30 | 31 | ||
| @@ -32,6 +33,7 @@ function RegisterForm() { | |||
| 32 | e.preventDefault(); | 33 | e.preventDefault(); |
| 33 | const u = username().trim(); | 34 | const u = username().trim(); |
| 34 | const p = password(); | 35 | const p = password(); |
| 36 | + const cp = confirmPassword(); | ||
| 35 | if (u.length < 3 || u.length > 32) { | 37 | if (u.length < 3 || u.length > 32) { |
| 36 | setError(t("auth.usernameHint")); | 38 | setError(t("auth.usernameHint")); |
| 37 | return; | 39 | return; |
| @@ -40,6 +42,10 @@ function RegisterForm() { | |||
| 40 | setError(t("auth.passwordHint")); | 42 | setError(t("auth.passwordHint")); |
| 41 | return; | 43 | return; |
| 42 | } | 44 | } |
| 45 | + if (p !== cp) { | ||
| 46 | + setError(t("auth.passwordMismatch")); | ||
| 47 | + return; | ||
| 48 | + } | ||
| 43 | setError(""); | 49 | setError(""); |
| 44 | setPending(true); | 50 | setPending(true); |
| 45 | try { | 51 | try { |
| @@ -54,33 +60,19 @@ function RegisterForm() { | |||
| 54 | }; | 60 | }; |
| 55 | 61 | ||
| 56 | return ( | 62 | return ( |
| 57 | - <div class="relative mx-auto grid min-h-[calc(100vh-5rem)] max-w-5xl items-center gap-8 lg:grid-cols-2"> | 63 | + <div class="-mx-4 -my-6 flex h-[calc(100dvh-3.5rem)] items-center justify-center overflow-hidden px-4 sm:-mx-6 sm:px-6 lg:-mx-8 lg:-my-8 lg:px-8"> |
| 58 | - <div class="hero-panel relative order-2 hidden overflow-hidden rounded-[2rem] border border-border/60 p-10 lg:order-1 lg:block"> | 64 | + <div class="surface-card w-full max-w-sm p-8 shadow-lg"> |
| 59 | - <p class="text-xs font-semibold uppercase tracking-[0.16em] text-primary">{t("app.name")}</p> | 65 | + <div class="mb-8 text-center"> |
| 60 | - <h1 class="mt-4 font-display text-4xl font-semibold leading-tight">{t("auth.createStudent")}</h1> | 66 | + <h1 class="font-display text-3xl font-semibold tracking-tight">{t("auth.registerTitle")}</h1> |
| 61 | - <p class="mt-4 max-w-sm text-sm leading-relaxed text-muted-foreground"> | 67 | + <p class="mt-1.5 text-sm text-muted-foreground">{t("auth.registerSubtitle")}</p> |
| 62 | - {t("auth.registerSubtitle")} | ||
| 63 | - </p> | ||
| 64 | - </div> | ||
| 65 | - | ||
| 66 | - <div class="surface-card order-1 mx-auto w-full max-w-md p-6 sm:p-8 lg:order-2"> | ||
| 67 | - <div class="mb-6 flex items-start justify-between gap-3"> | ||
| 68 | - <div> | ||
| 69 | - <h2 class="font-display text-2xl font-semibold">{t("auth.registerTitle")}</h2> | ||
| 70 | - <p class="mt-1 text-sm text-muted-foreground">{t("auth.registerSubtitle")}</p> | ||
| 71 | - </div> | ||
| 72 | - <div class="flex items-center gap-1"> | ||
| 73 | - <LocaleSwitcher /> | ||
| 74 | - <ThemeToggle /> | ||
| 75 | - </div> | ||
| 76 | </div> | 68 | </div> |
| 77 | 69 | ||
| 78 | - <form class="space-y-4" onSubmit={handleSubmit}> | 70 | + <form class="space-y-5" onSubmit={handleSubmit}> |
| 79 | - <div class="space-y-1.5"> | 71 | + <div class="space-y-2"> |
| 80 | <Label for="register-username">{t("auth.username")}</Label> | 72 | <Label for="register-username">{t("auth.username")}</Label> |
| 81 | <Input | 73 | <Input |
| 82 | id="register-username" | 74 | id="register-username" |
| 83 | - class="h-11 rounded-sm" | 75 | + class="h-11" |
| 84 | autocomplete="username" | 76 | autocomplete="username" |
| 85 | minlength={3} | 77 | minlength={3} |
| 86 | maxlength={32} | 78 | maxlength={32} |
| @@ -89,29 +81,59 @@ function RegisterForm() { | |||
| 89 | onInput={(e) => setUsername(e.currentTarget.value)} | 81 | onInput={(e) => setUsername(e.currentTarget.value)} |
| 90 | /> | 82 | /> |
| 91 | </div> | 83 | </div> |
| 92 | - <div class="space-y-1.5"> | 84 | + |
| 85 | + <div class="space-y-2"> | ||
| 93 | <Label for="register-password">{t("auth.password")}</Label> | 86 | <Label for="register-password">{t("auth.password")}</Label> |
| 87 | + <div class="relative"> | ||
| 88 | + <Input | ||
| 89 | + id="register-password" | ||
| 90 | + class="h-11 pr-10" | ||
| 91 | + type={showPassword() ? "text" : "password"} | ||
| 92 | + autocomplete="new-password" | ||
| 93 | + minlength={6} | ||
| 94 | + maxlength={128} | ||
| 95 | + required | ||
| 96 | + value={password()} | ||
| 97 | + onInput={(e) => setPassword(e.currentTarget.value)} | ||
| 98 | + /> | ||
| 99 | + <button | ||
| 100 | + type="button" | ||
| 101 | + onClick={() => setShowPassword(!showPassword())} | ||
| 102 | + class="absolute right-3 top-1/2 -translate-y-1/2 text-muted-foreground transition-colors hover:text-foreground" | ||
| 103 | + aria-label={showPassword() ? t("auth.hidePassword") : t("auth.showPassword")} | ||
| 104 | + > | ||
| 105 | + <Show when={showPassword()} fallback={<IconEye class="h-4 w-4" />}> | ||
| 106 | + <IconEyeOff class="h-4 w-4" /> | ||
| 107 | + </Show> | ||
| 108 | + </button> | ||
| 109 | + </div> | ||
| 110 | + </div> | ||
| 111 | + | ||
| 112 | + <div class="space-y-2"> | ||
| 113 | + <Label for="register-confirm">{t("auth.confirmPassword")}</Label> | ||
| 94 | <Input | 114 | <Input |
| 95 | - id="register-password" | 115 | + id="register-confirm" |
| 96 | - class="h-11 rounded-sm" | 116 | + class="h-11" |
| 97 | - type="password" | 117 | + type={showPassword() ? "text" : "password"} |
| 98 | autocomplete="new-password" | 118 | autocomplete="new-password" |
| 99 | minlength={6} | 119 | minlength={6} |
| 100 | maxlength={128} | 120 | maxlength={128} |
| 101 | required | 121 | required |
| 102 | - value={password()} | 122 | + value={confirmPassword()} |
| 103 | - onInput={(e) => setPassword(e.currentTarget.value)} | 123 | + onInput={(e) => setConfirmPassword(e.currentTarget.value)} |
| 104 | /> | 124 | /> |
| 105 | </div> | 125 | </div> |
| 126 | + | ||
| 106 | {error() && ( | 127 | {error() && ( |
| 107 | - <p class="rounded-sm bg-destructive/10 px-3 py-2 text-sm text-destructive">{error()}</p> | 128 | + <p class="rounded-md bg-destructive/10 px-3 py-2 text-sm text-destructive">{error()}</p> |
| 108 | )} | 129 | )} |
| 109 | - <Button type="submit" class="h-11 w-full rounded-sm text-base" disabled={pending()}> | 130 | + |
| 131 | + <Button type="submit" class="h-11 w-full text-base" disabled={pending()}> | ||
| 110 | {t("auth.register")} | 132 | {t("auth.register")} |
| 111 | </Button> | 133 | </Button> |
| 112 | </form> | 134 | </form> |
| 113 | 135 | ||
| 114 | - <p class="mt-6 text-center text-sm text-muted-foreground"> | 136 | + <p class="mt-8 text-center text-sm text-muted-foreground"> |
| 115 | {t("auth.hasAccount")}{" "} | 137 | {t("auth.hasAccount")}{" "} |
| 116 | <Link to="/login" class="font-semibold text-primary underline-offset-4 hover:underline"> | 138 | <Link to="/login" class="font-semibold text-primary underline-offset-4 hover:underline"> |
| 117 | {t("auth.login")} | 139 | {t("auth.login")} |