From 708f89b160133dc3416834cf5f62d84b9cd6ff34 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Burak=20Boduro=C4=9Flu?= <80620802+burakboduroglu@users.noreply.github.com> Date: Fri, 17 Jul 2026 19:32:48 +0300 Subject: [PATCH] =?UTF-8?q?feat:=20=E2=9C=A8=20support=20course=20kind=20l?= =?UTF-8?q?abels?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit - add course kind typing and create/edit API payload support - let teachers choose course or study when creating and editing courses - show localized course kind badges in course list and detail views --- src/api/patchCourseById.ts | 3 ++- src/api/postCourse.ts | 3 ++- src/api/types.ts | 2 ++ src/i18n/messages.ts | 9 +++++++++ src/pages/course-detail-page.tsx | 19 +++++++++++++++++++ src/pages/courses-page.tsx | 19 +++++++++++++++++-- 6 files changed, 51 insertions(+), 4 deletions(-) diff --git a/src/api/patchCourseById.ts b/src/api/patchCourseById.ts index 7cf801a..1f6787f 100644 --- a/src/api/patchCourseById.ts +++ b/src/api/patchCourseById.ts @@ -1,9 +1,10 @@ import { client } from "./client"; -import type { Course } from "./types"; +import type { Course, CourseKind } from "./types"; export type PatchCourseBody = { title?: string | null; description?: string | null; + kind?: CourseKind | null; term_id?: string | null; }; diff --git a/src/api/postCourse.ts b/src/api/postCourse.ts index 6a7e49b..def73a2 100644 --- a/src/api/postCourse.ts +++ b/src/api/postCourse.ts @@ -1,9 +1,10 @@ import { client } from "./client"; -import type { Course } from "./types"; +import type { Course, CourseKind } from "./types"; export type PostCourseBody = { title: string; description?: string | null; + kind?: CourseKind | null; term_id?: string | null; }; diff --git a/src/api/types.ts b/src/api/types.ts index 07b1a0f..c6c5636 100644 --- a/src/api/types.ts +++ b/src/api/types.ts @@ -3,6 +3,7 @@ export type { Page, PageParams } from "./page"; export type Role = "student" | "teacher" | "manager" | "admin"; export type UserTheme = "light" | "dark"; export type UserLanguage = "tr" | "en"; +export type CourseKind = "course" | "study" | string; export type CoreAttendanceStatus = "present" | "absent" | "late" | "excused"; export type AttendanceStatus = CoreAttendanceStatus | string; export type KnownExamKind = "homework" | "quiz" | "midterm" | "final" | "project" | "oral"; @@ -73,6 +74,7 @@ export type Course = { creator: string; title: string; description: string; + kind: CourseKind; /** Academic term id from API (`CourseResponse.term`). */ term?: string | null; }; diff --git a/src/i18n/messages.ts b/src/i18n/messages.ts index f0f2bb3..e65b831 100644 --- a/src/i18n/messages.ts +++ b/src/i18n/messages.ts @@ -386,6 +386,9 @@ export type MessageKey = | "courses.addExam" | "courses.weight" | "courses.delete" + | "courses.kind" + | "courses.kind.course" + | "courses.kind.study" | "marks.title" | "marks.subtitle" | "marks.overall" @@ -926,6 +929,9 @@ const en: Dict = { "courses.addExam": "Add exam", "courses.weight": "Weight", "courses.delete": "Delete course", + "courses.kind": "Course type", + "courses.kind.course": "Course", + "courses.kind.study": "Study", "marks.title": "Report card", "marks.subtitle": "Weighted averages across enrolled courses.", "marks.overall": "Overall average", @@ -1465,6 +1471,9 @@ const tr: Dict = { "courses.addExam": "Sınav ekle", "courses.weight": "Ağırlık", "courses.delete": "Dersi sil", + "courses.kind": "Ders türü", + "courses.kind.course": "Ders", + "courses.kind.study": "Etüt", "marks.title": "Karnem", "marks.subtitle": "Kayıtlı derslerdeki ağırlıklı ortalamalar.", "marks.overall": "Genel ortalama", diff --git a/src/pages/course-detail-page.tsx b/src/pages/course-detail-page.tsx index 8057011..cf3f874 100644 --- a/src/pages/course-detail-page.tsx +++ b/src/pages/course-detail-page.tsx @@ -12,6 +12,7 @@ import { patchCourseById } from "@/api/patchCourseById"; import { postCourseEnrollment } from "@/api/postCourseEnrollment"; import { postCourseExam } from "@/api/postCourseExam"; import { formatApiError } from "@/api/client"; +import type { CourseKind } from "@/api/types"; import { ExamLink } from "@/components/exams/exam-link"; import { ExamForm } from "@/components/exams/exam-form"; import { CourseSessionsPanel } from "@/components/sessions/course-sessions-panel"; @@ -46,6 +47,8 @@ import { examKindLabel } from "@/lib/exam-labels"; import { examWeight } from "@/lib/exam-weight"; import { hasMinRole } from "@/lib/roles"; +const COURSE_KINDS: CourseKind[] = ["course", "study"]; + export default function CourseDetailPage() { return ( @@ -88,6 +91,7 @@ function CourseDetailContent() { const [editing, setEditing] = createSignal(false); const [title, setTitle] = createSignal(""); const [description, setDescription] = createSignal(""); + const [kind, setKind] = createSignal("course"); const [termId, setTermId] = createSignal(""); const [showExamForm, setShowExamForm] = createSignal(false); const [showSessionForm, setShowSessionForm] = createSignal(false); @@ -117,6 +121,8 @@ function CourseDetailContent() { if (mode === "open") return t("exams.mode.open"); return t("exams.unscheduled"); }; + const courseKindLabel = (value: CourseKind | undefined) => + value === "study" ? t("courses.kind.study") : t("courses.kind.course"); const examCount = createMemo(() => exams()?.length ?? 0); const rosterCount = createMemo(() => roster()?.length ?? 0); @@ -144,6 +150,7 @@ function CourseDetailContent() { if (!c) return; setTitle(c.title); setDescription(c.description); + setKind(c.kind ?? "course"); setTermId(c.term ?? ""); setEditing(true); }; @@ -198,6 +205,11 @@ function CourseDetailContent() { } /> +
+ + {courseKindLabel(c().kind)} + +
setDescription(e.currentTarget.value)} /> +
+ + +