From 50fd345c74bf42405226513f7160428099065e26 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Burak=20Boduro=C4=9Flu?= <80620802+burakboduroglu@users.noreply.github.com> Date: Wed, 15 Jul 2026 10:31:46 +0300 Subject: [PATCH] =?UTF-8?q?feat:=20=E2=9C=A8=20Enhance=20dashboard=20with?= =?UTF-8?q?=20new=20portal=20cards=20and=20statistics?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/components/dashboard/role-home-panel.tsx | 95 --- src/i18n/messages.ts | 93 +++ src/pages/dashboard-page.tsx | 625 ++++++++++++------- 3 files changed, 476 insertions(+), 337 deletions(-) delete mode 100644 src/components/dashboard/role-home-panel.tsx diff --git a/src/components/dashboard/role-home-panel.tsx b/src/components/dashboard/role-home-panel.tsx deleted file mode 100644 index 8d99b9c..0000000 --- a/src/components/dashboard/role-home-panel.tsx +++ /dev/null @@ -1,95 +0,0 @@ -import { Link } from "@tanstack/solid-router"; -import { For } from "solid-js"; -import type { Role } from "@/api/types"; -import type { MessageKey } from "@/i18n/messages"; -import { useT } from "@/stores/preferences-context"; -import { cn } from "@/lib/cn"; - -type RoleAction = { - to: string; - title: MessageKey; - hint: MessageKey; - marker: string; - tone: "mint" | "sky" | "amber" | "violet" | "rose"; -}; - -const ROLE_KEY: Record = { - student: "role.student", - teacher: "role.teacher", - manager: "role.manager", - admin: "role.admin", -}; - -const ROLE_ACTIONS: Record = { - student: [ - { to: "/marks", title: "dashboard.action.marks", hint: "dashboard.action.marksHint", marker: "▤", tone: "mint" }, - { to: "/exams", title: "dashboard.myExams", hint: "exams.subtitle", marker: "☰", tone: "rose" }, - { to: "/events", title: "dashboard.action.attend", hint: "dashboard.action.attendHint", marker: "◷", tone: "sky" }, - ], - teacher: [ - { to: "/courses", title: "dashboard.action.course", hint: "dashboard.action.courseHint", marker: "▣", tone: "violet" }, - { to: "/courses", title: "dashboard.action.exam", hint: "dashboard.action.examHint", marker: "☰", tone: "rose" }, - { to: "/exams", title: "exams.liveMonitor", hint: "exams.liveMonitorDesc", marker: "◎", tone: "amber" }, - ], - manager: [ - { to: "/courses", title: "nav.courses", hint: "courses.subtitle", marker: "▣", tone: "violet" }, - { to: "/events", title: "nav.events", hint: "events.subtitle", marker: "◷", tone: "sky" }, - { to: "/exams", title: "exams.liveMonitor", hint: "exams.liveMonitorDesc", marker: "◎", tone: "amber" }, - { to: "/marks", title: "dashboard.action.marks", hint: "dashboard.action.marksHint", marker: "▤", tone: "mint" }, - ], - admin: [ - { to: "/admin/users", title: "nav.users", hint: "admin.subtitle", marker: "◉", tone: "amber" }, - { to: "/courses", title: "nav.courses", hint: "courses.subtitle", marker: "▣", tone: "violet" }, - { to: "/events", title: "nav.events", hint: "events.subtitle", marker: "◷", tone: "sky" }, - { to: "/exams", title: "exams.liveMonitor", hint: "exams.liveMonitorDesc", marker: "◎", tone: "rose" }, - ], -}; - -export function RoleHomePanel(props: { role: Role }) { - const t = useT(); - const actions = () => ROLE_ACTIONS[props.role]; - const markerTone = { - mint: "bg-emerald-500/10 text-emerald-700 dark:text-emerald-300", - sky: "bg-sky-500/10 text-sky-700 dark:text-sky-300", - amber: "bg-amber-500/10 text-amber-700 dark:text-amber-300", - violet: "bg-violet-500/10 text-violet-700 dark:text-violet-300", - rose: "bg-rose-500/10 text-rose-700 dark:text-rose-300", - }; - - return ( -
-
-
-
-

- {t("dashboard.overview")} -

-

- {t("dashboard.stats.role")}: {t(ROLE_KEY[props.role])} -

-
-
- -
- - {(action) => ( - - - {action.marker} - - - {t(action.title)} - - {t(action.hint)} - - - - )} - -
-
- ); -} diff --git a/src/i18n/messages.ts b/src/i18n/messages.ts index 68e48d4..a402a23 100644 --- a/src/i18n/messages.ts +++ b/src/i18n/messages.ts @@ -117,9 +117,28 @@ export type MessageKey = | "dashboard.stats.notes" | "dashboard.stats.events" | "dashboard.stats.exams" + | "dashboard.stats.courses" | "dashboard.stats.role" | "dashboard.stats.average" | "dashboard.stats.averageHint" + | "dashboard.commandCenter" + | "dashboard.observationOnly" + | "dashboard.today" + | "dashboard.reportCard" + | "dashboard.ready" + | "dashboard.attention" + | "dashboard.timeline" + | "dashboard.activeNow" + | "dashboard.upcoming" + | "dashboard.nextEvent" + | "dashboard.courseLoad" + | "dashboard.latestWindow" + | "dashboard.noAttention" + | "dashboard.allClear" + | "dashboard.roleLinks" + | "dashboard.activityGraph" + | "dashboard.activityGraphDesc" + | "dashboard.records" | "dashboard.myExams" | "dashboard.emptyExamsTitle" | "dashboard.emptyExamsCta" @@ -136,6 +155,18 @@ export type MessageKey = | "dashboard.helpTitle" | "dashboard.helpBody" | "dashboard.continueGuide" + | "dashboard.portal.sections" + | "dashboard.portal.coursesDesc" + | "dashboard.portal.examsDesc" + | "dashboard.portal.eventsDesc" + | "dashboard.portal.marksDesc" + | "dashboard.portal.notesDesc" + | "dashboard.portal.usersDesc" + | "dashboard.portal.attendanceDesc" + | "dashboard.portal.workDesc" + | "dashboard.portal.studentMarksDesc" + | "dashboard.portal.settingsDesc" + | "dashboard.portal.termsDesc" | "notes.title" | "notes.subtitle" | "notes.new" @@ -553,9 +584,28 @@ const en: Dict = { "dashboard.stats.notes": "Notes", "dashboard.stats.events": "Events", "dashboard.stats.exams": "Exams", + "dashboard.stats.courses": "Courses", "dashboard.stats.role": "Your role", "dashboard.stats.average": "Average", "dashboard.stats.averageHint": "Overall report card", + "dashboard.commandCenter": "Command center", + "dashboard.observationOnly": "A live read-only map of your school day.", + "dashboard.today": "Today", + "dashboard.reportCard": "Report card", + "dashboard.ready": "Ready", + "dashboard.attention": "Needs attention", + "dashboard.timeline": "Upcoming timeline", + "dashboard.activeNow": "Active now", + "dashboard.upcoming": "Upcoming", + "dashboard.nextEvent": "Next event", + "dashboard.courseLoad": "Course load", + "dashboard.latestWindow": "Latest window", + "dashboard.noAttention": "Nothing urgent", + "dashboard.allClear": "No active exam or near event needs action right now.", + "dashboard.roleLinks": "Workspace overview", + "dashboard.activityGraph": "Activity graph", + "dashboard.activityGraphDesc": "Events, exams, and courses at a glance.", + "dashboard.records": "records", "dashboard.myExams": "My exams", "dashboard.emptyExamsTitle": "No exams yet", "dashboard.emptyExamsCta": "Browse exams", @@ -573,6 +623,18 @@ const en: Dict = { "dashboard.helpBody": "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.", "dashboard.continueGuide": "Open the guide", + "dashboard.portal.sections": "Sections", + "dashboard.portal.coursesDesc": "Browse courses and class materials.", + "dashboard.portal.examsDesc": "Upcoming exams, deadlines, and results.", + "dashboard.portal.eventsDesc": "Sessions, meetups, and attendance.", + "dashboard.portal.marksDesc": "Your grades and overall report card.", + "dashboard.portal.notesDesc": "Private scratchpad for quick ideas.", + "dashboard.portal.usersDesc": "Manage user accounts and roles.", + "dashboard.portal.attendanceDesc": "Mark and review attendance records.", + "dashboard.portal.workDesc": "Track your work hours and shifts.", + "dashboard.portal.studentMarksDesc": "View and grade student results.", + "dashboard.portal.settingsDesc": "System preferences and configuration.", + "dashboard.portal.termsDesc": "Manage academic terms and periods.", "notes.title": "Notebook", "notes.subtitle": "Private scratchpad for class ideas and reminders.", "notes.new": "New note", @@ -1002,9 +1064,28 @@ const tr: Dict = { "dashboard.stats.notes": "Notlar", "dashboard.stats.events": "Etkinlikler", "dashboard.stats.exams": "Sınavlar", + "dashboard.stats.courses": "Dersler", "dashboard.stats.role": "Rolün", "dashboard.stats.average": "Ortalama", "dashboard.stats.averageHint": "Genel karne", + "dashboard.commandCenter": "Komuta merkezi", + "dashboard.observationOnly": "Okul gününün canlı ve salt okunur haritası.", + "dashboard.today": "Bugün", + "dashboard.reportCard": "Karne", + "dashboard.ready": "Hazır", + "dashboard.attention": "Dikkat isteyenler", + "dashboard.timeline": "Yaklaşan akış", + "dashboard.activeNow": "Şu an aktif", + "dashboard.upcoming": "Yaklaşan", + "dashboard.nextEvent": "Sıradaki etkinlik", + "dashboard.courseLoad": "Ders yükü", + "dashboard.latestWindow": "Güncel pencere", + "dashboard.noAttention": "Acil bir şey yok", + "dashboard.allClear": "Şu an işlem isteyen aktif sınav veya yakın etkinlik yok.", + "dashboard.roleLinks": "Çalışma alanı özeti", + "dashboard.activityGraph": "Aktivite grafiği", + "dashboard.activityGraphDesc": "Etkinlik, sınav ve ders yoğunluğu tek bakışta.", + "dashboard.records": "kayıt", "dashboard.myExams": "Sınavlarım", "dashboard.emptyExamsTitle": "Henüz sınav yok", "dashboard.emptyExamsCta": "Sınavlara git", @@ -1022,6 +1103,18 @@ const tr: Dict = { "dashboard.helpBody": "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ç.", "dashboard.continueGuide": "Rehberi aç", + "dashboard.portal.sections": "Bölümler", + "dashboard.portal.coursesDesc": "Dersleri ve ders materyallerini görüntüle.", + "dashboard.portal.examsDesc": "Sınavlar, son teslim tarihleri ve sonuçlar.", + "dashboard.portal.eventsDesc": "Oturumlar, etkinlikler ve yoklama.", + "dashboard.portal.marksDesc": "Notların ve genel karnen.", + "dashboard.portal.notesDesc": "Hızlı fikirler için özel not defteri.", + "dashboard.portal.usersDesc": "Kullanıcı hesaplarını ve rollerini yönet.", + "dashboard.portal.attendanceDesc": "Yoklama kayıtlarını işaretle ve incele.", + "dashboard.portal.workDesc": "Çalışma saatlerini ve mesainizi takip edin.", + "dashboard.portal.studentMarksDesc": "Öğrenci sonuçlarını görüntüle ve notlandır.", + "dashboard.portal.settingsDesc": "Sistem tercihleri ve yapılandırma.", + "dashboard.portal.termsDesc": "Akademik dönemleri ve periyotları yönet.", "notes.title": "Defter", "notes.subtitle": "Ders fikirleri ve hatırlatmalar için özel defter.", "notes.new": "Yeni not", diff --git a/src/pages/dashboard-page.tsx b/src/pages/dashboard-page.tsx index d86a161..c13361e 100644 --- a/src/pages/dashboard-page.tsx +++ b/src/pages/dashboard-page.tsx @@ -1,31 +1,75 @@ +import { For, Show, Suspense, createMemo, createResource, type JSX } from "solid-js"; import { Link } from "@tanstack/solid-router"; -import { For, Show, Suspense, createMemo, createResource } from "solid-js"; +import { formatApiError } from "@/api/client"; +import { getCourses } from "@/api/getCourses"; import { getEvents } from "@/api/getEvents"; import { getExams } from "@/api/getExams"; import { getMyCourses } from "@/api/getMyCourses"; import { getMyMarks } from "@/api/getMyMarks"; import { getNotes } from "@/api/getNotes"; -import { formatApiError } from "@/api/client"; -import type { Event, Exam, Note } from "@/api/types"; -import { ExamLink } from "@/components/exams/exam-link"; -import { RouteGuard } from "@/components/layout/route-guard"; +import type { Role } from "@/api/types"; import { PageHeader } from "@/components/layout/page-header"; +import { RouteGuard } from "@/components/layout/route-guard"; import { Alert } from "@/components/ui/alert"; import { Badge } from "@/components/ui/badge"; import { + IconBook, IconCalendar, + IconChart, + IconClipboardCheck, IconExam, IconNote, + IconReportAnalytics, + IconSchool, + IconSettings, + IconUsers, } from "@/components/ui/icons"; import { PageSpinner } from "@/components/ui/page-spinner"; -import { useAuth } from "@/stores/auth-context"; -import { usePreferences, useT } from "@/stores/preferences-context"; +import type { Locale, MessageKey } from "@/i18n/messages"; +import { cn } from "@/lib/cn"; import { examKindLabel } from "@/lib/exam-labels"; import { formatDateTime } from "@/lib/format"; -import { cn } from "@/lib/cn"; +import { hasMinRole } from "@/lib/roles"; +import { useAuth } from "@/stores/auth-context"; +import { usePreferences, useT } from "@/stores/preferences-context"; const PREVIEW_LIMIT = 5; +interface PortalCard { + icon: JSX.Element; + titleKey: MessageKey; + to: string; + descKey: MessageKey; + stat: () => string | number; + statSuffix?: MessageKey; + accent: string; + minRole?: Role; +} + +interface TimelineItem { + id: string; + type: "event" | "exam"; + title: string; + at: number | null; + subtitle: string; +} + +const ROLE_KEY: Record = { + student: "role.student", + teacher: "role.teacher", + manager: "role.manager", + admin: "role.admin", +}; + +const ROLE_BADGE_TONE: Record = { + student: "border-blue-500/30 bg-blue-500/10 text-blue-700 dark:text-blue-300", + teacher: "border-blue-500/30 bg-blue-500/10 text-blue-700 dark:text-blue-300", + manager: "border-amber-500/30 bg-amber-500/10 text-amber-700 dark:text-amber-300", + admin: "border-red-500/30 bg-red-500/10 text-red-700 dark:text-red-300", +}; + +const CHART_TONES = ["bg-violet-500", "bg-amber-500", "bg-sky-500", "bg-emerald-500", "bg-rose-500"]; + const roundAvg = (n: number) => (Math.round(n * 10) / 10).toString(); export default function DashboardPage() { @@ -41,281 +85,378 @@ function DashboardContent() { const t = useT(); const { locale } = usePreferences(); const user = () => auth.user()!; + const role = () => user().role; - const [notes] = createResource(() => getNotes()); + const [courses] = createResource(() => getCourses()); + const [myCourses] = createResource(async () => getMyCourses().catch(() => [])); const [events] = createResource(() => getEvents()); const [exams] = createResource(() => getExams()); - const [myCourses] = createResource( - () => (user().role === "student" ? true : null), - async (enabled) => (enabled ? getMyCourses() : []), + const [notes] = createResource(() => getNotes()); + const [marks] = createResource( + () => (role() === "student" ? true : null), + async (enabled) => (enabled ? getMyMarks() : null), ); - const [marks] = createResource(() => getMyMarks()); const resourceError = createMemo(() => { - const e = notes.error || events.error || exams.error || myCourses.error || marks.error; + const e = courses.error || myCourses.error || events.error || exams.error || notes.error || marks.error; return e ? formatApiError(e, locale()) : null; }); + const fullName = () => [user().name, user().surname].filter(Boolean).join(" ") || user().username; + + const now = () => Date.now(); + + const eventItems = () => (events() ?? []).map((event) => ({ + id: event.id, + type: "event" as const, + title: event.title, + at: event.starts_at, + subtitle: event.description || t("nav.events"), + })); + + const courseMap = createMemo(() => { + const map = new Map(); + for (const course of courses() ?? []) map.set(course.id, course.title); + for (const course of myCourses() ?? []) map.set(course.id, course.title); + return map; + }); + + const hasGlobalDashboardScope = createMemo(() => hasMinRole(role(), "admin")); + const scopedCourses = createMemo(() => (hasGlobalDashboardScope() ? courses() ?? [] : myCourses() ?? [])); + const scopedCourseIds = createMemo(() => new Set(scopedCourses().map((course) => course.id))); + const visibleExams = createMemo(() => { - const all = exams() ?? []; - if (user().role !== "student") return all; - const allowed = new Set((myCourses() ?? []).map((course) => course.id)); - return all.filter((exam) => allowed.has(exam.course)); + if (hasGlobalDashboardScope()) return exams() ?? []; + const allowed = scopedCourseIds(); + if (allowed.size === 0) return []; + return (exams() ?? []).filter((exam) => allowed.has(exam.course)); + }); + + const courseCount = createMemo(() => { + if (hasGlobalDashboardScope() && courses.loading) return null; + if (!hasGlobalDashboardScope() && myCourses.loading) return null; + return scopedCourses().length; }); + const totalExamsCount = createMemo(() => (exams.loading ? null : visibleExams().length)); + const totalEventsCount = createMemo(() => (events.loading ? null : events()?.length ?? 0)); + const totalNotesCount = createMemo(() => (notes.loading ? null : notes()?.length ?? 0)); + const displayCount = (count: number | null) => count ?? "..."; - const noteCount = createMemo(() => notes()?.length ?? 0); - const eventCount = createMemo(() => events()?.length ?? 0); - const examCount = createMemo(() => visibleExams().length); const overallAvg = createMemo(() => marks()?.overall_average ?? null); - const previewNotes = createMemo(() => (notes() ?? []).slice(0, PREVIEW_LIMIT)); - const previewEvents = createMemo(() => (events() ?? []).slice(0, PREVIEW_LIMIT)); - const previewExams = createMemo(() => visibleExams().slice(0, PREVIEW_LIMIT)); + const timeline = createMemo(() => { + const examItems: TimelineItem[] = visibleExams().map((exam) => ({ + id: exam.id, + type: "exam" as const, + title: exam.title, + at: exam.starts_at, + subtitle: courseMap().get(exam.course) ?? examKindLabel(String(exam.kind), t), + })); + const allItems = [...eventItems(), ...examItems]; + const upcomingItems = allItems + .filter((item) => item.at != null && item.at >= now()) + .sort((a, b) => (a.at ?? 0) - (b.at ?? 0)); + const fallbackItems = allItems + .sort((a, b) => (b.at ?? 0) - (a.at ?? 0)); + return (upcomingItems.length > 0 ? upcomingItems : fallbackItems).slice(0, PREVIEW_LIMIT); + }); + + const chartData = createMemo(() => [ + { label: t("dashboard.stats.courses"), value: courseCount() ?? 0 }, + { label: t("dashboard.stats.exams"), value: totalExamsCount() ?? 0 }, + { label: t("dashboard.stats.events"), value: totalEventsCount() ?? 0 }, + ]); + + const maxChartValue = createMemo(() => + Math.max(1, ...chartData().map((d) => d.value)), + ); + + const cards = createMemo(() => { + const roleVal = role(); + const list: PortalCard[] = []; + + if (roleVal === "student") { + list.push( + { + icon: , + titleKey: "nav.courses", + to: "/courses", + descKey: "dashboard.portal.coursesDesc", + stat: () => displayCount(courseCount()), + statSuffix: "dashboard.records", + accent: "violet", + }, + { + icon: , + titleKey: "nav.exams", + to: "/exams", + descKey: "dashboard.portal.examsDesc", + stat: () => displayCount(totalExamsCount()), + statSuffix: "dashboard.records", + accent: "amber", + }, + { + icon: , + titleKey: "nav.events", + to: "/events", + descKey: "dashboard.portal.eventsDesc", + stat: () => displayCount(totalEventsCount()), + statSuffix: "dashboard.records", + accent: "sky", + }, + { + icon: , + titleKey: "nav.marks", + to: "/marks", + descKey: "dashboard.portal.marksDesc", + stat: () => (overallAvg() == null ? "--" : roundAvg(overallAvg()!)), + accent: "mint", + }, + { + icon: , + titleKey: "nav.notes", + to: "/notes", + descKey: "dashboard.portal.notesDesc", + stat: () => displayCount(totalNotesCount()), + statSuffix: "dashboard.records", + accent: "rose", + }, + ); + } + + if (roleVal === "teacher") { + list.push( + { icon: , titleKey: "nav.courses", to: "/courses", descKey: "dashboard.portal.coursesDesc", stat: () => displayCount(courseCount()), statSuffix: "dashboard.records", accent: "violet" }, + { icon: , titleKey: "nav.exams", to: "/exams", descKey: "dashboard.portal.examsDesc", stat: () => displayCount(totalExamsCount()), statSuffix: "dashboard.records", accent: "amber" }, + { icon: , titleKey: "nav.events", to: "/events", descKey: "dashboard.portal.eventsDesc", stat: () => displayCount(totalEventsCount()), statSuffix: "dashboard.records", accent: "sky", minRole: "teacher" }, + { icon: , titleKey: "nav.studentMarks", to: "/management/student-marks", descKey: "dashboard.portal.studentMarksDesc", stat: () => "", accent: "mint", minRole: "teacher" }, + { icon: , titleKey: "nav.studentAttendance", to: "/management/student-attendance", descKey: "dashboard.portal.attendanceDesc", stat: () => "", accent: "rose", minRole: "teacher" }, + { icon: , titleKey: "nav.notes", to: "/notes", descKey: "dashboard.portal.notesDesc", stat: () => displayCount(totalNotesCount()), statSuffix: "dashboard.records", accent: "sky" }, + { icon: , titleKey: "nav.work", to: "/work", descKey: "dashboard.portal.workDesc", stat: () => "", accent: "amber", minRole: "teacher" }, + ); + } + + if (hasMinRole(roleVal, "manager")) { + list.unshift( + { icon: , titleKey: "nav.courses", to: "/courses", descKey: "dashboard.portal.coursesDesc", stat: () => displayCount(courseCount()), statSuffix: "dashboard.records", accent: "violet" }, + { icon: , titleKey: "nav.exams", to: "/exams", descKey: "dashboard.portal.examsDesc", stat: () => displayCount(totalExamsCount()), statSuffix: "dashboard.records", accent: "amber" }, + { icon: , titleKey: "nav.events", to: "/events", descKey: "dashboard.portal.eventsDesc", stat: () => displayCount(totalEventsCount()), statSuffix: "dashboard.records", accent: "sky" }, + { icon: , titleKey: "nav.settings", to: "/management/settings", descKey: "dashboard.portal.settingsDesc", stat: () => "", accent: "mint", minRole: "manager" }, + { icon: , titleKey: "nav.terms", to: "/management/terms", descKey: "dashboard.portal.termsDesc", stat: () => "", accent: "rose", minRole: "manager" }, + ); + if (roleVal === "admin") { + list.push( + { icon: , titleKey: "nav.users", to: "/admin/users", descKey: "dashboard.portal.usersDesc", stat: () => "", accent: "rose", minRole: "admin" }, + ); + } + } + + return list; + }); return (
- + +
+ + {t(ROLE_KEY[role()])} + + + {formatDateTime(Date.now(), locale()).split(",")[0]} + +
+
{(msg) => {msg()}} - {/* KPIs below actions */} }> -
- - - - + {(card) => } +
+ +
+ + - +
+ + ); +} - {/* Summaries */} -
-
-
-

{t("dashboard.recentNotes")}

-
-
- }> - 0} - fallback={ - } - title={t("dashboard.emptyNotesTitle")} - description={t("dashboard.noNotes")} - tone="amber" - /> - } - > -
    - - {(note: Note) => ( -
  • -
    -

    {note.title}

    -

    - {note.content || t("notes.noContent")} -

    -
    -
  • - )} -
    -
-
-
-
-
+function PortalCard(props: { card: PortalCard }) { + const t = useT(); + const { icon, titleKey, to, descKey, stat, statSuffix, accent, minRole } = props.card; + const statValue = stat(); -
-
-

{t("dashboard.upcomingEvents")}

-
-
- }> - 0} - fallback={ - } - title={t("dashboard.emptyEventsTitle")} - description={t("dashboard.noEvents")} - tone="sky" - /> - } - > -
    - - {(event: Event) => ( -
  • - -
    -

    {event.title}

    -

    - {formatDateTime(event.starts_at, locale())} -

    -
    - - → - - -
  • - )} -
    -
