From 076d907e989d0190cbc1c46e25309247fbf6eabf Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Burak=20Boduro=C4=9Flu?= <80620802+burakboduroglu@users.noreply.github.com> Date: Tue, 28 Jul 2026 15:02:07 +0300 Subject: [PATCH] =?UTF-8?q?refactor:=20=F0=9F=8E=A8=20simplify=20detail=20?= =?UTF-8?q?page=20layouts?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit - split course and exam topics into focused tabs with compact summaries - move secondary actions into menus and preserve role-gated workflows - use border-only accents and cap detail content at 1440px --- src/pages/course-detail-page.tsx | 214 ++++++++++--------- src/pages/exam-detail-page.tsx | 344 +++++++++++++++---------------- 2 files changed, 284 insertions(+), 274 deletions(-) diff --git a/src/pages/course-detail-page.tsx b/src/pages/course-detail-page.tsx index 00f64ce..f305e58 100644 --- a/src/pages/course-detail-page.tsx +++ b/src/pages/course-detail-page.tsx @@ -30,7 +30,7 @@ import { Button } from "@/components/ui/button"; import { ConfirmDialog } from "@/components/ui/confirm-dialog"; import { DataTable, DataTableSkeleton } from "@/components/ui/data-table"; import { EmptyState } from "@/components/ui/empty-state"; -import { IconChevronLeft, IconEdit, IconPlus, IconTrash } from "@/components/ui/icons"; +import { IconBook, IconCalendarDays, IconEdit, IconExam, IconHomework, IconPlus, IconSchool, IconTrash, IconUsers } from "@/components/ui/icons"; import { createFlash } from "@/lib/flash"; import { cn } from "@/lib/cn"; import { Input } from "@/components/ui/input"; @@ -69,7 +69,7 @@ function CourseDetailContent() { return params().id; }); - const [courseTab, setCourseTab] = createSignal("overview"); + const [courseTab, setCourseTab] = createSignal("subjects"); const [course, { refetch: refetchCourse }] = createResource(id, (courseId) => getCourseById(courseId)); const [terms] = createResource(async () => (await getTerms({ limit: 100 })).items); const [settings] = createResource(() => getSettings()); @@ -150,6 +150,11 @@ function CourseDetailContent() { const courseListSearch = (value: CourseKind | undefined) => value ? { kind: value } as never : {} as never; const examCount = createMemo(() => exams()?.length ?? 0); + const nextExam = createMemo(() => + (exams() ?? []) + .filter((exam) => (exam.ends_at ?? exam.starts_at ?? 0) > Date.now()) + .sort((a, b) => (a.starts_at ?? a.ends_at ?? 0) - (b.starts_at ?? b.ends_at ?? 0))[0], + ); const rosterCount = createMemo(() => roster()?.length ?? 0); const countDescription = (count: number, item: string) => t("common.countItem", { count, item }); @@ -274,50 +279,79 @@ function CourseDetailContent() { {(c) => ( }> {t("common.accessDenied")}}> -
+
+ - - - - -
- - - - -
-
-
+ + , + onSelect: startEdit, + }, + ...(canDeleteCourse() + ? [{ + label: t("courses.delete"), + icon: , + destructive: true, + onSelect: () => setDeleteOpen(true), + }] + : []), + ]} + /> + } /> -
-
-

{t("courses.kind")}

-

{courseKindLabel(c().kind)}

+
+
+ + + +
+

{t("courses.kind")}

+

{courseKindLabel(c().kind)}

+
+
+
+ + + +
+

{t("terms.term")}

+

{terms()?.find((term) => term.id === c().term)?.name ?? t("terms.unassigned")}

+
-
-

{t("terms.term")}

-

{terms()?.find((term) => term.id === c().term)?.name ?? t("terms.unassigned")}

+
+ + + +
+

{t("courses.capacity")}

+

{c().capacity == null ? "—" : hasCourseManagementRights() ? `${rosterCount()} / ${c().capacity}` : c().capacity}

+
-
-

{t("courses.capacity")}

-

{c().capacity == null ? "—" : hasCourseManagementRights() ? `${rosterCount()} / ${c().capacity}` : c().capacity}

+
+ + + +
+

{t("courses.nextExam")}

+ {t("courses.noUpcoming")}

}> + {(exam) => {exam().title}} +
+
@@ -556,58 +590,46 @@ function CourseDetailContent() { )} - - {t("courses.overview")} - {t("courses.work")} - {t("sessions.title")} - {t("courses.people")} + + {t("subjects.title")} + {t("courses.exams")} + {t("homework.title")} + {t("sessions.title")} + {t("courses.teachers")} + + {t("courses.roster")} + - -
-

