forge
Explore
Log in

Don't you dare go Hollow

✨ split courses into /courses, /studies, /clubs with shared page

Browse files at this commit

cd3f0a85e790c3252d66d3b19dda1a40cebef998Burak BoduroğluParent: e600469
  • feat
    • ✨ split courses into /courses, /studies, /clubs with shared page
Show full message
feat: ✨ split courses into /courses, /studies, /clubs with shared page
- added /studies and /clubs routes to router, both reuse CoursesPage
- CoursesPage detects page kind from location.pathname, filters courses
  by kind, removes explicit kind selector from create form
- course-detail-page: breadcrumb/back navigation respects course kind
- dashboard: separate portal cards for courses/studies/clubs with counts
- side-nav: added Studies and Clubs links under Education group
- i18n: nav.studies, nav.clubs, dashboard descriptions, dynamic {item}
  interpolation in courses page title/empty/createItem messages
src/components/layout/side-nav.tsxmodified+2 -0
@@ -58,6 +58,8 @@ const NAV_GROUPS: NavGroup[] = [
5858 Icon: IconSchool,
5959 items: [
6060 { to: "/courses", labelKey: "nav.courses", Icon: IconBook },
61+ { to: "/studies", labelKey: "nav.studies", Icon: IconClock },
62+ { to: "/clubs", labelKey: "nav.clubs", Icon: IconUsers },
6163 { to: "/exams", labelKey: "nav.exams", Icon: IconExam },
6264 { to: "/events", labelKey: "nav.events", Icon: IconCalendar },
6365 ],
src/i18n/messages.tsmodified+25 -10
@@ -8,6 +8,8 @@ export type MessageKey =
88 | "nav.events"
99 | "nav.exams"
1010 | "nav.courses"
11+ | "nav.studies"
12+ | "nav.clubs"
1113 | "nav.marks"
1214 | "nav.pomodoro"
1315 | "nav.attendance"
@@ -83,6 +85,7 @@ export type MessageKey =
8385 | "common.created"
8486 | "common.deleted"
8587 | "common.saved"
88+ | "common.createItem"
8689 | "common.countItem"
8790 | "theme.light"
8891 | "theme.dark"
@@ -169,6 +172,8 @@ export type MessageKey =
169172 | "dashboard.continueGuide"
170173 | "dashboard.portal.sections"
171174 | "dashboard.portal.coursesDesc"
175+ | "dashboard.portal.studiesDesc"
176+ | "dashboard.portal.clubsDesc"
172177 | "dashboard.portal.examsDesc"
173178 | "dashboard.portal.eventsDesc"
174179 | "dashboard.portal.marksDesc"
@@ -590,7 +595,9 @@ const en: Dict = {
590595 "nav.notes": "Notes",
591596 "nav.events": "Events",
592597 "nav.exams": "Exams",
593- "nav.courses": "Education",
598+ "nav.courses": "Courses",
599+ "nav.studies": "Study sessions",
600+ "nav.clubs": "Clubs",
594601 "nav.marks": "Report card",
595602 "nav.pomodoro": "Pomodoro",
596603 "nav.attendance": "Attendance",
@@ -666,6 +673,7 @@ const en: Dict = {
666673 "common.created": "Created.",
667674 "common.deleted": "Deleted.",
668675 "common.saved": "Saved.",
676+ "common.createItem": "Create {item}",
669677 "common.countItem": "{count} {item}",
670678 "theme.light": "Light",
671679 "theme.dark": "Dark",
@@ -751,7 +759,9 @@ const en: Dict = {
751759 "dashboard.helpBody": "Stuck on a page or looking for the next step? Open the short app guide.",
752760 "dashboard.continueGuide": "Guide",
753761 "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.",
755765 "dashboard.portal.examsDesc": "Course exams, deadlines, and results.",
756766 "dashboard.portal.eventsDesc": "Events with student attendance records.",
757767 "dashboard.portal.marksDesc": "Your grades and overall report card.",
@@ -1018,10 +1028,10 @@ const en: Dict = {
10181028 "role.manager": "Manager",
10191029 "role.admin": "ADMIN",
10201030 "courses.title": "Education",
1021- "courses.listTitle": "Education records",
1022- "courses.subtitle": "Courses, study sessions, clubs, enrollment, and exams live here.",
1031+ "courses.listTitle": "{item} records",
1032+ "courses.subtitle": "Manage {item}, enrollment, and exams here.",
10231033 "courses.create": "New education item",
1024- "courses.empty": "No courses yet.",
1034+ "courses.empty": "No {item} yet.",
10251035 "courses.enrolled": "Enrolled",
10261036 "courses.roster": "Roster",
10271037 "courses.rosterItem": "Student",
@@ -1185,7 +1195,9 @@ const tr: Dict = {
11851195 "nav.notes": "Notlar",
11861196 "nav.events": "Etkinlikler",
11871197 "nav.exams": "Sınavlar",
1188- "nav.courses": "Eğitim",
1198+ "nav.courses": "Ders",
1199+ "nav.studies": "Etüt",
1200+ "nav.clubs": "Kulüp",
11891201 "nav.marks": "Notlar",
11901202 "nav.pomodoro": "Pomodoro",
11911203 "nav.attendance": "Yoklamalar",
@@ -1261,6 +1273,7 @@ const tr: Dict = {
12611273 "common.created": "Oluşturuldu.",
12621274 "common.deleted": "Silindi.",
12631275 "common.saved": "Kaydedildi.",
1276+ "common.createItem": "{item} oluştur",
12641277 "common.countItem": "{count} Adet {item}",
12651278 "theme.light": "Açık",
12661279 "theme.dark": "Koyu",
@@ -1346,7 +1359,9 @@ const tr: Dict = {
13461359 "dashboard.helpBody": "Bir sayfada takıldın veya sonraki adımı mı arıyorsun? Kısa uygulama rehberini aç.",
13471360 "dashboard.continueGuide": "Rehber",
13481361 "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.",
13501365 "dashboard.portal.examsDesc": "Eğitim sınavları, tarihler ve sonuçlar.",
13511366 "dashboard.portal.eventsDesc": "Öğrenci yoklamalı etkinlikler.",
13521367 "dashboard.portal.marksDesc": "Notların ve genel karnen.",
@@ -1613,10 +1628,10 @@ const tr: Dict = {
16131628 "role.manager": "Yönetici",
16141629 "role.admin": "ADMIN",
16151630 "courses.title": "Eğitim",
1616- "courses.listTitle": "Eğitim kayıtları",
1617- "courses.subtitle": "Dersler, etütler, kulüpler, kayıtlar ve sınavlar burada.",
1631+ "courses.listTitle": "{item} kayıtları",
1632+ "courses.subtitle": "{item}, kayıtlar ve sınavlar burada.",
16181633 "courses.create": "Yeni eğitim kaydı",
1619- "courses.empty": "Henüz ders yok.",
1634+ "courses.empty": "Henüz {item} yok.",
16201635 "courses.enrolled": "Kayıtlı",
16211636 "courses.roster": "Sınıf listesi",
16221637 "courses.rosterItem": "Öğrenci",
src/pages/course-detail-page.tsxmodified+5 -4
@@ -122,6 +122,7 @@ function CourseDetailContent() {
122122 };
123123 const courseKindLabel = (value: CourseKind | undefined) =>
124124 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";
125126
126127 const examCount = createMemo(() => exams()?.length ?? 0);
127128 const rosterCount = createMemo(() => roster()?.length ?? 0);
@@ -257,18 +258,18 @@ function CourseDetailContent() {
257258 <div class="detail-breadcrumb">
258259 <span>{t("nav.group.classes")}</span>
259260 <span>/</span>
260- <Link to="/courses">{t("courses.title")}</Link>
261+ <Link to={courseListPath(c().kind)}>{courseKindLabel(c().kind)}</Link>
261262 <span>/</span>
262263 <span class="truncate">{c().title}</span>
263264 </div>
264265 <PageHeader
265266 accent="violet"
266- eyebrow={t("courses.title")}
267+ eyebrow={courseKindLabel(c().kind)}
267268 title={c().title}
268269 description={`${t("terms.term")}: ${terms()?.find((term) => term.id === c().term)?.name ?? t("terms.unassigned")}${c().description ? ` - ${c().description}` : ""}`}
269270 actions={
270271 <div class="detail-action-group">
271- <Link to="/courses">
272+ <Link to={courseListPath(c().kind)}>
272273 <Button variant="ghost" size="sm" class="w-full rounded-sm sm:w-auto">
273274 <IconChevronLeft class="h-4 w-4" />
274275 {t("common.back")}
@@ -307,7 +308,7 @@ function CourseDetailContent() {
307308 onConfirm={async () => {
308309 await wrap(async () => {
309310 await deleteCourseById(id());
310- void navigate({ to: "/courses" });
311+ void navigate({ to: courseListPath(c().kind) });
311312 });
312313 }}
313314 />
src/pages/courses-page.tsxmodified+17 -24
@@ -1,6 +1,6 @@
11 import { For, Show, Suspense, createMemo, createResource, createSignal } from "solid-js";
22 import type { ColumnDef } from "@tanstack/solid-table";
3-import { useNavigate } from "@tanstack/solid-router";
3+import { useLocation, useNavigate } from "@tanstack/solid-router";
44 import { getCourses } from "@/api/getCourses";
55 import { getMyCourses } from "@/api/getMyCourses";
66 import { getTerms } from "@/api/getTerms";
@@ -28,7 +28,6 @@ import { useT } from "@/stores/preferences-context";
2828 import { hasMinRole } from "@/lib/roles";
2929
3030 const COURSE_PAGE_SIZE = 12;
31-const COURSE_KINDS: CourseKind[] = ["course", "study", "club"];
3231
3332 export default function CoursesPage() {
3433 return (
@@ -41,11 +40,11 @@ export default function CoursesPage() {
4140 function CoursesContent() {
4241 const auth = useAuth();
4342 const navigate = useNavigate();
43+ const location = useLocation();
4444 const t = useT();
4545 const [showForm, setShowForm] = createSignal(false);
4646 const [title, setTitle] = createSignal("");
4747 const [description, setDescription] = createSignal("");
48- const [kind, setKind] = createSignal<CourseKind>("course");
4948 const [termId, setTermId] = createSignal("");
5049 const [capacity, setCapacity] = createSignal("");
5150 const [error, setError] = createSignal("");
@@ -65,6 +64,8 @@ function CoursesContent() {
6564 const termName = (id: string | null | undefined) => terms()?.find((term) => term.id === id)?.name ?? t("terms.unassigned");
6665 const courseKindLabel = (value: CourseKind | undefined) =>
6766 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());
6869 const creatorName = (creatorId: string) => {
6970 if (creatorId === auth.user()?.id) return auth.user()?.username ?? creatorId;
7071 return users()?.find((user) => user.id === creatorId)?.username ?? creatorId;
@@ -75,7 +76,7 @@ function CoursesContent() {
7576 return items.filter((course) => {
7677 if (selectedTerm === "unassigned" && course.term) return false;
7778 if (selectedTerm !== "all" && selectedTerm !== "unassigned" && course.term !== selectedTerm) return false;
78- return true;
79+ return course.kind === pageKind();
7980 });
8081 };
8182 const searchCourse = (course: Course, query: string) =>
@@ -93,11 +94,10 @@ function CoursesContent() {
9394 const columns = createMemo<ColumnDef<Course>[]>(() => [
9495 {
9596 accessorKey: "title",
96- header: t("courses.title"),
97+ header: pageLabel(),
9798 cell: (cell) => (
9899 <div class="min-w-0 space-y-1">
99100 <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>
101101 <Show when={isStudent()}>
102102 <Badge variant="secondary" class="rounded-sm">{t("courses.enrolled")}</Badge>
103103 </Show>
@@ -149,13 +149,12 @@ function CoursesContent() {
149149 await postCourse({
150150 title: title().trim(),
151151 description: description().trim() || undefined,
152- kind: kind(),
152+ kind: pageKind(),
153153 term_id: termId() || null,
154154 capacity: cap ? Number(cap) : null,
155155 });
156156 setTitle("");
157157 setDescription("");
158- setKind("course");
159158 setTermId("");
160159 setCapacity("");
161160 setShowForm(false);
@@ -174,25 +173,25 @@ function CoursesContent() {
174173 <div class="flex flex-wrap items-center gap-1 text-xs text-muted-foreground">
175174 <span>{t("nav.group.classes")}</span>
176175 <span>/</span>
177- <span>{t("nav.courses")}</span>
176+ <span>{pageLabel()}</span>
178177 </div>
179178 <PageHeader
180179 accent="violet"
181- eyebrow={t("nav.courses")}
182- title={t("courses.title")}
183- description={t("courses.subtitle")}
180+ eyebrow={t("nav.group.classes")}
181+ title={pageLabel()}
182+ description={t("courses.subtitle", { item: pageLabel() })}
184183 actions={
185184 canCreate() ? (
186185 <Button type="button" size="sm" class="min-w-[7.5rem] rounded-lg" onClick={() => setShowForm(true)}>
187186 <IconPlus class="h-4 w-4" />
188- {t("courses.create")}
187+ {t("common.createItem", { item: pageLabel() })}
189188 </Button>
190189 ) : undefined
191190 }
192191 />
193192 </div>
194193
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() })}>
196195 <form class="space-y-3" onSubmit={onCreate}>
197196 <div class="space-y-1.5">
198197 <Label for="course-title">{t("form.title")}</Label>
@@ -202,12 +201,6 @@ function CoursesContent() {
202201 <Label for="course-desc">{t("form.description")}</Label>
203202 <Textarea id="course-desc" maxlength={2000} rows={3} value={description()} onInput={(e) => setDescription(e.currentTarget.value)} />
204203 </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>
211204 <div class="space-y-1.5">
212205 <Label for="course-term">{t("terms.term")}</Label>
213206 <Select id="course-term" value={termId()} onChange={(e) => setTermId(e.currentTarget.value)}>
@@ -243,12 +236,12 @@ function CoursesContent() {
243236 when={rows().length > 0}
244237 fallback={
245238 <EmptyState
246- title={t("courses.empty")}
239+ title={t("courses.empty", { item: pageLabel() })}
247240 action={
248241 canCreate() ? (
249242 <Button type="button" size="sm" class="rounded-lg" onClick={() => setShowForm(true)}>
250243 <IconPlus class="h-4 w-4" />
251- {t("courses.create")}
244+ {t("common.createItem", { item: pageLabel() })}
252245 </Button>
253246 ) : undefined
254247 }
@@ -258,9 +251,9 @@ function CoursesContent() {
258251 <div class="space-y-4">
259252 <div class="flex flex-wrap items-center justify-between gap-3">
260253 <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>
262255 <p class="mt-1 text-sm text-muted-foreground">
263- {rows().length} {t("nav.courses")}
256+ {t("common.countItem", { count: rows().length, item: pageLabel() })}
264257 </p>
265258 </div>
266259 </div>
src/pages/dashboard-page.tsxmodified+13 -2
@@ -7,7 +7,7 @@ import { getExams } from "@/api/getExams";
77 import { getMyCourses } from "@/api/getMyCourses";
88 import { getMyMarks } from "@/api/getMyMarks";
99 import { getNotes } from "@/api/getNotes";
10-import type { Exam, Event, Role } from "@/api/types";
10+import type { Course, Exam, Event, Role } from "@/api/types";
1111 import { RouteGuard } from "@/components/layout/route-guard";
1212 import { Alert } from "@/components/ui/alert";
1313 import {
@@ -166,7 +166,10 @@ function DashboardContent() {
166166 return all;
167167 });
168168
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"));
170173 const examCount = createMemo(() => visibleExams().length);
171174 const eventCount = createMemo(() => events().length);
172175 const noteCount = createMemo(() => notes().length);
@@ -178,6 +181,8 @@ function DashboardContent() {
178181 const portalCards = createMemo<PortalCardDef[]>(() => {
179182 const r = role();
180183 const cc = String(courseCount());
184+ const sc = String(studyCount());
185+ const clc = String(clubCount());
181186 const ec = String(examCount());
182187 const evc = String(eventCount());
183188 const nc = String(noteCount());
@@ -186,6 +191,8 @@ function DashboardContent() {
186191 if (r === "student") {
187192 list.push(
188193 { 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 },
189196 { Icon: IconExam, titleKey: "nav.exams", to: "/exams", descKey: "dashboard.portal.examsDesc", stat: ec },
190197 { Icon: IconCalendar, titleKey: "nav.events", to: "/events", descKey: "dashboard.portal.eventsDesc", stat: evc },
191198 { Icon: IconChart, titleKey: "nav.marks", to: "/marks", descKey: "dashboard.portal.marksDesc", stat: avgLabel() },
@@ -198,6 +205,8 @@ function DashboardContent() {
198205 if (r === "teacher") {
199206 list.push(
200207 { 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 },
201210 { Icon: IconExam, titleKey: "nav.exams", to: "/exams", descKey: "dashboard.portal.examsDesc", stat: ec },
202211 { Icon: IconCalendar, titleKey: "nav.events", to: "/events", descKey: "dashboard.portal.eventsDesc", stat: evc, minRole: "teacher" },
203212 { Icon: IconChart, titleKey: "nav.studentMarks", to: "/management/student-marks", descKey: "dashboard.portal.studentMarksDesc", minRole: "teacher" },
@@ -211,6 +220,8 @@ function DashboardContent() {
211220 // manager + admin
212221 list.push(
213222 { 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 },
214225 { Icon: IconExam, titleKey: "nav.exams", to: "/exams", descKey: "dashboard.portal.examsDesc", stat: ec },
215226 { Icon: IconCalendar, titleKey: "nav.events", to: "/events", descKey: "dashboard.portal.eventsDesc", stat: evc },
216227 { 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({
130130 component: CoursesPage,
131131 });
132132
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+
133145 const courseDetailRoute = createRoute({
134146 getParentRoute: () => rootRoute,
135147 path: "/courses/$id",
@@ -226,6 +238,8 @@ const routeTree = rootRoute.addChildren([
226238 liveMonitorRoute,
227239 examsRoute,
228240 coursesRoute,
241+ studiesRoute,
242+ clubsRoute,
229243 courseDetailRoute,
230244 marksRoute,
231245 pomodoroRoute,