-
-
-
-
+ const iconAccentMap: Record = { + violet: "border-violet-500/30 bg-violet-500/10 text-violet-700 dark:text-violet-300", + amber: "border-amber-500/30 bg-amber-500/10 text-amber-700 dark:text-amber-300", + sky: "border-sky-500/30 bg-sky-500/10 text-sky-700 dark:text-sky-300", + mint: "border-emerald-500/30 bg-emerald-500/10 text-emerald-700 dark:text-emerald-300", + rose: "border-rose-500/30 bg-rose-500/10 text-rose-700 dark:text-rose-300", + }; -
-
-

{t("dashboard.myExams")}

-
-
- }> - 0} - fallback={ - } - title={t("dashboard.emptyExamsTitle")} - description={t("exams.empty")} - tone="rose" - /> - } + const dotMap: Record = { + violet: "bg-violet-500", + amber: "bg-amber-500", + sky: "bg-sky-500", + mint: "bg-emerald-500", + rose: "bg-rose-500", + }; + + return ( + +
+
+
+ {icon} +
+ + + +
+
+
+

{t(titleKey)}

+ + -
    - - {(exam: Exam) => ( -
  • - -
    -

    {exam.title}

    -

    - {exam.description || "—"} -

    -
    - - {examKindLabel(String(exam.kind), t)} - -
    -
  • - )} -
    -
-
- -
+ {t(ROLE_KEY[minRole!])} + +
-
- - + +

+ {statValue} + + {(suffix) => {t(suffix())}} + +

+
+

{t(descKey)}

+ + ); } -function StatTile(props: { - label: string; - value: string; - hint: string; - tone: "mint" | "sky" | "amber" | "violet"; - to?: string; - suffix?: string; +function UpcomingTimeline(props: { + timeline: TimelineItem[]; + locale: Locale; + t: (key: MessageKey, params?: Record) => string; }) { - const tones = { - mint: "text-emerald-700 dark:text-emerald-300", - sky: "text-sky-700 dark:text-sky-300", - amber: "text-amber-700 dark:text-amber-300", - violet: "text-violet-700 dark:text-violet-300", - }; - - const inner = ( -
-

{props.label}

-

- {props.value} - - {props.suffix} - -

-

{props.hint}

+ return ( +
+
+ +

{props.t("dashboard.upcoming")}

+
+ 0} + fallback={ +

{props.t("dashboard.noEvents")}

+ } + > +
+ + {(item) => ( + +
+ {item.type === "exam" + ? + : } +
+
+

{item.title}

+

{item.subtitle}

+
+ + {item.at == null ? props.t("exams.unscheduled") : formatDateTime(item.at, props.locale)} + + + )} +
+
+
); - - if (props.to) { - return ( - - {inner} - - ); - } - return inner; } -function EmptyPanel(props: { - icon: any; - title: string; - description: string; - tone: "amber" | "sky" | "rose"; +function ActivityChart(props: { + label: string; + items: { label: string; value: number }[]; + maxValue: number; }) { - const tones = { - amber: "from-amber-500/10 via-transparent to-transparent text-amber-700 dark:text-amber-300", - sky: "from-sky-500/10 via-transparent to-transparent text-sky-700 dark:text-sky-300", - rose: "from-rose-500/10 via-transparent to-transparent text-rose-700 dark:text-rose-300", - }; - return ( -
-
- {props.icon} +
+
+ +

{props.label}

+
+
+ + {(item, i) => ( +
+
+ {item.label} + {item.value} +
+
+
+
+
+ )} +
-

{props.title}

-

- {props.description} -

); }