♻️ move course session actions into side panels
Browse files at this commit0301cb05f8ed8a9595fab477efd46927aaad9ea0Parent: 828b795- refactor
- ♻️ move course session actions into side panels
4 changed files +150 -69
- src/components/sessions/course-sessions-panel.tsx +125 -63
- src/components/ui/section-disclosure.tsx +1 -1
- src/i18n/messages.ts +3 -0
- src/pages/course-detail-page.tsx +21 -5
src/components/sessions/course-sessions-panel.tsxmodified+125 -63
| @@ -1,19 +1,21 @@ | |||
| 1 | -import { For, Show, Suspense, createMemo, createResource, createSignal } from "solid-js"; | 1 | +import { For, Show, Suspense, createEffect, createMemo, createResource, createSignal } from "solid-js"; |
| 2 | import { deleteSessionById } from "@/api/deleteSessionById"; | 2 | import { deleteSessionById } from "@/api/deleteSessionById"; |
| 3 | import { getCourseSessions } from "@/api/getCourseSessions"; | 3 | import { getCourseSessions } from "@/api/getCourseSessions"; |
| 4 | import { getSessionAttendance } from "@/api/getSessionAttendance"; | 4 | import { getSessionAttendance } from "@/api/getSessionAttendance"; |
| 5 | import { postCourseSession } from "@/api/postCourseSession"; | 5 | import { postCourseSession } from "@/api/postCourseSession"; |
| 6 | import { postSessionAttendance } from "@/api/postSessionAttendance"; | 6 | import { postSessionAttendance } from "@/api/postSessionAttendance"; |
| 7 | import { formatApiError } from "@/api/client"; | 7 | import { formatApiError } from "@/api/client"; |
| 8 | -import type { AttendanceStatus, Enrollment, SessionAttendance } from "@/api/types"; | 8 | +import type { AttendanceStatus, CourseSession, Enrollment, SessionAttendance } from "@/api/types"; |
| 9 | import { AttendanceStatusPicker } from "@/components/events/attendance-status-picker"; | 9 | import { AttendanceStatusPicker } from "@/components/events/attendance-status-picker"; |
| 10 | import { Alert } from "@/components/ui/alert"; | 10 | import { Alert } from "@/components/ui/alert"; |
| 11 | import { Button } from "@/components/ui/button"; | 11 | import { Button } from "@/components/ui/button"; |
| 12 | import { DatePicker } from "@/components/ui/date-picker"; | 12 | import { DatePicker } from "@/components/ui/date-picker"; |
| 13 | -import { IconPlus, IconTrash } from "@/components/ui/icons"; | 13 | +import { IconTrash } from "@/components/ui/icons"; |
| 14 | import { Input } from "@/components/ui/input"; | 14 | import { Input } from "@/components/ui/input"; |
| 15 | import { Label } from "@/components/ui/label"; | 15 | import { Label } from "@/components/ui/label"; |
| 16 | import { PageSpinner } from "@/components/ui/page-spinner"; | 16 | import { PageSpinner } from "@/components/ui/page-spinner"; |
| 17 | +import { PaginationControls } from "@/components/ui/pagination-controls"; | ||
| 18 | +import { SidePanel } from "@/components/ui/side-panel"; | ||
| 17 | import { formatDateTime } from "@/lib/format"; | 19 | import { formatDateTime } from "@/lib/format"; |
| 18 | import { personLabel } from "@/lib/person"; | 20 | import { personLabel } from "@/lib/person"; |
| 19 | import { usePreferences, useT } from "@/stores/preferences-context"; | 21 | import { usePreferences, useT } from "@/stores/preferences-context"; |
| @@ -34,11 +36,19 @@ function dateInputToMs(date: string, time: string): number | null { | |||
| 34 | return d.getTime(); | 36 | return d.getTime(); |
| 35 | } | 37 | } |
| 36 | 38 | ||
| 37 | -export function CourseSessionsPanel(props: { courseId: string; roster: Enrollment[]; canManage: boolean }) { | 39 | +const ROLL_CALL_PAGE_SIZE = 8; |
| 40 | + | ||
| 41 | +export function CourseSessionsPanel(props: { | ||
| 42 | + courseId: string; | ||
| 43 | + roster: Enrollment[]; | ||
| 44 | + canManage: boolean; | ||
| 45 | + createOpen: boolean; | ||
| 46 | + onCreateOpenChange: (open: boolean) => void; | ||
| 47 | +}) { | ||
| 38 | const t = useT(); | 48 | const t = useT(); |
| 39 | const { locale } = usePreferences(); | 49 | const { locale } = usePreferences(); |
| 40 | const [sessions, { refetch }] = createResource(() => props.courseId, (courseId) => getCourseSessions(courseId)); | 50 | const [sessions, { refetch }] = createResource(() => props.courseId, (courseId) => getCourseSessions(courseId)); |
| 41 | - const [openSessionId, setOpenSessionId] = createSignal<string | null>(null); | 51 | + const [selectedSession, setSelectedSession] = createSignal<CourseSession | null>(null); |
| 42 | const [topic, setTopic] = createSignal(""); | 52 | const [topic, setTopic] = createSignal(""); |
| 43 | const [startsDate, setStartsDate] = createSignal(""); | 53 | const [startsDate, setStartsDate] = createSignal(""); |
| 44 | const [startsTime, setStartsTime] = createSignal(""); | 54 | const [startsTime, setStartsTime] = createSignal(""); |
| @@ -47,6 +57,15 @@ export function CourseSessionsPanel(props: { courseId: string; roster: Enrollmen | |||
| 47 | const [error, setError] = createSignal(""); | 57 | const [error, setError] = createSignal(""); |
| 48 | const [pending, setPending] = createSignal(false); | 58 | const [pending, setPending] = createSignal(false); |
| 49 | 59 | ||
| 60 | + const resetCreateForm = () => { | ||
| 61 | + setTopic(""); | ||
| 62 | + setStartsDate(""); | ||
| 63 | + setStartsTime(""); | ||
| 64 | + setEndsDate(""); | ||
| 65 | + setEndsTime(""); | ||
| 66 | + setError(""); | ||
| 67 | + }; | ||
| 68 | + | ||
| 50 | const createSession = async (e: SubmitEvent) => { | 69 | const createSession = async (e: SubmitEvent) => { |
| 51 | e.preventDefault(); | 70 | e.preventDefault(); |
| 52 | setError(""); | 71 | setError(""); |
| @@ -66,12 +85,14 @@ export function CourseSessionsPanel(props: { courseId: string; roster: Enrollmen | |||
| 66 | } | 85 | } |
| 67 | setPending(true); | 86 | setPending(true); |
| 68 | try { | 87 | try { |
| 69 | - await postCourseSession(props.courseId, { topic: topic().trim() || null, starts_at, ends_at }); | 88 | + const body = { |
| 70 | - setTopic(""); | 89 | + starts_at, |
| 71 | - setStartsDate(""); | 90 | + ...(topic().trim() ? { topic: topic().trim() } : {}), |
| 72 | - setStartsTime(""); | 91 | + ...(ends_at != null ? { ends_at } : {}), |
| 73 | - setEndsDate(""); | 92 | + }; |
| 74 | - setEndsTime(""); | 93 | + await postCourseSession(props.courseId, body); |
| 94 | + resetCreateForm(); | ||
| 95 | + props.onCreateOpenChange(false); | ||
| 75 | await refetch(); | 96 | await refetch(); |
| 76 | } catch (err) { | 97 | } catch (err) { |
| 77 | setError(formatApiError(err)); | 98 | setError(formatApiError(err)); |
| @@ -84,35 +105,6 @@ export function CourseSessionsPanel(props: { courseId: string; roster: Enrollmen | |||
| 84 | <div class="space-y-4"> | 105 | <div class="space-y-4"> |
| 85 | {error() && <Alert variant="destructive">{error()}</Alert>} | 106 | {error() && <Alert variant="destructive">{error()}</Alert>} |
| 86 | 107 | ||
| 87 | - <Show when={props.canManage}> | ||
| 88 | - <form class="grid gap-3 lg:grid-cols-[minmax(0,1fr)_minmax(0,1fr)_minmax(0,1fr)_auto]" onSubmit={createSession}> | ||
| 89 | - <div class="space-y-1.5"> | ||
| 90 | - <Label for="session-topic">{t("sessions.topic")}</Label> | ||
| 91 | - <Input id="session-topic" value={topic()} maxlength={200} onInput={(e) => setTopic(e.currentTarget.value)} /> | ||
| 92 | - </div> | ||
| 93 | - <div class="space-y-1.5"> | ||
| 94 | - <Label for="session-starts">{t("events.starts")}</Label> | ||
| 95 | - <div class="grid grid-cols-[minmax(0,1fr)_6.5rem] gap-2"> | ||
| 96 | - <DatePicker id="session-starts" placeholder={t("form.datePlaceholder")} value={startsDate()} required onChange={setStartsDate} /> | ||
| 97 | - <Input class="font-mono" placeholder="09:00" value={startsTime()} required onInput={(e) => setStartsTime(e.currentTarget.value)} /> | ||
| 98 | - </div> | ||
| 99 | - </div> | ||
| 100 | - <div class="space-y-1.5"> | ||
| 101 | - <Label for="session-ends">{t("events.ends")}</Label> | ||
| 102 | - <div class="grid grid-cols-[minmax(0,1fr)_6.5rem] gap-2"> | ||
| 103 | - <DatePicker id="session-ends" placeholder={t("form.datePlaceholder")} value={endsDate()} onChange={setEndsDate} /> | ||
| 104 | - <Input class="font-mono" placeholder="10:00" value={endsTime()} onInput={(e) => setEndsTime(e.currentTarget.value)} /> | ||
| 105 | - </div> | ||
| 106 | - </div> | ||
| 107 | - <div class="flex items-end"> | ||
| 108 | - <Button type="submit" disabled={pending()}> | ||
| 109 | - <IconPlus class="h-4 w-4" /> | ||
| 110 | - {t("sessions.add")} | ||
| 111 | - </Button> | ||
| 112 | - </div> | ||
| 113 | - </form> | ||
| 114 | - </Show> | ||
| 115 | - | ||
| 116 | <Suspense fallback={<PageSpinner />}> | 108 | <Suspense fallback={<PageSpinner />}> |
| 117 | <Show when={sessions.error}> | 109 | <Show when={sessions.error}> |
| 118 | <Alert variant="destructive">{formatApiError(sessions.error)}</Alert> | 110 | <Alert variant="destructive">{formatApiError(sessions.error)}</Alert> |
| @@ -121,7 +113,7 @@ export function CourseSessionsPanel(props: { courseId: string; roster: Enrollmen | |||
| 121 | <div class="space-y-3"> | 113 | <div class="space-y-3"> |
| 122 | <For each={sessions() ?? []}> | 114 | <For each={sessions() ?? []}> |
| 123 | {(session) => ( | 115 | {(session) => ( |
| 124 | - <article class="rounded-lg border bg-background/60 p-4"> | 116 | + <article class="rounded-xl border border-border/80 bg-card p-4 shadow-sm"> |
| 125 | <div class="flex flex-wrap items-start justify-between gap-3"> | 117 | <div class="flex flex-wrap items-start justify-between gap-3"> |
| 126 | <div> | 118 | <div> |
| 127 | <h3 class="font-medium">{session.topic || t("sessions.untitled")}</h3> | 119 | <h3 class="font-medium">{session.topic || t("sessions.untitled")}</h3> |
| @@ -131,25 +123,76 @@ export function CourseSessionsPanel(props: { courseId: string; roster: Enrollmen | |||
| 131 | <p class="mt-1 text-xs text-muted-foreground">{t("sessions.teacher")}: {personLabel(session.teacher)}</p> | 123 | <p class="mt-1 text-xs text-muted-foreground">{t("sessions.teacher")}: {personLabel(session.teacher)}</p> |
| 132 | </div> | 124 | </div> |
| 133 | <div class="flex gap-2"> | 125 | <div class="flex gap-2"> |
| 134 | - <Button type="button" variant="outline" size="sm" onClick={() => setOpenSessionId(openSessionId() === session.id ? null : session.id)}> | 126 | + <Button type="button" variant="outline" size="sm" class="rounded-lg" onClick={() => setSelectedSession(session)}> |
| 135 | {t("sessions.rollCall")} | 127 | {t("sessions.rollCall")} |
| 136 | </Button> | 128 | </Button> |
| 137 | <Show when={props.canManage}> | 129 | <Show when={props.canManage}> |
| 138 | - <Button type="button" variant="ghost" size="sm" class="text-destructive hover:text-destructive" onClick={async () => { await deleteSessionById(session.id); await refetch(); }}> | 130 | + <Button type="button" variant="ghost" size="sm" class="rounded-lg text-destructive hover:text-destructive" onClick={async () => { await deleteSessionById(session.id); await refetch(); }}> |
| 139 | <IconTrash class="h-4 w-4" /> | 131 | <IconTrash class="h-4 w-4" /> |
| 140 | </Button> | 132 | </Button> |
| 141 | </Show> | 133 | </Show> |
| 142 | </div> | 134 | </div> |
| 143 | </div> | 135 | </div> |
| 144 | - <Show when={openSessionId() === session.id}> | ||
| 145 | - <RollCall sessionId={session.id} roster={props.roster} /> | ||
| 146 | - </Show> | ||
| 147 | </article> | 136 | </article> |
| 148 | )} | 137 | )} |
| 149 | </For> | 138 | </For> |
| 150 | </div> | 139 | </div> |
| 151 | </Show> | 140 | </Show> |
| 152 | </Suspense> | 141 | </Suspense> |
| 142 | + | ||
| 143 | + <SidePanel | ||
| 144 | + open={props.createOpen} | ||
| 145 | + onOpenChange={(open) => { | ||
| 146 | + props.onCreateOpenChange(open); | ||
| 147 | + if (!open) resetCreateForm(); | ||
| 148 | + }} | ||
| 149 | + title={t("sessions.add")} | ||
| 150 | + description={t("sessions.subtitle")} | ||
| 151 | + > | ||
| 152 | + <form onSubmit={createSession}> | ||
| 153 | + <div class="space-y-1.5"> | ||
| 154 | + <Label for="session-topic">{t("sessions.topic")}</Label> | ||
| 155 | + <Input id="session-topic" value={topic()} maxlength={200} onInput={(e) => setTopic(e.currentTarget.value)} /> | ||
| 156 | + </div> | ||
| 157 | + <div class="grid gap-3"> | ||
| 158 | + <div class="space-y-1.5"> | ||
| 159 | + <Label for="session-starts">{t("events.starts")}</Label> | ||
| 160 | + <div class="grid grid-cols-[minmax(0,1fr)_6.5rem] gap-2"> | ||
| 161 | + <DatePicker id="session-starts" placeholder={t("form.datePlaceholder")} value={startsDate()} required onChange={setStartsDate} /> | ||
| 162 | + <Input class="font-mono placeholder:text-muted-foreground/35" placeholder="09:00" value={startsTime()} required onInput={(e) => setStartsTime(e.currentTarget.value)} /> | ||
| 163 | + </div> | ||
| 164 | + </div> | ||
| 165 | + <div class="space-y-1.5"> | ||
| 166 | + <Label for="session-ends">{t("events.ends")}</Label> | ||
| 167 | + <div class="grid grid-cols-[minmax(0,1fr)_6.5rem] gap-2"> | ||
| 168 | + <DatePicker id="session-ends" placeholder={t("form.datePlaceholder")} value={endsDate()} onChange={setEndsDate} /> | ||
| 169 | + <Input class="font-mono placeholder:text-muted-foreground/35" placeholder="10:00" value={endsTime()} onInput={(e) => setEndsTime(e.currentTarget.value)} /> | ||
| 170 | + </div> | ||
| 171 | + </div> | ||
| 172 | + </div> | ||
| 173 | + <div class="flex flex-wrap items-center gap-2"> | ||
| 174 | + <Button type="button" variant="outline" class="h-10 rounded-lg" onClick={() => props.onCreateOpenChange(false)}> | ||
| 175 | + {t("common.cancel")} | ||
| 176 | + </Button> | ||
| 177 | + <Button type="submit" class="h-10 rounded-lg" disabled={pending()}> | ||
| 178 | + {t("sessions.add")} | ||
| 179 | + </Button> | ||
| 180 | + </div> | ||
| 181 | + </form> | ||
| 182 | + </SidePanel> | ||
| 183 | + | ||
| 184 | + <SidePanel | ||
| 185 | + open={selectedSession() != null} | ||
| 186 | + onOpenChange={(open) => { | ||
| 187 | + if (!open) setSelectedSession(null); | ||
| 188 | + }} | ||
| 189 | + title={t("sessions.rollCall")} | ||
| 190 | + description={selectedSession() ? `${selectedSession()!.topic || t("sessions.untitled")} · ${formatDateTime(selectedSession()!.starts_at, locale())}` : undefined} | ||
| 191 | + > | ||
| 192 | + <Show when={selectedSession()}> | ||
| 193 | + {(session) => <RollCall sessionId={session().id} roster={props.roster} />} | ||
| 194 | + </Show> | ||
| 195 | + </SidePanel> | ||
| 153 | </div> | 196 | </div> |
| 154 | ); | 197 | ); |
| 155 | } | 198 | } |
| @@ -160,6 +203,17 @@ function RollCall(props: { sessionId: string; roster: Enrollment[] }) { | |||
| 160 | const rows = createMemo(() => new Map((attendance() ?? []).map((row) => [row.user.id, row]))); | 203 | const rows = createMemo(() => new Map((attendance() ?? []).map((row) => [row.user.id, row]))); |
| 161 | const [local, setLocal] = createSignal<Record<string, AttendanceStatus>>({}); | 204 | const [local, setLocal] = createSignal<Record<string, AttendanceStatus>>({}); |
| 162 | const [error, setError] = createSignal(""); | 205 | const [error, setError] = createSignal(""); |
| 206 | + const [page, setPage] = createSignal(0); | ||
| 207 | + const totalPages = createMemo(() => Math.max(1, Math.ceil(props.roster.length / ROLL_CALL_PAGE_SIZE))); | ||
| 208 | + const safePage = createMemo(() => Math.min(page(), totalPages() - 1)); | ||
| 209 | + const visibleRoster = createMemo(() => { | ||
| 210 | + const start = safePage() * ROLL_CALL_PAGE_SIZE; | ||
| 211 | + return props.roster.slice(start, start + ROLL_CALL_PAGE_SIZE); | ||
| 212 | + }); | ||
| 213 | + | ||
| 214 | + createEffect(() => { | ||
| 215 | + if (page() >= totalPages()) setPage(totalPages() - 1); | ||
| 216 | + }); | ||
| 163 | 217 | ||
| 164 | const statusFor = (userId: string) => local()[userId] ?? rows().get(userId)?.status ?? "present"; | 218 | const statusFor = (userId: string) => local()[userId] ?? rows().get(userId)?.status ?? "present"; |
| 165 | const save = async (userId: string) => { | 219 | const save = async (userId: string) => { |
| @@ -173,25 +227,33 @@ function RollCall(props: { sessionId: string; roster: Enrollment[] }) { | |||
| 173 | }; | 227 | }; |
| 174 | 228 | ||
| 175 | return ( | 229 | return ( |
| 176 | - <div class="mt-4 space-y-3 border-t pt-4"> | 230 | + <div class="space-y-3"> |
| 177 | {error() && <Alert variant="destructive">{error()}</Alert>} | 231 | {error() && <Alert variant="destructive">{error()}</Alert>} |
| 178 | - <For each={props.roster}> | 232 | + <Show |
| 179 | - {(row) => { | 233 | + when={props.roster.length > 0} |
| 180 | - const saved = () => rows().get(row.user.id) as SessionAttendance | undefined; | 234 | + fallback={<p class="rounded-xl border border-dashed border-border/80 bg-muted/20 px-4 py-8 text-center text-sm text-muted-foreground">{t("sessions.emptyRoster")}</p>} |
| 181 | - return ( | 235 | + > |
| 182 | - <div class="grid gap-2 rounded-md border bg-muted/15 p-3 sm:grid-cols-[minmax(0,1fr)_12rem_auto] sm:items-end"> | 236 | + <For each={visibleRoster()}> |
| 183 | - <div> | 237 | + {(row) => { |
| 184 | - <p class="font-medium">{personLabel(row.user)}</p> | 238 | + const saved = () => rows().get(row.user.id) as SessionAttendance | undefined; |
| 185 | - <p class="font-mono text-xs text-muted-foreground">{row.user.id}</p> | 239 | + return ( |
| 240 | + <div class="grid gap-3 rounded-xl border border-border/80 bg-card p-4 shadow-sm sm:grid-cols-[minmax(0,1fr)_13rem_auto] sm:items-end"> | ||
| 241 | + <div class="min-w-0"> | ||
| 242 | + <p class="truncate font-medium">{personLabel(row.user)}</p> | ||
| 243 | + <p class="mono mt-1 truncate text-xs text-muted-foreground">{row.user.id}</p> | ||
| 244 | + </div> | ||
| 245 | + <AttendanceStatusPicker id={`session-${props.sessionId}-${row.user.id}`} value={statusFor(row.user.id)} onChange={(status) => setLocal((current) => ({ ...current, [row.user.id]: status }))} /> | ||
| 246 | + <Button type="button" class="rounded-lg" variant={saved() ? "outline" : "default"} onClick={() => void save(row.user.id)}> | ||
| 247 | + {saved() ? t("common.update") : t("common.save")} | ||
| 248 | + </Button> | ||
| 186 | </div> | 249 | </div> |
| 187 | - <AttendanceStatusPicker id={`session-${props.sessionId}-${row.user.id}`} value={statusFor(row.user.id)} onChange={(status) => setLocal((current) => ({ ...current, [row.user.id]: status }))} /> | 250 | + ); |
| 188 | - <Button type="button" variant={saved() ? "outline" : "default"} onClick={() => void save(row.user.id)}> | 251 | + }} |
| 189 | - {saved() ? t("common.update") : t("common.save")} | 252 | + </For> |
| 190 | - </Button> | 253 | + </Show> |
| 191 | - </div> | 254 | + <Show when={totalPages() > 1}> |
| 192 | - ); | 255 | + <PaginationControls page={safePage()} totalPages={totalPages()} onPageChange={setPage} /> |
| 193 | - }} | 256 | + </Show> |
| 194 | - </For> | ||
| 195 | </div> | 257 | </div> |
| 196 | ); | 258 | ); |
| 197 | } | 259 | } |
src/components/ui/section-disclosure.tsxmodified+1 -1
| @@ -26,7 +26,7 @@ export function SectionDisclosure(props: ParentProps<{ | |||
| 26 | {props.description && <span class="mt-1 block truncate text-sm text-muted-foreground">{props.description}</span>} | 26 | {props.description && <span class="mt-1 block truncate text-sm text-muted-foreground">{props.description}</span>} |
| 27 | </span> | 27 | </span> |
| 28 | </button> | 28 | </button> |
| 29 | - <div class="flex items-center gap-2 [&>button]:h-8 [&>button]:min-w-32 [&>button]:justify-center [&>div]:h-8 [&>div]:min-w-8 [&>div]:justify-center"> | 29 | + <div class="flex items-center gap-2 [&>button]:h-8 [&>button]:min-w-36 [&>button]:justify-center [&>div]:h-8 [&>div]:justify-center"> |
| 30 | {props.meta} | 30 | {props.meta} |
| 31 | {props.actions} | 31 | {props.actions} |
| 32 | </div> | 32 | </div> |
src/i18n/messages.tsmodified+3 -0
| @@ -443,6 +443,7 @@ export type MessageKey = | |||
| 443 | | "sessions.untitled" | 443 | | "sessions.untitled" |
| 444 | | "sessions.teacher" | 444 | | "sessions.teacher" |
| 445 | | "sessions.rollCall" | 445 | | "sessions.rollCall" |
| 446 | + | "sessions.emptyRoster" | ||
| 446 | | "sessions.startRequired" | 447 | | "sessions.startRequired" |
| 447 | | "sessions.endInvalid" | 448 | | "sessions.endInvalid" |
| 448 | | "attendance.title" | 449 | | "attendance.title" |
| @@ -928,6 +929,7 @@ const en: Dict = { | |||
| 928 | "sessions.untitled": "Untitled lesson", | 929 | "sessions.untitled": "Untitled lesson", |
| 929 | "sessions.teacher": "Teacher", | 930 | "sessions.teacher": "Teacher", |
| 930 | "sessions.rollCall": "Roll call", | 931 | "sessions.rollCall": "Roll call", |
| 932 | + "sessions.emptyRoster": "No enrolled students yet.", | ||
| 931 | "sessions.startRequired": "Session start date and time are required.", | 933 | "sessions.startRequired": "Session start date and time are required.", |
| 932 | "sessions.endInvalid": "Enter both end date and end time, or leave both empty.", | 934 | "sessions.endInvalid": "Enter both end date and end time, or leave both empty.", |
| 933 | "attendance.title": "Attendance report", | 935 | "attendance.title": "Attendance report", |
| @@ -1412,6 +1414,7 @@ const tr: Dict = { | |||
| 1412 | "sessions.untitled": "Konu girilmemiş ders", | 1414 | "sessions.untitled": "Konu girilmemiş ders", |
| 1413 | "sessions.teacher": "Öğretmen", | 1415 | "sessions.teacher": "Öğretmen", |
| 1414 | "sessions.rollCall": "Yoklama", | 1416 | "sessions.rollCall": "Yoklama", |
| 1417 | + "sessions.emptyRoster": "Henüz kayıtlı öğrenci yok.", | ||
| 1415 | "sessions.startRequired": "Oturum başlangıç tarihi ve saati gerekli.", | 1418 | "sessions.startRequired": "Oturum başlangıç tarihi ve saati gerekli.", |
| 1416 | "sessions.endInvalid": "Bitiş için tarih ve saati birlikte gir ya da ikisini de boş bırak.", | 1419 | "sessions.endInvalid": "Bitiş için tarih ve saati birlikte gir ya da ikisini de boş bırak.", |
| 1417 | "attendance.title": "Yoklama raporu", | 1420 | "attendance.title": "Yoklama raporu", |
src/pages/course-detail-page.tsxmodified+21 -5
| @@ -82,6 +82,7 @@ function CourseDetailContent() { | |||
| 82 | const [description, setDescription] = createSignal(""); | 82 | const [description, setDescription] = createSignal(""); |
| 83 | const [termId, setTermId] = createSignal(""); | 83 | const [termId, setTermId] = createSignal(""); |
| 84 | const [showExamForm, setShowExamForm] = createSignal(false); | 84 | const [showExamForm, setShowExamForm] = createSignal(false); |
| 85 | + const [showSessionForm, setShowSessionForm] = createSignal(false); | ||
| 85 | const [showEnrollPanel, setShowEnrollPanel] = createSignal(false); | 86 | const [showEnrollPanel, setShowEnrollPanel] = createSignal(false); |
| 86 | const [openSections, setOpenSections] = createSignal({ exams: true, sessions: false, roster: false }); | 87 | const [openSections, setOpenSections] = createSignal({ exams: true, sessions: false, roster: false }); |
| 87 | const [enrollUserId, setEnrollUserId] = createSignal(""); | 88 | const [enrollUserId, setEnrollUserId] = createSignal(""); |
| @@ -375,10 +376,10 @@ function CourseDetailContent() { | |||
| 375 | onToggle={() => toggleSection("exams")} | 376 | onToggle={() => toggleSection("exams")} |
| 376 | title={t("courses.exams")} | 377 | title={t("courses.exams")} |
| 377 | description={`${examCount()} ${t("nav.exams")}`} | 378 | description={`${examCount()} ${t("nav.exams")}`} |
| 378 | - meta={<Badge variant="secondary" class="mono rounded-sm px-3 py-1">{examCount()}</Badge>} | 379 | + meta={<Badge variant="secondary" class="rounded-lg px-3 py-1"><span class="mono tabular-nums">{examCount()}</span><span class="ml-1">{t("nav.exams")}</span></Badge>} |
| 379 | actions={ | 380 | actions={ |
| 380 | <Show when={canManage()}> | 381 | <Show when={canManage()}> |
| 381 | - <Button type="button" variant="outline" size="sm" class="rounded-sm" onClick={() => setShowExamForm(true)}> | 382 | + <Button type="button" variant="outline" size="sm" class="rounded-lg" onClick={() => setShowExamForm(true)}> |
| 382 | <IconPlus class="h-4 w-4" /> | 383 | <IconPlus class="h-4 w-4" /> |
| 383 | {t("courses.addExam")} | 384 | {t("courses.addExam")} |
| 384 | </Button> | 385 | </Button> |
| @@ -432,8 +433,23 @@ function CourseDetailContent() { | |||
| 432 | onToggle={() => toggleSection("sessions")} | 433 | onToggle={() => toggleSection("sessions")} |
| 433 | title={t("sessions.title")} | 434 | title={t("sessions.title")} |
| 434 | description={t("sessions.subtitle")} | 435 | description={t("sessions.subtitle")} |
| 436 | + meta={<Badge variant="secondary" class="rounded-lg px-3 py-1">{t("sessions.title")}</Badge>} | ||
| 437 | + actions={ | ||
| 438 | + <Show when={canManage()}> | ||
| 439 | + <Button type="button" variant="outline" size="sm" class="rounded-lg" onClick={() => setShowSessionForm(true)}> | ||
| 440 | + <IconPlus class="h-4 w-4" /> | ||
| 441 | + {t("sessions.add")} | ||
| 442 | + </Button> | ||
| 443 | + </Show> | ||
| 444 | + } | ||
| 435 | > | 445 | > |
| 436 | - <CourseSessionsPanel courseId={id()} roster={roster() ?? []} canManage={canManage()} /> | 446 | + <CourseSessionsPanel |
| 447 | + courseId={id()} | ||
| 448 | + roster={roster() ?? []} | ||
| 449 | + canManage={canManage()} | ||
| 450 | + createOpen={showSessionForm()} | ||
| 451 | + onCreateOpenChange={setShowSessionForm} | ||
| 452 | + /> | ||
| 437 | </SectionDisclosure> | 453 | </SectionDisclosure> |
| 438 | 454 | ||
| 439 | <Show when={isTeacherPlus()}> | 455 | <Show when={isTeacherPlus()}> |
| @@ -442,10 +458,10 @@ function CourseDetailContent() { | |||
| 442 | onToggle={() => toggleSection("roster")} | 458 | onToggle={() => toggleSection("roster")} |
| 443 | title={t("courses.roster")} | 459 | title={t("courses.roster")} |
| 444 | description={t("courses.enroll")} | 460 | description={t("courses.enroll")} |
| 445 | - meta={<Badge variant="secondary" class="mono rounded-sm px-3 py-1">{rosterCount()}</Badge>} | 461 | + meta={<Badge variant="secondary" class="rounded-lg px-3 py-1"><span class="mono tabular-nums">{rosterCount()}</span><span class="ml-1">{t("courses.roster")}</span></Badge>} |
| 446 | actions={ | 462 | actions={ |
| 447 | <Show when={canManage()}> | 463 | <Show when={canManage()}> |
| 448 | - <Button type="button" variant="outline" size="sm" class="rounded-sm" onClick={() => setShowEnrollPanel(true)}> | 464 | + <Button type="button" variant="outline" size="sm" class="rounded-lg" onClick={() => setShowEnrollPanel(true)}> |
| 449 | <IconPlus class="h-4 w-4" /> | 465 | <IconPlus class="h-4 w-4" /> |
| 450 | {t("courses.enroll")} | 466 | {t("courses.enroll")} |
| 451 | </Button> | 467 | </Button> |