{t("courses.overview")}

-

{c().description || "—"}

-
-
-

{t("courses.upcoming")}

- (exam.ends_at ?? exam.starts_at ?? 0) > Date.now()).sort((a, b) => (a.starts_at ?? a.ends_at ?? 0) - (b.starts_at ?? b.ends_at ?? 0))[0]} - fallback={

{t("courses.noUpcoming")}

} - > - {(exam) => {exam().title}} -
+ +
+ {countDescription(subjectCount(), t("subjects.item"))} +
+
- -
-
-

{t("subjects.title")} · {countDescription(subjectCount(), t("subjects.item"))}

- -
- -
-
-
-

{t("courses.exams")} · {countDescription(examCount(), t("courses.examItem"))}

- -
- }> void navigate({ to: "/exams/$id", params: { id: exam.id } })} /> + +
+ {countDescription(examCount(), t("courses.examItem"))} +
-
-
-

{t("homework.title")} · {countDescription(homeworkCount(), t("homework.item"))}

- -
- + }> void navigate({ to: "/exams/$id", params: { id: exam.id } })} /> + + + +
+ {countDescription(homeworkCount(), t("homework.item"))} +
+
- -
-

{countDescription(sessionCount(), t("sessions.item"))}

+ +
+ {countDescription(sessionCount(), t("sessions.item"))} - @@ -616,25 +638,27 @@ function CourseDetailContent() { - -
-
-

{t("courses.teachers")} · {countDescription((c().teachers ?? []).length + 1, t("courses.teachers"))}

- -
-

{t("common.creator")}: {c().creator.display_name || c().creator.username}

- + +
+ {countDescription((c().teachers ?? []).length + 1, t("courses.teachers"))} +
- -
-
-

{t("courses.roster")} · {countDescription(rosterCount(), t("courses.rosterItem"))}

- -
- }> 0} fallback={}> -
-
+
+ + {t("common.creator")}: {c().creator.display_name || c().creator.username} +
+
+ + + +
+ {countDescription(rosterCount(), t("courses.rosterItem"))} + +
+ }> 0} fallback={}> +
+
diff --git a/src/pages/exam-detail-page.tsx b/src/pages/exam-detail-page.tsx index f59a19a..891a25f 100644 --- a/src/pages/exam-detail-page.tsx +++ b/src/pages/exam-detail-page.tsx @@ -28,7 +28,7 @@ import { Button } from "@/components/ui/button"; import { ConfirmDialog } from "@/components/ui/confirm-dialog"; import { DataTable, DataTableSkeleton } from "@/components/ui/data-table"; import { EmptyState } from "@/components/ui/empty-state"; -import { IconChevronDown, IconChevronLeft, IconEdit, IconExam, IconEye, IconPlus, IconTrash } from "@/components/ui/icons"; +import { IconCalendarDays, IconChart, IconChevronDown, IconClipboardCheck, IconClock, IconEdit, IconExam, IconEye, IconPencilQuestion, IconRefresh, IconTrash } from "@/components/ui/icons"; import { Input } from "@/components/ui/input"; import { PaginationControls } from "@/components/ui/pagination-controls"; import { PageSpinner } from "@/components/ui/page-spinner"; @@ -43,7 +43,7 @@ import { examDurationMs, formatDateTime, formatDurationMinutes } from "@/lib/for import { personId, personLabel, personLabelWithId } from "@/lib/person"; import { cn } from "@/lib/cn"; import { createFlash } from "@/lib/flash"; -import { scheduleStatusClass, scheduleStatusDotClass } from "@/lib/schedule-status"; +import { scheduleStatusClass } from "@/lib/schedule-status"; import { useAuth } from "@/stores/auth-context"; import { usePreferences, useT } from "@/stores/preferences-context"; @@ -118,8 +118,7 @@ function ExamDetailContent() { const [answerMark, setAnswerMark] = createSignal("0"); const [answerError, setAnswerError] = createSignal(""); const [answerPending, setAnswerPending] = createSignal(false); - const [questionCreateOpen, setQuestionCreateOpen] = createSignal(false); - const [examTab, setExamTab] = createSignal("schedule"); + const [examTab, setExamTab] = createSignal("questions"); const isSittable = () => { const e = exam(); return e ? isSittableExam(e) : false; @@ -203,6 +202,13 @@ function ExamDetailContent() { }; const isFinished = () => examStatus().finished; const isUpcoming = () => examStatus().upcoming; + let defaultTabExamId = ""; + createEffect(() => { + const current = exam(); + if (!current || current.id === defaultTabExamId) return; + defaultTabExamId = current.id; + setExamTab(current.ends_at != null && current.ends_at < now() ? "results" : "questions"); + }); const ownAttemptSummary = (): ExamAttemptSummary | null => { const attempt = ownAttempt(); return attempt ? { status: attempt.status, attempts_used: attempt.attempts_used, max_attempts: attempt.max_attempts } : null; @@ -377,21 +383,20 @@ function ExamDetailContent() { {(ex) => ( }> {t("common.accessDenied")}}> -
-
+
+
+ - - - +
- -
- - -
+ , + onSelect: () => setEditing(true), + }, + { + label: t("common.delete"), + icon: , + destructive: true, + disabled: pending(), + onSelect: () => setDeleteOpen(true), + }, + ]} + />
} - /> -
- - - -
-
-

