🐛 sync frontend with person-based API responses
Browse files at this commit64327d66e40a3fefe2fe3d73c5dd9675d6b8eee4Parent: 3d9f9c4- fix
- 🐛 sync frontend with person-based API responses
10 changed files +103 -40
- src/api/types.ts +14 -12
- src/components/events/attendance-table.tsx +4 -3
- src/components/exams/answer-sheet-view.tsx +2 -1
- src/components/exams/exam-room-ws.tsx +3 -2
- src/components/exams/student-exam-room.tsx +4 -3
- src/lib/create-now.ts +15 -2
- src/lib/person.ts +20 -0
- src/pages/dashboard-page.tsx +15 -3
- src/pages/exam-detail-page.tsx +10 -6
- src/pages/live-monitor-page.tsx +16 -8
src/api/types.tsmodified+14 -12
| @@ -48,9 +48,9 @@ export type Event = { | |||
| 48 | export type Attendance = { | 48 | export type Attendance = { |
| 49 | id: string; | 49 | id: string; |
| 50 | event: string; | 50 | event: string; |
| 51 | - user: string; | 51 | + user: PersonRef; |
| 52 | status: AttendanceStatus; | 52 | status: AttendanceStatus; |
| 53 | - marked_by: string; | 53 | + marked_by: PersonRef; |
| 54 | }; | 54 | }; |
| 55 | 55 | ||
| 56 | export type Course = { | 56 | export type Course = { |
| @@ -84,9 +84,9 @@ export type Exam = { | |||
| 84 | export type ExamResult = { | 84 | export type ExamResult = { |
| 85 | id: string; | 85 | id: string; |
| 86 | exam: string; | 86 | exam: string; |
| 87 | - user: string; | 87 | + user: PersonRef; |
| 88 | mark: number; | 88 | mark: number; |
| 89 | - graded_by: string; | 89 | + graded_by: PersonRef; |
| 90 | }; | 90 | }; |
| 91 | 91 | ||
| 92 | export type ExamQuestion = { | 92 | export type ExamQuestion = { |
| @@ -102,10 +102,10 @@ export type ExamQuestion = { | |||
| 102 | export type ExamAttempt = { | 102 | export type ExamAttempt = { |
| 103 | id?: string; | 103 | id?: string; |
| 104 | exam?: string; | 104 | exam?: string; |
| 105 | - user?: string; | 105 | + user?: PersonRef; |
| 106 | status: AttemptStatus; | 106 | status: AttemptStatus; |
| 107 | deadline: number | null; | 107 | deadline: number | null; |
| 108 | - remaining_ms: number; | 108 | + remaining_ms: number | null; |
| 109 | mark: number | null; | 109 | mark: number | null; |
| 110 | answered: number; | 110 | answered: number; |
| 111 | question_count: number; | 111 | question_count: number; |
| @@ -170,33 +170,35 @@ export type GradedAnswer = { | |||
| 170 | }; | 170 | }; |
| 171 | 171 | ||
| 172 | export type StudentAnswerSheet = { | 172 | export type StudentAnswerSheet = { |
| 173 | - user: string; | 173 | + user: PersonRef; |
| 174 | answers: GradedAnswer[]; | 174 | answers: GradedAnswer[]; |
| 175 | auto_score: { earned: number; possible: number }; | 175 | auto_score: { earned: number; possible: number }; |
| 176 | }; | 176 | }; |
| 177 | 177 | ||
| 178 | export type LiveRosterEntry = { | 178 | export type LiveRosterEntry = { |
| 179 | - user: string; | 179 | + user: PersonRef; |
| 180 | - username: string; | ||
| 181 | - display_name: string | null; | ||
| 182 | status: AttemptStatus | "not_started"; | 180 | status: AttemptStatus | "not_started"; |
| 183 | deadline: number | null; | 181 | deadline: number | null; |
| 184 | - remaining_ms: number; | 182 | + remaining_ms: number | null; |
| 185 | mark: number | null; | 183 | mark: number | null; |
| 186 | answered: number; | 184 | answered: number; |
| 185 | + started_at?: number | null; | ||
| 186 | + finished_at?: number | null; | ||
| 187 | last_activity: number | null; | 187 | last_activity: number | null; |
| 188 | }; | 188 | }; |
| 189 | 189 | ||
| 190 | export type LiveMonitor = { | 190 | export type LiveMonitor = { |
| 191 | - exam: string; | 191 | + exam: Exam; |
| 192 | now: number; | 192 | now: number; |
| 193 | question_count: number; | 193 | question_count: number; |
| 194 | students: LiveRosterEntry[]; | 194 | students: LiveRosterEntry[]; |
| 195 | counts: { | 195 | counts: { |
| 196 | + enrolled?: number; | ||
| 196 | not_started: number; | 197 | not_started: number; |
| 197 | in_progress: number; | 198 | in_progress: number; |
| 198 | submitted: number; | 199 | submitted: number; |
| 199 | expired: number; | 200 | expired: number; |
| 201 | + graded?: number; | ||
| 200 | }; | 202 | }; |
| 201 | }; | 203 | }; |
| 202 | 204 | ||
src/components/events/attendance-table.tsxmodified+4 -3
| @@ -12,6 +12,7 @@ import { | |||
| 12 | TableRow, | 12 | TableRow, |
| 13 | } from "@/components/ui/table"; | 13 | } from "@/components/ui/table"; |
| 14 | import { Badge } from "@/components/ui/badge"; | 14 | import { Badge } from "@/components/ui/badge"; |
| 15 | +import { personId, personLabel } from "@/lib/person"; | ||
| 15 | import { useT } from "@/stores/preferences-context"; | 16 | import { useT } from "@/stores/preferences-context"; |
| 16 | 17 | ||
| 17 | export function AttendanceTable(props: { | 18 | export function AttendanceTable(props: { |
| @@ -49,13 +50,13 @@ export function AttendanceTable(props: { | |||
| 49 | <For each={props.rows}> | 50 | <For each={props.rows}> |
| 50 | {(row) => ( | 51 | {(row) => ( |
| 51 | <TableRow class="h-12"> | 52 | <TableRow class="h-12"> |
| 52 | - <TableCell class="font-mono text-xs">{row.user}</TableCell> | 53 | + <TableCell class="font-medium">{personLabel(row.user)}</TableCell> |
| 53 | <TableCell> | 54 | <TableCell> |
| 54 | <Badge variant="secondary" class="capitalize"> | 55 | <Badge variant="secondary" class="capitalize"> |
| 55 | {row.status} | 56 | {row.status} |
| 56 | </Badge> | 57 | </Badge> |
| 57 | </TableCell> | 58 | </TableCell> |
| 58 | - <TableCell class="font-mono text-xs">{row.marked_by}</TableCell> | 59 | + <TableCell class="text-sm text-muted-foreground">{personLabel(row.marked_by)}</TableCell> |
| 59 | <Show when={props.canRemove && props.onRemove}> | 60 | <Show when={props.canRemove && props.onRemove}> |
| 60 | <TableCell> | 61 | <TableCell> |
| 61 | <Button | 62 | <Button |
| @@ -63,7 +64,7 @@ export function AttendanceTable(props: { | |||
| 63 | variant="ghost" | 64 | variant="ghost" |
| 64 | size="sm" | 65 | size="sm" |
| 65 | class="text-destructive hover:bg-destructive/10 hover:text-destructive" | 66 | class="text-destructive hover:bg-destructive/10 hover:text-destructive" |
| 66 | - onClick={() => setTargetUser(row.user)} | 67 | + onClick={() => setTargetUser(personId(row.user))} |
| 67 | > | 68 | > |
| 68 | <IconTrash class="h-4 w-4" /> | 69 | <IconTrash class="h-4 w-4" /> |
| 69 | {t("common.remove")} | 70 | {t("common.remove")} |
src/components/exams/answer-sheet-view.tsxmodified+2 -1
| @@ -2,6 +2,7 @@ import { For, Show, Suspense, createResource } from "solid-js"; | |||
| 2 | import { getStudentAnswers } from "@/api/getStudentAnswers"; | 2 | import { getStudentAnswers } from "@/api/getStudentAnswers"; |
| 3 | import { Badge } from "@/components/ui/badge"; | 3 | import { Badge } from "@/components/ui/badge"; |
| 4 | import { PageSpinner } from "@/components/ui/page-spinner"; | 4 | import { PageSpinner } from "@/components/ui/page-spinner"; |
| 5 | +import { personLabelWithId } from "@/lib/person"; | ||
| 5 | import { useT } from "@/stores/preferences-context"; | 6 | import { useT } from "@/stores/preferences-context"; |
| 6 | 7 | ||
| 7 | export function AnswerSheetView(props: { examId: string; userId: string }) { | 8 | export function AnswerSheetView(props: { examId: string; userId: string }) { |
| @@ -17,7 +18,7 @@ export function AnswerSheetView(props: { examId: string; userId: string }) { | |||
| 17 | {(s) => ( | 18 | {(s) => ( |
| 18 | <div class="space-y-4"> | 19 | <div class="space-y-4"> |
| 19 | <div class="flex flex-wrap items-center justify-between gap-2 rounded-md border bg-muted/30 px-4 py-3"> | 20 | <div class="flex flex-wrap items-center justify-between gap-2 rounded-md border bg-muted/30 px-4 py-3"> |
| 20 | - <p class="text-sm font-medium">{props.userId}</p> | 21 | + <p class="text-sm font-medium">{personLabelWithId(s().user)}</p> |
| 21 | <Badge variant="secondary"> | 22 | <Badge variant="secondary"> |
| 22 | {t("exams.autoScore")}: {s().auto_score.earned}/{s().auto_score.possible} | 23 | {t("exams.autoScore")}: {s().auto_score.earned}/{s().auto_score.possible} |
| 23 | </Badge> | 24 | </Badge> |
src/components/exams/exam-room-ws.tsxmodified+3 -2
| @@ -223,9 +223,10 @@ export function ExamRoomWS(props: { exam: Exam }) { | |||
| 223 | 223 | ||
| 224 | createEffect(() => { | 224 | createEffect(() => { |
| 225 | const current = attempt(); | 225 | const current = attempt(); |
| 226 | - if (!current || current.status !== "in_progress" || current.remaining_ms <= 0) return; | 226 | + const remaining = current?.remaining_ms ?? 0; |
| 227 | + if (!current || current.status !== "in_progress" || remaining <= 0) return; | ||
| 227 | const startedAt = Date.now(); | 228 | const startedAt = Date.now(); |
| 228 | - const initial = current.remaining_ms; | 229 | + const initial = remaining; |
| 229 | const timer = window.setInterval(() => { | 230 | const timer = window.setInterval(() => { |
| 230 | setRemainingMs(Math.max(0, initial - (Date.now() - startedAt))); | 231 | setRemainingMs(Math.max(0, initial - (Date.now() - startedAt))); |
| 231 | }, 1000); | 232 | }, 1000); |
src/components/exams/student-exam-room.tsxmodified+4 -3
| @@ -53,10 +53,11 @@ export function StudentExamRoom(props: { exam: Exam; compact?: boolean }) { | |||
| 53 | 53 | ||
| 54 | createEffect(() => { | 54 | createEffect(() => { |
| 55 | const current = attempt(); | 55 | const current = attempt(); |
| 56 | - setRemainingMs(current?.remaining_ms ?? 0); | 56 | + const remaining = current?.remaining_ms ?? 0; |
| 57 | - if (!current || current.status !== "in_progress" || current.remaining_ms <= 0) return; | 57 | + setRemainingMs(remaining); |
| 58 | + if (!current || current.status !== "in_progress" || remaining <= 0) return; | ||
| 58 | const startedAt = Date.now(); | 59 | const startedAt = Date.now(); |
| 59 | - const initial = current.remaining_ms; | 60 | + const initial = remaining; |
| 60 | const timer = window.setInterval(() => { | 61 | const timer = window.setInterval(() => { |
| 61 | setRemainingMs(Math.max(0, initial - (Date.now() - startedAt))); | 62 | setRemainingMs(Math.max(0, initial - (Date.now() - startedAt))); |
| 62 | }, 1000); | 63 | }, 1000); |
src/lib/create-now.tsmodified+15 -2
| @@ -1,8 +1,21 @@ | |||
| 1 | import { createSignal, onCleanup } from "solid-js"; | 1 | import { createSignal, onCleanup } from "solid-js"; |
| 2 | +import { getTime } from "@/api/getTime"; | ||
| 2 | 3 | ||
| 3 | export function createNow(intervalMs = 1000) { | 4 | export function createNow(intervalMs = 1000) { |
| 4 | - const [now, setNow] = createSignal(Date.now()); | 5 | + let offset = 0; |
| 5 | - const interval = setInterval(() => setNow(Date.now()), intervalMs); | 6 | + const serverNow = () => Date.now() + offset; |
| 7 | + const [now, setNow] = createSignal(serverNow()); | ||
| 8 | + | ||
| 9 | + void getTime() | ||
| 10 | + .then((data) => { | ||
| 11 | + offset = data.now - Date.now(); | ||
| 12 | + setNow(serverNow()); | ||
| 13 | + }) | ||
| 14 | + .catch(() => { | ||
| 15 | + offset = 0; | ||
| 16 | + }); | ||
| 17 | + | ||
| 18 | + const interval = setInterval(() => setNow(serverNow()), intervalMs); | ||
| 6 | onCleanup(() => clearInterval(interval)); | 19 | onCleanup(() => clearInterval(interval)); |
| 7 | return now; | 20 | return now; |
| 8 | } | 21 | } |
src/lib/person.tsadded+20 -0
| @@ -0,0 +1,20 @@ | |||
| 1 | +import type { PersonRef } from "@/api/types"; | ||
| 2 | + | ||
| 3 | +export type PersonLike = PersonRef | string | null | undefined; | ||
| 4 | + | ||
| 5 | +export function personId(person: PersonLike): string { | ||
| 6 | + if (!person) return ""; | ||
| 7 | + return typeof person === "string" ? person : person.id; | ||
| 8 | +} | ||
| 9 | + | ||
| 10 | +export function personLabel(person: PersonLike): string { | ||
| 11 | + if (!person) return "—"; | ||
| 12 | + if (typeof person === "string") return person; | ||
| 13 | + return person.display_name || person.username || person.id; | ||
| 14 | +} | ||
| 15 | + | ||
| 16 | +export function personLabelWithId(person: PersonLike): string { | ||
| 17 | + if (!person) return "—"; | ||
| 18 | + if (typeof person === "string") return person; | ||
| 19 | + return `${personLabel(person)} - ${person.id}`; | ||
| 20 | +} | ||
src/pages/dashboard-page.tsxmodified+15 -3
| @@ -2,6 +2,7 @@ import { Link } from "@tanstack/solid-router"; | |||
| 2 | import { For, Show, Suspense, createMemo, createResource } from "solid-js"; | 2 | import { For, Show, Suspense, createMemo, createResource } from "solid-js"; |
| 3 | import { getEvents } from "@/api/getEvents"; | 3 | import { getEvents } from "@/api/getEvents"; |
| 4 | import { getExams } from "@/api/getExams"; | 4 | import { getExams } from "@/api/getExams"; |
| 5 | +import { getMyCourses } from "@/api/getMyCourses"; | ||
| 5 | import { getMyMarks } from "@/api/getMyMarks"; | 6 | import { getMyMarks } from "@/api/getMyMarks"; |
| 6 | import { getNotes } from "@/api/getNotes"; | 7 | import { getNotes } from "@/api/getNotes"; |
| 7 | import { formatApiError } from "@/api/client"; | 8 | import { formatApiError } from "@/api/client"; |
| @@ -45,21 +46,32 @@ function DashboardContent() { | |||
| 45 | const [notes] = createResource(() => getNotes()); | 46 | const [notes] = createResource(() => getNotes()); |
| 46 | const [events] = createResource(() => getEvents()); | 47 | const [events] = createResource(() => getEvents()); |
| 47 | const [exams] = createResource(() => getExams()); | 48 | const [exams] = createResource(() => getExams()); |
| 49 | + const [myCourses] = createResource( | ||
| 50 | + () => (user().role === "student" ? true : null), | ||
| 51 | + async (enabled) => (enabled ? getMyCourses() : []), | ||
| 52 | + ); | ||
| 48 | const [marks] = createResource(() => getMyMarks()); | 53 | const [marks] = createResource(() => getMyMarks()); |
| 49 | 54 | ||
| 50 | const resourceError = createMemo(() => { | 55 | const resourceError = createMemo(() => { |
| 51 | - const e = notes.error || events.error || exams.error || marks.error; | 56 | + const e = notes.error || events.error || exams.error || myCourses.error || marks.error; |
| 52 | return e ? formatApiError(e, locale()) : null; | 57 | return e ? formatApiError(e, locale()) : null; |
| 53 | }); | 58 | }); |
| 54 | 59 | ||
| 60 | + const visibleExams = createMemo(() => { | ||
| 61 | + const all = exams() ?? []; | ||
| 62 | + if (user().role !== "student") return all; | ||
| 63 | + const allowed = new Set((myCourses() ?? []).map((course) => course.id)); | ||
| 64 | + return all.filter((exam) => allowed.has(exam.course)); | ||
| 65 | + }); | ||
| 66 | + | ||
| 55 | const noteCount = createMemo(() => notes()?.length ?? 0); | 67 | const noteCount = createMemo(() => notes()?.length ?? 0); |
| 56 | const eventCount = createMemo(() => events()?.length ?? 0); | 68 | const eventCount = createMemo(() => events()?.length ?? 0); |
| 57 | - const examCount = createMemo(() => exams()?.length ?? 0); | 69 | + const examCount = createMemo(() => visibleExams().length); |
| 58 | const overallAvg = createMemo(() => marks()?.overall_average ?? null); | 70 | const overallAvg = createMemo(() => marks()?.overall_average ?? null); |
| 59 | 71 | ||
| 60 | const previewNotes = createMemo(() => (notes() ?? []).slice(0, PREVIEW_LIMIT)); | 72 | const previewNotes = createMemo(() => (notes() ?? []).slice(0, PREVIEW_LIMIT)); |
| 61 | const previewEvents = createMemo(() => (events() ?? []).slice(0, PREVIEW_LIMIT)); | 73 | const previewEvents = createMemo(() => (events() ?? []).slice(0, PREVIEW_LIMIT)); |
| 62 | - const previewExams = createMemo(() => (exams() ?? []).slice(0, PREVIEW_LIMIT)); | 74 | + const previewExams = createMemo(() => visibleExams().slice(0, PREVIEW_LIMIT)); |
| 63 | 75 | ||
| 64 | return ( | 76 | return ( |
| 65 | <div class="space-y-5"> | 77 | <div class="space-y-5"> |
src/pages/exam-detail-page.tsxmodified+10 -6
| @@ -36,6 +36,7 @@ import { hasMinRole } from "@/lib/roles"; | |||
| 36 | import { createNow } from "@/lib/create-now"; | 36 | import { createNow } from "@/lib/create-now"; |
| 37 | import { examKindLabel } from "@/lib/exam-labels"; | 37 | import { examKindLabel } from "@/lib/exam-labels"; |
| 38 | import { examDurationMs, formatDateTime, formatDurationMinutes } from "@/lib/format"; | 38 | import { examDurationMs, formatDateTime, formatDurationMinutes } from "@/lib/format"; |
| 39 | +import { personId, personLabel, personLabelWithId } from "@/lib/person"; | ||
| 39 | import { cn } from "@/lib/cn"; | 40 | import { cn } from "@/lib/cn"; |
| 40 | import { useAuth } from "@/stores/auth-context"; | 41 | import { useAuth } from "@/stores/auth-context"; |
| 41 | import { usePreferences, useT } from "@/stores/preferences-context"; | 42 | import { usePreferences, useT } from "@/stores/preferences-context"; |
| @@ -142,12 +143,12 @@ function ExamDetailContent() { | |||
| 142 | }; | 143 | }; |
| 143 | const isScheduled = () => exam()?.mode === "sync" || exam()?.mode === "async"; | 144 | const isScheduled = () => exam()?.mode === "sync" || exam()?.mode === "async"; |
| 144 | const gradeStudents = () => { | 145 | const gradeStudents = () => { |
| 145 | - const graded = new Set((results() ?? []).map((row) => row.user)); | 146 | + const graded = new Set((results() ?? []).map((row) => personId(row.user))); |
| 146 | return (roster() ?? []) | 147 | return (roster() ?? []) |
| 147 | .filter((row) => !graded.has(row.user.id)) | 148 | .filter((row) => !graded.has(row.user.id)) |
| 148 | .map((row) => ({ | 149 | .map((row) => ({ |
| 149 | id: row.user.id, | 150 | id: row.user.id, |
| 150 | - label: `${row.user.display_name || row.user.username} · ${row.user.id}`, | 151 | + label: personLabelWithId(row.user), |
| 151 | })); | 152 | })); |
| 152 | }; | 153 | }; |
| 153 | 154 | ||
| @@ -410,18 +411,21 @@ function ExamDetailContent() { | |||
| 410 | <For each={results() ?? []}> | 411 | <For each={results() ?? []}> |
| 411 | {(row) => ( | 412 | {(row) => ( |
| 412 | <TableRow class="h-12"> | 413 | <TableRow class="h-12"> |
| 413 | - <TableCell class="font-mono text-xs">{row.user}</TableCell> | 414 | + <TableCell class="font-medium">{personLabel(row.user)}</TableCell> |
| 414 | <TableCell> | 415 | <TableCell> |
| 415 | <ExamResultBadge mark={row.mark} /> | 416 | <ExamResultBadge mark={row.mark} /> |
| 416 | </TableCell> | 417 | </TableCell> |
| 417 | - <TableCell class="font-mono text-xs">{row.graded_by}</TableCell> | 418 | + <TableCell class="text-sm text-muted-foreground">{personLabel(row.graded_by)}</TableCell> |
| 418 | <TableCell> | 419 | <TableCell> |
| 419 | <Button | 420 | <Button |
| 420 | type="button" | 421 | type="button" |
| 421 | variant="ghost" | 422 | variant="ghost" |
| 422 | size="sm" | 423 | size="sm" |
| 423 | class="rounded-md" | 424 | class="rounded-md" |
| 424 | - onClick={() => setSheetUserId(sheetUserId() === row.user ? null : row.user)} | 425 | + onClick={() => { |
| 426 | + const rowUserId = personId(row.user); | ||
| 427 | + setSheetUserId(sheetUserId() === rowUserId ? null : rowUserId); | ||
| 428 | + }} | ||
| 425 | > | 429 | > |
| 426 | <IconEye class="h-4 w-4" /> | 430 | <IconEye class="h-4 w-4" /> |
| 427 | </Button> | 431 | </Button> |
| @@ -433,7 +437,7 @@ function ExamDetailContent() { | |||
| 433 | variant="ghost" | 437 | variant="ghost" |
| 434 | size="sm" | 438 | size="sm" |
| 435 | class="text-destructive hover:bg-destructive/10 hover:text-destructive" | 439 | class="text-destructive hover:bg-destructive/10 hover:text-destructive" |
| 436 | - onClick={() => setRemoveUserId(row.user)} | 440 | + onClick={() => setRemoveUserId(personId(row.user))} |
| 437 | > | 441 | > |
| 438 | <IconTrash class="h-4 w-4" /> | 442 | <IconTrash class="h-4 w-4" /> |
| 439 | {t("common.remove")} | 443 | {t("common.remove")} |
src/pages/live-monitor-page.tsxmodified+16 -8
| @@ -71,6 +71,18 @@ function liveRosterName(entry: LiveRosterEntry, fallback: string): string { | |||
| 71 | ); | 71 | ); |
| 72 | } | 72 | } |
| 73 | 73 | ||
| 74 | +function remainingMinutesLabel(entry: LiveRosterEntry): string { | ||
| 75 | + const remaining = entry.remaining_ms ?? 0; | ||
| 76 | + if (entry.status !== "in_progress") return "—"; | ||
| 77 | + if (remaining > 0) return `${Math.ceil(remaining / 60000)}dk`; | ||
| 78 | + return "<1dk"; | ||
| 79 | +} | ||
| 80 | + | ||
| 81 | +function isLowRemaining(entry: LiveRosterEntry): boolean { | ||
| 82 | + const remaining = entry.remaining_ms ?? 0; | ||
| 83 | + return entry.status === "in_progress" && remaining <= 5 * 60 * 1000; | ||
| 84 | +} | ||
| 85 | + | ||
| 74 | function LiveMonitorContent() { | 86 | function LiveMonitorContent() { |
| 75 | const params = useParams({ from: "/exams/$id/live" }); | 87 | const params = useParams({ from: "/exams/$id/live" }); |
| 76 | const t = useT(); | 88 | const t = useT(); |
| @@ -106,9 +118,9 @@ function LiveMonitorContent() { | |||
| 106 | const e = exam(); | 118 | const e = exam(); |
| 107 | if (!eid || !e) return; | 119 | if (!eid || !e) return; |
| 108 | void fetchSnapshot(); | 120 | void fetchSnapshot(); |
| 109 | - if (e.ends_at != null && e.ends_at < Date.now()) return; | 121 | + if (e.ends_at != null && e.ends_at < now()) return; |
| 110 | const interval = setInterval(() => { | 122 | const interval = setInterval(() => { |
| 111 | - if (e.ends_at != null && e.ends_at < Date.now()) { | 123 | + if (e.ends_at != null && e.ends_at < now()) { |
| 112 | clearInterval(interval); | 124 | clearInterval(interval); |
| 113 | void fetchSnapshot(); | 125 | void fetchSnapshot(); |
| 114 | return; | 126 | return; |
| @@ -263,12 +275,8 @@ function LiveMonitorContent() { | |||
| 263 | </div> | 275 | </div> |
| 264 | </TableCell> | 276 | </TableCell> |
| 265 | <TableCell class="tabular-nums text-center"> | 277 | <TableCell class="tabular-nums text-center"> |
| 266 | - <span class={entry.status === "in_progress" && entry.remaining_ms <= 5 * 60 * 1000 ? "rounded-full bg-amber-500/10 px-2 py-1 text-amber-700 dark:text-amber-300" : ""}> | 278 | + <span class={isLowRemaining(entry) ? "rounded-full bg-amber-500/10 px-2 py-1 text-amber-700 dark:text-amber-300" : ""}> |
| 267 | - {entry.status === "in_progress" && entry.remaining_ms > 0 | 279 | + {remainingMinutesLabel(entry)} |
| 268 | - ? `${Math.ceil(entry.remaining_ms / 60000)}dk` | ||
| 269 | - : entry.status === "in_progress" && entry.remaining_ms <= 0 | ||
| 270 | - ? `<1dk` | ||
| 271 | - : "—"} | ||
| 272 | </span> | 280 | </span> |
| 273 | </TableCell> | 281 | </TableCell> |
| 274 | <TableCell class="text-center text-xs"> | 282 | <TableCell class="text-center text-xs"> |