From 6195b47b497bb71280cac92b3c0aae4385e3b95f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Burak=20Boduro=C4=9Flu?= <80620802+burakboduroglu@users.noreply.github.com> Date: Sun, 2 Aug 2026 09:55:04 +0300 Subject: [PATCH] =?UTF-8?q?feat:=20=F0=9F=8D=BD=EF=B8=8F=20class-source=20?= =?UTF-8?q?roster=20badge=20and=20manager=20booking=20cancel=20(phase=204)?= =?UTF-8?q?=20-=20course-detail=20roster:=20badge=20students=20a=20class?= =?UTF-8?q?=20pumped=20("from=209-A")=20by=20=20=20resolving=20enrollment.?= =?UTF-8?q?source=20via=20one=20getClasses()=20lookup,=20so=20a=20manager?= =?UTF-8?q?=20sees=20=20=20which=20rows=20a=20class=20change=20will=20swee?= =?UTF-8?q?p;=20hand-placed=20rows=20stay=20unbadged=20-=20meal-detail=20s?= =?UTF-8?q?ervice=20list:=20manager+=20can=20cancel=20any=20booked=20row?= =?UTF-8?q?=20(backend=20=20=20bypasses=20the=20cutoff=20for=20managers)?= =?UTF-8?q?=20via=20a=20per-row=20action=20+=20confirm=20dialog=20-=20i18n?= =?UTF-8?q?:=20course.fromClass=20in=20en/tr?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/i18n/messages.ts | 3 +++ src/pages/course-detail-page.tsx | 15 ++++++++++++++- src/pages/meal-detail-page.tsx | 6 +++++- 3 files changed, 22 insertions(+), 2 deletions(-) diff --git a/src/i18n/messages.ts b/src/i18n/messages.ts index a8e7312..6d2d118 100644 --- a/src/i18n/messages.ts +++ b/src/i18n/messages.ts @@ -875,6 +875,7 @@ export type MessageKey = | "ws.error" | "ws.ping" | "course.removeStudent" + | "course.fromClass" | "course.removeStudentConfirm" | "events.userIdRequired" | "settings.title" @@ -2211,6 +2212,7 @@ const en: Dict = { "ws.error": "Connection error", "ws.ping": "Ping", "course.removeStudent": "Remove student", + "course.fromClass": "from {name}", "course.removeStudentConfirm": "Are you sure you want to remove", "events.userIdRequired": "Please select a student first.", "settings.title": "School settings", @@ -3473,6 +3475,7 @@ const tr: Dict = { "ws.error": "Bağlantı hatası", "ws.ping": "Ping", "course.removeStudent": "Öğrenciyi çıkar", + "course.fromClass": "{name} şubesinden", "course.removeStudentConfirm": "Bu öğrenciyi çıkarmak istediğine emin misin?", "events.userIdRequired": "Önce bir öğrenci seçmelisin.", "settings.title": "Okul ayarları", diff --git a/src/pages/course-detail-page.tsx b/src/pages/course-detail-page.tsx index 1dd8845..af31c2d 100644 --- a/src/pages/course-detail-page.tsx +++ b/src/pages/course-detail-page.tsx @@ -6,6 +6,7 @@ import { deleteCourseEnrollmentByUserId } from "@/api/courses"; import { getCourseById } from "@/api/courses"; import { getCourseEnrollments } from "@/api/courses"; import { getCourseExams } from "@/api/courses"; +import { getClasses } from "@/api/classes"; import { getMyCourses } from "@/api/reports"; import { getSettings } from "@/api/settings"; import { getTerms } from "@/api/terms"; @@ -159,13 +160,25 @@ function CourseDetailContent() { const countDescription = (count: number, item: string) => t("common.countItem", { count, item }); const enrolledUserIds = () => (roster() ?? []).map((row) => row.user.id); + // Resolve a pumped enrollment's `source` (class id) to a class name so a + // manager can see which rows a class change will sweep. One list call, + // teacher+ only (matches roster visibility); null-source rows show nothing. + const [classList] = createResource(() => hasCourseManagementRights() ? getClasses().then((page) => page.items) : null); + const className = (source: string | null) => source ? (classList.latest?.find((c) => c.id === source)?.name ?? null) : null; const rosterColumns = createMemo[]>(() => [ { id: "username", accessorFn: (row) => row.user.display_name || row.user.username, header: t("admin.username"), meta: { cellClass: "font-medium" }, - cell: (cell) => cell.row.original.user.display_name || cell.row.original.user.username, + cell: (cell) => ( + + {cell.row.original.user.display_name || cell.row.original.user.username} + + {(name) => {t("course.fromClass", { name: name() })}} + + + ), }, { id: "actions", diff --git a/src/pages/meal-detail-page.tsx b/src/pages/meal-detail-page.tsx index 7501d76..183462f 100644 --- a/src/pages/meal-detail-page.tsx +++ b/src/pages/meal-detail-page.tsx @@ -86,6 +86,9 @@ function MealDetailContent() { const [success, setSuccess] = createSignal(""); const [pending, setPending] = createSignal(false); const [cancelOpen, setCancelOpen] = createSignal(false); + // Manager-only: cancel any student's booking from the service list (backend + // lets manager+ bypass the cutoff). Holds the booking pending confirmation. + const [cancelBooking, setCancelBooking] = createSignal(null); const [deleteMenuOpen, setDeleteMenuOpen] = createSignal(false); const [deleteDish, setDeleteDish] = createSignal(null); @@ -247,7 +250,7 @@ function MealDetailContent() { void refetchService()} />
- {(entry) =>

{personLabel(entry.student)}

{entry.booking ? t("meals.booked") : t("meals.walkIn")} · {entry.attendance?.status ?? t("meals.notMarked")}

}
+ {(entry) =>

{personLabel(entry.student)}

{entry.booking ? t("meals.booked") : t("meals.walkIn")} · {entry.attendance?.status ?? t("meals.notMarked")}

}
@@ -272,6 +275,7 @@ function MealDetailContent() { run(async () => { const booking = activeBooking(); if (!booking) return; await deleteMealBookingById(booking.id); await Promise.all([refetchBookings(), refetchBalance(), refetchLedger()]); }, t("meals.cancelled"))} /> + !open && setCancelBooking(null)} title={t("meals.cancelBooking")} variant="destructive" summary={cancelBooking() ? `${t("meals.cancelSummary")} · ${personLabel(cancelBooking()!.student)}` : ""} onConfirm={() => run(async () => { const booking = cancelBooking(); if (!booking) return; await deleteMealBookingById(booking.id); setCancelBooking(null); await Promise.all([refetchService(), refetchServiceBookings()]); }, t("meals.cancelled"))} /> run(async () => { await deleteMealMenuById(id()); void navigate({ to: "/meals" }); }, t("common.deleted"))} /> !open && setDeleteDish(null)} title={t("meals.deleteDish")} variant="destructive" summary={deleteDish()?.name ?? ""} onConfirm={() => run(async () => { if (!deleteDish()) return; await deleteMealDishById(deleteDish()!.id); setDeleteDish(null); await refetchMenu(); }, t("common.deleted"))} />