📋 event registration roster with DataTable, remove 6 unused API files
Browse files at this commit8d7909bb754fde0dc2000abf319c0fb211270a7eParent: 758d094- feat
- 📋 event registration roster with DataTable, remove 6 unused API files
12 changed files +198 -34
- src/api/deleteEventRegisterByUserId.ts +5 -0
- src/api/deleteSessionAttendanceByUserId.ts +0 -5
- src/api/getEventRoster.ts +12 -0
- src/api/getExamChoiceImageBlob.ts +0 -5
- src/api/getExamQuestionImageBlob.ts +0 -5
- src/api/getNoteById.ts +0 -6
- src/api/getUserById.ts +0 -6
- src/api/patchUserProfile.ts +0 -6
- src/api/postEventRegister.ts +13 -0
- src/api/types.ts +12 -0
- src/i18n/messages.ts +21 -0
- src/pages/event-detail-page.tsx +135 -1
src/api/deleteEventRegisterByUserId.tsadded+5 -0
| @@ -0,0 +1,5 @@ | |||
| 1 | +import { client } from "./client"; | ||
| 2 | + | ||
| 3 | +export function deleteEventRegisterByUserId(eventId: string, userId: string): Promise<void> { | ||
| 4 | + return client<void>(`/events/${eventId}/register/${userId}`, { method: "DELETE" }); | ||
| 5 | +} | ||
src/api/deleteSessionAttendanceByUserId.tsdeleted+0 -5
| @@ -1,5 +0,0 @@ | |||
| 1 | -import { client } from "./client"; | ||
| 2 | - | ||
| 3 | -export function deleteSessionAttendanceByUserId(id: string, userId: string): Promise<void> { | ||
| 4 | - return client<void>(`/sessions/${id}/attendance/${userId}`, { method: "DELETE" }); | ||
| 5 | -} | ||
src/api/getEventRoster.tsadded+12 -0
| @@ -0,0 +1,12 @@ | |||
| 1 | +import { client } from "./client"; | ||
| 2 | +import { normalizePage, pageQuery, type Page, type PageParams } from "./page"; | ||
| 3 | +import type { EventRosterEntry } from "./types"; | ||
| 4 | + | ||
| 5 | +export async function getEventRoster( | ||
| 6 | + eventId: string, | ||
| 7 | + params?: PageParams, | ||
| 8 | + signal?: AbortSignal, | ||
| 9 | +): Promise<Page<EventRosterEntry>> { | ||
| 10 | + const data = await client<unknown>(`/events/${eventId}/roster${pageQuery(params)}`, { signal }); | ||
| 11 | + return normalizePage<EventRosterEntry>(data); | ||
| 12 | +} | ||
src/api/getExamChoiceImageBlob.tsdeleted+0 -5
| @@ -1,5 +0,0 @@ | |||
| 1 | -import { blobClient } from "./client"; | ||
| 2 | - | ||
| 3 | -export function getExamChoiceImageBlob(examId: string, questionId: string, index: number, signal?: AbortSignal): Promise<Blob> { | ||
| 4 | - return blobClient(`/exams/${examId}/questions/${questionId}/choices/${index}/image`, signal); | ||
| 5 | -} | ||
src/api/getExamQuestionImageBlob.tsdeleted+0 -5
| @@ -1,5 +0,0 @@ | |||
| 1 | -import { blobClient } from "./client"; | ||
| 2 | - | ||
| 3 | -export function getExamQuestionImageBlob(examId: string, questionId: string, signal?: AbortSignal): Promise<Blob> { | ||
| 4 | - return blobClient(`/exams/${examId}/questions/${questionId}/image`, signal); | ||
| 5 | -} | ||
src/api/getNoteById.tsdeleted+0 -6
| @@ -1,6 +0,0 @@ | |||
| 1 | -import { client } from "./client"; | ||
| 2 | -import type { Note } from "./types"; | ||
| 3 | - | ||
| 4 | -export function getNoteById(id: string, signal?: AbortSignal): Promise<Note> { | ||
| 5 | - return client<Note>(`/notes/${id}`, { signal }); | ||
| 6 | -} | ||
src/api/getUserById.tsdeleted+0 -6
| @@ -1,6 +0,0 @@ | |||
| 1 | -import { client } from "@/api/client"; | ||
| 2 | -import type { User } from "@/api/types"; | ||
| 3 | - | ||
| 4 | -export async function getUserById(id: string, signal?: AbortSignal): Promise<User> { | ||
| 5 | - return client<User>(`/users/${encodeURIComponent(id)}`, { signal }); | ||
| 6 | -} | ||
src/api/patchUserProfile.tsdeleted+0 -6
| @@ -1,6 +0,0 @@ | |||
| 1 | -import { client } from "@/api/client"; | ||
| 2 | -import type { ProfileUpdate, User } from "@/api/types"; | ||
| 3 | - | ||
| 4 | -export function patchUserProfile(id: string, body: ProfileUpdate): Promise<User> { | ||
| 5 | - return client<User>(`/users/${encodeURIComponent(id)}/profile`, { method: "PATCH", body }); | ||
| 6 | -} | ||
src/api/postEventRegister.tsadded+13 -0
| @@ -0,0 +1,13 @@ | |||
| 1 | +import { client } from "./client"; | ||
| 2 | +import type { EventRegistration } from "./types"; | ||
| 3 | + | ||
| 4 | +export type PostEventRegisterBody = { | ||
| 5 | + user_id?: string | null; | ||
| 6 | +}; | ||
| 7 | + | ||
| 8 | +export function postEventRegister(eventId: string, body: PostEventRegisterBody): Promise<EventRegistration> { | ||
| 9 | + return client<EventRegistration>(`/events/${eventId}/register`, { | ||
| 10 | + method: "POST", | ||
| 11 | + body, | ||
| 12 | + }); | ||
| 13 | +} | ||
src/api/types.tsmodified+12 -0
| @@ -76,6 +76,18 @@ export type Attendance = { | |||
| 76 | marked_by: PersonRef; | 76 | marked_by: PersonRef; |
| 77 | }; | 77 | }; |
| 78 | 78 | ||
| 79 | +export type EventRosterEntry = { | ||
| 80 | + user: PersonRef; | ||
| 81 | + status: AttendanceStatus | null; | ||
| 82 | + marked_by: PersonRef | null; | ||
| 83 | +}; | ||
| 84 | + | ||
| 85 | +export type EventRegistration = { | ||
| 86 | + event: string; | ||
| 87 | + user: PersonRef; | ||
| 88 | + registered_by: PersonRef; | ||
| 89 | +}; | ||
| 90 | + | ||
| 79 | export type Course = { | 91 | export type Course = { |
| 80 | id: string; | 92 | id: string; |
| 81 | creator: string; | 93 | creator: string; |
src/i18n/messages.tsmodified+21 -0
| @@ -80,6 +80,7 @@ export type MessageKey = | |||
| 80 | | "confirm.deleteSession" | 80 | | "confirm.deleteSession" |
| 81 | | "confirm.updateExam" | 81 | | "confirm.updateExam" |
| 82 | | "confirm.removeAttendance" | 82 | | "confirm.removeAttendance" |
| 83 | + | "confirm.removeEventRegistration" | ||
| 83 | | "confirm.removeResult" | 84 | | "confirm.removeResult" |
| 84 | | "confirm.updateRole" | 85 | | "confirm.updateRole" |
| 85 | | "confirm.gradeStudent" | 86 | | "confirm.gradeStudent" |
| @@ -228,6 +229,12 @@ export type MessageKey = | |||
| 228 | | "events.attendanceRecords" | 229 | | "events.attendanceRecords" |
| 229 | | "events.attendanceRecordsHelp" | 230 | | "events.attendanceRecordsHelp" |
| 230 | | "events.noAttendance" | 231 | | "events.noAttendance" |
| 232 | + | "events.registrationRoster" | ||
| 233 | + | "events.registrationRosterHelp" | ||
| 234 | + | "events.registerStudent" | ||
| 235 | + | "events.unregister" | ||
| 236 | + | "events.noRoster" | ||
| 237 | + | "events.notMarked" | ||
| 231 | | "events.attendee" | 238 | | "events.attendee" |
| 232 | | "events.selectAttendee" | 239 | | "events.selectAttendee" |
| 233 | | "events.noAttendees" | 240 | | "events.noAttendees" |
| @@ -677,6 +684,7 @@ const en: Dict = { | |||
| 677 | "confirm.deleteSession": "Delete session “{title}”?", | 684 | "confirm.deleteSession": "Delete session “{title}”?", |
| 678 | "confirm.updateExam": "Update exam “{title}”?", | 685 | "confirm.updateExam": "Update exam “{title}”?", |
| 679 | "confirm.removeAttendance": "Remove attendance for user {user}?", | 686 | "confirm.removeAttendance": "Remove attendance for user {user}?", |
| 687 | + "confirm.removeEventRegistration": "Remove registration for user {user}?", | ||
| 680 | "confirm.removeResult": "Remove grade for user {user}?", | 688 | "confirm.removeResult": "Remove grade for user {user}?", |
| 681 | "confirm.updateRole": "Change role of {user} from {from} to {to}?", | 689 | "confirm.updateRole": "Change role of {user} from {from} to {to}?", |
| 682 | "confirm.gradeStudent": "Grade user {user} with mark {mark}/100?", | 690 | "confirm.gradeStudent": "Grade user {user} with mark {mark}/100?", |
| @@ -826,6 +834,12 @@ const en: Dict = { | |||
| 826 | "events.attendanceRecords": "Attendance records", | 834 | "events.attendanceRecords": "Attendance records", |
| 827 | "events.attendanceRecordsHelp": "Saved student attendance for this event, including who recorded each row.", | 835 | "events.attendanceRecordsHelp": "Saved student attendance for this event, including who recorded each row.", |
| 828 | "events.noAttendance": "No attendance rows yet.", | 836 | "events.noAttendance": "No attendance rows yet.", |
| 837 | + "events.registrationRoster": "Registration list", | ||
| 838 | + "events.registrationRosterHelp": "Add students before attendance and review who is expected for this event.", | ||
| 839 | + "events.registerStudent": "Register student", | ||
| 840 | + "events.unregister": "Remove registration", | ||
| 841 | + "events.noRoster": "No students registered yet.", | ||
| 842 | + "events.notMarked": "Not marked", | ||
| 829 | "events.attendee": "Student", | 843 | "events.attendee": "Student", |
| 830 | "events.selectAttendee": "Search student", | 844 | "events.selectAttendee": "Search student", |
| 831 | "events.noAttendees": "No students found", | 845 | "events.noAttendees": "No students found", |
| @@ -1286,6 +1300,7 @@ const tr: Dict = { | |||
| 1286 | "confirm.deleteSession": "“{title}” oturumu silinsin mi?", | 1300 | "confirm.deleteSession": "“{title}” oturumu silinsin mi?", |
| 1287 | "confirm.updateExam": "“{title}” sınavı güncellensin mi?", | 1301 | "confirm.updateExam": "“{title}” sınavı güncellensin mi?", |
| 1288 | "confirm.removeAttendance": "{user} kullanıcısının yoklaması kaldırılsın mı?", | 1302 | "confirm.removeAttendance": "{user} kullanıcısının yoklaması kaldırılsın mı?", |
| 1303 | + "confirm.removeEventRegistration": "{user} kullanıcısının etkinlik kaydı kaldırılsın mı?", | ||
| 1289 | "confirm.removeResult": "{user} kullanıcısının notu kaldırılsın mı?", | 1304 | "confirm.removeResult": "{user} kullanıcısının notu kaldırılsın mı?", |
| 1290 | "confirm.updateRole": "{user} rolü {from} → {to} olarak değiştirilsin mi?", | 1305 | "confirm.updateRole": "{user} rolü {from} → {to} olarak değiştirilsin mi?", |
| 1291 | "confirm.gradeStudent": "{user} kullanıcısına {mark}/100 notu verilsin mi?", | 1306 | "confirm.gradeStudent": "{user} kullanıcısına {mark}/100 notu verilsin mi?", |
| @@ -1435,6 +1450,12 @@ const tr: Dict = { | |||
| 1435 | "events.attendanceRecords": "Yoklama kayıtları", | 1450 | "events.attendanceRecords": "Yoklama kayıtları", |
| 1436 | "events.attendanceRecordsHelp": "Bu etkinlik için kaydedilmiş öğrenci yoklaması ve kaydı kimin girdiği.", | 1451 | "events.attendanceRecordsHelp": "Bu etkinlik için kaydedilmiş öğrenci yoklaması ve kaydı kimin girdiği.", |
| 1437 | "events.noAttendance": "Henüz yoklama kaydı yok.", | 1452 | "events.noAttendance": "Henüz yoklama kaydı yok.", |
| 1453 | + "events.registrationRoster": "Kayıt listesi", | ||
| 1454 | + "events.registrationRosterHelp": "Yoklama öncesi öğrencileri ekle ve bu etkinlikte beklenenleri kontrol et.", | ||
| 1455 | + "events.registerStudent": "Öğrenciyi kaydet", | ||
| 1456 | + "events.unregister": "Kaydı kaldır", | ||
| 1457 | + "events.noRoster": "Henüz kayıtlı öğrenci yok.", | ||
| 1458 | + "events.notMarked": "İşaretlenmedi", | ||
| 1438 | "events.attendee": "Öğrenci", | 1459 | "events.attendee": "Öğrenci", |
| 1439 | "events.selectAttendee": "Öğrenci ara", | 1460 | "events.selectAttendee": "Öğrenci ara", |
| 1440 | "events.noAttendees": "Öğrenci bulunamadı", | 1461 | "events.noAttendees": "Öğrenci bulunamadı", |
src/pages/event-detail-page.tsxmodified+135 -1
| @@ -1,13 +1,17 @@ | |||
| 1 | import { Link, useLocation, useNavigate, useParams } from "@tanstack/solid-router"; | 1 | import { Link, useLocation, useNavigate, useParams } from "@tanstack/solid-router"; |
| 2 | +import type { ColumnDef } from "@tanstack/solid-table"; | ||
| 2 | import { Show, Suspense, createMemo, createResource, createSignal } from "solid-js"; | 3 | import { Show, Suspense, createMemo, createResource, createSignal } from "solid-js"; |
| 4 | +import { deleteEventRegisterByUserId } from "@/api/deleteEventRegisterByUserId"; | ||
| 3 | import { deleteEventAttendanceByUserId } from "@/api/deleteEventAttendanceByUserId"; | 5 | import { deleteEventAttendanceByUserId } from "@/api/deleteEventAttendanceByUserId"; |
| 4 | import { deleteEventById } from "@/api/deleteEventById"; | 6 | import { deleteEventById } from "@/api/deleteEventById"; |
| 5 | import { getEventAttendance } from "@/api/getEventAttendance"; | 7 | import { getEventAttendance } from "@/api/getEventAttendance"; |
| 6 | import { getEventById } from "@/api/getEventById"; | 8 | import { getEventById } from "@/api/getEventById"; |
| 9 | +import { getEventRoster } from "@/api/getEventRoster"; | ||
| 7 | import { patchEventById } from "@/api/patchEventById"; | 10 | import { patchEventById } from "@/api/patchEventById"; |
| 8 | import { postEventAttendance } from "@/api/postEventAttendance"; | 11 | import { postEventAttendance } from "@/api/postEventAttendance"; |
| 12 | +import { postEventRegister } from "@/api/postEventRegister"; | ||
| 9 | import { formatApiError } from "@/api/client"; | 13 | import { formatApiError } from "@/api/client"; |
| 10 | -import type { AttendanceStatus, EventAudience } from "@/api/types"; | 14 | +import type { AttendanceStatus, EventAudience, EventRosterEntry } from "@/api/types"; |
| 11 | import type { MessageKey } from "@/i18n/messages"; | 15 | import type { MessageKey } from "@/i18n/messages"; |
| 12 | import { AttendanceStatusPicker } from "@/components/events/attendance-status-picker"; | 16 | import { AttendanceStatusPicker } from "@/components/events/attendance-status-picker"; |
| 13 | import { AttendanceTable } from "@/components/events/attendance-table"; | 17 | import { AttendanceTable } from "@/components/events/attendance-table"; |
| @@ -15,15 +19,21 @@ import { EventForm } from "@/components/events/event-form"; | |||
| 15 | import { RouteGuard } from "@/components/layout/route-guard"; | 19 | import { RouteGuard } from "@/components/layout/route-guard"; |
| 16 | import { PageHeader } from "@/components/layout/page-header"; | 20 | import { PageHeader } from "@/components/layout/page-header"; |
| 17 | import { Alert } from "@/components/ui/alert"; | 21 | import { Alert } from "@/components/ui/alert"; |
| 22 | +import { Badge } from "@/components/ui/badge"; | ||
| 18 | import { Button } from "@/components/ui/button"; | 23 | import { Button } from "@/components/ui/button"; |
| 19 | import { ConfirmDialog } from "@/components/ui/confirm-dialog"; | 24 | import { ConfirmDialog } from "@/components/ui/confirm-dialog"; |
| 25 | +import { DataTable } from "@/components/ui/data-table"; | ||
| 20 | import { IconChevronLeft, IconEdit, IconTrash } from "@/components/ui/icons"; | 26 | import { IconChevronLeft, IconEdit, IconTrash } from "@/components/ui/icons"; |
| 21 | import { PageSpinner } from "@/components/ui/page-spinner"; | 27 | import { PageSpinner } from "@/components/ui/page-spinner"; |
| 22 | import { SectionDisclosure } from "@/components/ui/section-disclosure"; | 28 | import { SectionDisclosure } from "@/components/ui/section-disclosure"; |
| 23 | import { SidePanel } from "@/components/ui/side-panel"; | 29 | import { SidePanel } from "@/components/ui/side-panel"; |
| 30 | +import { TableRowActions } from "@/components/ui/table-row-actions"; | ||
| 24 | import { UserSearchSelect } from "@/components/users/user-search-select"; | 31 | import { UserSearchSelect } from "@/components/users/user-search-select"; |
| 32 | +import { getAttendanceStatusMeta } from "@/lib/attendance-status"; | ||
| 33 | +import { cn } from "@/lib/cn"; | ||
| 25 | import { createFlash } from "@/lib/flash"; | 34 | import { createFlash } from "@/lib/flash"; |
| 26 | import { formatDateTime } from "@/lib/format"; | 35 | import { formatDateTime } from "@/lib/format"; |
| 36 | +import { personId, personLabel } from "@/lib/person"; | ||
| 27 | import { hasMinRole } from "@/lib/roles"; | 37 | import { hasMinRole } from "@/lib/roles"; |
| 28 | import { useAuth } from "@/stores/auth-context"; | 38 | import { useAuth } from "@/stores/auth-context"; |
| 29 | import { usePreferences, useT } from "@/stores/preferences-context"; | 39 | import { usePreferences, useT } from "@/stores/preferences-context"; |
| @@ -57,8 +67,11 @@ function EventDetailContent() { | |||
| 57 | 67 | ||
| 58 | const [status, setStatus] = createSignal<AttendanceStatus>("present"); | 68 | const [status, setStatus] = createSignal<AttendanceStatus>("present"); |
| 59 | const [otherUserId, setOtherUserId] = createSignal(""); | 69 | const [otherUserId, setOtherUserId] = createSignal(""); |
| 70 | + const [registrationUserId, setRegistrationUserId] = createSignal(""); | ||
| 60 | const [editing, setEditing] = createSignal(false); | 71 | const [editing, setEditing] = createSignal(false); |
| 61 | const [deleteOpen, setDeleteOpen] = createSignal(false); | 72 | const [deleteOpen, setDeleteOpen] = createSignal(false); |
| 73 | + const [registrationOpen, setRegistrationOpen] = createSignal(false); | ||
| 74 | + const [registrationTarget, setRegistrationTarget] = createSignal<string | null>(null); | ||
| 62 | const [studentAttendanceOpen, setStudentAttendanceOpen] = createSignal(false); | 75 | const [studentAttendanceOpen, setStudentAttendanceOpen] = createSignal(false); |
| 63 | const [attendanceOpen, setAttendanceOpen] = createSignal(false); | 76 | const [attendanceOpen, setAttendanceOpen] = createSignal(false); |
| 64 | const [error, setError] = createSignal(""); | 77 | const [error, setError] = createSignal(""); |
| @@ -67,6 +80,10 @@ function EventDetailContent() { | |||
| 67 | const isTeacherPlus = () => hasMinRole(auth.user()?.role, "teacher"); | 80 | const isTeacherPlus = () => hasMinRole(auth.user()?.role, "teacher"); |
| 68 | 81 | ||
| 69 | const [event, { refetch: refetchEvent }] = createResource(id, (eventId) => getEventById(eventId)); | 82 | const [event, { refetch: refetchEvent }] = createResource(id, (eventId) => getEventById(eventId)); |
| 83 | + const [roster, { refetch: refetchRoster }] = createResource( | ||
| 84 | + () => (isTeacherPlus() && event()?.audience.kind === "registration" && registrationOpen() ? id() : null), | ||
| 85 | + async (eventId) => (eventId ? (await getEventRoster(eventId)).items : []), | ||
| 86 | + ); | ||
| 70 | const [attendance, { refetch: refetchAttendance }] = createResource( | 87 | const [attendance, { refetch: refetchAttendance }] = createResource( |
| 71 | () => (isTeacherPlus() && attendanceOpen() ? id() : null), | 88 | () => (isTeacherPlus() && attendanceOpen() ? id() : null), |
| 72 | async (eventId) => (eventId ? (await getEventAttendance(eventId)).items : []), | 89 | async (eventId) => (eventId ? (await getEventAttendance(eventId)).items : []), |
| @@ -79,6 +96,50 @@ function EventDetailContent() { | |||
| 79 | return e.creator === u.id || hasMinRole(u.role, "manager"); | 96 | return e.creator === u.id || hasMinRole(u.role, "manager"); |
| 80 | }; | 97 | }; |
| 81 | const [flash, setFlash] = createFlash(); | 98 | const [flash, setFlash] = createFlash(); |
| 99 | + const rosterColumns = createMemo<ColumnDef<EventRosterEntry>[]>(() => [ | ||
| 100 | + { | ||
| 101 | + id: "attendee", | ||
| 102 | + accessorFn: (row) => personLabel(row.user), | ||
| 103 | + header: t("events.attendee"), | ||
| 104 | + cell: (cell) => <span class="font-medium">{personLabel(cell.row.original.user)}</span>, | ||
| 105 | + }, | ||
| 106 | + { | ||
| 107 | + id: "status", | ||
| 108 | + accessorFn: (row) => row.status ?? "", | ||
| 109 | + header: t("events.status"), | ||
| 110 | + cell: (cell) => { | ||
| 111 | + const status = cell.row.original.status; | ||
| 112 | + const meta = status ? getAttendanceStatusMeta(status) : null; | ||
| 113 | + return status ? ( | ||
| 114 | + <Badge variant="outline" class={cn("gap-1 rounded-full border px-2.5 py-1 normal-case", meta?.class)}> | ||
| 115 | + {meta ? t(meta.key) : status} | ||
| 116 | + </Badge> | ||
| 117 | + ) : <span class="text-sm text-muted-foreground">{t("events.notMarked")}</span>; | ||
| 118 | + }, | ||
| 119 | + }, | ||
| 120 | + { | ||
| 121 | + id: "marked_by", | ||
| 122 | + accessorFn: (row) => row.marked_by ? personLabel(row.marked_by) : "", | ||
| 123 | + header: t("events.markedBy"), | ||
| 124 | + cell: (cell) => <span class="text-sm text-muted-foreground">{cell.row.original.marked_by ? personLabel(cell.row.original.marked_by) : "—"}</span>, | ||
| 125 | + }, | ||
| 126 | + { | ||
| 127 | + id: "actions", | ||
| 128 | + header: t("common.actions"), | ||
| 129 | + meta: { headerClass: "w-14 text-center", cellClass: "px-1 text-center" }, | ||
| 130 | + cell: (cell) => ( | ||
| 131 | + <TableRowActions | ||
| 132 | + label={t("common.actions")} | ||
| 133 | + actions={[{ | ||
| 134 | + label: t("events.unregister"), | ||
| 135 | + icon: <IconTrash class="h-4 w-4" />, | ||
| 136 | + destructive: true, | ||
| 137 | + onSelect: () => setRegistrationTarget(personId(cell.row.original.user)), | ||
| 138 | + }]} | ||
| 139 | + /> | ||
| 140 | + ), | ||
| 141 | + }, | ||
| 142 | + ]); | ||
| 82 | 143 | ||
| 83 | const wrap = async (fn: () => Promise<void>, ok?: string) => { | 144 | const wrap = async (fn: () => Promise<void>, ok?: string) => { |
| 84 | setError(""); | 145 | setError(""); |
| @@ -190,6 +251,79 @@ function EventDetailContent() { | |||
| 190 | /> | 251 | /> |
| 191 | </SidePanel> | 252 | </SidePanel> |
| 192 | 253 | ||
| 254 | + <ConfirmDialog | ||
| 255 | + open={registrationTarget() != null} | ||
| 256 | + onOpenChange={(open) => { | ||
| 257 | + if (!open) setRegistrationTarget(null); | ||
| 258 | + }} | ||
| 259 | + title={t("confirm.deleteTitle")} | ||
| 260 | + variant="destructive" | ||
| 261 | + summary={t("confirm.removeEventRegistration", { user: registrationTarget() ?? "" })} | ||
| 262 | + onConfirm={async () => { | ||
| 263 | + const userId = registrationTarget(); | ||
| 264 | + if (!userId) return; | ||
| 265 | + await wrap(async () => { | ||
| 266 | + await deleteEventRegisterByUserId(id(), userId); | ||
| 267 | + await refetchRoster(); | ||
| 268 | + }, t("common.deleted")); | ||
| 269 | + setRegistrationTarget(null); | ||
| 270 | + }} | ||
| 271 | + /> | ||
| 272 | + | ||
| 273 | + <Show when={isTeacherPlus() && ev().audience.kind === "registration"}> | ||
| 274 | + <SectionDisclosure | ||
| 275 | + open={registrationOpen()} | ||
| 276 | + onToggle={() => setRegistrationOpen((open) => !open)} | ||
| 277 | + title={t("events.registrationRoster")} | ||
| 278 | + description={t("events.registrationRosterHelp")} | ||
| 279 | + > | ||
| 280 | + <div class="space-y-3"> | ||
| 281 | + <div class="grid gap-3 rounded-lg border bg-muted/20 p-3 lg:grid-cols-[minmax(0,1fr)_auto] lg:items-end"> | ||
| 282 | + <UserSearchSelect | ||
| 283 | + id="registration-user" | ||
| 284 | + label={t("events.attendee")} | ||
| 285 | + value={registrationUserId()} | ||
| 286 | + placeholder={t("events.selectAttendee")} | ||
| 287 | + emptyMessage={t("events.noAttendees")} | ||
| 288 | + role="student" | ||
| 289 | + onChange={setRegistrationUserId} | ||
| 290 | + /> | ||
| 291 | + <Button | ||
| 292 | + type="button" | ||
| 293 | + class="rounded-sm" | ||
| 294 | + disabled={pending()} | ||
| 295 | + onClick={() => { | ||
| 296 | + const uid = registrationUserId().trim(); | ||
| 297 | + if (!uid) { | ||
| 298 | + setError(t("events.userIdRequired")); | ||
| 299 | + return; | ||
| 300 | + } | ||
| 301 | + void wrap(async () => { | ||
| 302 | + await postEventRegister(id(), { user_id: uid }); | ||
| 303 | + setRegistrationUserId(""); | ||
| 304 | + await refetchRoster(); | ||
| 305 | + }, t("common.saved")); | ||
| 306 | + }} | ||
| 307 | + > | ||
| 308 | + {t("events.registerStudent")} | ||
| 309 | + </Button> | ||
| 310 | + </div> | ||
| 311 | + <Suspense fallback={<PageSpinner />}> | ||
| 312 | + <Show when={roster()}> | ||
| 313 | + {(rows) => ( | ||
| 314 | + <Show | ||
| 315 | + when={rows().length > 0} | ||
| 316 | + fallback={<p class="rounded-lg border border-dashed border-border/80 bg-muted/20 px-4 py-8 text-center text-sm text-muted-foreground">{t("events.noRoster")}</p>} | ||
| 317 | + > | ||
| 318 | + <DataTable columns={rosterColumns()} data={rows()} filterColumn="attendee" enablePagination pageSize={10} /> | ||
| 319 | + </Show> | ||
| 320 | + )} | ||
| 321 | + </Show> | ||
| 322 | + </Suspense> | ||
| 323 | + </div> | ||
| 324 | + </SectionDisclosure> | ||
| 325 | + </Show> | ||
| 326 | + | ||
| 193 | <Show when={isTeacherPlus()}> | 327 | <Show when={isTeacherPlus()}> |
| 194 | <SectionDisclosure | 328 | <SectionDisclosure |
| 195 | open={studentAttendanceOpen()} | 329 | open={studentAttendanceOpen()} |