diff --git a/.claude/skills/dashboard-design/SKILL.md b/.claude/skills/dashboard-design/SKILL.md index 336fa01..82ba66a 100644 --- a/.claude/skills/dashboard-design/SKILL.md +++ b/.claude/skills/dashboard-design/SKILL.md @@ -10,20 +10,25 @@ Reference: `src/pages/dashboard-page.tsx`. The homepage is a **read-only status - **No mutations:** no create/edit/delete buttons, no primary CTAs that open forms. Links only navigate to existing list/detail routes. - **Charts are allowed, on real data only.** The homepage follows the Knowvio-style layout: a Highlights stat-card row, a Progress-overview chart, an Activity/attendance - split, and an Upcoming-deadlines table. Charts use the `Chart*` components in - `src/components/ui/` (accent = `hsl(var(--primary))`, semantic tints for status). + split, and an Upcoming-deadlines table. Charts use `ChartBar` and + `ChartProgressRing` from `src/components/ui/` (accent = + `hsl(var(--primary))`, semantic tints for status). **Every chart/stat must be backed by a live API field** — no fabricated trends, - streak counters, or `+%` delta badges the backend can't produce. Hide a panel when - its data source is empty for the current role rather than faking it. + streak counters, sparklines, or `+%` delta badges the backend can't produce. + Categorical series use bars, with a plain empty state when no records exist. - **Layout order (top → bottom):** 1. Compact header — greeting, role chip (neutral), date. 2. **Highlights** — role-scoped stat cards (icon + label + mono value). 3. **Progress overview** chart + **Activity split** on `lg+`. 4. **Upcoming deadlines** `DataTable` (exams / events / homework / appointments). - 5. Optional role-scoped workspace links / recent list. + 5. Optional teacher+ Question Bank / Question Pool links. - **Grid:** stat row `1 → 2 sm → 4 lg`; charts `lg:grid-cols-3` (progress spans 2). - **Role scoping:** stat/chart set matches nav/role matrix (student personal tools + marks/attendance; teacher teaching tools; manager+ management; parent children/meals). Show only panels whose data exists for the role. - **Deadlines table:** active / today / soon items only, semantic status badge, rows - navigate to detail. Empty state is plain text, not a create CTA. + navigate by pointer, Enter, or Space. Empty state is plain text, not a create CTA. +- **Semantics:** student progress = per-course averages; staff progress = + `Course.capacity` labeled as course capacity, never enrollment/class size. +- **Role privacy:** question navigation is teacher+ only. Student/parent deadlines + span full width. No inferred priority or manual refresh. diff --git a/.codex/skills/dashboard-design/SKILL.md b/.codex/skills/dashboard-design/SKILL.md index 336fa01..82ba66a 100644 --- a/.codex/skills/dashboard-design/SKILL.md +++ b/.codex/skills/dashboard-design/SKILL.md @@ -10,20 +10,25 @@ Reference: `src/pages/dashboard-page.tsx`. The homepage is a **read-only status - **No mutations:** no create/edit/delete buttons, no primary CTAs that open forms. Links only navigate to existing list/detail routes. - **Charts are allowed, on real data only.** The homepage follows the Knowvio-style layout: a Highlights stat-card row, a Progress-overview chart, an Activity/attendance - split, and an Upcoming-deadlines table. Charts use the `Chart*` components in - `src/components/ui/` (accent = `hsl(var(--primary))`, semantic tints for status). + split, and an Upcoming-deadlines table. Charts use `ChartBar` and + `ChartProgressRing` from `src/components/ui/` (accent = + `hsl(var(--primary))`, semantic tints for status). **Every chart/stat must be backed by a live API field** — no fabricated trends, - streak counters, or `+%` delta badges the backend can't produce. Hide a panel when - its data source is empty for the current role rather than faking it. + streak counters, sparklines, or `+%` delta badges the backend can't produce. + Categorical series use bars, with a plain empty state when no records exist. - **Layout order (top → bottom):** 1. Compact header — greeting, role chip (neutral), date. 2. **Highlights** — role-scoped stat cards (icon + label + mono value). 3. **Progress overview** chart + **Activity split** on `lg+`. 4. **Upcoming deadlines** `DataTable` (exams / events / homework / appointments). - 5. Optional role-scoped workspace links / recent list. + 5. Optional teacher+ Question Bank / Question Pool links. - **Grid:** stat row `1 → 2 sm → 4 lg`; charts `lg:grid-cols-3` (progress spans 2). - **Role scoping:** stat/chart set matches nav/role matrix (student personal tools + marks/attendance; teacher teaching tools; manager+ management; parent children/meals). Show only panels whose data exists for the role. - **Deadlines table:** active / today / soon items only, semantic status badge, rows - navigate to detail. Empty state is plain text, not a create CTA. + navigate by pointer, Enter, or Space. Empty state is plain text, not a create CTA. +- **Semantics:** student progress = per-course averages; staff progress = + `Course.capacity` labeled as course capacity, never enrollment/class size. +- **Role privacy:** question navigation is teacher+ only. Student/parent deadlines + span full width. No inferred priority or manual refresh. diff --git a/src/components/ui/chart-area-trend.tsx b/src/components/ui/chart-area-trend.tsx deleted file mode 100644 index 4d067f4..0000000 --- a/src/components/ui/chart-area-trend.tsx +++ /dev/null @@ -1,204 +0,0 @@ -import { For, Show, createSignal, type Component } from "solid-js"; -import { cn } from "@/lib/cn"; -import { useT } from "@/stores/preferences-context"; - -export type ChartAreaTrendItem = { - label: string; - value: number; - formattedValue?: string; -}; - -export type ChartAreaTrendProps = { - title: string; - subtitle?: string; - items: ChartAreaTrendItem[]; - class?: string; - minScale?: number; - maxScale?: number; - unit?: string; -}; - -export const ChartAreaTrend: Component = (props) => { - const [hoverIndex, setHoverIndex] = createSignal(null); - const t = useT(); - - const values = () => props.items.map((i) => i.value); - const minVal = () => props.minScale ?? Math.min(0, ...values()); - const maxVal = () => props.maxScale ?? Math.max(1, ...values()); - - const width = 360; - const height = 120; - const paddingX = 20; - const paddingTop = 15; - const paddingBottom = 25; - - const points = () => { - const list = props.items; - if (list.length === 0) return []; - const min = minVal(); - const max = maxVal(); - const range = max - min || 1; - const stepX = (width - paddingX * 2) / Math.max(1, list.length - 1); - const usableH = height - paddingTop - paddingBottom; - - return list.map((item, i) => { - const x = paddingX + i * stepX; - const normalized = (item.value - min) / range; - const y = height - paddingBottom - normalized * usableH; - return { x, y, item, index: i }; - }); - }; - - const linePath = () => { - const pts = points(); - if (pts.length === 0) return ""; - return pts.reduce((acc, p, idx) => (idx === 0 ? `M ${p.x} ${p.y}` : `${acc} L ${p.x} ${p.y}`), ""); - }; - - const areaPath = () => { - const pts = points(); - if (pts.length === 0) return ""; - const first = pts[0]; - const last = pts[pts.length - 1]; - const bottomY = height - paddingBottom; - return `${linePath()} L ${last.x} ${bottomY} L ${first.x} ${bottomY} Z`; - }; - - return ( -
-
-
-

{props.title}

- -

{props.subtitle}

-
-
- 0}> -
- {hoverIndex() !== null - ? (props.items[hoverIndex()!]?.formattedValue ?? `${props.items[hoverIndex()!]?.value}${props.unit ?? ""}`) - : (props.items[props.items.length - 1]?.formattedValue ?? `${props.items[props.items.length - 1]?.value}${props.unit ?? ""}`)} -
-
-
- - 0} - fallback={ -
-
- - - -
-

{t("dashboard.chartEmpty")}

-

{t("dashboard.chartEmptyHint")}

-
- } - > -
- - - - - - - - - {/* Horizontal Grid lines */} - - - - - {/* Hover Vertical Guideline */} - - {(p) => ( - - )} - - - {/* Filled Area */} - - - {/* Trend Line */} - - - {/* Data Points */} - - {(p) => ( - setHoverIndex(p.index)} onMouseLeave={() => setHoverIndex(null)}> - - - {p.item.label} - - - )} - - - {/* Floating Active Hover Tooltip */} - - {(p) => { - const text = p().item.formattedValue ?? `${p().item.value}${props.unit ?? ""}`; - const rectW = 64; - const rectH = 20; - const tooltipX = Math.max(paddingX, Math.min(width - paddingX - rectW, p().x - rectW / 2)); - const tooltipY = Math.max(2, p().y - 26); - return ( - - - - - {text} - - - ); - }} - - -
-
-
- ); -}; diff --git a/src/components/ui/chart-bar.tsx b/src/components/ui/chart-bar.tsx index 0ee5036..f58738b 100644 --- a/src/components/ui/chart-bar.tsx +++ b/src/components/ui/chart-bar.tsx @@ -30,9 +30,9 @@ export const ChartBar: Component = (props) => { }; return ( -
+
-
+

{props.title}

@@ -45,12 +45,7 @@ export const ChartBar: Component = (props) => { 0} fallback={ -
-
- - - -
+

{t("dashboard.chartEmpty")}

{t("dashboard.chartEmptyHint")}

diff --git a/src/components/ui/chart-progress-ring.tsx b/src/components/ui/chart-progress-ring.tsx index df76a60..491a1fb 100644 --- a/src/components/ui/chart-progress-ring.tsx +++ b/src/components/ui/chart-progress-ring.tsx @@ -24,9 +24,9 @@ export const ChartProgressRing: Component = (props) => { const calculatedTotal = () => props.total ?? props.segments.reduce((acc, s) => acc + s.value, 0); return ( -
+
-
+

{props.title}

@@ -39,13 +39,7 @@ export const ChartProgressRing: Component = (props) => { 0} fallback={ -
-
- - - - -
+

{t("dashboard.chartEmpty")}

{t("dashboard.chartEmptyHint")}

diff --git a/src/pages/dashboard-page.test.tsx b/src/pages/dashboard-page.test.tsx new file mode 100644 index 0000000..142ffb0 --- /dev/null +++ b/src/pages/dashboard-page.test.tsx @@ -0,0 +1,149 @@ +import { cleanup, fireEvent, render, screen } from "@solidjs/testing-library"; +import type { JSX } from "solid-js"; +import DashboardPage from "@/pages/dashboard-page"; +import { PreferencesProvider } from "@/stores/preferences-context"; + +const { navigate, authUser } = vi.hoisted(() => ({ + navigate: vi.fn(), + authUser: { role: "student" }, +})); + +vi.mock("@tanstack/solid-router", () => ({ + Link: (props: { to: string; children: JSX.Element; class?: string }) => ( + {props.children} + ), + Navigate: () => null, + useNavigate: () => navigate, +})); +vi.mock("@/stores/auth-context", () => ({ + useAuth: () => ({ + user: () => ({ + id: "u-1", + username: "demo", + role: authUser.role, + name: "Demo", + surname: "User", + }), + loading: () => false, + error: () => undefined, + refresh: async () => undefined, + }), +})); + +const now = Date.UTC(2026, 6, 28, 9); +const page = (items: T[]) => ({ items, total: items.length, limit: 50, offset: 0 }); +const course = { id: "course-1", title: "Algebra", capacity: 24 }; + +vi.mock("@/api/time/getTime", () => ({ getTime: async () => ({ now }) })); +vi.mock("@/api/courses", () => ({ getCourses: async () => page([course]) })); +vi.mock("@/api/reports", () => ({ + getMyCourses: async () => page([course]), + getMyMarks: async () => ({ + overall_average: 82.5, + courses: [{ course, results: [], average: 82.5 }], + }), + getMyAttendance: async () => ({ + events: { total: 3, present: 2, absent: 1, late: 0, excused: 0 }, + sessions: { total: 2, present: 1, absent: 0, late: 1, excused: 0 }, + }), +})); +vi.mock("@/api/exams", () => ({ + getExams: async () => page([{ + id: "exam-1", + title: "Exam deadline", + starts_at: now + 1_000, + ends_at: now + 3_000, + }]), +})); +vi.mock("@/api/events", () => ({ + getEvents: async () => page([{ + id: "event-1", + title: "Event deadline", + starts_at: now + 2_000, + ends_at: now + 4_000, + }]), +})); +vi.mock("@/api/homework", () => ({ + getHomework: async () => page([{ + id: "homework-1", + title: "Homework deadline", + due_at: now + 5_000, + }]), +})); +vi.mock("@/api/appointments", () => ({ + getAppointments: async () => page([{ + id: "appointment-1", + status: "approved", + starts_at: now + 6_000, + ends_at: now + 7_000, + teacher: { username: "teacher", display_name: "Teacher Name" }, + }]), +})); +vi.mock("@/api/parents", () => ({ + getMyStudents: async () => page([{ id: "child-1" }]), +})); +vi.mock("@/api/meals", () => ({ + getMealMenus: async () => page([{ id: "menu-1" }]), +})); + +afterEach(() => { + cleanup(); + navigate.mockReset(); +}); + +function renderDashboard(role: string) { + authUser.role = role; + return render(() => ( + + + + )); +} + +test("student sees truthful charts, full-width deadlines, and no teaching resources", async () => { + const view = renderDashboard("student"); + + expect(await screen.findByText("Course averages")).toBeTruthy(); + expect(screen.getByText("Attendance split")).toBeTruthy(); + expect(screen.queryByText("Teaching resources")).toBeNull(); + expect(screen.getByRole("link", { name: "Appointments" })).toBeTruthy(); + expect(screen.getByRole("heading", { name: "Upcoming deadlines" }).closest("section")?.className).toContain("lg:col-span-3"); + expect(view.container.querySelector("polyline")).toBeNull(); + expect(screen.queryByText("Priority")).toBeNull(); + expect(screen.queryByText("Refresh data")).toBeNull(); + expect(screen.queryByText("Ask a question")).toBeNull(); + + fireEvent.click(await screen.findByRole("button", { name: /Event deadline/ })); + fireEvent.keyDown(screen.getByRole("button", { name: /Homework deadline/ }), { key: "Enter" }); + fireEvent.keyDown(screen.getByRole("button", { name: /Exam deadline/ }), { key: " " }); + fireEvent.click(screen.getByRole("button", { name: /Teacher Name/ })); + + expect(navigate).toHaveBeenCalledWith({ to: "/events/$id", params: { id: "event-1" } }); + expect(navigate).toHaveBeenCalledWith({ to: "/homework/$id", params: { id: "homework-1" } }); + expect(navigate).toHaveBeenCalledWith({ to: "/exams/$id", params: { id: "exam-1" } }); + expect(navigate).toHaveBeenCalledWith({ to: "/appointments" }); +}); + +test("teacher sees capacities and useful teaching-resource links", async () => { + renderDashboard("teacher"); + + expect(await screen.findByText("Course capacities")).toBeTruthy(); + expect(screen.queryByText("Class sizes")).toBeNull(); + expect(screen.getByText("Workload split")).toBeTruthy(); + expect(screen.getByText("Teaching resources")).toBeTruthy(); + expect(screen.getByRole("link", { name: /Build and reuse question templates/ })).toBeTruthy(); + expect(screen.getByRole("link", { name: /Review questions submitted by students/ })).toBeTruthy(); + expect(screen.getByRole("heading", { name: "Upcoming deadlines" }).closest("section")?.className).toContain("lg:col-span-2"); +}); + +test("parent sees family highlights and appointment deadlines without staff charts", async () => { + renderDashboard("parent"); + + expect(await screen.findByText("Children")).toBeTruthy(); + expect(screen.getAllByText("Appointments").length).toBeGreaterThan(0); + expect(screen.getByText("Meal menus")).toBeTruthy(); + expect(screen.queryByText("Progress overview")).toBeNull(); + expect(screen.queryByText("Teaching resources")).toBeNull(); + expect(await screen.findByRole("button", { name: /Teacher Name/ })).toBeTruthy(); + expect(screen.getByRole("heading", { name: "Upcoming deadlines" }).closest("section")?.className).toContain("lg:col-span-3"); +}); diff --git a/src/pages/dashboard-page.tsx b/src/pages/dashboard-page.tsx index 35de547..b218342 100644 --- a/src/pages/dashboard-page.tsx +++ b/src/pages/dashboard-page.tsx @@ -1,5 +1,5 @@ -import { For, Show, Suspense, createMemo, createResource, createSignal, type Component } from "solid-js"; -import { Link } from "@tanstack/solid-router"; +import { For, Show, Suspense, createMemo, createResource, type Component } from "solid-js"; +import { Link, useNavigate } from "@tanstack/solid-router"; import type { ColumnDef } from "@tanstack/solid-table"; import type { Role } from "@/api/client"; import { formatApiError } from "@/api/client"; @@ -14,21 +14,16 @@ import { getMyAttendance, getMyCourses, getMyMarks } from "@/api/reports"; import { getTime } from "@/api/time/getTime"; import { RouteGuard } from "@/components/layout/route-guard"; import { Badge } from "@/components/ui/badge"; -import { ChartAreaTrend } from "@/components/ui/chart-area-trend"; import { ChartBar } from "@/components/ui/chart-bar"; import { ChartProgressRing } from "@/components/ui/chart-progress-ring"; import { DataTable } from "@/components/ui/data-table"; import { - IconArchive, IconBook, IconCalendarDays, IconChart, IconClipboardCheck, IconExam, - IconHelpCircle, IconHomework, - IconRefresh, - IconSearch, IconUsers, IconUtensils, } from "@/components/ui/icons"; @@ -36,6 +31,7 @@ import { PageSpinner } from "@/components/ui/page-spinner"; import type { MessageKey } from "@/i18n/messages"; import { cn } from "@/lib/cn"; import { formatDateTime } from "@/lib/format"; +import { hasMinRole } from "@/lib/roles"; import { useAuth } from "@/stores/auth-context"; import { usePreferences, useT } from "@/stores/preferences-context"; @@ -57,36 +53,8 @@ type StatCardData = { labelKey: MessageKey; value: string; Icon: Component<{ class?: string }>; - spark?: number[]; }; -// Tiny real-data sparkline; renders nothing when there's no series. -function StatSpark(props: { values: number[] }) { - const pts = () => { - const v = props.values; - if (v.length < 2) return ""; - const min = Math.min(...v); - const max = Math.max(...v); - const range = max - min || 1; - const w = 64; - const h = 24; - return v - .map((val, i) => { - const x = (i / (v.length - 1)) * w; - const y = h - ((val - min) / range) * h; - return `${x.toFixed(1)},${y.toFixed(1)}`; - }) - .join(" "); - }; - return ( - - - - - - ); -} - const roleKeys: Record = { student: "role.student", parent: "role.parent", @@ -113,63 +81,47 @@ function scheduleStatus(startsAt: number | null, endsAt: number | null, now: num export default function DashboardPage() { const auth = useAuth(); const t = useT(); + const navigate = useNavigate(); const { locale } = usePreferences(); const user = () => auth.user()!; const role = () => user().role; - const [clock, clockQ] = createResource(() => getTime().catch(() => ({ now: Date.now() }))); - const [courses, coursesQ] = createResource( + const [clock] = createResource(() => getTime().catch(() => ({ now: Date.now() }))); + const [courses] = createResource( () => role() === "parent" ? null : role(), (currentRole) => currentRole === "student" ? getMyCourses({ kind: "course", limit: 12 }) : getCourses({ kind: "course", limit: 12 }), ); - const [events, eventsQ] = createResource( + const [events] = createResource( () => role() === "parent" ? null : clock()?.now, (now) => getEvents({ ends_after: now, limit: 50 }), ); - const [exams, examsQ] = createResource( + const [exams] = createResource( () => role() === "parent" ? null : role(), () => getExams({ limit: 50 }), ); - const [homework, homeworkQ] = createResource( + const [homework] = createResource( () => role() === "parent" ? null : clock()?.now, (now) => getHomework({ due_after: now, limit: 50 }), ); - const [children, childrenQ] = createResource( + const [children] = createResource( () => role() === "parent" ? true : null, () => getMyStudents({ limit: 12 }), ); - const [appointments, appointmentsQ] = createResource( - () => role() === "parent" ? true : null, - () => getAppointments({ limit: 20 }), - ); - const [menus, menusQ] = createResource( + const [appointments] = createResource(() => getAppointments({ limit: 20 })); + const [menus] = createResource( () => clock()?.now, (now) => getMealMenus({ from: new Date(now).toISOString().slice(0, 10), limit: 1 }), ); - const [marks, marksQ] = createResource( + const [marks] = createResource( () => role() === "student" ? true : null, () => getMyMarks(), ); - const [attendance, attendanceQ] = createResource( + const [attendance] = createResource( () => role() === "student" ? true : null, () => getMyAttendance(), ); - const [refreshing, setRefreshing] = createSignal(false); - const refresh = async () => { - if (refreshing()) return; - setRefreshing(true); - try { - await Promise.all( - [clockQ, coursesQ, eventsQ, examsQ, homeworkQ, childrenQ, appointmentsQ, menusQ, marksQ, attendanceQ] - .map((q) => q.refetch()), - ); - } finally { - setRefreshing(false); - } - }; - const fullName = () => [user().name, user().surname].filter(Boolean).join(" ") || user().username; const now = () => clock()?.now ?? Date.now(); @@ -181,30 +133,19 @@ export default function DashboardPage() { return total ? Math.round((present / total) * 100) : null; }); - const capacities = () => - (courses()?.items ?? []).map((c) => c.capacity).filter((n): n is number => n != null); - const courseAvgValues = () => - (marks()?.courses ?? []).filter((c) => c.average != null).map((c) => c.average!); - const attendanceValues = () => { - const report = attendance(); - if (!report) return []; - const sum = (k: "present" | "absent" | "late" | "excused") => report.events[k] + report.sessions[k]; - return [sum("present"), sum("late"), sum("excused"), sum("absent")]; - }; - const stats = createMemo(() => { const r = role(); if (r === "student") { return [ - { labelKey: "dashboard.stats.courses", value: String(courses()?.total ?? 0), Icon: IconBook, spark: capacities() }, + { labelKey: "dashboard.stats.courses", value: String(courses()?.total ?? 0), Icon: IconBook }, { labelKey: "dashboard.stats.exams", value: String(exams()?.total ?? 0), Icon: IconExam }, - { labelKey: "dashboard.stats.average", value: marks()?.overall_average == null ? "—" : marks()!.overall_average!.toFixed(1), Icon: IconChart, spark: courseAvgValues() }, - { labelKey: "dashboard.stats.attendance", value: attendanceRate() == null ? "—" : `${attendanceRate()}%`, Icon: IconClipboardCheck, spark: attendanceValues() }, + { labelKey: "dashboard.stats.average", value: marks()?.overall_average == null ? "—" : marks()!.overall_average!.toFixed(1), Icon: IconChart }, + { labelKey: "dashboard.stats.attendance", value: attendanceRate() == null ? "—" : `${attendanceRate()}%`, Icon: IconClipboardCheck }, ]; } if (r === "teacher") { return [ - { labelKey: "dashboard.stats.courses", value: String(courses()?.total ?? 0), Icon: IconBook, spark: capacities() }, + { labelKey: "dashboard.stats.courses", value: String(courses()?.total ?? 0), Icon: IconBook }, { labelKey: "dashboard.stats.exams", value: String(exams()?.total ?? 0), Icon: IconExam }, { labelKey: "dashboard.stats.events", value: String(events()?.total ?? 0), Icon: IconCalendarDays }, { labelKey: "dashboard.stats.homework", value: String(homework()?.total ?? 0), Icon: IconHomework }, @@ -218,20 +159,20 @@ export default function DashboardPage() { ]; } return [ - { labelKey: "dashboard.stats.courses", value: String(courses()?.total ?? 0), Icon: IconBook, spark: capacities() }, + { labelKey: "dashboard.stats.courses", value: String(courses()?.total ?? 0), Icon: IconBook }, { labelKey: "dashboard.stats.exams", value: String(exams()?.total ?? 0), Icon: IconExam }, { labelKey: "dashboard.stats.events", value: String(events()?.total ?? 0), Icon: IconCalendarDays }, { labelKey: "dashboard.stats.meals", value: String(menus()?.total ?? 0), Icon: IconUtensils }, ]; }); - // Progress panel — student: per-course averages; teacher/manager/admin: class sizes. + // Progress panel — student: per-course averages; teacher/manager/admin: course capacities. const courseAverages = createMemo(() => (marks()?.courses ?? []) .filter((c) => c.average != null) - .map((c) => ({ label: c.course.title, value: c.average!, formattedValue: c.average!.toFixed(1) })), + .map((c) => ({ id: c.course.id, label: c.course.title, value: c.average!, formattedValue: c.average!.toFixed(1) })), ); - const classSizes = createMemo(() => + const courseCapacities = createMemo(() => (courses()?.items ?? []) .filter((c) => c.capacity != null) .map((c) => ({ id: c.id, label: c.title, value: c.capacity! })), @@ -327,23 +268,21 @@ export default function DashboardPage() { ); }, }, - { - id: "priority", - header: t("dashboard.col.priority"), - enableSorting: false, - meta: { headerClass }, - cell: (info) => { - const high = info.row.original.status !== "soon"; - return ( - - {high ? t("dashboard.priority.high") : t("dashboard.priority.medium")} - - ); - }, - }, ]); const deadlineSearch = (row: DeadlineRow, q: string) => row.title.toLowerCase().includes(q.toLowerCase()); + const openDeadline = (row: DeadlineRow) => { + switch (row.kind) { + case "exam": + return navigate({ to: "/exams/$id", params: { id: row.id } }); + case "event": + return navigate({ to: "/events/$id", params: { id: row.id } }); + case "homework": + return navigate({ to: "/homework/$id", params: { id: row.id } }); + case "appointment": + return navigate({ to: "/appointments" }); + } + }; const error = createMemo(() => { const problem = courses.error || events.error || exams.error || homework.error || children.error || appointments.error || menus.error || marks.error || attendance.error; @@ -383,9 +322,8 @@ export default function DashboardPage() {

{t(stat.labelKey)}

-
+

{stat.value}

- {(s) => }
)} @@ -396,12 +334,11 @@ export default function DashboardPage() {
- @@ -409,8 +346,8 @@ export default function DashboardPage() { @@ -431,8 +368,16 @@ export default function DashboardPage() {
-
-

{t("dashboard.deadlines")}

+
+
+

{t("dashboard.deadlines")}

+ + {t("nav.appointments")} + +
- +
-

{t("nav.questionBank")}

-

{t("dashboard.questionHubDesc")}

+

{t("dashboard.teachingResources")}

+

{t("dashboard.teachingResourcesDesc")}

- - - {t("dashboard.questionHubPlaceholder")} - -
- - {(Icon) => ( - - - - )} - -
-
+
- {t("nav.questionBank")} + {t("nav.questionBank")} + {t("dashboard.questionBankDesc")} - {t("dashboard.askQuestion")} + {t("nav.questions")} + {t("dashboard.questionPoolDesc")}
- -
- -