✨ split courses into /courses, /studies, /clubs with shared page
Browse files at this commitcd3f0a85e790c3252d66d3b19dda1a40cebef998Parent: e600469- feat
- ✨ split courses into /courses, /studies, /clubs with shared page
6 changed files +76 -40
- src/components/layout/side-nav.tsx +2 -0
- src/i18n/messages.ts +25 -10
- src/pages/course-detail-page.tsx +5 -4
- src/pages/courses-page.tsx +17 -24
- src/pages/dashboard-page.tsx +13 -2
- src/routes/router.tsx +14 -0
src/components/layout/side-nav.tsxmodified+2 -0
| @@ -58,6 +58,8 @@ const NAV_GROUPS: NavGroup[] = [ | |||
| 58 | Icon: IconSchool, | 58 | Icon: IconSchool, |
| 59 | items: [ | 59 | items: [ |
| 60 | { to: "/courses", labelKey: "nav.courses", Icon: IconBook }, | 60 | { to: "/courses", labelKey: "nav.courses", Icon: IconBook }, |
| 61 | + { to: "/studies", labelKey: "nav.studies", Icon: IconClock }, | ||
| 62 | + { to: "/clubs", labelKey: "nav.clubs", Icon: IconUsers }, | ||
| 61 | { to: "/exams", labelKey: "nav.exams", Icon: IconExam }, | 63 | { to: "/exams", labelKey: "nav.exams", Icon: IconExam }, |
| 62 | { to: "/events", labelKey: "nav.events", Icon: IconCalendar }, | 64 | { to: "/events", labelKey: "nav.events", Icon: IconCalendar }, |
| 63 | ], | 65 | ], |
src/i18n/messages.tsmodified+25 -10
| @@ -8,6 +8,8 @@ export type MessageKey = | |||
| 8 | | "nav.events" | 8 | | "nav.events" |
| 9 | | "nav.exams" | 9 | | "nav.exams" |
| 10 | | "nav.courses" | 10 | | "nav.courses" |
| 11 | + | "nav.studies" | ||
| 12 | + | "nav.clubs" | ||
| 11 | | "nav.marks" | 13 | | "nav.marks" |
| 12 | | "nav.pomodoro" | 14 | | "nav.pomodoro" |
| 13 | | "nav.attendance" | 15 | | "nav.attendance" |
| @@ -83,6 +85,7 @@ export type MessageKey = | |||
| 83 | | "common.created" | 85 | | "common.created" |
| 84 | | "common.deleted" | 86 | | "common.deleted" |
| 85 | | "common.saved" | 87 | | "common.saved" |
| 88 | + | "common.createItem" | ||
| 86 | | "common.countItem" | 89 | | "common.countItem" |
| 87 | | "theme.light" | 90 | | "theme.light" |
| 88 | | "theme.dark" | 91 | | "theme.dark" |
| @@ -169,6 +172,8 @@ export type MessageKey = | |||
| 169 | | "dashboard.continueGuide" | 172 | | "dashboard.continueGuide" |
| 170 | | "dashboard.portal.sections" | 173 | | "dashboard.portal.sections" |
| 171 | | "dashboard.portal.coursesDesc" | 174 | | "dashboard.portal.coursesDesc" |
| 175 | + | "dashboard.portal.studiesDesc" | ||
| 176 | + | "dashboard.portal.clubsDesc" | ||
| 172 | | "dashboard.portal.examsDesc" | 177 | | "dashboard.portal.examsDesc" |
| 173 | | "dashboard.portal.eventsDesc" | 178 | | "dashboard.portal.eventsDesc" |
| 174 | | "dashboard.portal.marksDesc" | 179 | | "dashboard.portal.marksDesc" |
| @@ -590,7 +595,9 @@ const en: Dict = { | |||
| 590 | "nav.notes": "Notes", | 595 | "nav.notes": "Notes", |
| 591 | "nav.events": "Events", | 596 | "nav.events": "Events", |
| 592 | "nav.exams": "Exams", | 597 | "nav.exams": "Exams", |
| 593 | - "nav.courses": "Education", | 598 | + "nav.courses": "Courses", |
| 599 | + "nav.studies": "Study sessions", | ||
| 600 | + "nav.clubs": "Clubs", | ||
| 594 | "nav.marks": "Report card", | 601 | "nav.marks": "Report card", |
| 595 | "nav.pomodoro": "Pomodoro", | 602 | "nav.pomodoro": "Pomodoro", |
| 596 | "nav.attendance": "Attendance", | 603 | "nav.attendance": "Attendance", |
| @@ -666,6 +673,7 @@ const en: Dict = { | |||
| 666 | "common.created": "Created.", | 673 | "common.created": "Created.", |
| 667 | "common.deleted": "Deleted.", | 674 | "common.deleted": "Deleted.", |
| 668 | "common.saved": "Saved.", | 675 | "common.saved": "Saved.", |
| 676 | + "common.createItem": "Create {item}", | ||
| 669 | "common.countItem": "{count} {item}", | 677 | "common.countItem": "{count} {item}", |
| 670 | "theme.light": "Light", | 678 | "theme.light": "Light", |
| 671 | "theme.dark": "Dark", | 679 | "theme.dark": "Dark", |
| @@ -751,7 +759,9 @@ const en: Dict = { | |||
| 751 | "dashboard.helpBody": "Stuck on a page or looking for the next step? Open the short app guide.", | 759 | "dashboard.helpBody": "Stuck on a page or looking for the next step? Open the short app guide.", |
| 752 | "dashboard.continueGuide": "Guide", | 760 | "dashboard.continueGuide": "Guide", |
| 753 | "dashboard.portal.sections": "Sections", | 761 | "dashboard.portal.sections": "Sections", |
| 754 | - "dashboard.portal.coursesDesc": "Browse courses, study sessions, clubs, and materials.", | 762 | + "dashboard.portal.coursesDesc": "Browse course rosters, subjects, and exams.", |
| 763 | + "dashboard.portal.studiesDesc": "Browse study sessions, rosters, and exams.", | ||
| 764 | + "dashboard.portal.clubsDesc": "Browse clubs, rosters, and exams.", | ||
| 755 | "dashboard.portal.examsDesc": "Course exams, deadlines, and results.", | 765 | "dashboard.portal.examsDesc": "Course exams, deadlines, and results.", |
| 756 | "dashboard.portal.eventsDesc": "Events with student attendance records.", | 766 | "dashboard.portal.eventsDesc": "Events with student attendance records.", |
| 757 | "dashboard.portal.marksDesc": "Your grades and overall report card.", | 767 | "dashboard.portal.marksDesc": "Your grades and overall report card.", |
| @@ -1018,10 +1028,10 @@ const en: Dict = { | |||
| 1018 | "role.manager": "Manager", | 1028 | "role.manager": "Manager", |
| 1019 | "role.admin": "ADMIN", | 1029 | "role.admin": "ADMIN", |
| 1020 | "courses.title": "Education", | 1030 | "courses.title": "Education", |
| 1021 | - "courses.listTitle": "Education records", | 1031 | + "courses.listTitle": "{item} records", |
| 1022 | - "courses.subtitle": "Courses, study sessions, clubs, enrollment, and exams live here.", | 1032 | + "courses.subtitle": "Manage {item}, enrollment, and exams here.", |
| 1023 | "courses.create": "New education item", | 1033 | "courses.create": "New education item", |
| 1024 | - "courses.empty": "No courses yet.", | 1034 | + "courses.empty": "No {item} yet.", |
| 1025 | "courses.enrolled": "Enrolled", | 1035 | "courses.enrolled": "Enrolled", |
| 1026 | "courses.roster": "Roster", | 1036 | "courses.roster": "Roster", |
| 1027 | "courses.rosterItem": "Student", | 1037 | "courses.rosterItem": "Student", |
| @@ -1185,7 +1195,9 @@ const tr: Dict = { | |||
| 1185 | "nav.notes": "Notlar", | 1195 | "nav.notes": "Notlar", |
| 1186 | "nav.events": "Etkinlikler", | 1196 | "nav.events": "Etkinlikler", |
| 1187 | "nav.exams": "Sınavlar", | 1197 | "nav.exams": "Sınavlar", |
| 1188 | - "nav.courses": "Eğitim", | 1198 | + "nav.courses": "Ders", |
| 1199 | + "nav.studies": "Etüt", | ||
| 1200 | + "nav.clubs": "Kulüp", | ||
| 1189 | "nav.marks": "Notlar", | 1201 | "nav.marks": "Notlar", |
| 1190 | "nav.pomodoro": "Pomodoro", | 1202 | "nav.pomodoro": "Pomodoro", |
| 1191 | "nav.attendance": "Yoklamalar", | 1203 | "nav.attendance": "Yoklamalar", |
| @@ -1261,6 +1273,7 @@ const tr: Dict = { | |||
| 1261 | "common.created": "Oluşturuldu.", | 1273 | "common.created": "Oluşturuldu.", |
| 1262 | "common.deleted": "Silindi.", | 1274 | "common.deleted": "Silindi.", |
| 1263 | "common.saved": "Kaydedildi.", | 1275 | "common.saved": "Kaydedildi.", |
| 1276 | + "common.createItem": "{item} oluştur", | ||
| 1264 | "common.countItem": "{count} Adet {item}", | 1277 | "common.countItem": "{count} Adet {item}", |
| 1265 | "theme.light": "Açık", | 1278 | "theme.light": "Açık", |
| 1266 | "theme.dark": "Koyu", | 1279 | "theme.dark": "Koyu", |
| @@ -1346,7 +1359,9 @@ const tr: Dict = { | |||
| 1346 | "dashboard.helpBody": "Bir sayfada takıldın veya sonraki adımı mı arıyorsun? Kısa uygulama rehberini aç.", | 1359 | "dashboard.helpBody": "Bir sayfada takıldın veya sonraki adımı mı arıyorsun? Kısa uygulama rehberini aç.", |
| 1347 | "dashboard.continueGuide": "Rehber", | 1360 | "dashboard.continueGuide": "Rehber", |
| 1348 | "dashboard.portal.sections": "Bölümler", | 1361 | "dashboard.portal.sections": "Bölümler", |
| 1349 | - "dashboard.portal.coursesDesc": "Dersleri, etütleri, kulüpleri ve materyalleri görüntüle.", | 1362 | + "dashboard.portal.coursesDesc": "Dersleri, konuları, kayıtları ve sınavları görüntüle.", |
| 1363 | + "dashboard.portal.studiesDesc": "Etütleri, kayıtları ve sınavları görüntüle.", | ||
| 1364 | + "dashboard.portal.clubsDesc": "Kulüpleri, kayıtları ve sınavları görüntüle.", | ||
| 1350 | "dashboard.portal.examsDesc": "Eğitim sınavları, tarihler ve sonuçlar.", | 1365 | "dashboard.portal.examsDesc": "Eğitim sınavları, tarihler ve sonuçlar.", |
| 1351 | "dashboard.portal.eventsDesc": "Öğrenci yoklamalı etkinlikler.", | 1366 | "dashboard.portal.eventsDesc": "Öğrenci yoklamalı etkinlikler.", |
| 1352 | "dashboard.portal.marksDesc": "Notların ve genel karnen.", | 1367 | "dashboard.portal.marksDesc": "Notların ve genel karnen.", |
| @@ -1613,10 +1628,10 @@ const tr: Dict = { | |||
| 1613 | "role.manager": "Yönetici", | 1628 | "role.manager": "Yönetici", |
| 1614 | "role.admin": "ADMIN", | 1629 | "role.admin": "ADMIN", |
| 1615 | "courses.title": "Eğitim", | 1630 | "courses.title": "Eğitim", |
| 1616 | - "courses.listTitle": "Eğitim kayıtları", | 1631 | + "courses.listTitle": "{item} kayıtları", |
| 1617 | - "courses.subtitle": "Dersler, etütler, kulüpler, kayıtlar ve sınavlar burada.", | 1632 | + "courses.subtitle": "{item}, kayıtlar ve sınavlar burada.", |
| 1618 | "courses.create": "Yeni eğitim kaydı", | 1633 | "courses.create": "Yeni eğitim kaydı", |
| 1619 | - "courses.empty": "Henüz ders yok.", | 1634 | + "courses.empty": "Henüz {item} yok.", |
| 1620 | "courses.enrolled": "Kayıtlı", | 1635 | "courses.enrolled": "Kayıtlı", |
| 1621 | "courses.roster": "Sınıf listesi", | 1636 | "courses.roster": "Sınıf listesi", |
| 1622 | "courses.rosterItem": "Öğrenci", | 1637 | "courses.rosterItem": "Öğrenci", |
src/pages/course-detail-page.tsxmodified+5 -4
| @@ -122,6 +122,7 @@ function CourseDetailContent() { | |||
| 122 | }; | 122 | }; |
| 123 | const courseKindLabel = (value: CourseKind | undefined) => | 123 | const courseKindLabel = (value: CourseKind | undefined) => |
| 124 | value === "study" ? t("courses.kind.study") : value === "club" ? t("courses.kind.club") : t("courses.kind.course"); | 124 | value === "study" ? t("courses.kind.study") : value === "club" ? t("courses.kind.club") : t("courses.kind.course"); |
| 125 | + const courseListPath = (value: CourseKind | undefined) => value === "study" ? "/studies" : value === "club" ? "/clubs" : "/courses"; | ||
| 125 | 126 | ||
| 126 | const examCount = createMemo(() => exams()?.length ?? 0); | 127 | const examCount = createMemo(() => exams()?.length ?? 0); |
| 127 | const rosterCount = createMemo(() => roster()?.length ?? 0); | 128 | const rosterCount = createMemo(() => roster()?.length ?? 0); |
| @@ -257,18 +258,18 @@ function CourseDetailContent() { | |||
| 257 | <div class="detail-breadcrumb"> | 258 | <div class="detail-breadcrumb"> |
| 258 | <span>{t("nav.group.classes")}</span> | 259 | <span>{t("nav.group.classes")}</span> |
| 259 | <span>/</span> | 260 | <span>/</span> |
| 260 | - <Link to="/courses">{t("courses.title")}</Link> | 261 | + <Link to={courseListPath(c().kind)}>{courseKindLabel(c().kind)}</Link> |
| 261 | <span>/</span> | 262 | <span>/</span> |
| 262 | <span class="truncate">{c().title}</span> | 263 | <span class="truncate">{c().title}</span> |
| 263 | </div> | 264 | </div> |
| 264 | <PageHeader | 265 | <PageHeader |
| 265 | accent="violet" | 266 | accent="violet" |
| 266 | - eyebrow={t("courses.title")} | 267 | + eyebrow={courseKindLabel(c().kind)} |
| 267 | title={c().title} | 268 | title={c().title} |
| 268 | description={`${t("terms.term")}: ${terms()?.find((term) => term.id === c().term)?.name ?? t("terms.unassigned")}${c().description ? ` - ${c().description}` : ""}`} | 269 | description={`${t("terms.term")}: ${terms()?.find((term) => term.id === c().term)?.name ?? t("terms.unassigned")}${c().description ? ` - ${c().description}` : ""}`} |
| 269 | actions={ | 270 | actions={ |
| 270 | <div class="detail-action-group"> | 271 | <div class="detail-action-group"> |
| 271 | - <Link to="/courses"> | 272 | + <Link to={courseListPath(c().kind)}> |
| 272 | <Button variant="ghost" size="sm" class="w-full rounded-sm sm:w-auto"> | 273 | <Button variant="ghost" size="sm" class="w-full rounded-sm sm:w-auto"> |
| 273 | <IconChevronLeft class="h-4 w-4" /> | 274 | <IconChevronLeft class="h-4 w-4" /> |
| 274 | {t("common.back")} | 275 | {t("common.back")} |
| @@ -307,7 +308,7 @@ function CourseDetailContent() { | |||
| 307 | onConfirm={async () => { | 308 | onConfirm={async () => { |
| 308 | await wrap(async () => { | 309 | await wrap(async () => { |
| 309 | await deleteCourseById(id()); | 310 | await deleteCourseById(id()); |
| 310 | - void navigate({ to: "/courses" }); | 311 | + void navigate({ to: courseListPath(c().kind) }); |
| 311 | }); | 312 | }); |
| 312 | }} | 313 | }} |
| 313 | /> | 314 | /> |
src/pages/courses-page.tsxmodified+17 -24
| @@ -1,6 +1,6 @@ | |||
| 1 | import { For, Show, Suspense, createMemo, createResource, createSignal } from "solid-js"; | 1 | import { For, Show, Suspense, createMemo, createResource, createSignal } from "solid-js"; |
| 2 | import type { ColumnDef } from "@tanstack/solid-table"; | 2 | import type { ColumnDef } from "@tanstack/solid-table"; |
| 3 | -import { useNavigate } from "@tanstack/solid-router"; | 3 | +import { useLocation, useNavigate } from "@tanstack/solid-router"; |
| 4 | import { getCourses } from "@/api/getCourses"; | 4 | import { getCourses } from "@/api/getCourses"; |
| 5 | import { getMyCourses } from "@/api/getMyCourses"; | 5 | import { getMyCourses } from "@/api/getMyCourses"; |
| 6 | import { getTerms } from "@/api/getTerms"; | 6 | import { getTerms } from "@/api/getTerms"; |
| @@ -28,7 +28,6 @@ import { useT } from "@/stores/preferences-context"; | |||
| 28 | import { hasMinRole } from "@/lib/roles"; | 28 | import { hasMinRole } from "@/lib/roles"; |
| 29 | 29 | ||
| 30 | const COURSE_PAGE_SIZE = 12; | 30 | const COURSE_PAGE_SIZE = 12; |
| 31 | -const COURSE_KINDS: CourseKind[] = ["course", "study", "club"]; | ||
| 32 | 31 | ||
| 33 | export default function CoursesPage() { | 32 | export default function CoursesPage() { |
| 34 | return ( | 33 | return ( |
| @@ -41,11 +40,11 @@ export default function CoursesPage() { | |||
| 41 | function CoursesContent() { | 40 | function CoursesContent() { |
| 42 | const auth = useAuth(); | 41 | const auth = useAuth(); |
| 43 | const navigate = useNavigate(); | 42 | const navigate = useNavigate(); |
| 43 | + const location = useLocation(); | ||
| 44 | const t = useT(); | 44 | const t = useT(); |
| 45 | const [showForm, setShowForm] = createSignal(false); | 45 | const [showForm, setShowForm] = createSignal(false); |
| 46 | const [title, setTitle] = createSignal(""); | 46 | const [title, setTitle] = createSignal(""); |
| 47 | const [description, setDescription] = createSignal(""); | 47 | const [description, setDescription] = createSignal(""); |
| 48 | - const [kind, setKind] = createSignal<CourseKind>("course"); | ||
| 49 | const [termId, setTermId] = createSignal(""); | 48 | const [termId, setTermId] = createSignal(""); |
| 50 | const [capacity, setCapacity] = createSignal(""); | 49 | const [capacity, setCapacity] = createSignal(""); |
| 51 | const [error, setError] = createSignal(""); | 50 | const [error, setError] = createSignal(""); |
| @@ -65,6 +64,8 @@ function CoursesContent() { | |||
| 65 | const termName = (id: string | null | undefined) => terms()?.find((term) => term.id === id)?.name ?? t("terms.unassigned"); | 64 | const termName = (id: string | null | undefined) => terms()?.find((term) => term.id === id)?.name ?? t("terms.unassigned"); |
| 66 | const courseKindLabel = (value: CourseKind | undefined) => | 65 | const courseKindLabel = (value: CourseKind | undefined) => |
| 67 | value === "study" ? t("courses.kind.study") : value === "club" ? t("courses.kind.club") : t("courses.kind.course"); | 66 | value === "study" ? t("courses.kind.study") : value === "club" ? t("courses.kind.club") : t("courses.kind.course"); |
| 67 | + const pageKind = (): CourseKind => location().pathname.startsWith("/studies") ? "study" : location().pathname.startsWith("/clubs") ? "club" : "course"; | ||
| 68 | + const pageLabel = () => courseKindLabel(pageKind()); | ||
| 68 | const creatorName = (creatorId: string) => { | 69 | const creatorName = (creatorId: string) => { |
| 69 | if (creatorId === auth.user()?.id) return auth.user()?.username ?? creatorId; | 70 | if (creatorId === auth.user()?.id) return auth.user()?.username ?? creatorId; |
| 70 | return users()?.find((user) => user.id === creatorId)?.username ?? creatorId; | 71 | return users()?.find((user) => user.id === creatorId)?.username ?? creatorId; |
| @@ -75,7 +76,7 @@ function CoursesContent() { | |||
| 75 | return items.filter((course) => { | 76 | return items.filter((course) => { |
| 76 | if (selectedTerm === "unassigned" && course.term) return false; | 77 | if (selectedTerm === "unassigned" && course.term) return false; |
| 77 | if (selectedTerm !== "all" && selectedTerm !== "unassigned" && course.term !== selectedTerm) return false; | 78 | if (selectedTerm !== "all" && selectedTerm !== "unassigned" && course.term !== selectedTerm) return false; |
| 78 | - return true; | 79 | + return course.kind === pageKind(); |
| 79 | }); | 80 | }); |
| 80 | }; | 81 | }; |
| 81 | const searchCourse = (course: Course, query: string) => | 82 | const searchCourse = (course: Course, query: string) => |
| @@ -93,11 +94,10 @@ function CoursesContent() { | |||
| 93 | const columns = createMemo<ColumnDef<Course>[]>(() => [ | 94 | const columns = createMemo<ColumnDef<Course>[]>(() => [ |
| 94 | { | 95 | { |
| 95 | accessorKey: "title", | 96 | accessorKey: "title", |
| 96 | - header: t("courses.title"), | 97 | + header: pageLabel(), |
| 97 | cell: (cell) => ( | 98 | cell: (cell) => ( |
| 98 | <div class="min-w-0 space-y-1"> | 99 | <div class="min-w-0 space-y-1"> |
| 99 | <p class="truncate font-medium">{cell.row.original.title}</p> | 100 | <p class="truncate font-medium">{cell.row.original.title}</p> |
| 100 | - <Badge variant="outline" class="rounded-sm text-[11px]">{courseKindLabel(cell.row.original.kind)}</Badge> | ||
| 101 | <Show when={isStudent()}> | 101 | <Show when={isStudent()}> |
| 102 | <Badge variant="secondary" class="rounded-sm">{t("courses.enrolled")}</Badge> | 102 | <Badge variant="secondary" class="rounded-sm">{t("courses.enrolled")}</Badge> |
| 103 | </Show> | 103 | </Show> |
| @@ -149,13 +149,12 @@ function CoursesContent() { | |||
| 149 | await postCourse({ | 149 | await postCourse({ |
| 150 | title: title().trim(), | 150 | title: title().trim(), |
| 151 | description: description().trim() || undefined, | 151 | description: description().trim() || undefined, |
| 152 | - kind: kind(), | 152 | + kind: pageKind(), |
| 153 | term_id: termId() || null, | 153 | term_id: termId() || null, |
| 154 | capacity: cap ? Number(cap) : null, | 154 | capacity: cap ? Number(cap) : null, |
| 155 | }); | 155 | }); |
| 156 | setTitle(""); | 156 | setTitle(""); |
| 157 | setDescription(""); | 157 | setDescription(""); |
| 158 | - setKind("course"); | ||
| 159 | setTermId(""); | 158 | setTermId(""); |
| 160 | setCapacity(""); | 159 | setCapacity(""); |
| 161 | setShowForm(false); | 160 | setShowForm(false); |
| @@ -174,25 +173,25 @@ function CoursesContent() { | |||
| 174 | <div class="flex flex-wrap items-center gap-1 text-xs text-muted-foreground"> | 173 | <div class="flex flex-wrap items-center gap-1 text-xs text-muted-foreground"> |
| 175 | <span>{t("nav.group.classes")}</span> | 174 | <span>{t("nav.group.classes")}</span> |
| 176 | <span>/</span> | 175 | <span>/</span> |
| 177 | - <span>{t("nav.courses")}</span> | 176 | + <span>{pageLabel()}</span> |
| 178 | </div> | 177 | </div> |
| 179 | <PageHeader | 178 | <PageHeader |
| 180 | accent="violet" | 179 | accent="violet" |
| 181 | - eyebrow={t("nav.courses")} | 180 | + eyebrow={t("nav.group.classes")} |
| 182 | - title={t("courses.title")} | 181 | + title={pageLabel()} |
| 183 | - description={t("courses.subtitle")} | 182 | + description={t("courses.subtitle", { item: pageLabel() })} |
| 184 | actions={ | 183 | actions={ |
| 185 | canCreate() ? ( | 184 | canCreate() ? ( |
| 186 | <Button type="button" size="sm" class="min-w-[7.5rem] rounded-lg" onClick={() => setShowForm(true)}> | 185 | <Button type="button" size="sm" class="min-w-[7.5rem] rounded-lg" onClick={() => setShowForm(true)}> |
| 187 | <IconPlus class="h-4 w-4" /> | 186 | <IconPlus class="h-4 w-4" /> |
| 188 | - {t("courses.create")} | 187 | + {t("common.createItem", { item: pageLabel() })} |
| 189 | </Button> | 188 | </Button> |
| 190 | ) : undefined | 189 | ) : undefined |
| 191 | } | 190 | } |
| 192 | /> | 191 | /> |
| 193 | </div> | 192 | </div> |
| 194 | 193 | ||
| 195 | - <SidePanel open={canCreate() && showForm()} onOpenChange={setShowForm} title={t("courses.create")} description={t("courses.subtitle")}> | 194 | + <SidePanel open={canCreate() && showForm()} onOpenChange={setShowForm} title={t("common.createItem", { item: pageLabel() })} description={t("courses.subtitle", { item: pageLabel() })}> |
| 196 | <form class="space-y-3" onSubmit={onCreate}> | 195 | <form class="space-y-3" onSubmit={onCreate}> |
| 197 | <div class="space-y-1.5"> | 196 | <div class="space-y-1.5"> |
| 198 | <Label for="course-title">{t("form.title")}</Label> | 197 | <Label for="course-title">{t("form.title")}</Label> |
| @@ -202,12 +201,6 @@ function CoursesContent() { | |||
| 202 | <Label for="course-desc">{t("form.description")}</Label> | 201 | <Label for="course-desc">{t("form.description")}</Label> |
| 203 | <Textarea id="course-desc" maxlength={2000} rows={3} value={description()} onInput={(e) => setDescription(e.currentTarget.value)} /> | 202 | <Textarea id="course-desc" maxlength={2000} rows={3} value={description()} onInput={(e) => setDescription(e.currentTarget.value)} /> |
| 204 | </div> | 203 | </div> |
| 205 | - <div class="space-y-1.5"> | ||
| 206 | - <Label for="course-kind">{t("courses.kind")}</Label> | ||
| 207 | - <Select id="course-kind" value={kind()} onChange={(e) => setKind(e.currentTarget.value as CourseKind)}> | ||
| 208 | - <For each={COURSE_KINDS}>{(item) => <option value={item}>{courseKindLabel(item)}</option>}</For> | ||
| 209 | - </Select> | ||
| 210 | - </div> | ||
| 211 | <div class="space-y-1.5"> | 204 | <div class="space-y-1.5"> |
| 212 | <Label for="course-term">{t("terms.term")}</Label> | 205 | <Label for="course-term">{t("terms.term")}</Label> |
| 213 | <Select id="course-term" value={termId()} onChange={(e) => setTermId(e.currentTarget.value)}> | 206 | <Select id="course-term" value={termId()} onChange={(e) => setTermId(e.currentTarget.value)}> |
| @@ -243,12 +236,12 @@ function CoursesContent() { | |||
| 243 | when={rows().length > 0} | 236 | when={rows().length > 0} |
| 244 | fallback={ | 237 | fallback={ |
| 245 | <EmptyState | 238 | <EmptyState |
| 246 | - title={t("courses.empty")} | 239 | + title={t("courses.empty", { item: pageLabel() })} |
| 247 | action={ | 240 | action={ |
| 248 | canCreate() ? ( | 241 | canCreate() ? ( |
| 249 | <Button type="button" size="sm" class="rounded-lg" onClick={() => setShowForm(true)}> | 242 | <Button type="button" size="sm" class="rounded-lg" onClick={() => setShowForm(true)}> |
| 250 | <IconPlus class="h-4 w-4" /> | 243 | <IconPlus class="h-4 w-4" /> |
| 251 | - {t("courses.create")} | 244 | + {t("common.createItem", { item: pageLabel() })} |
| 252 | </Button> | 245 | </Button> |
| 253 | ) : undefined | 246 | ) : undefined |
| 254 | } | 247 | } |
| @@ -258,9 +251,9 @@ function CoursesContent() { | |||
| 258 | <div class="space-y-4"> | 251 | <div class="space-y-4"> |
| 259 | <div class="flex flex-wrap items-center justify-between gap-3"> | 252 | <div class="flex flex-wrap items-center justify-between gap-3"> |
| 260 | <div> | 253 | <div> |
| 261 | - <h2 class="font-display text-lg font-semibold">{t("courses.listTitle")}</h2> | 254 | + <h2 class="font-display text-lg font-semibold">{t("courses.listTitle", { item: pageLabel() })}</h2> |
| 262 | <p class="mt-1 text-sm text-muted-foreground"> | 255 | <p class="mt-1 text-sm text-muted-foreground"> |
| 263 | - {rows().length} {t("nav.courses")} | 256 | + {t("common.countItem", { count: rows().length, item: pageLabel() })} |
| 264 | </p> | 257 | </p> |
| 265 | </div> | 258 | </div> |
| 266 | </div> | 259 | </div> |
src/pages/dashboard-page.tsxmodified+13 -2
| @@ -7,7 +7,7 @@ import { getExams } from "@/api/getExams"; | |||
| 7 | import { getMyCourses } from "@/api/getMyCourses"; | 7 | import { getMyCourses } from "@/api/getMyCourses"; |
| 8 | import { getMyMarks } from "@/api/getMyMarks"; | 8 | import { getMyMarks } from "@/api/getMyMarks"; |
| 9 | import { getNotes } from "@/api/getNotes"; | 9 | import { getNotes } from "@/api/getNotes"; |
| 10 | -import type { Exam, Event, Role } from "@/api/types"; | 10 | +import type { Course, Exam, Event, Role } from "@/api/types"; |
| 11 | import { RouteGuard } from "@/components/layout/route-guard"; | 11 | import { RouteGuard } from "@/components/layout/route-guard"; |
| 12 | import { Alert } from "@/components/ui/alert"; | 12 | import { Alert } from "@/components/ui/alert"; |
| 13 | import { | 13 | import { |
| @@ -166,7 +166,10 @@ function DashboardContent() { | |||
| 166 | return all; | 166 | return all; |
| 167 | }); | 167 | }); |
| 168 | 168 | ||
| 169 | - const courseCount = createMemo(() => scopedCourses().length); | 169 | + const countCoursesByKind = (kind: Course["kind"]) => scopedCourses().filter((course) => course.kind === kind).length; |
| 170 | + const courseCount = createMemo(() => countCoursesByKind("course")); | ||
| 171 | + const studyCount = createMemo(() => countCoursesByKind("study")); | ||
| 172 | + const clubCount = createMemo(() => countCoursesByKind("club")); | ||
| 170 | const examCount = createMemo(() => visibleExams().length); | 173 | const examCount = createMemo(() => visibleExams().length); |
| 171 | const eventCount = createMemo(() => events().length); | 174 | const eventCount = createMemo(() => events().length); |
| 172 | const noteCount = createMemo(() => notes().length); | 175 | const noteCount = createMemo(() => notes().length); |
| @@ -178,6 +181,8 @@ function DashboardContent() { | |||
| 178 | const portalCards = createMemo<PortalCardDef[]>(() => { | 181 | const portalCards = createMemo<PortalCardDef[]>(() => { |
| 179 | const r = role(); | 182 | const r = role(); |
| 180 | const cc = String(courseCount()); | 183 | const cc = String(courseCount()); |
| 184 | + const sc = String(studyCount()); | ||
| 185 | + const clc = String(clubCount()); | ||
| 181 | const ec = String(examCount()); | 186 | const ec = String(examCount()); |
| 182 | const evc = String(eventCount()); | 187 | const evc = String(eventCount()); |
| 183 | const nc = String(noteCount()); | 188 | const nc = String(noteCount()); |
| @@ -186,6 +191,8 @@ function DashboardContent() { | |||
| 186 | if (r === "student") { | 191 | if (r === "student") { |
| 187 | list.push( | 192 | list.push( |
| 188 | { Icon: IconBook, titleKey: "nav.courses", to: "/courses", descKey: "dashboard.portal.coursesDesc", stat: cc }, | 193 | { Icon: IconBook, titleKey: "nav.courses", to: "/courses", descKey: "dashboard.portal.coursesDesc", stat: cc }, |
| 194 | + { Icon: IconClock, titleKey: "nav.studies", to: "/studies", descKey: "dashboard.portal.studiesDesc", stat: sc }, | ||
| 195 | + { Icon: IconUsers, titleKey: "nav.clubs", to: "/clubs", descKey: "dashboard.portal.clubsDesc", stat: clc }, | ||
| 189 | { Icon: IconExam, titleKey: "nav.exams", to: "/exams", descKey: "dashboard.portal.examsDesc", stat: ec }, | 196 | { Icon: IconExam, titleKey: "nav.exams", to: "/exams", descKey: "dashboard.portal.examsDesc", stat: ec }, |
| 190 | { Icon: IconCalendar, titleKey: "nav.events", to: "/events", descKey: "dashboard.portal.eventsDesc", stat: evc }, | 197 | { Icon: IconCalendar, titleKey: "nav.events", to: "/events", descKey: "dashboard.portal.eventsDesc", stat: evc }, |
| 191 | { Icon: IconChart, titleKey: "nav.marks", to: "/marks", descKey: "dashboard.portal.marksDesc", stat: avgLabel() }, | 198 | { Icon: IconChart, titleKey: "nav.marks", to: "/marks", descKey: "dashboard.portal.marksDesc", stat: avgLabel() }, |
| @@ -198,6 +205,8 @@ function DashboardContent() { | |||
| 198 | if (r === "teacher") { | 205 | if (r === "teacher") { |
| 199 | list.push( | 206 | list.push( |
| 200 | { Icon: IconBook, titleKey: "nav.courses", to: "/courses", descKey: "dashboard.portal.coursesDesc", stat: cc }, | 207 | { Icon: IconBook, titleKey: "nav.courses", to: "/courses", descKey: "dashboard.portal.coursesDesc", stat: cc }, |
| 208 | + { Icon: IconClock, titleKey: "nav.studies", to: "/studies", descKey: "dashboard.portal.studiesDesc", stat: sc }, | ||
| 209 | + { Icon: IconUsers, titleKey: "nav.clubs", to: "/clubs", descKey: "dashboard.portal.clubsDesc", stat: clc }, | ||
| 201 | { Icon: IconExam, titleKey: "nav.exams", to: "/exams", descKey: "dashboard.portal.examsDesc", stat: ec }, | 210 | { Icon: IconExam, titleKey: "nav.exams", to: "/exams", descKey: "dashboard.portal.examsDesc", stat: ec }, |
| 202 | { Icon: IconCalendar, titleKey: "nav.events", to: "/events", descKey: "dashboard.portal.eventsDesc", stat: evc, minRole: "teacher" }, | 211 | { Icon: IconCalendar, titleKey: "nav.events", to: "/events", descKey: "dashboard.portal.eventsDesc", stat: evc, minRole: "teacher" }, |
| 203 | { Icon: IconChart, titleKey: "nav.studentMarks", to: "/management/student-marks", descKey: "dashboard.portal.studentMarksDesc", minRole: "teacher" }, | 212 | { Icon: IconChart, titleKey: "nav.studentMarks", to: "/management/student-marks", descKey: "dashboard.portal.studentMarksDesc", minRole: "teacher" }, |
| @@ -211,6 +220,8 @@ function DashboardContent() { | |||
| 211 | // manager + admin | 220 | // manager + admin |
| 212 | list.push( | 221 | list.push( |
| 213 | { Icon: IconBook, titleKey: "nav.courses", to: "/courses", descKey: "dashboard.portal.coursesDesc", stat: cc }, | 222 | { Icon: IconBook, titleKey: "nav.courses", to: "/courses", descKey: "dashboard.portal.coursesDesc", stat: cc }, |
| 223 | + { Icon: IconClock, titleKey: "nav.studies", to: "/studies", descKey: "dashboard.portal.studiesDesc", stat: sc }, | ||
| 224 | + { Icon: IconUsers, titleKey: "nav.clubs", to: "/clubs", descKey: "dashboard.portal.clubsDesc", stat: clc }, | ||
| 214 | { Icon: IconExam, titleKey: "nav.exams", to: "/exams", descKey: "dashboard.portal.examsDesc", stat: ec }, | 225 | { Icon: IconExam, titleKey: "nav.exams", to: "/exams", descKey: "dashboard.portal.examsDesc", stat: ec }, |
| 215 | { Icon: IconCalendar, titleKey: "nav.events", to: "/events", descKey: "dashboard.portal.eventsDesc", stat: evc }, | 226 | { Icon: IconCalendar, titleKey: "nav.events", to: "/events", descKey: "dashboard.portal.eventsDesc", stat: evc }, |
| 216 | { Icon: IconNote, titleKey: "nav.notes", to: "/notes", descKey: "dashboard.portal.notesDesc", stat: nc }, | 227 | { Icon: IconNote, titleKey: "nav.notes", to: "/notes", descKey: "dashboard.portal.notesDesc", stat: nc }, |
src/routes/router.tsxmodified+14 -0
| @@ -130,6 +130,18 @@ const coursesRoute = createRoute({ | |||
| 130 | component: CoursesPage, | 130 | component: CoursesPage, |
| 131 | }); | 131 | }); |
| 132 | 132 | ||
| 133 | +const studiesRoute = createRoute({ | ||
| 134 | + getParentRoute: () => rootRoute, | ||
| 135 | + path: "/studies", | ||
| 136 | + component: CoursesPage, | ||
| 137 | +}); | ||
| 138 | + | ||
| 139 | +const clubsRoute = createRoute({ | ||
| 140 | + getParentRoute: () => rootRoute, | ||
| 141 | + path: "/clubs", | ||
| 142 | + component: CoursesPage, | ||
| 143 | +}); | ||
| 144 | + | ||
| 133 | const courseDetailRoute = createRoute({ | 145 | const courseDetailRoute = createRoute({ |
| 134 | getParentRoute: () => rootRoute, | 146 | getParentRoute: () => rootRoute, |
| 135 | path: "/courses/$id", | 147 | path: "/courses/$id", |
| @@ -226,6 +238,8 @@ const routeTree = rootRoute.addChildren([ | |||
| 226 | liveMonitorRoute, | 238 | liveMonitorRoute, |
| 227 | examsRoute, | 239 | examsRoute, |
| 228 | coursesRoute, | 240 | coursesRoute, |
| 241 | + studiesRoute, | ||
| 242 | + clubsRoute, | ||
| 229 | courseDetailRoute, | 243 | courseDetailRoute, |
| 230 | marksRoute, | 244 | marksRoute, |
| 231 | pomodoroRoute, | 245 | pomodoroRoute, |