✨ mobile tab bar, settings dirty-state, terms sidepanel, UX polish batch
Browse files at this commit0be69830b88167cc16fe17439e3013c400dcf07aParent: dd92ac6- feat
- ✨ mobile tab bar, settings dirty-state, terms sidepanel, UX polish batch
22 changed files +807 -304
- docs/frontend-next-steps.md +12 -1
- src/components/layout/app-shell.tsx +22 -18
- src/components/layout/mobile-tab-bar.tsx +83 -0
- src/components/layout/side-nav.tsx +21 -8
- src/components/notes/note-list.tsx +3 -3
- src/components/sessions/course-sessions-panel.tsx +33 -2
- src/components/ui/error-alert.tsx +24 -0
- src/components/users/user-search-select.tsx +6 -1
- src/i18n/messages.ts +24 -11
- src/pages/courses-page.tsx +1 -1
- src/pages/dashboard-page.tsx +34 -16
- src/pages/events-page.tsx +2 -2
- src/pages/exam-room-page.tsx +28 -19
- src/pages/exams-page.tsx +8 -8
- src/pages/live-monitor-page.tsx +26 -17
- src/pages/notes-page.tsx +1 -1
- src/pages/profile-page.tsx +10 -1
- src/pages/settings-page.tsx +330 -119
- src/pages/student-attendance-page.tsx +12 -5
- src/pages/student-marks-page.tsx +12 -7
- src/pages/terms-page.tsx +112 -62
- src/pages/work-log-page.tsx +3 -2
docs/frontend-next-steps.mdmodified+12 -1
| @@ -62,4 +62,15 @@ validation, and list filtering cleanup. | |||
| 62 | 62 | ||
| 63 | ## Active Backlog | 63 | ## Active Backlog |
| 64 | 64 | ||
| 65 | -- No active frontend backlog items remain in this audit batch. | 65 | +- Backend server-side pagination/search/filter params still pending (see Backend-Dependent Follow-Up). |
| 66 | +- Deferred product features (not started): exam `allow_rejoin` UI, manager work-log corrections, session edit (`PATCH`). | ||
| 67 | + | ||
| 68 | +## UX polish batch (completed) | ||
| 69 | + | ||
| 70 | +- Session delete uses ConfirmDialog; exam room guards stale id on route change. | ||
| 71 | +- Mobile bottom tab bar (home/courses/exams/notes/menu); exam-room hides tab chrome. | ||
| 72 | +- Shared ErrorAlert with try-again; lookup pages show person labels; profile shows localized role. | ||
| 73 | +- Manager/admin dashboard portal includes daily tools + management cards; compact guide CTA on dashboard (guide stays in account menu). | ||
| 74 | +- Terms page: SidePanel create/edit + dense table row actions; header create buttons use shared min-width/radius. | ||
| 75 | +- Settings: dirty-state save gate and auto-clearing success message. | ||
| 76 | +- Nested breadcrumbs on exam room and live monitor. | ||
src/components/layout/app-shell.tsxmodified+22 -18
| @@ -1,11 +1,12 @@ | |||
| 1 | import type { ParentProps } from "solid-js"; | 1 | import type { ParentProps } from "solid-js"; |
| 2 | import { Link, useLocation, useNavigate } from "@tanstack/solid-router"; | 2 | import { Link, useLocation, useNavigate } from "@tanstack/solid-router"; |
| 3 | import { Show, createSignal } from "solid-js"; | 3 | import { Show, createSignal } from "solid-js"; |
| 4 | +import { MobileTabBar } from "@/components/layout/mobile-tab-bar"; | ||
| 4 | import { NavBar } from "@/components/layout/nav-bar"; | 5 | import { NavBar } from "@/components/layout/nav-bar"; |
| 5 | import { SideNav } from "@/components/layout/side-nav"; | 6 | import { SideNav } from "@/components/layout/side-nav"; |
| 6 | import { SidebarAccount } from "@/components/layout/sidebar-account"; | 7 | import { SidebarAccount } from "@/components/layout/sidebar-account"; |
| 7 | import { Button } from "@/components/ui/button"; | 8 | import { Button } from "@/components/ui/button"; |
| 8 | -import { IconMenu, IconPanelLeft } from "@/components/ui/icons"; | 9 | +import { IconPanelLeft } from "@/components/ui/icons"; |
| 9 | import { useAuth } from "@/stores/auth-context"; | 10 | import { useAuth } from "@/stores/auth-context"; |
| 10 | import { usePreferences, useT } from "@/stores/preferences-context"; | 11 | import { usePreferences, useT } from "@/stores/preferences-context"; |
| 11 | import { cn } from "@/lib/cn"; | 12 | import { cn } from "@/lib/cn"; |
| @@ -32,18 +33,6 @@ export function AppShell(props: ParentProps) { | |||
| 32 | <Show when={!auth.user()}> | 33 | <Show when={!auth.user()}> |
| 33 | <NavBar /> | 34 | <NavBar /> |
| 34 | </Show> | 35 | </Show> |
| 35 | - <Show when={auth.user()}> | ||
| 36 | - <Button | ||
| 37 | - type="button" | ||
| 38 | - variant="outline" | ||
| 39 | - size="sm" | ||
| 40 | - class="fixed left-3 top-3 z-40 h-10 w-10 rounded-xl bg-background/90 px-0 shadow-sm backdrop-blur lg:hidden" | ||
| 41 | - aria-label={t("nav.menu")} | ||
| 42 | - onClick={() => setMobileOpen(true)} | ||
| 43 | - > | ||
| 44 | - <IconMenu class="h-5 w-5" /> | ||
| 45 | - </Button> | ||
| 46 | - </Show> | ||
| 47 | <div class="flex w-full"> | 36 | <div class="flex w-full"> |
| 48 | <Show when={auth.user()}> | 37 | <Show when={auth.user()}> |
| 49 | <aside | 38 | <aside |
| @@ -54,15 +43,21 @@ export function AppShell(props: ParentProps) { | |||
| 54 | > | 43 | > |
| 55 | <div | 44 | <div |
| 56 | class={cn( | 45 | class={cn( |
| 57 | - "flex h-16 shrink-0 items-center gap-2 border-b border-border/70", | 46 | + "flex shrink-0 items-center gap-2 border-b border-border/70", |
| 58 | - collapsed() ? "justify-center px-2" : "px-2", | 47 | + collapsed() ? "h-auto flex-col justify-center gap-1.5 px-2 py-2" : "h-16 px-2", |
| 59 | )} | 48 | )} |
| 60 | > | 49 | > |
| 61 | - <Link to="/" class={cn("flex min-w-0 flex-1 items-center gap-2", collapsed() && "hidden")}> | 50 | + <Link |
| 51 | + to="/" | ||
| 52 | + class={cn("flex min-w-0 items-center gap-2", collapsed() ? "justify-center" : "flex-1")} | ||
| 53 | + title={t("app.name")} | ||
| 54 | + > | ||
| 62 | <span class="flex h-9 w-9 shrink-0 items-center justify-center rounded-xl bg-primary text-sm font-black text-primary-foreground shadow-sm"> | 55 | <span class="flex h-9 w-9 shrink-0 items-center justify-center rounded-xl bg-primary text-sm font-black text-primary-foreground shadow-sm"> |
| 63 | H | 56 | H |
| 64 | </span> | 57 | </span> |
| 65 | - <span class="truncate font-display text-lg font-semibold tracking-tight">{t("app.name")}</span> | 58 | + <Show when={!collapsed()}> |
| 59 | + <span class="truncate font-display text-lg font-semibold tracking-tight">{t("app.name")}</span> | ||
| 60 | + </Show> | ||
| 66 | </Link> | 61 | </Link> |
| 67 | <Button | 62 | <Button |
| 68 | type="button" | 63 | type="button" |
| @@ -115,11 +110,20 @@ export function AppShell(props: ParentProps) { | |||
| 115 | </Show> | 110 | </Show> |
| 116 | 111 | ||
| 117 | <main class="min-w-0 flex-1"> | 112 | <main class="min-w-0 flex-1"> |
| 118 | - <div class={cn("mx-auto w-full px-4 py-6 sm:px-6 lg:px-8 lg:py-5", wide() ? "max-w-none" : "max-w-[1200px]") }> | 113 | + <div |
| 114 | + class={cn( | ||
| 115 | + "mx-auto w-full px-4 py-6 sm:px-6 lg:px-8 lg:py-5", | ||
| 116 | + auth.user() && !wide() && "pb-24 lg:pb-5", | ||
| 117 | + wide() ? "max-w-none" : "max-w-[1200px]", | ||
| 118 | + )} | ||
| 119 | + > | ||
| 119 | {props.children} | 120 | {props.children} |
| 120 | </div> | 121 | </div> |
| 121 | </main> | 122 | </main> |
| 122 | </div> | 123 | </div> |
| 124 | + <Show when={auth.user() && !wide()}> | ||
| 125 | + <MobileTabBar onMenu={() => setMobileOpen(true)} /> | ||
| 126 | + </Show> | ||
| 123 | </div> | 127 | </div> |
| 124 | ); | 128 | ); |
| 125 | } | 129 | } |
src/components/layout/mobile-tab-bar.tsxadded+83 -0
| @@ -0,0 +1,83 @@ | |||
| 1 | +import { For, Show } from "solid-js"; | ||
| 2 | +import { Link, useRouterState } from "@tanstack/solid-router"; | ||
| 3 | +import { | ||
| 4 | + IconBook, | ||
| 5 | + IconExam, | ||
| 6 | + IconHome, | ||
| 7 | + IconMenu, | ||
| 8 | + IconNote, | ||
| 9 | +} from "@/components/ui/icons"; | ||
| 10 | +import type { MessageKey } from "@/i18n/messages"; | ||
| 11 | +import { cn } from "@/lib/cn"; | ||
| 12 | +import { useT } from "@/stores/preferences-context"; | ||
| 13 | +import type { Component } from "solid-js"; | ||
| 14 | + | ||
| 15 | +type TabItem = { | ||
| 16 | + to: string; | ||
| 17 | + labelKey: MessageKey; | ||
| 18 | + Icon: Component<{ class?: string }>; | ||
| 19 | + exact?: boolean; | ||
| 20 | + action?: "menu"; | ||
| 21 | +}; | ||
| 22 | + | ||
| 23 | +const TABS: TabItem[] = [ | ||
| 24 | + { to: "/", labelKey: "nav.home", Icon: IconHome, exact: true }, | ||
| 25 | + { to: "/courses", labelKey: "nav.courses", Icon: IconBook }, | ||
| 26 | + { to: "/exams", labelKey: "nav.exams", Icon: IconExam }, | ||
| 27 | + { to: "/notes", labelKey: "nav.notes", Icon: IconNote }, | ||
| 28 | + { to: "#menu", labelKey: "nav.menu", Icon: IconMenu, action: "menu" }, | ||
| 29 | +]; | ||
| 30 | + | ||
| 31 | +function pathActive(pathname: string, to: string, exact?: boolean) { | ||
| 32 | + if (exact) return pathname === to; | ||
| 33 | + return pathname === to || pathname.startsWith(`${to}/`); | ||
| 34 | +} | ||
| 35 | + | ||
| 36 | +export function MobileTabBar(props: { onMenu: () => void }) { | ||
| 37 | + const t = useT(); | ||
| 38 | + const pathname = useRouterState({ select: (s) => s.location.pathname }); | ||
| 39 | + | ||
| 40 | + return ( | ||
| 41 | + <nav | ||
| 42 | + class="fixed inset-x-0 bottom-0 z-40 border-t border-border/80 bg-background/95 pb-[env(safe-area-inset-bottom)] shadow-[0_-1px_0_hsl(var(--border)/0.5)] backdrop-blur lg:hidden" | ||
| 43 | + aria-label={t("nav.menu")} | ||
| 44 | + > | ||
| 45 | + <ul class="mx-auto grid h-14 max-w-[1200px] grid-cols-5"> | ||
| 46 | + <For each={TABS}> | ||
| 47 | + {(tab) => { | ||
| 48 | + const active = () => tab.action === "menu" ? false : pathActive(pathname(), tab.to, tab.exact); | ||
| 49 | + return ( | ||
| 50 | + <li class="min-w-0"> | ||
| 51 | + <Show | ||
| 52 | + when={tab.action === "menu"} | ||
| 53 | + fallback={ | ||
| 54 | + <Link | ||
| 55 | + to={tab.to} | ||
| 56 | + aria-current={active() ? "page" : undefined} | ||
| 57 | + class={cn( | ||
| 58 | + "flex h-full w-full flex-col items-center justify-center gap-0.5 px-1 text-[10px] font-medium transition-colors", | ||
| 59 | + active() ? "text-primary" : "text-muted-foreground", | ||
| 60 | + )} | ||
| 61 | + > | ||
| 62 | + <tab.Icon class={cn("h-5 w-5", active() ? "text-primary" : "text-muted-foreground")} /> | ||
| 63 | + <span class="truncate">{t(tab.labelKey)}</span> | ||
| 64 | + </Link> | ||
| 65 | + } | ||
| 66 | + > | ||
| 67 | + <button | ||
| 68 | + type="button" | ||
| 69 | + class="flex h-full w-full flex-col items-center justify-center gap-0.5 px-1 text-[10px] font-medium text-muted-foreground transition-colors" | ||
| 70 | + onClick={() => props.onMenu()} | ||
| 71 | + > | ||
| 72 | + <tab.Icon class="h-5 w-5" /> | ||
| 73 | + <span class="truncate">{t(tab.labelKey)}</span> | ||
| 74 | + </button> | ||
| 75 | + </Show> | ||
| 76 | + </li> | ||
| 77 | + ); | ||
| 78 | + }} | ||
| 79 | + </For> | ||
| 80 | + </ul> | ||
| 81 | + </nav> | ||
| 82 | + ); | ||
| 83 | +} | ||
src/components/layout/side-nav.tsxmodified+21 -8
| @@ -164,21 +164,34 @@ export function SideNav(props: { onNavigate?: () => void; collapsed?: boolean }) | |||
| 164 | })) | 164 | })) |
| 165 | .filter((group) => group.items.length > 0), | 165 | .filter((group) => group.items.length > 0), |
| 166 | ); | 166 | ); |
| 167 | - const activeGroupId = createMemo(() => visibleGroups().find((group) => group.items.some((item) => pathActive(pathname(), item.to, item.exact)))?.id ?? visibleGroups()[0]?.id ?? ""); | 167 | + const activeGroupId = createMemo( |
| 168 | - const [openGroup, setOpenGroup] = createSignal(activeGroupId()); | 168 | + () => |
| 169 | + visibleGroups().find((group) => group.items.some((item) => pathActive(pathname(), item.to, item.exact)))?.id ?? | ||
| 170 | + "", | ||
| 171 | + ); | ||
| 172 | + const [openGroups, setOpenGroups] = createSignal<Record<string, boolean>>({}); | ||
| 173 | + | ||
| 174 | + const isOpen = (groupId: string) => openGroups()[groupId] === true; | ||
| 175 | + | ||
| 176 | + const toggleGroup = (groupId: string) => { | ||
| 177 | + setOpenGroups((current) => ({ ...current, [groupId]: !current[groupId] })); | ||
| 178 | + }; | ||
| 169 | 179 | ||
| 170 | createEffect(() => { | 180 | createEffect(() => { |
| 171 | const active = activeGroupId(); | 181 | const active = activeGroupId(); |
| 172 | - if (active) setOpenGroup(active); | 182 | + if (!active) return; |
| 183 | + setOpenGroups((current) => (current[active] ? current : { ...current, [active]: true })); | ||
| 173 | }); | 184 | }); |
| 174 | 185 | ||
| 175 | return ( | 186 | return ( |
| 176 | - <nav class="flex h-full flex-col" aria-label="Main"> | 187 | + <nav class="flex h-full flex-col" aria-label={t("nav.menu")}> |
| 177 | <div class="flex flex-col gap-1 px-2"> | 188 | <div class="flex flex-col gap-1 px-2"> |
| 178 | <NavLink item={HOME_ITEM} collapsed={props.collapsed} onNavigate={props.onNavigate} standalone /> | 189 | <NavLink item={HOME_ITEM} collapsed={props.collapsed} onNavigate={props.onNavigate} standalone /> |
| 179 | <For each={visibleGroups()}> | 190 | <For each={visibleGroups()}> |
| 180 | {(group, index) => { | 191 | {(group, index) => { |
| 181 | - const open = () => openGroup() === group.id; | 192 | + const open = () => isOpen(group.id); |
| 193 | + const groupActive = () => | ||
| 194 | + group.items.some((item) => pathActive(pathname(), item.to, item.exact)); | ||
| 182 | const showManagementDivider = () => !!group.minRole && !visibleGroups()[index() - 1]?.minRole; | 195 | const showManagementDivider = () => !!group.minRole && !visibleGroups()[index() - 1]?.minRole; |
| 183 | return ( | 196 | return ( |
| 184 | <> | 197 | <> |
| @@ -209,11 +222,11 @@ export function SideNav(props: { onNavigate?: () => void; collapsed?: boolean }) | |||
| 209 | type="button" | 222 | type="button" |
| 210 | class={cn( | 223 | class={cn( |
| 211 | "flex h-8 w-full items-center gap-2 rounded-sm px-2 text-[11px] font-semibold uppercase tracking-[0.08em] text-muted-foreground transition-colors duration-150 hover:bg-muted hover:text-foreground", | 224 | "flex h-8 w-full items-center gap-2 rounded-sm px-2 text-[11px] font-semibold uppercase tracking-[0.08em] text-muted-foreground transition-colors duration-150 hover:bg-muted hover:text-foreground", |
| 212 | - open() && "text-foreground", | 225 | + (open() || groupActive()) && "text-foreground", |
| 213 | )} | 226 | )} |
| 214 | title={t(group.labelKey)} | 227 | title={t(group.labelKey)} |
| 215 | aria-expanded={open()} | 228 | aria-expanded={open()} |
| 216 | - onClick={() => setOpenGroup(open() ? "" : group.id)} | 229 | + onClick={() => toggleGroup(group.id)} |
| 217 | > | 230 | > |
| 218 | <group.Icon class="h-3.5 w-3.5" /> | 231 | <group.Icon class="h-3.5 w-3.5" /> |
| 219 | <span class="min-w-0 flex-1 truncate text-left">{t(group.labelKey)}</span> | 232 | <span class="min-w-0 flex-1 truncate text-left">{t(group.labelKey)}</span> |
| @@ -233,7 +246,7 @@ export function SideNav(props: { onNavigate?: () => void; collapsed?: boolean }) | |||
| 233 | <DropdownMenuTrigger | 246 | <DropdownMenuTrigger |
| 234 | class={cn( | 247 | class={cn( |
| 235 | "relative flex h-8 w-full items-center justify-center rounded-sm px-0 text-muted-foreground outline-none transition-colors duration-150 hover:bg-muted hover:text-foreground focus-visible:ring-2 focus-visible:ring-ring data-[expanded]:bg-muted data-[expanded]:text-foreground", | 248 | "relative flex h-8 w-full items-center justify-center rounded-sm px-0 text-muted-foreground outline-none transition-colors duration-150 hover:bg-muted hover:text-foreground focus-visible:ring-2 focus-visible:ring-ring data-[expanded]:bg-muted data-[expanded]:text-foreground", |
| 236 | - open() && "text-foreground", | 249 | + groupActive() && "text-foreground", |
| 237 | )} | 250 | )} |
| 238 | title={t(group.labelKey)} | 251 | title={t(group.labelKey)} |
| 239 | aria-label={t(group.labelKey)} | 252 | aria-label={t(group.labelKey)} |
src/components/notes/note-list.tsxmodified+3 -3
| @@ -12,12 +12,12 @@ export function NoteList(props: { | |||
| 12 | <Show | 12 | <Show |
| 13 | when={props.notes.length > 0} | 13 | when={props.notes.length > 0} |
| 14 | fallback={ | 14 | fallback={ |
| 15 | - <div class="flex min-h-[12rem] items-center justify-center rounded-sm border border-dashed border-border bg-muted/20 px-6 text-center text-sm text-muted-foreground"> | 15 | + <div class="flex min-h-[12rem] items-center justify-center rounded-lg border border-dashed border-border/80 bg-muted/20 px-6 text-center text-sm text-muted-foreground"> |
| 16 | - {props.emptyLabel ?? "No notes yet."} | 16 | + {props.emptyLabel ?? ""} |
| 17 | </div> | 17 | </div> |
| 18 | } | 18 | } |
| 19 | > | 19 | > |
| 20 | - <ul class="grid gap-3 sm:grid-cols-2 xl:grid-cols-3"> | 20 | + <ul class="grid grid-cols-2 gap-3 xl:grid-cols-3"> |
| 21 | <For each={props.notes}> | 21 | <For each={props.notes}> |
| 22 | {(note) => ( | 22 | {(note) => ( |
| 23 | <li class="animate-fade-up"> | 23 | <li class="animate-fade-up"> |
src/components/sessions/course-sessions-panel.tsxmodified+33 -2
| @@ -10,7 +10,9 @@ import type { AttendanceStatus, CourseSession, Enrollment, SessionAttendance } f | |||
| 10 | import { AttendanceStatusPicker } from "@/components/events/attendance-status-picker"; | 10 | import { AttendanceStatusPicker } from "@/components/events/attendance-status-picker"; |
| 11 | import { Alert } from "@/components/ui/alert"; | 11 | import { Alert } from "@/components/ui/alert"; |
| 12 | import { Button } from "@/components/ui/button"; | 12 | import { Button } from "@/components/ui/button"; |
| 13 | +import { ConfirmDialog } from "@/components/ui/confirm-dialog"; | ||
| 13 | import { DatePicker } from "@/components/ui/date-picker"; | 14 | import { DatePicker } from "@/components/ui/date-picker"; |
| 15 | +import { ErrorAlert } from "@/components/ui/error-alert"; | ||
| 14 | import { IconTrash } from "@/components/ui/icons"; | 16 | import { IconTrash } from "@/components/ui/icons"; |
| 15 | import { Input } from "@/components/ui/input"; | 17 | import { Input } from "@/components/ui/input"; |
| 16 | import { Label } from "@/components/ui/label"; | 18 | import { Label } from "@/components/ui/label"; |
| @@ -54,6 +56,7 @@ export function CourseSessionsPanel(props: { | |||
| 54 | async (courseId) => (courseId ? getCourseSessions(courseId) : []), | 56 | async (courseId) => (courseId ? getCourseSessions(courseId) : []), |
| 55 | ); | 57 | ); |
| 56 | const [selectedSession, setSelectedSession] = createSignal<CourseSession | null>(null); | 58 | const [selectedSession, setSelectedSession] = createSignal<CourseSession | null>(null); |
| 59 | + const [deleteTarget, setDeleteTarget] = createSignal<CourseSession | null>(null); | ||
| 57 | const [topic, setTopic] = createSignal(""); | 60 | const [topic, setTopic] = createSignal(""); |
| 58 | const [startsDate, setStartsDate] = createSignal(""); | 61 | const [startsDate, setStartsDate] = createSignal(""); |
| 59 | const [startsTime, setStartsTime] = createSignal(""); | 62 | const [startsTime, setStartsTime] = createSignal(""); |
| @@ -117,7 +120,7 @@ export function CourseSessionsPanel(props: { | |||
| 117 | 120 | ||
| 118 | <Suspense fallback={<PageSpinner />}> | 121 | <Suspense fallback={<PageSpinner />}> |
| 119 | <Show when={sessions.error}> | 122 | <Show when={sessions.error}> |
| 120 | - <Alert variant="destructive">{formatApiError(sessions.error)}</Alert> | 123 | + <ErrorAlert message={formatApiError(sessions.error)} onRetry={() => void refetch()} /> |
| 121 | </Show> | 124 | </Show> |
| 122 | <Show when={(sessions() ?? []).length > 0} fallback={<div class="rounded-lg border border-dashed border-border/80 bg-muted/20 px-4 py-8 text-center text-sm text-muted-foreground">{t("sessions.empty")}</div>}> | 125 | <Show when={(sessions() ?? []).length > 0} fallback={<div class="rounded-lg border border-dashed border-border/80 bg-muted/20 px-4 py-8 text-center text-sm text-muted-foreground">{t("sessions.empty")}</div>}> |
| 123 | <div class="space-y-3"> | 126 | <div class="space-y-3"> |
| @@ -137,7 +140,14 @@ export function CourseSessionsPanel(props: { | |||
| 137 | <Button type="button" variant="outline" size="sm" class="rounded-lg" onClick={() => setSelectedSession(session)}> | 140 | <Button type="button" variant="outline" size="sm" class="rounded-lg" onClick={() => setSelectedSession(session)}> |
| 138 | {t("sessions.rollCall")} | 141 | {t("sessions.rollCall")} |
| 139 | </Button> | 142 | </Button> |
| 140 | - <Button type="button" variant="ghost" size="sm" class="rounded-lg text-destructive hover:text-destructive" onClick={async () => { await deleteSessionById(session.id); await refetch(); }}> | 143 | + <Button |
| 144 | + type="button" | ||
| 145 | + variant="ghost" | ||
| 146 | + size="sm" | ||
| 147 | + class="rounded-lg text-destructive hover:text-destructive" | ||
| 148 | + aria-label={t("common.delete")} | ||
| 149 | + onClick={() => setDeleteTarget(session)} | ||
| 150 | + > | ||
| 141 | <IconTrash class="h-4 w-4" /> | 151 | <IconTrash class="h-4 w-4" /> |
| 142 | </Button> | 152 | </Button> |
| 143 | </Show> | 153 | </Show> |
| @@ -203,6 +213,27 @@ export function CourseSessionsPanel(props: { | |||
| 203 | {(session) => <RollCall sessionId={session().id} roster={props.roster} />} | 213 | {(session) => <RollCall sessionId={session().id} roster={props.roster} />} |
| 204 | </Show> | 214 | </Show> |
| 205 | </SidePanel> | 215 | </SidePanel> |
| 216 | + | ||
| 217 | + <ConfirmDialog | ||
| 218 | + open={deleteTarget() != null} | ||
| 219 | + onOpenChange={(open) => !open && setDeleteTarget(null)} | ||
| 220 | + title={t("confirm.deleteTitle")} | ||
| 221 | + variant="destructive" | ||
| 222 | + summary={t("confirm.deleteSession", { title: deleteTarget()?.topic || t("sessions.untitled") })} | ||
| 223 | + onConfirm={async () => { | ||
| 224 | + const session = deleteTarget(); | ||
| 225 | + if (!session) return; | ||
| 226 | + try { | ||
| 227 | + await deleteSessionById(session.id); | ||
| 228 | + if (selectedSession()?.id === session.id) setSelectedSession(null); | ||
| 229 | + await refetch(); | ||
| 230 | + } catch (err) { | ||
| 231 | + setError(formatApiError(err)); | ||
| 232 | + } finally { | ||
| 233 | + setDeleteTarget(null); | ||
| 234 | + } | ||
| 235 | + }} | ||
| 236 | + /> | ||
| 206 | </div> | 237 | </div> |
| 207 | ); | 238 | ); |
| 208 | } | 239 | } |
src/components/ui/error-alert.tsxadded+24 -0
| @@ -0,0 +1,24 @@ | |||
| 1 | +import { Show } from "solid-js"; | ||
| 2 | +import { Alert } from "@/components/ui/alert"; | ||
| 3 | +import { Button } from "@/components/ui/button"; | ||
| 4 | +import { useT } from "@/stores/preferences-context"; | ||
| 5 | + | ||
| 6 | +export function ErrorAlert(props: { message: string; onRetry?: () => void }) { | ||
| 7 | + const t = useT(); | ||
| 8 | + return ( | ||
| 9 | + <Alert variant="destructive" class="flex flex-wrap items-center justify-between gap-3"> | ||
| 10 | + <span class="min-w-0 flex-1">{props.message}</span> | ||
| 11 | + <Show when={!!props.onRetry}> | ||
| 12 | + <Button | ||
| 13 | + type="button" | ||
| 14 | + size="sm" | ||
| 15 | + variant="outline" | ||
| 16 | + class="shrink-0 rounded-lg border-destructive/40" | ||
| 17 | + onClick={() => props.onRetry?.()} | ||
| 18 | + > | ||
| 19 | + {t("common.tryAgain")} | ||
| 20 | + </Button> | ||
| 21 | + </Show> | ||
| 22 | + </Alert> | ||
| 23 | + ); | ||
| 24 | +} | ||
src/components/users/user-search-select.tsxmodified+6 -1
| @@ -12,6 +12,7 @@ export function UserSearchSelect(props: { | |||
| 12 | id: string; | 12 | id: string; |
| 13 | value: string; | 13 | value: string; |
| 14 | onChange: (value: string) => void; | 14 | onChange: (value: string) => void; |
| 15 | + onSelectUser?: (user: PersonRef | null) => void; | ||
| 15 | label?: string; | 16 | label?: string; |
| 16 | excludeIds?: string[]; | 17 | excludeIds?: string[]; |
| 17 | placeholder?: string; | 18 | placeholder?: string; |
| @@ -67,7 +68,10 @@ export function UserSearchSelect(props: { | |||
| 67 | createEffect(() => { | 68 | createEffect(() => { |
| 68 | const value = props.value.trim(); | 69 | const value = props.value.trim(); |
| 69 | if (!value) { | 70 | if (!value) { |
| 70 | - if (selectedUser()) setSelectedUser(null); | 71 | + if (selectedUser()) { |
| 72 | + setSelectedUser(null); | ||
| 73 | + props.onSelectUser?.(null); | ||
| 74 | + } | ||
| 71 | if (query() === lastSelectedLabel()) { | 75 | if (query() === lastSelectedLabel()) { |
| 72 | setQuery(""); | 76 | setQuery(""); |
| 73 | if (inputRef) inputRef.value = ""; | 77 | if (inputRef) inputRef.value = ""; |
| @@ -112,6 +116,7 @@ export function UserSearchSelect(props: { | |||
| 112 | setQuery(label); | 116 | setQuery(label); |
| 113 | setOpen(false); | 117 | setOpen(false); |
| 114 | props.onChange(user.id); | 118 | props.onChange(user.id); |
| 119 | + props.onSelectUser?.(user); | ||
| 115 | if (inputRef) inputRef.value = label; | 120 | if (inputRef) inputRef.value = label; |
| 116 | queueMicrotask(() => inputRef?.focus({ preventScroll: true })); | 121 | queueMicrotask(() => inputRef?.focus({ preventScroll: true })); |
| 117 | }; | 122 | }; |
src/i18n/messages.tsmodified+24 -11
| @@ -62,6 +62,7 @@ export type MessageKey = | |||
| 62 | | "confirm.deleteEvent" | 62 | | "confirm.deleteEvent" |
| 63 | | "confirm.updateEvent" | 63 | | "confirm.updateEvent" |
| 64 | | "confirm.deleteExam" | 64 | | "confirm.deleteExam" |
| 65 | + | "confirm.deleteSession" | ||
| 65 | | "confirm.updateExam" | 66 | | "confirm.updateExam" |
| 66 | | "confirm.removeAttendance" | 67 | | "confirm.removeAttendance" |
| 67 | | "confirm.removeResult" | 68 | | "confirm.removeResult" |
| @@ -434,6 +435,9 @@ export type MessageKey = | |||
| 434 | | "settings.min" | 435 | | "settings.min" |
| 435 | | "settings.label" | 436 | | "settings.label" |
| 436 | | "settings.addRow" | 437 | | "settings.addRow" |
| 438 | + | "settings.locked" | ||
| 439 | + | "settings.unsaved" | ||
| 440 | + | "settings.empty" | ||
| 437 | | "terms.title" | 441 | | "terms.title" |
| 438 | | "terms.subtitle" | 442 | | "terms.subtitle" |
| 439 | | "terms.create" | 443 | | "terms.create" |
| @@ -475,7 +479,8 @@ export type MessageKey = | |||
| 475 | | "work.empty" | 479 | | "work.empty" |
| 476 | | "work.duration" | 480 | | "work.duration" |
| 477 | | "work.open" | 481 | | "work.open" |
| 478 | - | "work.closed"; | 482 | + | "work.closed" |
| 483 | + | "work.status"; | ||
| 479 | 484 | ||
| 480 | type Dict = Record<MessageKey, string>; | 485 | type Dict = Record<MessageKey, string>; |
| 481 | 486 | ||
| @@ -541,6 +546,7 @@ const en: Dict = { | |||
| 541 | "confirm.deleteEvent": "Delete event “{title}”?", | 546 | "confirm.deleteEvent": "Delete event “{title}”?", |
| 542 | "confirm.updateEvent": "Update event “{title}”?", | 547 | "confirm.updateEvent": "Update event “{title}”?", |
| 543 | "confirm.deleteExam": "Delete exam “{title}”?", | 548 | "confirm.deleteExam": "Delete exam “{title}”?", |
| 549 | + "confirm.deleteSession": "Delete session “{title}”?", | ||
| 544 | "confirm.updateExam": "Update exam “{title}”?", | 550 | "confirm.updateExam": "Update exam “{title}”?", |
| 545 | "confirm.removeAttendance": "Remove attendance for user {user}?", | 551 | "confirm.removeAttendance": "Remove attendance for user {user}?", |
| 546 | "confirm.removeResult": "Remove grade for user {user}?", | 552 | "confirm.removeResult": "Remove grade for user {user}?", |
| @@ -631,10 +637,9 @@ const en: Dict = { | |||
| 631 | "dashboard.emptyEventsCta": "Browse events", | 637 | "dashboard.emptyEventsCta": "Browse events", |
| 632 | "dashboard.viewAll": "View all", | 638 | "dashboard.viewAll": "View all", |
| 633 | "dashboard.getStarted": "Get started", | 639 | "dashboard.getStarted": "Get started", |
| 634 | - "dashboard.helpTitle": "How this home works", | 640 | + "dashboard.helpTitle": "Need a hand?", |
| 635 | - "dashboard.helpBody": | 641 | + "dashboard.helpBody": "Stuck on a page or looking for the next step? Open the short app guide.", |
| 636 | - "Home shows live counts and shortcuts for notes, events, courses, exams, and your report card. Open Guide (bottom of the sidebar) for the full walkthrough.", | 642 | + "dashboard.continueGuide": "Guide", |
| 637 | - "dashboard.continueGuide": "Open the guide", | ||
| 638 | "dashboard.portal.sections": "Sections", | 643 | "dashboard.portal.sections": "Sections", |
| 639 | "dashboard.portal.coursesDesc": "Browse courses and class materials.", | 644 | "dashboard.portal.coursesDesc": "Browse courses and class materials.", |
| 640 | "dashboard.portal.examsDesc": "Upcoming exams, deadlines, and results.", | 645 | "dashboard.portal.examsDesc": "Upcoming exams, deadlines, and results.", |
| @@ -831,7 +836,7 @@ const en: Dict = { | |||
| 831 | "status.lateDetail": "Joined late", | 836 | "status.lateDetail": "Joined late", |
| 832 | "status.excusedDetail": "Excused absence", | 837 | "status.excusedDetail": "Excused absence", |
| 833 | "guide.tip1": "TR / EN and theme live in the avatar dropdown (submenus with icons).", | 838 | "guide.tip1": "TR / EN and theme live in the avatar dropdown (submenus with icons).", |
| 834 | - "guide.tip2": "Guide is pinned at the bottom of the sidebar, above @Hezarfen - 2026.", | 839 | + "guide.tip2": "Open the guide from your account menu or the home dashboard when you need a refresher.", |
| 835 | "guide.tip3": "“?” help panels start closed — open only when you need them.", | 840 | "guide.tip3": "“?” help panels start closed — open only when you need them.", |
| 836 | "guide.tip4": "Create exams under a course; read averages on the report card.", | 841 | "guide.tip4": "Create exams under a course; read averages on the report card.", |
| 837 | "auth.featureModules": "Courses · Exams · Report card", | 842 | "auth.featureModules": "Courses · Exams · Report card", |
| @@ -927,6 +932,9 @@ const en: Dict = { | |||
| 927 | "settings.min": "Minimum", | 932 | "settings.min": "Minimum", |
| 928 | "settings.label": "Label", | 933 | "settings.label": "Label", |
| 929 | "settings.addRow": "Add row", | 934 | "settings.addRow": "Add row", |
| 935 | + "settings.locked": "Locked", | ||
| 936 | + "settings.unsaved": "Unsaved changes", | ||
| 937 | + "settings.empty": "No rows yet.", | ||
| 930 | "terms.title": "Academic terms", | 938 | "terms.title": "Academic terms", |
| 931 | "terms.subtitle": "Manage calendar terms and assign courses to them.", | 939 | "terms.subtitle": "Manage calendar terms and assign courses to them.", |
| 932 | "terms.create": "Create term", | 940 | "terms.create": "Create term", |
| @@ -969,6 +977,7 @@ const en: Dict = { | |||
| 969 | "work.duration": "Duration", | 977 | "work.duration": "Duration", |
| 970 | "work.open": "Open", | 978 | "work.open": "Open", |
| 971 | "work.closed": "Closed", | 979 | "work.closed": "Closed", |
| 980 | + "work.status": "Status", | ||
| 972 | }; | 981 | }; |
| 973 | 982 | ||
| 974 | const tr: Dict = { | 983 | const tr: Dict = { |
| @@ -1033,6 +1042,7 @@ const tr: Dict = { | |||
| 1033 | "confirm.deleteEvent": "“{title}” etkinliği silinsin mi?", | 1042 | "confirm.deleteEvent": "“{title}” etkinliği silinsin mi?", |
| 1034 | "confirm.updateEvent": "“{title}” etkinliği güncellensin mi?", | 1043 | "confirm.updateEvent": "“{title}” etkinliği güncellensin mi?", |
| 1035 | "confirm.deleteExam": "“{title}” sınavı silinsin mi?", | 1044 | "confirm.deleteExam": "“{title}” sınavı silinsin mi?", |
| 1045 | + "confirm.deleteSession": "“{title}” oturumu silinsin mi?", | ||
| 1036 | "confirm.updateExam": "“{title}” sınavı güncellensin mi?", | 1046 | "confirm.updateExam": "“{title}” sınavı güncellensin mi?", |
| 1037 | "confirm.removeAttendance": "{user} kullanıcısının yoklaması kaldırılsın mı?", | 1047 | "confirm.removeAttendance": "{user} kullanıcısının yoklaması kaldırılsın mı?", |
| 1038 | "confirm.removeResult": "{user} kullanıcısının notu kaldırılsın mı?", | 1048 | "confirm.removeResult": "{user} kullanıcısının notu kaldırılsın mı?", |
| @@ -1123,10 +1133,9 @@ const tr: Dict = { | |||
| 1123 | "dashboard.emptyEventsCta": "Etkinliklere git", | 1133 | "dashboard.emptyEventsCta": "Etkinliklere git", |
| 1124 | "dashboard.viewAll": "Tümünü gör", | 1134 | "dashboard.viewAll": "Tümünü gör", |
| 1125 | "dashboard.getStarted": "Başla", | 1135 | "dashboard.getStarted": "Başla", |
| 1126 | - "dashboard.helpTitle": "Ana sayfa nasıl çalışır?", | 1136 | + "dashboard.helpTitle": "Yardıma mı ihtiyacın var?", |
| 1127 | - "dashboard.helpBody": | 1137 | + "dashboard.helpBody": "Bir sayfada takıldın veya sonraki adımı mı arıyorsun? Kısa uygulama rehberini aç.", |
| 1128 | - "Ana sayfa not, etkinlik, ders, sınav ve karne kısayollarını gösterir. Tam tur için sidebar’ın altındaki Rehber’i aç.", | 1138 | + "dashboard.continueGuide": "Rehber", |
| 1129 | - "dashboard.continueGuide": "Rehberi aç", | ||
| 1130 | "dashboard.portal.sections": "Bölümler", | 1139 | "dashboard.portal.sections": "Bölümler", |
| 1131 | "dashboard.portal.coursesDesc": "Dersleri ve ders materyallerini görüntüle.", | 1140 | "dashboard.portal.coursesDesc": "Dersleri ve ders materyallerini görüntüle.", |
| 1132 | "dashboard.portal.examsDesc": "Sınavlar, son teslim tarihleri ve sonuçlar.", | 1141 | "dashboard.portal.examsDesc": "Sınavlar, son teslim tarihleri ve sonuçlar.", |
| @@ -1323,7 +1332,7 @@ const tr: Dict = { | |||
| 1323 | "status.lateDetail": "Geç katıldı", | 1332 | "status.lateDetail": "Geç katıldı", |
| 1324 | "status.excusedDetail": "Mazeretli yok", | 1333 | "status.excusedDetail": "Mazeretli yok", |
| 1325 | "guide.tip1": "Dil ve tema avatar menüsünde (ikonlu alt menüler).", | 1334 | "guide.tip1": "Dil ve tema avatar menüsünde (ikonlu alt menüler).", |
| 1326 | - "guide.tip2": "Rehber, sidebar’ın altında @Hezarfen - 2026’nın hemen üstünde.", | 1335 | + "guide.tip2": "İhtiyacın olduğunda rehberi hesap menüsünden veya ana sayfadaki kısayoldan aç.", |
| 1327 | "guide.tip3": "“?” panelleri kapalı gelir — ihtiyaç olunca aç.", | 1336 | "guide.tip3": "“?” panelleri kapalı gelir — ihtiyaç olunca aç.", |
| 1328 | "guide.tip4": "Sınavı dersin içinde oluştur; ortalamayı Karnem’de oku.", | 1337 | "guide.tip4": "Sınavı dersin içinde oluştur; ortalamayı Karnem’de oku.", |
| 1329 | "auth.featureModules": "Dersler · Sınavlar · Karne", | 1338 | "auth.featureModules": "Dersler · Sınavlar · Karne", |
| @@ -1419,6 +1428,9 @@ const tr: Dict = { | |||
| 1419 | "settings.min": "Alt sınır", | 1428 | "settings.min": "Alt sınır", |
| 1420 | "settings.label": "Etiket", | 1429 | "settings.label": "Etiket", |
| 1421 | "settings.addRow": "Satır ekle", | 1430 | "settings.addRow": "Satır ekle", |
| 1431 | + "settings.locked": "Kilitli", | ||
| 1432 | + "settings.unsaved": "Kaydedilmemiş değişiklikler", | ||
| 1433 | + "settings.empty": "Henüz satır yok.", | ||
| 1422 | "terms.title": "Akademik dönemler", | 1434 | "terms.title": "Akademik dönemler", |
| 1423 | "terms.subtitle": "Takvim dönemlerini yönet ve dersleri dönemlere bağla.", | 1435 | "terms.subtitle": "Takvim dönemlerini yönet ve dersleri dönemlere bağla.", |
| 1424 | "terms.create": "Dönem oluştur", | 1436 | "terms.create": "Dönem oluştur", |
| @@ -1461,6 +1473,7 @@ const tr: Dict = { | |||
| 1461 | "work.duration": "Süre", | 1473 | "work.duration": "Süre", |
| 1462 | "work.open": "Açık", | 1474 | "work.open": "Açık", |
| 1463 | "work.closed": "Kapalı", | 1475 | "work.closed": "Kapalı", |
| 1476 | + "work.status": "Durum", | ||
| 1464 | }; | 1477 | }; |
| 1465 | 1478 | ||
| 1466 | export const messages: Record<Locale, Dict> = { en, tr }; | 1479 | export const messages: Record<Locale, Dict> = { en, tr }; |
src/pages/courses-page.tsxmodified+1 -1
| @@ -128,7 +128,7 @@ function CoursesContent() { | |||
| 128 | description={t("courses.subtitle")} | 128 | description={t("courses.subtitle")} |
| 129 | actions={ | 129 | actions={ |
| 130 | canCreate() ? ( | 130 | canCreate() ? ( |
| 131 | - <Button type="button" size="sm" class="rounded-sm" onClick={() => setShowForm(true)}> | 131 | + <Button type="button" size="sm" class="min-w-[7.5rem] rounded-lg" onClick={() => setShowForm(true)}> |
| 132 | <IconPlus class="h-4 w-4" /> | 132 | <IconPlus class="h-4 w-4" /> |
| 133 | {t("courses.create")} | 133 | {t("courses.create")} |
| 134 | </Button> | 134 | </Button> |
src/pages/dashboard-page.tsxmodified+34 -16
| @@ -193,25 +193,15 @@ function DashboardContent() { | |||
| 193 | { icon: <IconReportAnalytics class="h-5 w-5" />, titleKey: "nav.marks", to: "/marks", descKey: "dashboard.portal.marksDesc", stat: avg, accent: "mint" }, | 193 | { icon: <IconReportAnalytics class="h-5 w-5" />, titleKey: "nav.marks", to: "/marks", descKey: "dashboard.portal.marksDesc", stat: avg, accent: "mint" }, |
| 194 | { icon: <IconNote class="h-5 w-5" />, titleKey: "nav.notes", to: "/notes", descKey: "dashboard.portal.notesDesc", stat: nc, statSuffix: "dashboard.records", accent: "rose" }, | 194 | { icon: <IconNote class="h-5 w-5" />, titleKey: "nav.notes", to: "/notes", descKey: "dashboard.portal.notesDesc", stat: nc, statSuffix: "dashboard.records", accent: "rose" }, |
| 195 | ); | 195 | ); |
| 196 | - } | 196 | + } else if (hasMinRole(roleVal, "manager")) { |
| 197 | - | ||
| 198 | - if (roleVal === "teacher") { | ||
| 199 | list.push( | 197 | list.push( |
| 200 | { icon: <IconSchool class="h-5 w-5" />, titleKey: "nav.courses", to: "/courses", descKey: "dashboard.portal.coursesDesc", stat: cc, statSuffix: "dashboard.records", accent: "violet" }, | 198 | { icon: <IconSchool class="h-5 w-5" />, titleKey: "nav.courses", to: "/courses", descKey: "dashboard.portal.coursesDesc", stat: cc, statSuffix: "dashboard.records", accent: "violet" }, |
| 201 | { icon: <IconExam class="h-5 w-5" />, titleKey: "nav.exams", to: "/exams", descKey: "dashboard.portal.examsDesc", stat: ec, statSuffix: "dashboard.records", accent: "amber" }, | 199 | { icon: <IconExam class="h-5 w-5" />, titleKey: "nav.exams", to: "/exams", descKey: "dashboard.portal.examsDesc", stat: ec, statSuffix: "dashboard.records", accent: "amber" }, |
| 202 | - { icon: <IconCalendar class="h-5 w-5" />, titleKey: "nav.events", to: "/events", descKey: "dashboard.portal.eventsDesc", stat: evc, statSuffix: "dashboard.records", accent: "sky", minRole: "teacher" }, | 200 | + { icon: <IconCalendar class="h-5 w-5" />, titleKey: "nav.events", to: "/events", descKey: "dashboard.portal.eventsDesc", stat: evc, statSuffix: "dashboard.records", accent: "sky" }, |
| 203 | - { icon: <IconChart class="h-5 w-5" />, titleKey: "nav.studentMarks", to: "/management/student-marks", descKey: "dashboard.portal.studentMarksDesc", stat: "", accent: "mint", minRole: "teacher" }, | ||
| 204 | - { icon: <IconClipboardCheck class="h-5 w-5" />, titleKey: "nav.studentAttendance", to: "/management/student-attendance", descKey: "dashboard.portal.attendanceDesc", stat: "", accent: "rose", minRole: "teacher" }, | ||
| 205 | { icon: <IconNote class="h-5 w-5" />, titleKey: "nav.notes", to: "/notes", descKey: "dashboard.portal.notesDesc", stat: nc, statSuffix: "dashboard.records", accent: "sky" }, | 201 | { icon: <IconNote class="h-5 w-5" />, titleKey: "nav.notes", to: "/notes", descKey: "dashboard.portal.notesDesc", stat: nc, statSuffix: "dashboard.records", accent: "sky" }, |
| 206 | { icon: <IconReportAnalytics class="h-5 w-5" />, titleKey: "nav.work", to: "/work", descKey: "dashboard.portal.workDesc", stat: "", accent: "amber", minRole: "teacher" }, | 202 | { icon: <IconReportAnalytics class="h-5 w-5" />, titleKey: "nav.work", to: "/work", descKey: "dashboard.portal.workDesc", stat: "", accent: "amber", minRole: "teacher" }, |
| 207 | - ); | 203 | + { icon: <IconChart class="h-5 w-5" />, titleKey: "nav.studentMarks", to: "/management/student-marks", descKey: "dashboard.portal.studentMarksDesc", stat: "", accent: "mint", minRole: "teacher" }, |
| 208 | - } | 204 | + { icon: <IconClipboardCheck class="h-5 w-5" />, titleKey: "nav.studentAttendance", to: "/management/student-attendance", descKey: "dashboard.portal.attendanceDesc", stat: "", accent: "rose", minRole: "teacher" }, |
| 209 | - | ||
| 210 | - if (hasMinRole(roleVal, "manager")) { | ||
| 211 | - list.unshift( | ||
| 212 | - { icon: <IconSchool class="h-5 w-5" />, titleKey: "nav.courses", to: "/courses", descKey: "dashboard.portal.coursesDesc", stat: cc, statSuffix: "dashboard.records", accent: "violet" }, | ||
| 213 | - { icon: <IconExam class="h-5 w-5" />, titleKey: "nav.exams", to: "/exams", descKey: "dashboard.portal.examsDesc", stat: ec, statSuffix: "dashboard.records", accent: "amber" }, | ||
| 214 | - { icon: <IconCalendar class="h-5 w-5" />, titleKey: "nav.events", to: "/events", descKey: "dashboard.portal.eventsDesc", stat: evc, statSuffix: "dashboard.records", accent: "sky" }, | ||
| 215 | { icon: <IconSettings class="h-5 w-5" />, titleKey: "nav.settings", to: "/management/settings", descKey: "dashboard.portal.settingsDesc", stat: "", accent: "mint", minRole: "manager" }, | 205 | { icon: <IconSettings class="h-5 w-5" />, titleKey: "nav.settings", to: "/management/settings", descKey: "dashboard.portal.settingsDesc", stat: "", accent: "mint", minRole: "manager" }, |
| 216 | { icon: <IconBook class="h-5 w-5" />, titleKey: "nav.terms", to: "/management/terms", descKey: "dashboard.portal.termsDesc", stat: "", accent: "rose", minRole: "manager" }, | 206 | { icon: <IconBook class="h-5 w-5" />, titleKey: "nav.terms", to: "/management/terms", descKey: "dashboard.portal.termsDesc", stat: "", accent: "rose", minRole: "manager" }, |
| 217 | ); | 207 | ); |
| @@ -220,6 +210,16 @@ function DashboardContent() { | |||
| 220 | { icon: <IconUsers class="h-5 w-5" />, titleKey: "nav.users", to: "/admin/users", descKey: "dashboard.portal.usersDesc", stat: "", accent: "rose", minRole: "admin" }, | 210 | { icon: <IconUsers class="h-5 w-5" />, titleKey: "nav.users", to: "/admin/users", descKey: "dashboard.portal.usersDesc", stat: "", accent: "rose", minRole: "admin" }, |
| 221 | ); | 211 | ); |
| 222 | } | 212 | } |
| 213 | + } else if (roleVal === "teacher") { | ||
| 214 | + list.push( | ||
| 215 | + { icon: <IconSchool class="h-5 w-5" />, titleKey: "nav.courses", to: "/courses", descKey: "dashboard.portal.coursesDesc", stat: cc, statSuffix: "dashboard.records", accent: "violet" }, | ||
| 216 | + { icon: <IconExam class="h-5 w-5" />, titleKey: "nav.exams", to: "/exams", descKey: "dashboard.portal.examsDesc", stat: ec, statSuffix: "dashboard.records", accent: "amber" }, | ||
| 217 | + { icon: <IconCalendar class="h-5 w-5" />, titleKey: "nav.events", to: "/events", descKey: "dashboard.portal.eventsDesc", stat: evc, statSuffix: "dashboard.records", accent: "sky", minRole: "teacher" }, | ||
| 218 | + { icon: <IconChart class="h-5 w-5" />, titleKey: "nav.studentMarks", to: "/management/student-marks", descKey: "dashboard.portal.studentMarksDesc", stat: "", accent: "mint", minRole: "teacher" }, | ||
| 219 | + { icon: <IconClipboardCheck class="h-5 w-5" />, titleKey: "nav.studentAttendance", to: "/management/student-attendance", descKey: "dashboard.portal.attendanceDesc", stat: "", accent: "rose", minRole: "teacher" }, | ||
| 220 | + { icon: <IconNote class="h-5 w-5" />, titleKey: "nav.notes", to: "/notes", descKey: "dashboard.portal.notesDesc", stat: nc, statSuffix: "dashboard.records", accent: "sky" }, | ||
| 221 | + { icon: <IconReportAnalytics class="h-5 w-5" />, titleKey: "nav.work", to: "/work", descKey: "dashboard.portal.workDesc", stat: "", accent: "amber", minRole: "teacher" }, | ||
| 222 | + ); | ||
| 223 | } | 223 | } |
| 224 | 224 | ||
| 225 | return list; | 225 | return list; |
| @@ -243,7 +243,7 @@ function DashboardContent() { | |||
| 243 | </Show> | 243 | </Show> |
| 244 | 244 | ||
| 245 | <Suspense fallback={<PageSpinner />}> | 245 | <Suspense fallback={<PageSpinner />}> |
| 246 | - <div class="grid gap-4 sm:grid-cols-2 lg:grid-cols-3 xl:grid-cols-4 auto-rows-fr"> | 246 | + <div class="grid grid-cols-2 gap-3 sm:gap-4 lg:grid-cols-3 xl:grid-cols-4 auto-rows-fr"> |
| 247 | <For each={cards()}>{(card) => <PortalCard card={card} />}</For> | 247 | <For each={cards()}>{(card) => <PortalCard card={card} />}</For> |
| 248 | </div> | 248 | </div> |
| 249 | 249 | ||
| @@ -255,6 +255,19 @@ function DashboardContent() { | |||
| 255 | maxValue={maxChartValue()} | 255 | maxValue={maxChartValue()} |
| 256 | /> | 256 | /> |
| 257 | </div> | 257 | </div> |
| 258 | + | ||
| 259 | + <div class="rounded-xl border border-border/60 bg-card p-4 shadow-xs sm:flex sm:items-center sm:justify-between sm:gap-4"> | ||
| 260 | + <div> | ||
| 261 | + <h2 class="font-display text-sm font-semibold">{t("dashboard.helpTitle")}</h2> | ||
| 262 | + <p class="mt-1 text-xs text-muted-foreground">{t("dashboard.helpBody")}</p> | ||
| 263 | + </div> | ||
| 264 | + <Link | ||
| 265 | + to="/guide" | ||
| 266 | + class="mt-3 inline-flex h-7 items-center justify-center rounded-md border border-border bg-background px-2.5 text-xs font-medium transition-colors hover:bg-muted sm:mt-0" | ||
| 267 | + > | ||
| 268 | + {t("dashboard.continueGuide")} | ||
| 269 | + </Link> | ||
| 270 | + </div> | ||
| 258 | </Suspense> | 271 | </Suspense> |
| 259 | </div> | 272 | </div> |
| 260 | ); | 273 | ); |
| @@ -343,7 +356,12 @@ function UpcomingTimeline(props: { | |||
| 343 | <Show | 356 | <Show |
| 344 | when={props.timeline.length > 0} | 357 | when={props.timeline.length > 0} |
| 345 | fallback={ | 358 | fallback={ |
| 346 | - <p class="py-6 text-center text-sm text-muted-foreground">{props.t("dashboard.noEvents")}</p> | 359 | + <div class="flex flex-col items-center gap-2 py-6 text-center"> |
| 360 | + <p class="text-sm text-muted-foreground">{props.t("dashboard.emptyEventsTitle")}</p> | ||
| 361 | + <Link to="/events" class="text-sm font-medium text-primary hover:underline"> | ||
| 362 | + {props.t("dashboard.emptyEventsCta")} | ||
| 363 | + </Link> | ||
| 364 | + </div> | ||
| 347 | } | 365 | } |
| 348 | > | 366 | > |
| 349 | <div class="space-y-3"> | 367 | <div class="space-y-3"> |
src/pages/events-page.tsxmodified+2 -2
| @@ -77,7 +77,7 @@ function EventsContent() { | |||
| 77 | description={t("events.subtitle")} | 77 | description={t("events.subtitle")} |
| 78 | actions={ | 78 | actions={ |
| 79 | canCreate() ? ( | 79 | canCreate() ? ( |
| 80 | - <Button type="button" size="sm" class="rounded-sm" onClick={() => setShowForm(true)}> | 80 | + <Button type="button" size="sm" class="min-w-[7.5rem] rounded-lg" onClick={() => setShowForm(true)}> |
| 81 | <IconPlus class="h-4 w-4" /> | 81 | <IconPlus class="h-4 w-4" /> |
| 82 | {t("events.create")} | 82 | {t("events.create")} |
| 83 | </Button> | 83 | </Button> |
| @@ -160,7 +160,7 @@ function EventsContent() { | |||
| 160 | <p class="mt-1 text-sm text-muted-foreground">{filteredEvents().length} / {eventList().length} {t("nav.events")}</p> | 160 | <p class="mt-1 text-sm text-muted-foreground">{filteredEvents().length} / {eventList().length} {t("nav.events")}</p> |
| 161 | </div> | 161 | </div> |
| 162 | </div> | 162 | </div> |
| 163 | - <ul class="grid gap-3 sm:grid-cols-2 xl:grid-cols-3"> | 163 | + <ul class="grid grid-cols-2 gap-3 xl:grid-cols-3"> |
| 164 | <For each={pageItems()}> | 164 | <For each={pageItems()}> |
| 165 | {(event) => ( | 165 | {(event) => ( |
| 166 | <li class="animate-fade-up"> | 166 | <li class="animate-fade-up"> |
src/pages/exam-room-page.tsxmodified+28 -19
| @@ -47,9 +47,9 @@ function ExamRoomContent() { | |||
| 47 | return ( | 47 | return ( |
| 48 | <Suspense fallback={<PageSpinner />}> | 48 | <Suspense fallback={<PageSpinner />}> |
| 49 | <Show | 49 | <Show |
| 50 | - when={exam()} | 50 | + when={exam()?.id === id() ? exam() : undefined} |
| 51 | fallback={ | 51 | fallback={ |
| 52 | - <Show when={exam.error}> | 52 | + <Show when={exam.error} fallback={<PageSpinner />}> |
| 53 | <Alert variant="destructive">{formatApiError(exam.error)}</Alert> | 53 | <Alert variant="destructive">{formatApiError(exam.error)}</Alert> |
| 54 | </Show> | 54 | </Show> |
| 55 | } | 55 | } |
| @@ -58,23 +58,32 @@ function ExamRoomContent() { | |||
| 58 | <Show when={accessReady()} fallback={<PageSpinner />}> | 58 | <Show when={accessReady()} fallback={<PageSpinner />}> |
| 59 | <Show when={canViewExam()} fallback={<Alert variant="destructive">{t("common.accessDenied")}</Alert>}> | 59 | <Show when={canViewExam()} fallback={<Alert variant="destructive">{t("common.accessDenied")}</Alert>}> |
| 60 | <div class="space-y-6"> | 60 | <div class="space-y-6"> |
| 61 | - <PageHeader | 61 | + <div class="space-y-2"> |
| 62 | - compact | 62 | + <div class="flex flex-wrap items-center gap-1 text-xs text-muted-foreground"> |
| 63 | - accent="rose" | 63 | + <Link to="/exams" class="hover:text-foreground">{t("nav.exams")}</Link> |
| 64 | - eyebrow={t("attempt.title")} | 64 | + <span>/</span> |
| 65 | - title={ex().title} | 65 | + <Link to="/exams/$id" params={{ id: id() }} class="hover:text-foreground truncate max-w-[12rem]">{ex().title}</Link> |
| 66 | - description={ex().description || undefined} | 66 | + <span>/</span> |
| 67 | - actions={ | 67 | + <span>{t("attempt.title")}</span> |
| 68 | - <div class="flex w-full flex-wrap items-center gap-1 rounded-lg border bg-background/80 p-1 shadow-sm sm:w-auto"> | 68 | + </div> |
| 69 | - <Link to="/exams/$id" params={{ id: id() }}> | 69 | + <PageHeader |
| 70 | - <Button variant="ghost" size="sm" class="w-full rounded-md sm:w-auto"> | 70 | + compact |
| 71 | - <IconChevronLeft class="h-4 w-4" /> | 71 | + accent="rose" |
| 72 | - {t("common.back")} | 72 | + eyebrow={t("attempt.title")} |
| 73 | - </Button> | 73 | + title={ex().title} |
| 74 | - </Link> | 74 | + description={ex().description || undefined} |
| 75 | - </div> | 75 | + actions={ |
| 76 | - } | 76 | + <div class="flex w-full flex-wrap items-center gap-1 rounded-lg border bg-background/80 p-1 shadow-sm sm:w-auto"> |
| 77 | - /> | 77 | + <Link to="/exams/$id" params={{ id: id() }}> |
| 78 | + <Button variant="ghost" size="sm" class="w-full rounded-md sm:w-auto"> | ||
| 79 | + <IconChevronLeft class="h-4 w-4" /> | ||
| 80 | + {t("common.back")} | ||
| 81 | + </Button> | ||
| 82 | + </Link> | ||
| 83 | + </div> | ||
| 84 | + } | ||
| 85 | + /> | ||
| 86 | + </div> | ||
| 78 | <ExamRoomWS exam={ex()} /> | 87 | <ExamRoomWS exam={ex()} /> |
| 79 | </div> | 88 | </div> |
| 80 | </Show> | 89 | </Show> |
src/pages/exams-page.tsxmodified+8 -8
| @@ -164,6 +164,14 @@ function ExamsContent() { | |||
| 164 | eyebrow={t("nav.exams")} | 164 | eyebrow={t("nav.exams")} |
| 165 | title={t("exams.title")} | 165 | title={t("exams.title")} |
| 166 | description={t("exams.subtitle")} | 166 | description={t("exams.subtitle")} |
| 167 | + actions={ | ||
| 168 | + canCreate() ? ( | ||
| 169 | + <Button type="button" size="sm" class="min-w-[7.5rem] rounded-lg" onClick={() => setCreateOpen(true)}> | ||
| 170 | + <IconPlus class="h-4 w-4" /> | ||
| 171 | + {t("exams.create")} | ||
| 172 | + </Button> | ||
| 173 | + ) : undefined | ||
| 174 | + } | ||
| 167 | /> | 175 | /> |
| 168 | </div> | 176 | </div> |
| 169 | 177 | ||
| @@ -209,14 +217,6 @@ function ExamsContent() { | |||
| 209 | </Button> | 217 | </Button> |
| 210 | </> | 218 | </> |
| 211 | } | 219 | } |
| 212 | - actions={ | ||
| 213 | - <Show when={canCreate()}> | ||
| 214 | - <Button type="button" size="sm" class="h-9 rounded-sm" onClick={() => setCreateOpen(true)}> | ||
| 215 | - <IconPlus class="h-4 w-4" /> | ||
| 216 | - {t("exams.create")} | ||
| 217 | - </Button> | ||
| 218 | - </Show> | ||
| 219 | - } | ||
| 220 | /> | 220 | /> |
| 221 | 221 | ||
| 222 | <Suspense fallback={<DataTableSkeleton columns={6} rows={8} />}> | 222 | <Suspense fallback={<DataTableSkeleton columns={6} rows={8} />}> |
src/pages/live-monitor-page.tsxmodified+26 -17
| @@ -217,23 +217,32 @@ function LiveMonitorContent() { | |||
| 217 | </Show> | 217 | </Show> |
| 218 | <Show when={exam()}> | 218 | <Show when={exam()}> |
| 219 | {(ex) => ( | 219 | {(ex) => ( |
| 220 | - <PageHeader | 220 | + <div class="space-y-2"> |
| 221 | - compact | 221 | + <div class="flex flex-wrap items-center gap-1 text-xs text-muted-foreground"> |
| 222 | - accent="rose" | 222 | + <Link to="/exams" class="hover:text-foreground">{t("nav.exams")}</Link> |
| 223 | - eyebrow={isFinished() ? t("exams.finalState") : t("exams.liveMonitor")} | 223 | + <span>/</span> |
| 224 | - title={ex().title} | 224 | + <Link to="/exams/$id" params={{ id: id() }} class="max-w-[12rem] truncate hover:text-foreground">{ex().title}</Link> |
| 225 | - description={isFinished() ? t("exams.finalStateDesc") : t("exams.liveMonitorDesc")} | 225 | + <span>/</span> |
| 226 | - actions={ | 226 | + <span>{isFinished() ? t("exams.finalState") : t("exams.liveMonitor")}</span> |
| 227 | - <div class="flex w-full flex-wrap items-center gap-1 rounded-lg border bg-background/80 p-1 shadow-sm sm:w-auto"> | 227 | + </div> |
| 228 | - <Link to="/exams/$id" params={{ id: id() }}> | 228 | + <PageHeader |
| 229 | - <Button variant="ghost" size="sm" class="w-full rounded-md sm:w-auto"> | 229 | + compact |
| 230 | - <IconChevronLeft class="h-4 w-4" /> | 230 | + accent="rose" |
| 231 | - {t("common.back")} | 231 | + eyebrow={isFinished() ? t("exams.finalState") : t("exams.liveMonitor")} |
| 232 | - </Button> | 232 | + title={ex().title} |
| 233 | - </Link> | 233 | + description={isFinished() ? t("exams.finalStateDesc") : t("exams.liveMonitorDesc")} |
| 234 | - </div> | 234 | + actions={ |
| 235 | - } | 235 | + <div class="flex w-full flex-wrap items-center gap-1 rounded-lg border bg-background/80 p-1 shadow-sm sm:w-auto"> |
| 236 | - /> | 236 | + <Link to="/exams/$id" params={{ id: id() }}> |
| 237 | + <Button variant="ghost" size="sm" class="w-full rounded-md sm:w-auto"> | ||
| 238 | + <IconChevronLeft class="h-4 w-4" /> | ||
| 239 | + {t("common.back")} | ||
| 240 | + </Button> | ||
| 241 | + </Link> | ||
| 242 | + </div> | ||
| 243 | + } | ||
| 244 | + /> | ||
| 245 | + </div> | ||
| 237 | )} | 246 | )} |
| 238 | </Show> | 247 | </Show> |
| 239 | 248 | ||
src/pages/notes-page.tsxmodified+1 -1
| @@ -51,7 +51,7 @@ function NotesContent() { | |||
| 51 | title={t("notes.title")} | 51 | title={t("notes.title")} |
| 52 | description={t("notes.subtitle")} | 52 | description={t("notes.subtitle")} |
| 53 | actions={ | 53 | actions={ |
| 54 | - <Button type="button" size="sm" class="rounded-sm" onClick={() => setCreateOpen(true)}> | 54 | + <Button type="button" size="sm" class="min-w-[7.5rem] rounded-lg" onClick={() => setCreateOpen(true)}> |
| 55 | <IconPlus class="h-4 w-4" /> | 55 | <IconPlus class="h-4 w-4" /> |
| 56 | {t("notes.new")} | 56 | {t("notes.new")} |
| 57 | </Button> | 57 | </Button> |
src/pages/profile-page.tsxmodified+10 -1
| @@ -1,11 +1,20 @@ | |||
| 1 | import { Show, Suspense } from "solid-js"; | 1 | import { Show, Suspense } from "solid-js"; |
| 2 | +import type { Role } from "@/api/types"; | ||
| 2 | import { ProfileForm } from "@/components/users/profile-form"; | 3 | import { ProfileForm } from "@/components/users/profile-form"; |
| 3 | import { RouteGuard } from "@/components/layout/route-guard"; | 4 | import { RouteGuard } from "@/components/layout/route-guard"; |
| 4 | import { PageHeader } from "@/components/layout/page-header"; | 5 | import { PageHeader } from "@/components/layout/page-header"; |
| 5 | import { PageSpinner } from "@/components/ui/page-spinner"; | 6 | import { PageSpinner } from "@/components/ui/page-spinner"; |
| 7 | +import type { MessageKey } from "@/i18n/messages"; | ||
| 6 | import { useAuth } from "@/stores/auth-context"; | 8 | import { useAuth } from "@/stores/auth-context"; |
| 7 | import { useT } from "@/stores/preferences-context"; | 9 | import { useT } from "@/stores/preferences-context"; |
| 8 | 10 | ||
| 11 | +const ROLE_KEY: Record<Role, MessageKey> = { | ||
| 12 | + student: "role.student", | ||
| 13 | + teacher: "role.teacher", | ||
| 14 | + manager: "role.manager", | ||
| 15 | + admin: "role.admin", | ||
| 16 | +}; | ||
| 17 | + | ||
| 9 | export default function ProfilePage() { | 18 | export default function ProfilePage() { |
| 10 | return ( | 19 | return ( |
| 11 | <RouteGuard> | 20 | <RouteGuard> |
| @@ -27,7 +36,7 @@ function ProfileContent() { | |||
| 27 | accent="mint" | 36 | accent="mint" |
| 28 | eyebrow={t("nav.account")} | 37 | eyebrow={t("nav.account")} |
| 29 | title={u().username} | 38 | title={u().username} |
| 30 | - description={`${u().role} · ${u().id}`} | 39 | + description={t(ROLE_KEY[u().role])} |
| 31 | /> | 40 | /> |
| 32 | 41 | ||
| 33 | <div class="grid gap-6 lg:grid-cols-2"> | 42 | <div class="grid gap-6 lg:grid-cols-2"> |
src/pages/settings-page.tsxmodified+330 -119
| @@ -6,10 +6,14 @@ import { formatApiError } from "@/api/client"; | |||
| 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 { Alert } from "@/components/ui/alert"; | 8 | import { Alert } from "@/components/ui/alert"; |
| 9 | +import { Badge } from "@/components/ui/badge"; | ||
| 9 | import { Button } from "@/components/ui/button"; | 10 | import { Button } from "@/components/ui/button"; |
| 11 | +import { ErrorAlert } from "@/components/ui/error-alert"; | ||
| 10 | import { IconPlus, IconTrash } from "@/components/ui/icons"; | 12 | import { IconPlus, IconTrash } from "@/components/ui/icons"; |
| 11 | import { Input } from "@/components/ui/input"; | 13 | import { Input } from "@/components/ui/input"; |
| 12 | import { PageSpinner } from "@/components/ui/page-spinner"; | 14 | import { PageSpinner } from "@/components/ui/page-spinner"; |
| 15 | +import { getAttendanceStatusMeta } from "@/lib/attendance-status"; | ||
| 16 | +import { cn } from "@/lib/cn"; | ||
| 13 | import { useT } from "@/stores/preferences-context"; | 17 | import { useT } from "@/stores/preferences-context"; |
| 14 | 18 | ||
| 15 | const CORE_ATTENDANCE = new Set(["present", "absent", "late", "excused"]); | 19 | const CORE_ATTENDANCE = new Set(["present", "absent", "late", "excused"]); |
| @@ -41,6 +45,15 @@ function SettingsContent() { | |||
| 41 | const [error, setError] = createSignal(""); | 45 | const [error, setError] = createSignal(""); |
| 42 | const [saved, setSaved] = createSignal(false); | 46 | const [saved, setSaved] = createSignal(false); |
| 43 | const [pending, setPending] = createSignal(false); | 47 | const [pending, setPending] = createSignal(false); |
| 48 | + const [baseline, setBaseline] = createSignal(""); | ||
| 49 | + let savedTimer: number | undefined; | ||
| 50 | + | ||
| 51 | + const snapshot = () => | ||
| 52 | + JSON.stringify({ | ||
| 53 | + exam_kinds: examKinds(), | ||
| 54 | + attendance_statuses: attendanceStatuses(), | ||
| 55 | + grade_bands: gradeBands(), | ||
| 56 | + }); | ||
| 44 | 57 | ||
| 45 | createEffect(() => { | 58 | createEffect(() => { |
| 46 | const next = settings(); | 59 | const next = settings(); |
| @@ -48,6 +61,19 @@ function SettingsContent() { | |||
| 48 | setExamKinds(next.exam_kinds.map((item) => ({ ...item }))); | 61 | setExamKinds(next.exam_kinds.map((item) => ({ ...item }))); |
| 49 | setAttendanceStatuses([...next.attendance_statuses]); | 62 | setAttendanceStatuses([...next.attendance_statuses]); |
| 50 | setGradeBands(next.grade_bands.map((item) => ({ ...item }))); | 63 | setGradeBands(next.grade_bands.map((item) => ({ ...item }))); |
| 64 | + setBaseline( | ||
| 65 | + JSON.stringify({ | ||
| 66 | + exam_kinds: next.exam_kinds, | ||
| 67 | + attendance_statuses: next.attendance_statuses, | ||
| 68 | + grade_bands: next.grade_bands, | ||
| 69 | + }), | ||
| 70 | + ); | ||
| 71 | + }); | ||
| 72 | + | ||
| 73 | + const dirty = () => baseline() !== "" && snapshot() !== baseline(); | ||
| 74 | + | ||
| 75 | + createEffect(() => { | ||
| 76 | + if (dirty() && saved()) setSaved(false); | ||
| 51 | }); | 77 | }); |
| 52 | 78 | ||
| 53 | const save = async () => { | 79 | const save = async () => { |
| @@ -61,7 +87,16 @@ function SettingsContent() { | |||
| 61 | grade_bands: gradeBands().map((band) => ({ min: Number(band.min), label: band.label.trim() })), | 87 | grade_bands: gradeBands().map((band) => ({ min: Number(band.min), label: band.label.trim() })), |
| 62 | }); | 88 | }); |
| 63 | mutate(next); | 89 | mutate(next); |
| 90 | + setBaseline( | ||
| 91 | + JSON.stringify({ | ||
| 92 | + exam_kinds: next.exam_kinds, | ||
| 93 | + attendance_statuses: next.attendance_statuses, | ||
| 94 | + grade_bands: next.grade_bands, | ||
| 95 | + }), | ||
| 96 | + ); | ||
| 64 | setSaved(true); | 97 | setSaved(true); |
| 98 | + if (savedTimer) window.clearTimeout(savedTimer); | ||
| 99 | + savedTimer = window.setTimeout(() => setSaved(false), 3000); | ||
| 65 | await refetch(); | 100 | await refetch(); |
| 66 | } catch (err) { | 101 | } catch (err) { |
| 67 | setError(formatApiError(err)); | 102 | setError(formatApiError(err)); |
| @@ -78,144 +113,320 @@ function SettingsContent() { | |||
| 78 | <span>/</span> | 113 | <span>/</span> |
| 79 | <span>{t("settings.title")}</span> | 114 | <span>{t("settings.title")}</span> |
| 80 | </div> | 115 | </div> |
| 81 | - <PageHeader accent="violet" eyebrow={t("nav.admin")} title={t("settings.title")} description={t("settings.subtitle")} /> | 116 | + <PageHeader |
| 117 | + accent="violet" | ||
| 118 | + eyebrow={t("nav.admin")} | ||
| 119 | + title={t("settings.title")} | ||
| 120 | + description={t("settings.subtitle")} | ||
| 121 | + actions={ | ||
| 122 | + <div class="flex flex-wrap items-center gap-2"> | ||
| 123 | + <Show when={dirty()}> | ||
| 124 | + <span class="text-xs text-muted-foreground">{t("settings.unsaved")}</span> | ||
| 125 | + </Show> | ||
| 126 | + <Show when={saved() && !dirty()}> | ||
| 127 | + <span class="text-xs text-emerald-700 dark:text-emerald-300">{t("settings.saved")}</span> | ||
| 128 | + </Show> | ||
| 129 | + <Button | ||
| 130 | + type="button" | ||
| 131 | + size="sm" | ||
| 132 | + class="min-w-[7.5rem] rounded-lg" | ||
| 133 | + disabled={pending() || !dirty()} | ||
| 134 | + onClick={() => void save()} | ||
| 135 | + > | ||
| 136 | + {t("common.save")} | ||
| 137 | + </Button> | ||
| 138 | + </div> | ||
| 139 | + } | ||
| 140 | + /> | ||
| 82 | </div> | 141 | </div> |
| 83 | 142 | ||
| 84 | - {error() && <Alert variant="destructive">{error()}</Alert>} | 143 | + <Show when={error()}> |
| 85 | - {saved() && <p class="rounded-md bg-emerald-500/10 px-3 py-2 text-sm text-emerald-700 dark:text-emerald-300">{t("settings.saved")}</p>} | 144 | + <Alert variant="destructive">{error()}</Alert> |
| 145 | + </Show> | ||
| 86 | 146 | ||
| 87 | <Suspense fallback={<PageSpinner />}> | 147 | <Suspense fallback={<PageSpinner />}> |
| 88 | <Show when={settings.error}> | 148 | <Show when={settings.error}> |
| 89 | - <Alert variant="destructive">{formatApiError(settings.error)}</Alert> | 149 | + <ErrorAlert message={formatApiError(settings.error)} onRetry={() => void refetch()} /> |
| 90 | </Show> | 150 | </Show> |
| 91 | <Show when={settings()}> | 151 | <Show when={settings()}> |
| 92 | - <div class="grid gap-5 xl:grid-cols-3"> | 152 | + <section class="grid grid-cols-3 gap-3"> |
| 93 | - <section class="data-shell space-y-4 p-4"> | 153 | + <Metric label={t("settings.examKinds")} value={examKinds().length} /> |
| 94 | - <div> | 154 | + <Metric label={t("settings.attendanceStatuses")} value={attendanceStatuses().length} /> |
| 95 | - <h2 class="font-display text-lg font-semibold">{t("settings.examKinds")}</h2> | 155 | + <Metric label={t("settings.gradeBands")} value={gradeBands().length} /> |
| 96 | - <p class="mt-1 text-sm text-muted-foreground">{t("settings.examKindsHelp")}</p> | 156 | + </section> |
| 97 | - </div> | 157 | + |
| 98 | - <div class="space-y-2"> | 158 | + <div class="grid gap-4 xl:grid-cols-3"> |
| 99 | - <For each={examKinds()}> | 159 | + <section class="data-shell flex flex-col overflow-hidden"> |
| 100 | - {(item, index) => ( | 160 | + <header class="border-b border-border/70 px-4 py-3"> |
| 101 | - <div class="grid grid-cols-[minmax(0,1fr)_5rem_2.25rem] gap-2"> | 161 | + <div class="flex items-start justify-between gap-3"> |
| 102 | - <Input | 162 | + <div class="min-w-0"> |
| 103 | - aria-label={t("settings.name")} | 163 | + <h2 class="font-display text-base font-semibold">{t("settings.examKinds")}</h2> |
| 104 | - class="rounded-lg bg-background/80" | 164 | + <p class="mt-0.5 text-xs leading-relaxed text-muted-foreground">{t("settings.examKindsHelp")}</p> |
| 105 | - value={item.name} | 165 | + </div> |
| 106 | - onInput={(e) => setExamKinds((rows) => rows.map((row, i) => (i === index() ? { ...row, name: e.currentTarget.value } : row)))} | 166 | + <Badge variant="secondary" class="mono shrink-0 rounded-sm tabular-nums"> |
| 107 | - /> | 167 | + {examKinds().length} |
| 108 | - <Input | 168 | + </Badge> |
| 109 | - aria-label={t("settings.weight")} | 169 | + </div> |
| 110 | - class="rounded-lg bg-background/80" | 170 | + </header> |
| 111 | - type="number" | 171 | + |
| 112 | - min={1} | 172 | + <div class="flex-1 space-y-2 p-4"> |
| 113 | - max={100} | 173 | + <div class="grid grid-cols-[minmax(0,1fr)_4.5rem_2.25rem] gap-2 px-0.5 text-[11px] font-medium uppercase tracking-wide text-muted-foreground"> |
| 114 | - value={item.weight} | 174 | + <span>{t("settings.name")}</span> |
| 115 | - onInput={(e) => setExamKinds((rows) => rows.map((row, i) => (i === index() ? { ...row, weight: Number(e.currentTarget.value) } : row)))} | 175 | + <span class="text-center">{t("settings.weight")}</span> |
| 116 | - /> | 176 | + <span class="sr-only">{t("common.actions")}</span> |
| 117 | - <Button type="button" variant="ghost" size="icon" class="rounded-lg" onClick={() => setExamKinds((rows) => rows.filter((_, i) => i !== index()))}> | 177 | + </div> |
| 118 | - <IconTrash class="h-4 w-4" /> | 178 | + <Show |
| 119 | - </Button> | 179 | + when={examKinds().length > 0} |
| 120 | - </div> | 180 | + fallback={<EmptyRows label={t("settings.empty")} />} |
| 121 | - )} | 181 | + > |
| 122 | - </For> | 182 | + <For each={examKinds()}> |
| 183 | + {(item, index) => ( | ||
| 184 | + <div class="grid grid-cols-[minmax(0,1fr)_4.5rem_2.25rem] items-center gap-2 rounded-lg border border-border/60 bg-card px-2 py-1.5 shadow-xs"> | ||
| 185 | + <Input | ||
| 186 | + aria-label={t("settings.name")} | ||
| 187 | + class="h-9 rounded-md border-0 bg-transparent shadow-none focus-visible:ring-1" | ||
| 188 | + value={item.name} | ||
| 189 | + placeholder={t("settings.name")} | ||
| 190 | + onInput={(e) => | ||
| 191 | + setExamKinds((rows) => | ||
| 192 | + rows.map((row, i) => (i === index() ? { ...row, name: e.currentTarget.value } : row)), | ||
| 193 | + ) | ||
| 194 | + } | ||
| 195 | + /> | ||
| 196 | + <Input | ||
| 197 | + aria-label={t("settings.weight")} | ||
| 198 | + class="h-9 rounded-md border-0 bg-muted/40 text-center font-mono shadow-none focus-visible:ring-1" | ||
| 199 | + type="number" | ||
| 200 | + min={1} | ||
| 201 | + max={100} | ||
| 202 | + value={item.weight} | ||
| 203 | + onInput={(e) => | ||
| 204 | + setExamKinds((rows) => | ||
| 205 | + rows.map((row, i) => | ||
| 206 | + i === index() ? { ...row, weight: Number(e.currentTarget.value) } : row, | ||
| 207 | + ), | ||
| 208 | + ) | ||
| 209 | + } | ||
| 210 | + /> | ||
| 211 | + <Button | ||
| 212 | + type="button" | ||
| 213 | + variant="ghost" | ||
| 214 | + size="icon" | ||
| 215 | + class="h-9 w-9 rounded-md text-muted-foreground hover:text-destructive" | ||
| 216 | + aria-label={t("common.delete")} | ||
| 217 | + onClick={() => setExamKinds((rows) => rows.filter((_, i) => i !== index()))} | ||
| 218 | + > | ||
| 219 | + <IconTrash class="h-4 w-4" /> | ||
| 220 | + </Button> | ||
| 221 | + </div> | ||
| 222 | + )} | ||
| 223 | + </For> | ||
| 224 | + </Show> | ||
| 123 | </div> | 225 | </div> |
| 124 | - <Button type="button" variant="outline" class="rounded-lg" onClick={() => setExamKinds((rows) => [...rows, { name: "", weight: 1 }])}> | 226 | + |
| 125 | - <IconPlus class="h-4 w-4" /> | 227 | + <footer class="border-t border-border/70 px-4 py-3"> |
| 126 | - {t("settings.addRow")} | 228 | + <Button |
| 127 | - </Button> | 229 | + type="button" |
| 230 | + variant="outline" | ||
| 231 | + size="sm" | ||
| 232 | + class="w-full rounded-lg" | ||
| 233 | + onClick={() => setExamKinds((rows) => [...rows, { name: "", weight: 1 }])} | ||
| 234 | + > | ||
| 235 | + <IconPlus class="h-4 w-4" /> | ||
| 236 | + {t("settings.addRow")} | ||
| 237 | + </Button> | ||
| 238 | + </footer> | ||
| 128 | </section> | 239 | </section> |
| 129 | 240 | ||
| 130 | - <section class="data-shell space-y-4 p-4"> | 241 | + <section class="data-shell flex flex-col overflow-hidden"> |
| 131 | - <div> | 242 | + <header class="border-b border-border/70 px-4 py-3"> |
| 132 | - <h2 class="font-display text-lg font-semibold">{t("settings.attendanceStatuses")}</h2> | 243 | + <div class="flex items-start justify-between gap-3"> |
| 133 | - <p class="mt-1 text-sm text-muted-foreground">{t("settings.attendanceHelp")}</p> | 244 | + <div class="min-w-0"> |
| 134 | - </div> | 245 | + <h2 class="font-display text-base font-semibold">{t("settings.attendanceStatuses")}</h2> |
| 135 | - <div class="space-y-2"> | 246 | + <p class="mt-0.5 text-xs leading-relaxed text-muted-foreground">{t("settings.attendanceHelp")}</p> |
| 136 | - <For each={attendanceStatuses()}> | 247 | + </div> |
| 137 | - {(status, index) => ( | 248 | + <Badge variant="secondary" class="mono shrink-0 rounded-sm tabular-nums"> |
| 138 | - <div class="grid grid-cols-[minmax(0,1fr)_2.25rem] gap-2"> | 249 | + {attendanceStatuses().length} |
| 139 | - <Show | 250 | + </Badge> |
| 140 | - when={isCoreAttendance(status)} | 251 | + </div> |
| 141 | - fallback={ | 252 | + </header> |
| 142 | - <Input | 253 | + |
| 143 | - aria-label={t("settings.status")} | 254 | + <div class="flex-1 space-y-2 p-4"> |
| 144 | - class="rounded-lg bg-background/80" | 255 | + <div class="grid grid-cols-[minmax(0,1fr)_2.25rem] gap-2 px-0.5 text-[11px] font-medium uppercase tracking-wide text-muted-foreground"> |
| 145 | - value={status} | 256 | + <span>{t("settings.status")}</span> |
| 146 | - onInput={(e) => setAttendanceStatuses((rows) => rows.map((row, i) => (i === index() ? e.currentTarget.value : row)))} | 257 | + <span class="sr-only">{t("common.actions")}</span> |
| 147 | - /> | 258 | + </div> |
| 148 | - } | 259 | + <Show |
| 149 | - > | 260 | + when={attendanceStatuses().length > 0} |
| 150 | - <div class="flex h-9 items-center rounded-lg border border-input bg-muted/40 px-3 text-sm text-muted-foreground"> | 261 | + fallback={<EmptyRows label={t("settings.empty")} />} |
| 151 | - {t(CORE_ATTENDANCE_LABELS[status as keyof typeof CORE_ATTENDANCE_LABELS])} | 262 | + > |
| 263 | + <For each={attendanceStatuses()}> | ||
| 264 | + {(status, index) => { | ||
| 265 | + const meta = () => getAttendanceStatusMeta(status); | ||
| 266 | + return ( | ||
| 267 | + <div class="grid grid-cols-[minmax(0,1fr)_2.25rem] items-center gap-2 rounded-lg border border-border/60 bg-card px-2 py-1.5 shadow-xs"> | ||
| 268 | + <Show | ||
| 269 | + when={isCoreAttendance(status)} | ||
| 270 | + fallback={ | ||
| 271 | + <Input | ||
| 272 | + aria-label={t("settings.status")} | ||
| 273 | + class="h-9 rounded-md border-0 bg-transparent shadow-none focus-visible:ring-1" | ||
| 274 | + value={status} | ||
| 275 | + placeholder={t("settings.status")} | ||
| 276 | + onInput={(e) => | ||
| 277 | + setAttendanceStatuses((rows) => | ||
| 278 | + rows.map((row, i) => (i === index() ? e.currentTarget.value : row)), | ||
| 279 | + ) | ||
| 280 | + } | ||
| 281 | + /> | ||
| 282 | + } | ||
| 283 | + > | ||
| 284 | + <div class="flex h-9 items-center gap-2 px-1"> | ||
| 285 | + <span | ||
| 286 | + class={cn( | ||
| 287 | + "inline-flex items-center rounded-full border px-2.5 py-0.5 text-xs font-medium", | ||
| 288 | + meta()?.class ?? "border-border bg-muted text-muted-foreground", | ||
| 289 | + )} | ||
| 290 | + > | ||
| 291 | + {t(CORE_ATTENDANCE_LABELS[status as keyof typeof CORE_ATTENDANCE_LABELS])} | ||
| 292 | + </span> | ||
| 293 | + <span class="text-[10px] font-medium uppercase tracking-wide text-muted-foreground"> | ||
| 294 | + {t("settings.locked")} | ||
| 295 | + </span> | ||
| 296 | + </div> | ||
| 297 | + </Show> | ||
| 298 | + <Button | ||
| 299 | + type="button" | ||
| 300 | + variant="ghost" | ||
| 301 | + size="icon" | ||
| 302 | + class="h-9 w-9 rounded-md text-muted-foreground hover:text-destructive disabled:opacity-30" | ||
| 303 | + aria-label={t("common.delete")} | ||
| 304 | + disabled={CORE_ATTENDANCE.has(status)} | ||
| 305 | + onClick={() => setAttendanceStatuses((rows) => rows.filter((_, i) => i !== index()))} | ||
| 306 | + > | ||
| 307 | + <IconTrash class="h-4 w-4" /> | ||
| 308 | + </Button> | ||
| 152 | </div> | 309 | </div> |
| 153 | - </Show> | 310 | + ); |
| 154 | - <Button | 311 | + }} |
| 155 | - type="button" | 312 | + </For> |
| 156 | - variant="ghost" | 313 | + </Show> |
| 157 | - size="icon" | ||
| 158 | - class="rounded-lg" | ||
| 159 | - disabled={CORE_ATTENDANCE.has(status)} | ||
| 160 | - onClick={() => setAttendanceStatuses((rows) => rows.filter((_, i) => i !== index()))} | ||
| 161 | - > | ||
| 162 | - <IconTrash class="h-4 w-4" /> | ||
| 163 | - </Button> | ||
| 164 | - </div> | ||
| 165 | - )} | ||
| 166 | - </For> | ||
| 167 | </div> | 314 | </div> |
| 168 | - <Button type="button" variant="outline" class="rounded-lg" onClick={() => setAttendanceStatuses((rows) => [...rows, ""])}> | 315 | + |
| 169 | - <IconPlus class="h-4 w-4" /> | 316 | + <footer class="border-t border-border/70 px-4 py-3"> |
| 170 | - {t("settings.addRow")} | 317 | + <Button |
| 171 | - </Button> | 318 | + type="button" |
| 319 | + variant="outline" | ||
| 320 | + size="sm" | ||
| 321 | + class="w-full rounded-lg" | ||
| 322 | + onClick={() => setAttendanceStatuses((rows) => [...rows, ""])} | ||
| 323 | + > | ||
| 324 | + <IconPlus class="h-4 w-4" /> | ||
| 325 | + {t("settings.addRow")} | ||
| 326 | + </Button> | ||
| 327 | + </footer> | ||
| 172 | </section> | 328 | </section> |
| 173 | 329 | ||
| 174 | - <section class="data-shell space-y-4 p-4"> | 330 | + <section class="data-shell flex flex-col overflow-hidden"> |
| 175 | - <div> | 331 | + <header class="border-b border-border/70 px-4 py-3"> |
| 176 | - <h2 class="font-display text-lg font-semibold">{t("settings.gradeBands")}</h2> | 332 | + <div class="flex items-start justify-between gap-3"> |
| 177 | - <p class="mt-1 text-sm text-muted-foreground">{t("settings.gradeBandsHelp")}</p> | 333 | + <div class="min-w-0"> |
| 178 | - </div> | 334 | + <h2 class="font-display text-base font-semibold">{t("settings.gradeBands")}</h2> |
| 179 | - <div class="space-y-2"> | 335 | + <p class="mt-0.5 text-xs leading-relaxed text-muted-foreground">{t("settings.gradeBandsHelp")}</p> |
| 180 | - <For each={gradeBands()}> | 336 | + </div> |
| 181 | - {(band, index) => ( | 337 | + <Badge variant="secondary" class="mono shrink-0 rounded-sm tabular-nums"> |
| 182 | - <div class="grid grid-cols-[5rem_minmax(0,1fr)_2.25rem] gap-2"> | 338 | + {gradeBands().length} |
| 183 | - <Input | 339 | + </Badge> |
| 184 | - aria-label={t("settings.min")} | 340 | + </div> |
| 185 | - class="rounded-lg bg-background/80" | 341 | + </header> |
| 186 | - type="number" | 342 | + |
| 187 | - min={0} | 343 | + <div class="flex-1 space-y-2 p-4"> |
| 188 | - max={100} | 344 | + <div class="grid grid-cols-[4.5rem_minmax(0,1fr)_2.25rem] gap-2 px-0.5 text-[11px] font-medium uppercase tracking-wide text-muted-foreground"> |
| 189 | - value={band.min} | 345 | + <span>{t("settings.min")}</span> |
| 190 | - onInput={(e) => setGradeBands((rows) => rows.map((row, i) => (i === index() ? { ...row, min: Number(e.currentTarget.value) } : row)))} | 346 | + <span>{t("settings.label")}</span> |
| 191 | - /> | 347 | + <span class="sr-only">{t("common.actions")}</span> |
| 192 | - <Input | 348 | + </div> |
| 193 | - aria-label={t("settings.label")} | 349 | + <Show when={gradeBands().length > 0} fallback={<EmptyRows label={t("settings.empty")} />}> |
| 194 | - class="rounded-lg bg-background/80" | 350 | + <For each={gradeBands()}> |
| 195 | - value={band.label} | 351 | + {(band, index) => ( |
| 196 | - onInput={(e) => setGradeBands((rows) => rows.map((row, i) => (i === index() ? { ...row, label: e.currentTarget.value } : row)))} | 352 | + <div class="grid grid-cols-[4.5rem_minmax(0,1fr)_2.25rem] items-center gap-2 rounded-lg border border-border/60 bg-card px-2 py-1.5 shadow-xs"> |
| 197 | - /> | 353 | + <Input |
| 198 | - <Button type="button" variant="ghost" size="icon" class="rounded-lg" onClick={() => setGradeBands((rows) => rows.filter((_, i) => i !== index()))}> | 354 | + aria-label={t("settings.min")} |
| 199 | - <IconTrash class="h-4 w-4" /> | 355 | + class="h-9 rounded-md border-0 bg-muted/40 text-center font-mono shadow-none focus-visible:ring-1" |
| 200 | - </Button> | 356 | + type="number" |
| 201 | - </div> | 357 | + min={0} |
| 202 | - )} | 358 | + max={100} |
| 203 | - </For> | 359 | + value={band.min} |
| 360 | + onInput={(e) => | ||
| 361 | + setGradeBands((rows) => | ||
| 362 | + rows.map((row, i) => | ||
| 363 | + i === index() ? { ...row, min: Number(e.currentTarget.value) } : row, | ||
| 364 | + ), | ||
| 365 | + ) | ||
| 366 | + } | ||
| 367 | + /> | ||
| 368 | + <Input | ||
| 369 | + aria-label={t("settings.label")} | ||
| 370 | + class="h-9 rounded-md border-0 bg-transparent shadow-none focus-visible:ring-1" | ||
| 371 | + value={band.label} | ||
| 372 | + placeholder={t("settings.label")} | ||
| 373 | + onInput={(e) => | ||
| 374 | + setGradeBands((rows) => | ||
| 375 | + rows.map((row, i) => | ||
| 376 | + i === index() ? { ...row, label: e.currentTarget.value } : row, | ||
| 377 | + ), | ||
| 378 | + ) | ||
| 379 | + } | ||
| 380 | + /> | ||
| 381 | + <Button | ||
| 382 | + type="button" | ||
| 383 | + variant="ghost" | ||
| 384 | + size="icon" | ||
| 385 | + class="h-9 w-9 rounded-md text-muted-foreground hover:text-destructive" | ||
| 386 | + aria-label={t("common.delete")} | ||
| 387 | + onClick={() => setGradeBands((rows) => rows.filter((_, i) => i !== index()))} | ||
| 388 | + > | ||
| 389 | + <IconTrash class="h-4 w-4" /> | ||
| 390 | + </Button> | ||
| 391 | + </div> | ||
| 392 | + )} | ||
| 393 | + </For> | ||
| 394 | + </Show> | ||
| 204 | </div> | 395 | </div> |
| 205 | - <Button type="button" variant="outline" class="rounded-lg" onClick={() => setGradeBands((rows) => [...rows, { min: 0, label: "" }])}> | ||
| 206 | - <IconPlus class="h-4 w-4" /> | ||
| 207 | - {t("settings.addRow")} | ||
| 208 | - </Button> | ||
| 209 | - </section> | ||
| 210 | - </div> | ||
| 211 | 396 | ||
| 212 | - <div class="flex justify-end"> | 397 | + <footer class="border-t border-border/70 px-4 py-3"> |
| 213 | - <Button type="button" class="rounded-lg" disabled={pending()} onClick={() => void save()}> | 398 | + <Button |
| 214 | - {t("common.save")} | 399 | + type="button" |
| 215 | - </Button> | 400 | + variant="outline" |
| 401 | + size="sm" | ||
| 402 | + class="w-full rounded-lg" | ||
| 403 | + onClick={() => setGradeBands((rows) => [...rows, { min: 0, label: "" }])} | ||
| 404 | + > | ||
| 405 | + <IconPlus class="h-4 w-4" /> | ||
| 406 | + {t("settings.addRow")} | ||
| 407 | + </Button> | ||
| 408 | + </footer> | ||
| 409 | + </section> | ||
| 216 | </div> | 410 | </div> |
| 217 | </Show> | 411 | </Show> |
| 218 | </Suspense> | 412 | </Suspense> |
| 219 | </div> | 413 | </div> |
| 220 | ); | 414 | ); |
| 221 | } | 415 | } |
| 416 | + | ||
| 417 | +function Metric(props: { label: string; value: number }) { | ||
| 418 | + return ( | ||
| 419 | + <div class="rounded-xl border border-border/60 bg-card px-3 py-3 shadow-xs"> | ||
| 420 | + <p class="truncate text-[11px] font-medium uppercase tracking-wide text-muted-foreground">{props.label}</p> | ||
| 421 | + <p class="mt-1 font-display text-xl font-semibold tabular-nums tracking-tight">{props.value}</p> | ||
| 422 | + </div> | ||
| 423 | + ); | ||
| 424 | +} | ||
| 425 | + | ||
| 426 | +function EmptyRows(props: { label: string }) { | ||
| 427 | + return ( | ||
| 428 | + <div class="rounded-lg border border-dashed border-border/80 bg-muted/15 px-3 py-8 text-center text-xs text-muted-foreground"> | ||
| 429 | + {props.label} | ||
| 430 | + </div> | ||
| 431 | + ); | ||
| 432 | +} | ||
src/pages/student-attendance-page.tsxmodified+12 -5
| @@ -1,12 +1,15 @@ | |||
| 1 | import { Show, Suspense, createResource, createSignal } from "solid-js"; | 1 | import { Show, Suspense, createResource, createSignal } from "solid-js"; |
| 2 | import { getUserAttendance } from "@/api/getUserAttendance"; | 2 | import { getUserAttendance } from "@/api/getUserAttendance"; |
| 3 | import { formatApiError } from "@/api/client"; | 3 | import { formatApiError } from "@/api/client"; |
| 4 | +import type { PersonRef } from "@/api/types"; | ||
| 4 | import { AttendanceReportView } from "@/components/attendance/attendance-report-view"; | 5 | import { AttendanceReportView } from "@/components/attendance/attendance-report-view"; |
| 5 | import { RouteGuard } from "@/components/layout/route-guard"; | 6 | import { RouteGuard } from "@/components/layout/route-guard"; |
| 6 | import { PageHeader } from "@/components/layout/page-header"; | 7 | import { PageHeader } from "@/components/layout/page-header"; |
| 7 | import { UserSearchSelect } from "@/components/users/user-search-select"; | 8 | import { UserSearchSelect } from "@/components/users/user-search-select"; |
| 8 | import { Button } from "@/components/ui/button"; | 9 | import { Button } from "@/components/ui/button"; |
| 10 | +import { ErrorAlert } from "@/components/ui/error-alert"; | ||
| 9 | import { PageSpinner } from "@/components/ui/page-spinner"; | 11 | import { PageSpinner } from "@/components/ui/page-spinner"; |
| 12 | +import { personLabel } from "@/lib/person"; | ||
| 10 | import { useT } from "@/stores/preferences-context"; | 13 | import { useT } from "@/stores/preferences-context"; |
| 11 | 14 | ||
| 12 | export default function StudentAttendancePage() { | 15 | export default function StudentAttendancePage() { |
| @@ -20,8 +23,10 @@ export default function StudentAttendancePage() { | |||
| 20 | function StudentAttendanceContent() { | 23 | function StudentAttendanceContent() { |
| 21 | const t = useT(); | 24 | const t = useT(); |
| 22 | const [userId, setUserId] = createSignal(""); | 25 | const [userId, setUserId] = createSignal(""); |
| 26 | + const [selectedUser, setSelectedUser] = createSignal<PersonRef | null>(null); | ||
| 23 | const [lookupId, setLookupId] = createSignal<string | null>(null); | 27 | const [lookupId, setLookupId] = createSignal<string | null>(null); |
| 24 | - const [report] = createResource(lookupId, async (id) => { | 28 | + const [lookupLabel, setLookupLabel] = createSignal(""); |
| 29 | + const [report, { refetch }] = createResource(lookupId, async (id) => { | ||
| 25 | if (!id) return null; | 30 | if (!id) return null; |
| 26 | return getUserAttendance(id); | 31 | return getUserAttendance(id); |
| 27 | }); | 32 | }); |
| @@ -42,6 +47,7 @@ function StudentAttendanceContent() { | |||
| 42 | const id = userId().trim(); | 47 | const id = userId().trim(); |
| 43 | if (!id) return; | 48 | if (!id) return; |
| 44 | setLookupId(id); | 49 | setLookupId(id); |
| 50 | + setLookupLabel(personLabel(selectedUser()) === "—" ? id : personLabel(selectedUser())); | ||
| 45 | }} | 51 | }} |
| 46 | > | 52 | > |
| 47 | <UserSearchSelect | 53 | <UserSearchSelect |
| @@ -49,17 +55,18 @@ function StudentAttendanceContent() { | |||
| 49 | label={t("marks.userIdentity")} | 55 | label={t("marks.userIdentity")} |
| 50 | value={userId()} | 56 | value={userId()} |
| 51 | onChange={setUserId} | 57 | onChange={setUserId} |
| 58 | + onSelectUser={setSelectedUser} | ||
| 52 | placeholder={t("common.searchPlaceholder")} | 59 | placeholder={t("common.searchPlaceholder")} |
| 53 | selectPlaceholder={t("marks.userIdentity")} | 60 | selectPlaceholder={t("marks.userIdentity")} |
| 54 | - emptyMessage={t("admin.noUsers")} | 61 | + emptyMessage={t("form.noStudents")} |
| 55 | allowManualValue | 62 | allowManualValue |
| 56 | role="student" | 63 | role="student" |
| 57 | /> | 64 | /> |
| 58 | - <Button type="submit" class="h-9 w-full rounded-sm sm:w-auto">{t("attendance.show")}</Button> | 65 | + <Button type="submit" class="h-9 w-full rounded-lg sm:w-auto">{t("attendance.show")}</Button> |
| 59 | </form> | 66 | </form> |
| 60 | 67 | ||
| 61 | <Show when={report.error}> | 68 | <Show when={report.error}> |
| 62 | - <p class="rounded-md bg-destructive/10 px-3 py-2 text-sm text-destructive">{formatApiError(report.error)}</p> | 69 | + <ErrorAlert message={formatApiError(report.error)} onRetry={() => void refetch()} /> |
| 63 | </Show> | 70 | </Show> |
| 64 | </section> | 71 | </section> |
| 65 | 72 | ||
| @@ -68,7 +75,7 @@ function StudentAttendanceContent() { | |||
| 68 | {(r) => ( | 75 | {(r) => ( |
| 69 | <div class="space-y-4"> | 76 | <div class="space-y-4"> |
| 70 | <p class="data-shell px-4 py-3 text-sm text-muted-foreground"> | 77 | <p class="data-shell px-4 py-3 text-sm text-muted-foreground"> |
| 71 | - {t("attendance.forUser", { user: lookupId() ?? "" })} | 78 | + {t("attendance.forUser", { user: lookupLabel() || lookupId() || "" })} |
| 72 | </p> | 79 | </p> |
| 73 | <AttendanceReportView report={r()} /> | 80 | <AttendanceReportView report={r()} /> |
| 74 | </div> | 81 | </div> |
src/pages/student-marks-page.tsxmodified+12 -7
| @@ -1,12 +1,15 @@ | |||
| 1 | import { Show, Suspense, createResource, createSignal } from "solid-js"; | 1 | import { Show, Suspense, createResource, createSignal } from "solid-js"; |
| 2 | import { getUserMarks } from "@/api/getUserMarks"; | 2 | import { getUserMarks } from "@/api/getUserMarks"; |
| 3 | import { formatApiError } from "@/api/client"; | 3 | import { formatApiError } from "@/api/client"; |
| 4 | +import type { PersonRef } from "@/api/types"; | ||
| 4 | import { MarksReportView } from "@/components/marks/marks-report-view"; | 5 | import { MarksReportView } from "@/components/marks/marks-report-view"; |
| 5 | import { RouteGuard } from "@/components/layout/route-guard"; | 6 | import { RouteGuard } from "@/components/layout/route-guard"; |
| 6 | import { PageHeader } from "@/components/layout/page-header"; | 7 | import { PageHeader } from "@/components/layout/page-header"; |
| 7 | import { UserSearchSelect } from "@/components/users/user-search-select"; | 8 | import { UserSearchSelect } from "@/components/users/user-search-select"; |
| 8 | import { Button } from "@/components/ui/button"; | 9 | import { Button } from "@/components/ui/button"; |
| 10 | +import { ErrorAlert } from "@/components/ui/error-alert"; | ||
| 9 | import { PageSpinner } from "@/components/ui/page-spinner"; | 11 | import { PageSpinner } from "@/components/ui/page-spinner"; |
| 12 | +import { personLabel } from "@/lib/person"; | ||
| 10 | import { useT } from "@/stores/preferences-context"; | 13 | import { useT } from "@/stores/preferences-context"; |
| 11 | 14 | ||
| 12 | export default function StudentMarksPage() { | 15 | export default function StudentMarksPage() { |
| @@ -20,8 +23,10 @@ export default function StudentMarksPage() { | |||
| 20 | function StudentMarksContent() { | 23 | function StudentMarksContent() { |
| 21 | const t = useT(); | 24 | const t = useT(); |
| 22 | const [userId, setUserId] = createSignal(""); | 25 | const [userId, setUserId] = createSignal(""); |
| 26 | + const [selectedUser, setSelectedUser] = createSignal<PersonRef | null>(null); | ||
| 23 | const [lookupId, setLookupId] = createSignal<string | null>(null); | 27 | const [lookupId, setLookupId] = createSignal<string | null>(null); |
| 24 | - const [report] = createResource(lookupId, async (id) => { | 28 | + const [lookupLabel, setLookupLabel] = createSignal(""); |
| 29 | + const [report, { refetch }] = createResource(lookupId, async (id) => { | ||
| 25 | if (!id) return null; | 30 | if (!id) return null; |
| 26 | return getUserMarks(id); | 31 | return getUserMarks(id); |
| 27 | }); | 32 | }); |
| @@ -47,6 +52,7 @@ function StudentMarksContent() { | |||
| 47 | const id = userId().trim(); | 52 | const id = userId().trim(); |
| 48 | if (!id) return; | 53 | if (!id) return; |
| 49 | setLookupId(id); | 54 | setLookupId(id); |
| 55 | + setLookupLabel(personLabel(selectedUser()) === "—" ? id : personLabel(selectedUser())); | ||
| 50 | }} | 56 | }} |
| 51 | > | 57 | > |
| 52 | <UserSearchSelect | 58 | <UserSearchSelect |
| @@ -54,19 +60,18 @@ function StudentMarksContent() { | |||
| 54 | label={t("marks.userIdentity")} | 60 | label={t("marks.userIdentity")} |
| 55 | value={userId()} | 61 | value={userId()} |
| 56 | onChange={setUserId} | 62 | onChange={setUserId} |
| 63 | + onSelectUser={setSelectedUser} | ||
| 57 | placeholder={t("common.searchPlaceholder")} | 64 | placeholder={t("common.searchPlaceholder")} |
| 58 | selectPlaceholder={t("marks.userIdentity")} | 65 | selectPlaceholder={t("marks.userIdentity")} |
| 59 | - emptyMessage={t("admin.noUsers")} | 66 | + emptyMessage={t("form.noStudents")} |
| 60 | allowManualValue | 67 | allowManualValue |
| 61 | role="student" | 68 | role="student" |
| 62 | /> | 69 | /> |
| 63 | - <Button type="submit" class="h-9 w-full rounded-sm sm:w-auto">{t("marks.show")}</Button> | 70 | + <Button type="submit" class="h-9 w-full rounded-lg sm:w-auto">{t("marks.show")}</Button> |
| 64 | </form> | 71 | </form> |
| 65 | 72 | ||
| 66 | <Show when={report.error}> | 73 | <Show when={report.error}> |
| 67 | - <p class="rounded-md bg-destructive/10 px-3 py-2 text-sm text-destructive"> | 74 | + <ErrorAlert message={formatApiError(report.error)} onRetry={() => void refetch()} /> |
| 68 | - {formatApiError(report.error)} | ||
| 69 | - </p> | ||
| 70 | </Show> | 75 | </Show> |
| 71 | </section> | 76 | </section> |
| 72 | 77 | ||
| @@ -75,7 +80,7 @@ function StudentMarksContent() { | |||
| 75 | {(r) => ( | 80 | {(r) => ( |
| 76 | <div class="space-y-4"> | 81 | <div class="space-y-4"> |
| 77 | <p class="data-shell px-4 py-3 text-sm text-muted-foreground"> | 82 | <p class="data-shell px-4 py-3 text-sm text-muted-foreground"> |
| 78 | - {t("marks.forUser", { user: lookupId() ?? "" })} | 83 | + {t("marks.forUser", { user: lookupLabel() || lookupId() || "" })} |
| 79 | </p> | 84 | </p> |
| 80 | <MarksReportView report={r()} /> | 85 | <MarksReportView report={r()} /> |
| 81 | </div> | 86 | </div> |
src/pages/terms-page.tsxmodified+112 -62
| @@ -1,5 +1,4 @@ | |||
| 1 | -import { For, Show, Suspense, createSignal } from "solid-js"; | 1 | +import { For, Show, Suspense, createResource, createSignal } from "solid-js"; |
| 2 | -import { createResource } from "solid-js"; | ||
| 3 | import { deleteTermById } from "@/api/deleteTermById"; | 2 | import { deleteTermById } from "@/api/deleteTermById"; |
| 4 | import { getTerms } from "@/api/getTerms"; | 3 | import { getTerms } from "@/api/getTerms"; |
| 5 | import { patchTermById } from "@/api/patchTermById"; | 4 | import { patchTermById } from "@/api/patchTermById"; |
| @@ -11,11 +10,15 @@ import { PageHeader } from "@/components/layout/page-header"; | |||
| 11 | import { Alert } from "@/components/ui/alert"; | 10 | import { Alert } from "@/components/ui/alert"; |
| 12 | import { Button } from "@/components/ui/button"; | 11 | import { Button } from "@/components/ui/button"; |
| 13 | import { ConfirmDialog } from "@/components/ui/confirm-dialog"; | 12 | import { ConfirmDialog } from "@/components/ui/confirm-dialog"; |
| 13 | +import { DataTableEmpty, DataTableFrame, DataTableSkeleton } from "@/components/ui/data-table"; | ||
| 14 | import { DatePicker } from "@/components/ui/date-picker"; | 14 | import { DatePicker } from "@/components/ui/date-picker"; |
| 15 | -import { IconEdit, IconTrash } from "@/components/ui/icons"; | 15 | +import { ErrorAlert } from "@/components/ui/error-alert"; |
| 16 | +import { IconEdit, IconPlus, IconTrash } from "@/components/ui/icons"; | ||
| 16 | import { Input } from "@/components/ui/input"; | 17 | import { Input } from "@/components/ui/input"; |
| 17 | import { Label } from "@/components/ui/label"; | 18 | import { Label } from "@/components/ui/label"; |
| 18 | -import { PageSpinner } from "@/components/ui/page-spinner"; | 19 | +import { SidePanel } from "@/components/ui/side-panel"; |
| 20 | +import { Table, TableBody, TableCell, TableHead, TableHeader, TableRow } from "@/components/ui/table"; | ||
| 21 | +import { TableRowActions } from "@/components/ui/table-row-actions"; | ||
| 19 | import { formatDateTime } from "@/lib/format"; | 22 | import { formatDateTime } from "@/lib/format"; |
| 20 | import { usePreferences, useT } from "@/stores/preferences-context"; | 23 | import { usePreferences, useT } from "@/stores/preferences-context"; |
| 21 | 24 | ||
| @@ -49,6 +52,7 @@ function TermsContent() { | |||
| 49 | const t = useT(); | 52 | const t = useT(); |
| 50 | const { locale } = usePreferences(); | 53 | const { locale } = usePreferences(); |
| 51 | const [terms, { refetch }] = createResource(() => getTerms()); | 54 | const [terms, { refetch }] = createResource(() => getTerms()); |
| 55 | + const [panelOpen, setPanelOpen] = createSignal(false); | ||
| 52 | const [name, setName] = createSignal(""); | 56 | const [name, setName] = createSignal(""); |
| 53 | const [starts, setStarts] = createSignal(""); | 57 | const [starts, setStarts] = createSignal(""); |
| 54 | const [ends, setEnds] = createSignal(""); | 58 | const [ends, setEnds] = createSignal(""); |
| @@ -62,6 +66,12 @@ function TermsContent() { | |||
| 62 | setStarts(""); | 66 | setStarts(""); |
| 63 | setEnds(""); | 67 | setEnds(""); |
| 64 | setEditing(null); | 68 | setEditing(null); |
| 69 | + setError(""); | ||
| 70 | + }; | ||
| 71 | + | ||
| 72 | + const openCreate = () => { | ||
| 73 | + resetForm(); | ||
| 74 | + setPanelOpen(true); | ||
| 65 | }; | 75 | }; |
| 66 | 76 | ||
| 67 | const startEdit = (term: Term) => { | 77 | const startEdit = (term: Term) => { |
| @@ -69,6 +79,8 @@ function TermsContent() { | |||
| 69 | setStarts(dateInputFromMs(term.starts_at)); | 79 | setStarts(dateInputFromMs(term.starts_at)); |
| 70 | setEnds(dateInputFromMs(term.ends_at)); | 80 | setEnds(dateInputFromMs(term.ends_at)); |
| 71 | setEditing(term); | 81 | setEditing(term); |
| 82 | + setError(""); | ||
| 83 | + setPanelOpen(true); | ||
| 72 | }; | 84 | }; |
| 73 | 85 | ||
| 74 | const save = async (e: SubmitEvent) => { | 86 | const save = async (e: SubmitEvent) => { |
| @@ -93,6 +105,7 @@ function TermsContent() { | |||
| 93 | await postTerm({ name: name().trim(), starts_at, ends_at }); | 105 | await postTerm({ name: name().trim(), starts_at, ends_at }); |
| 94 | } | 106 | } |
| 95 | resetForm(); | 107 | resetForm(); |
| 108 | + setPanelOpen(false); | ||
| 96 | await refetch(); | 109 | await refetch(); |
| 97 | } catch (err) { | 110 | } catch (err) { |
| 98 | setError(formatApiError(err)); | 111 | setError(formatApiError(err)); |
| @@ -109,73 +122,110 @@ function TermsContent() { | |||
| 109 | <span>/</span> | 122 | <span>/</span> |
| 110 | <span>{t("terms.title")}</span> | 123 | <span>{t("terms.title")}</span> |
| 111 | </div> | 124 | </div> |
| 112 | - <PageHeader accent="violet" eyebrow={t("nav.admin")} title={t("terms.title")} description={t("terms.subtitle")} /> | 125 | + <PageHeader |
| 126 | + accent="violet" | ||
| 127 | + eyebrow={t("nav.admin")} | ||
| 128 | + title={t("terms.title")} | ||
| 129 | + description={t("terms.subtitle")} | ||
| 130 | + actions={ | ||
| 131 | + <Button type="button" size="sm" class="min-w-[7.5rem] rounded-lg" onClick={openCreate}> | ||
| 132 | + <IconPlus class="h-4 w-4" /> | ||
| 133 | + {t("terms.create")} | ||
| 134 | + </Button> | ||
| 135 | + } | ||
| 136 | + /> | ||
| 113 | </div> | 137 | </div> |
| 114 | 138 | ||
| 115 | - {error() && <Alert variant="destructive">{error()}</Alert>} | 139 | + <Show when={error() && !panelOpen()}> |
| 140 | + <Alert variant="destructive">{error()}</Alert> | ||
| 141 | + </Show> | ||
| 116 | 142 | ||
| 117 | <section class="data-shell space-y-4 p-4"> | 143 | <section class="data-shell space-y-4 p-4"> |
| 118 | - <h2 class="font-display text-lg font-semibold">{editing() ? t("terms.edit") : t("terms.create")}</h2> | 144 | + <Suspense fallback={<DataTableSkeleton columns={4} rows={6} />}> |
| 119 | - <form class="space-y-5" onSubmit={save}> | 145 | + <Show when={terms.error}> |
| 120 | - <div class="grid gap-3 md:grid-cols-[minmax(0,1fr)_12rem_12rem]"> | 146 | + <ErrorAlert message={formatApiError(terms.error)} onRetry={() => void refetch()} /> |
| 121 | - <div class="space-y-1.5 rounded-xl border border-border/80 bg-card p-4 shadow-sm"> | 147 | + </Show> |
| 122 | - <Label for="term-name">{t("settings.name")}</Label> | 148 | + <Show when={(terms() ?? []).length > 0} fallback={<DataTableEmpty>{t("terms.empty")}</DataTableEmpty>}> |
| 123 | - <Input id="term-name" class="rounded-lg bg-background/80" required maxlength={100} value={name()} onInput={(e) => setName(e.currentTarget.value)} /> | 149 | + <DataTableFrame> |
| 124 | - </div> | 150 | + <Table class="data-table min-w-[40rem]"> |
| 125 | - <div class="space-y-1.5 rounded-xl border border-border/80 bg-card p-4 shadow-sm"> | 151 | + <TableHeader> |
| 126 | - <Label for="term-starts">{t("events.starts")}</Label> | 152 | + <TableRow> |
| 127 | - <DatePicker id="term-starts" placeholder={t("form.datePlaceholder")} required value={starts()} onChange={setStarts} /> | 153 | + <TableHead>{t("settings.name")}</TableHead> |
| 128 | - </div> | 154 | + <TableHead>{t("events.starts")}</TableHead> |
| 129 | - <div class="space-y-1.5 rounded-xl border border-border/80 bg-card p-4 shadow-sm"> | 155 | + <TableHead>{t("events.ends")}</TableHead> |
| 130 | - <Label for="term-ends">{t("events.ends")}</Label> | 156 | + <TableHead class="w-14 text-center">{t("common.actions")}</TableHead> |
| 131 | - <DatePicker id="term-ends" placeholder={t("form.datePlaceholder")} required value={ends()} onChange={setEnds} /> | 157 | + </TableRow> |
| 132 | - </div> | 158 | + </TableHeader> |
| 159 | + <TableBody> | ||
| 160 | + <For each={terms() ?? []}> | ||
| 161 | + {(term) => ( | ||
| 162 | + <TableRow> | ||
| 163 | + <TableCell class="font-medium">{term.name}</TableCell> | ||
| 164 | + <TableCell class="mono text-sm">{formatDateTime(term.starts_at, locale())}</TableCell> | ||
| 165 | + <TableCell class="mono text-sm">{formatDateTime(term.ends_at, locale())}</TableCell> | ||
| 166 | + <TableCell> | ||
| 167 | + <TableRowActions | ||
| 168 | + label={t("common.actions")} | ||
| 169 | + actions={[ | ||
| 170 | + { | ||
| 171 | + label: t("common.edit"), | ||
| 172 | + icon: <IconEdit class="h-4 w-4" />, | ||
| 173 | + onSelect: () => startEdit(term), | ||
| 174 | + }, | ||
| 175 | + { | ||
| 176 | + label: t("common.delete"), | ||
| 177 | + icon: <IconTrash class="h-4 w-4" />, | ||
| 178 | + destructive: true, | ||
| 179 | + onSelect: () => setDeleteTarget(term), | ||
| 180 | + }, | ||
| 181 | + ]} | ||
| 182 | + /> | ||
| 183 | + </TableCell> | ||
| 184 | + </TableRow> | ||
| 185 | + )} | ||
| 186 | + </For> | ||
| 187 | + </TableBody> | ||
| 188 | + </Table> | ||
| 189 | + </DataTableFrame> | ||
| 190 | + </Show> | ||
| 191 | + </Suspense> | ||
| 192 | + </section> | ||
| 193 | + | ||
| 194 | + <SidePanel | ||
| 195 | + open={panelOpen()} | ||
| 196 | + onOpenChange={(open) => { | ||
| 197 | + setPanelOpen(open); | ||
| 198 | + if (!open) resetForm(); | ||
| 199 | + }} | ||
| 200 | + title={editing() ? t("terms.edit") : t("terms.create")} | ||
| 201 | + description={t("terms.subtitle")} | ||
| 202 | + > | ||
| 203 | + <form class="space-y-4" onSubmit={save}> | ||
| 204 | + <Show when={error()}> | ||
| 205 | + <Alert variant="destructive">{error()}</Alert> | ||
| 206 | + </Show> | ||
| 207 | + <div class="space-y-1.5"> | ||
| 208 | + <Label for="term-name">{t("settings.name")}</Label> | ||
| 209 | + <Input id="term-name" class="rounded-lg" required maxlength={100} value={name()} onInput={(e) => setName(e.currentTarget.value)} /> | ||
| 210 | + </div> | ||
| 211 | + <div class="space-y-1.5"> | ||
| 212 | + <Label for="term-starts">{t("events.starts")}</Label> | ||
| 213 | + <DatePicker id="term-starts" placeholder={t("form.datePlaceholder")} required value={starts()} onChange={setStarts} /> | ||
| 214 | + </div> | ||
| 215 | + <div class="space-y-1.5"> | ||
| 216 | + <Label for="term-ends">{t("events.ends")}</Label> | ||
| 217 | + <DatePicker id="term-ends" placeholder={t("form.datePlaceholder")} required value={ends()} onChange={setEnds} /> | ||
| 133 | </div> | 218 | </div> |
| 134 | - <div class="flex flex-wrap items-center justify-end gap-2 border-t border-border/80 pt-4"> | 219 | + <div class="flex flex-wrap items-center gap-2"> |
| 135 | - <Show when={editing()}> | 220 | + <Button type="button" variant="outline" class="h-10 rounded-lg" onClick={() => setPanelOpen(false)}> |
| 136 | - <Button type="button" variant="outline" class="rounded-lg" onClick={resetForm}>{t("common.cancel")}</Button> | 221 | + {t("common.cancel")} |
| 137 | - </Show> | 222 | + </Button> |
| 138 | - <Button type="submit" class="rounded-lg" disabled={pending()}> | 223 | + <Button type="submit" class="h-10 rounded-lg" disabled={pending()}> |
| 139 | {editing() ? t("common.update") : t("common.create")} | 224 | {editing() ? t("common.update") : t("common.create")} |
| 140 | </Button> | 225 | </Button> |
| 141 | </div> | 226 | </div> |
| 142 | </form> | 227 | </form> |
| 143 | - </section> | 228 | + </SidePanel> |
| 144 | - | ||
| 145 | - <Suspense fallback={<PageSpinner />}> | ||
| 146 | - <Show when={terms.error}> | ||
| 147 | - <Alert variant="destructive">{formatApiError(terms.error)}</Alert> | ||
| 148 | - </Show> | ||
| 149 | - <Show | ||
| 150 | - when={(terms() ?? []).length > 0} | ||
| 151 | - fallback={<div class="rounded-md border border-dashed px-6 py-16 text-center text-sm text-muted-foreground">{t("terms.empty")}</div>} | ||
| 152 | - > | ||
| 153 | - <section class="grid gap-3 md:grid-cols-2 xl:grid-cols-3"> | ||
| 154 | - <For each={terms() ?? []}> | ||
| 155 | - {(term) => ( | ||
| 156 | - <article class="data-shell space-y-3 p-4"> | ||
| 157 | - <div> | ||
| 158 | - <h3 class="font-display text-lg font-semibold">{term.name}</h3> | ||
| 159 | - <p class="mono mt-1 text-sm text-muted-foreground"> | ||
| 160 | - {formatDateTime(term.starts_at, locale())} - {formatDateTime(term.ends_at, locale())} | ||
| 161 | - </p> | ||
| 162 | - </div> | ||
| 163 | - <div class="flex gap-2"> | ||
| 164 | - <Button type="button" variant="outline" size="sm" class="rounded-lg" onClick={() => startEdit(term)}> | ||
| 165 | - <IconEdit class="h-4 w-4" /> | ||
| 166 | - {t("common.edit")} | ||
| 167 | - </Button> | ||
| 168 | - <Button type="button" variant="ghost" size="sm" class="rounded-lg text-destructive hover:text-destructive" onClick={() => setDeleteTarget(term)}> | ||
| 169 | - <IconTrash class="h-4 w-4" /> | ||
| 170 | - {t("common.delete")} | ||
| 171 | - </Button> | ||
| 172 | - </div> | ||
| 173 | - </article> | ||
| 174 | - )} | ||
| 175 | - </For> | ||
| 176 | - </section> | ||
| 177 | - </Show> | ||
| 178 | - </Suspense> | ||
| 179 | 229 | ||
| 180 | <ConfirmDialog | 230 | <ConfirmDialog |
| 181 | open={deleteTarget() != null} | 231 | open={deleteTarget() != null} |
src/pages/work-log-page.tsxmodified+3 -2
| @@ -9,6 +9,7 @@ import { Alert } from "@/components/ui/alert"; | |||
| 9 | import { Badge } from "@/components/ui/badge"; | 9 | import { Badge } from "@/components/ui/badge"; |
| 10 | import { Button } from "@/components/ui/button"; | 10 | import { Button } from "@/components/ui/button"; |
| 11 | import { DataTableFrame } from "@/components/ui/data-table"; | 11 | import { DataTableFrame } from "@/components/ui/data-table"; |
| 12 | +import { ErrorAlert } from "@/components/ui/error-alert"; | ||
| 12 | import { PageSpinner } from "@/components/ui/page-spinner"; | 13 | import { PageSpinner } from "@/components/ui/page-spinner"; |
| 13 | import { Table, TableBody, TableCell, TableHead, TableHeader, TableRow } from "@/components/ui/table"; | 14 | import { Table, TableBody, TableCell, TableHead, TableHeader, TableRow } from "@/components/ui/table"; |
| 14 | import { formatDateTime, formatDurationMinutes } from "@/lib/format"; | 15 | import { formatDateTime, formatDurationMinutes } from "@/lib/format"; |
| @@ -81,7 +82,7 @@ function WorkLogContent() { | |||
| 81 | </div> | 82 | </div> |
| 82 | <Suspense fallback={<PageSpinner />}> | 83 | <Suspense fallback={<PageSpinner />}> |
| 83 | <Show when={entries.error}> | 84 | <Show when={entries.error}> |
| 84 | - <Alert variant="destructive">{formatApiError(entries.error)}</Alert> | 85 | + <ErrorAlert message={formatApiError(entries.error)} onRetry={() => void refetch()} /> |
| 85 | </Show> | 86 | </Show> |
| 86 | <Show | 87 | <Show |
| 87 | when={(entries() ?? []).length > 0} | 88 | when={(entries() ?? []).length > 0} |
| @@ -94,7 +95,7 @@ function WorkLogContent() { | |||
| 94 | <TableHead>{t("work.checkIn")}</TableHead> | 95 | <TableHead>{t("work.checkIn")}</TableHead> |
| 95 | <TableHead>{t("work.checkOut")}</TableHead> | 96 | <TableHead>{t("work.checkOut")}</TableHead> |
| 96 | <TableHead>{t("work.duration")}</TableHead> | 97 | <TableHead>{t("work.duration")}</TableHead> |
| 97 | - <TableHead>{t("attempt.status")}</TableHead> | 98 | + <TableHead>{t("work.status")}</TableHead> |
| 98 | </TableRow> | 99 | </TableRow> |
| 99 | </TableHeader> | 100 | </TableHeader> |
| 100 | <TableBody> | 101 | <TableBody> |