{t("work.status")}

+
- + {detailStatusLabel()} + + {examKindLabel(String(ex().kind), t)} +
-
-

{t("exams.kind")}

-

{examKindLabel(String(ex().kind), t)}

-
-
-

{t("exams.mode")}

-

{examModeLabel(ex().mode)}

+ +
+
+
+ + + +
+

{t("exams.mode")}

+

{examModeLabel(ex().mode)}

-
-

{t("exams.maxAttempts")}

-

+

+
+ + + +
+

{t("exams.maxAttempts")}

+

{ownAttemptSummary() ? `${ownAttemptSummary()!.attempts_used} / ${ex().max_attempts}` : `0 / ${ex().max_attempts}`} - - ({t("exams.attemptsLeft")}: {ex().max_attempts - (ownAttemptSummary()?.attempts_used ?? 0)}) -

+ +

{t("exams.attemptsLeft")}: {ex().max_attempts - (ownAttemptSummary()?.attempts_used ?? 0)}

+
- -
-

{t("exams.startsAt")}

-

{formatDateTime(ex().starts_at, locale())}

-
-
- -
-

{t("exams.endsAt")}

-

{formatDateTime(ex().ends_at, locale())}

-
-
- - {(dur) => ( -
-

{t("exams.durationMinutes")}

-

{formatDurationMinutes(dur(), locale())}

-
- )} -
+
+ + + +
+

{t("exams.window")}

+

+ {formatDateTime(ex().starts_at, locale())} +

+ +

{formatDateTime(ex().ends_at, locale())}

+
+
+
+
+ + + +
+

{t("exams.durationMinutes")}

+

+ {formatDurationMinutes(examDurationMs(ex().duration_ms, ex().starts_at, ex().ends_at), locale())} +

+
+
+
- - - {t("exams.schedule")} - - {t("exams.yourResult")} - - - {t("exams.statistics")} - {t("questions.title")} - {t("exams.results")} - - - - -
{t("exams.details")}
-
-
-

{t("exams.mode")}

-

{examModeLabel(ex().mode)}

+ + {(result) => ( +
+
+ + + +

{t("exams.yourResult")}

+
-
-

{t("events.starts")}

-

{formatDateTime(ex().starts_at, locale())}

-
-
-

{t("events.ends")}

-

{formatDateTime(ex().ends_at, locale())}

-
-
-

{t("exams.durationMinutes")}

-

{formatDurationMinutes(examDurationMs(ex().duration_ms, ex().starts_at, ex().ends_at), locale())}

-
-
- - - - -
{ownResult() ? `${t("form.mark")}: ${ownResult()!.mark}` : t("exams.notGraded")}
- }> - }> - {(r) => } - - - -
- -
+ + -
-
+ + )} + + + + + + {t("exams.statistics")} + {t("questions.title")} + {t("exams.results")} + - - -
{t("exams.examStatistics")}
+ }> {(s) => ( -
-
+
+

{t("exams.graded")}

{s().graded}

-
+

{t("exams.average")}

{s().average == null ? "—" : s().average}

-
+

{t("exams.min")}

{s().min == null ? "—" : s().min}

-
+

{t("exams.max")}

{s().max == null ? "—" : s().max}

@@ -698,18 +669,55 @@ function ExamDetailContent() { - -
-

{t("exams.examQuestions")}

- - - +
- + }> + 0} + fallback={} + > + + RESULT_PAGE_SIZE}> + + + + + - - -
-

{`${resultTotal()} ${t("exams.studentResults")}`}

- -
- }> - 0} - fallback={} - > - - RESULT_PAGE_SIZE}> - - - - -
- - + {flash()}