@@ -27,7 +36,7 @@ function ProfileContent() {
accent="mint"
eyebrow={t("nav.account")}
title={u().username}
- description={`${u().role} · ${u().id}`}
+ description={t(ROLE_KEY[u().role])}
/>
diff --git a/src/pages/settings-page.tsx b/src/pages/settings-page.tsx
index edd48bf..737e68b 100644
--- a/src/pages/settings-page.tsx
+++ b/src/pages/settings-page.tsx
@@ -6,10 +6,14 @@ import { formatApiError } from "@/api/client";
import { RouteGuard } from "@/components/layout/route-guard";
import { PageHeader } from "@/components/layout/page-header";
import { Alert } from "@/components/ui/alert";
+import { Badge } from "@/components/ui/badge";
import { Button } from "@/components/ui/button";
+import { ErrorAlert } from "@/components/ui/error-alert";
import { IconPlus, IconTrash } from "@/components/ui/icons";
import { Input } from "@/components/ui/input";
import { PageSpinner } from "@/components/ui/page-spinner";
+import { getAttendanceStatusMeta } from "@/lib/attendance-status";
+import { cn } from "@/lib/cn";
import { useT } from "@/stores/preferences-context";
const CORE_ATTENDANCE = new Set(["present", "absent", "late", "excused"]);
@@ -41,6 +45,15 @@ function SettingsContent() {
const [error, setError] = createSignal("");
const [saved, setSaved] = createSignal(false);
const [pending, setPending] = createSignal(false);
+ const [baseline, setBaseline] = createSignal("");
+ let savedTimer: number | undefined;
+
+ const snapshot = () =>
+ JSON.stringify({
+ exam_kinds: examKinds(),
+ attendance_statuses: attendanceStatuses(),
+ grade_bands: gradeBands(),
+ });
createEffect(() => {
const next = settings();
@@ -48,6 +61,19 @@ function SettingsContent() {
setExamKinds(next.exam_kinds.map((item) => ({ ...item })));
setAttendanceStatuses([...next.attendance_statuses]);
setGradeBands(next.grade_bands.map((item) => ({ ...item })));
+ setBaseline(
+ JSON.stringify({
+ exam_kinds: next.exam_kinds,
+ attendance_statuses: next.attendance_statuses,
+ grade_bands: next.grade_bands,
+ }),
+ );
+ });
+
+ const dirty = () => baseline() !== "" && snapshot() !== baseline();
+
+ createEffect(() => {
+ if (dirty() && saved()) setSaved(false);
});
const save = async () => {
@@ -61,7 +87,16 @@ function SettingsContent() {
grade_bands: gradeBands().map((band) => ({ min: Number(band.min), label: band.label.trim() })),
});
mutate(next);
+ setBaseline(
+ JSON.stringify({
+ exam_kinds: next.exam_kinds,
+ attendance_statuses: next.attendance_statuses,
+ grade_bands: next.grade_bands,
+ }),
+ );
setSaved(true);
+ if (savedTimer) window.clearTimeout(savedTimer);
+ savedTimer = window.setTimeout(() => setSaved(false), 3000);
await refetch();
} catch (err) {
setError(formatApiError(err));
@@ -78,144 +113,320 @@ function SettingsContent() {
/
{t("settings.title")}
-
+
+
+ {t("settings.unsaved")}
+
+
+ {t("settings.saved")}
+
+
+
+ }
+ />
- {error() && {error()}}
- {saved() && {t("settings.saved")}
}
+
+ {error()}
+
}>
- {formatApiError(settings.error)}
+ void refetch()} />
-
-
-
-
{t("settings.examKinds")}
-
{t("settings.examKindsHelp")}
-
-
-
- {(item, index) => (
-
- setExamKinds((rows) => rows.map((row, i) => (i === index() ? { ...row, name: e.currentTarget.value } : row)))}
- />
- setExamKinds((rows) => rows.map((row, i) => (i === index() ? { ...row, weight: Number(e.currentTarget.value) } : row)))}
- />
-
-
- )}
-
+
+
+
+
+
+
+
+
{t("settings.examKinds")}
+
{t("settings.examKindsHelp")}
+
+
+ {examKinds().length}
+
+
+
+
+
-
+
+
-
-
-
{t("settings.attendanceStatuses")}
-
{t("settings.attendanceHelp")}
-
-
-
- {(status, index) => (
-
-
setAttendanceStatuses((rows) => rows.map((row, i) => (i === index() ? e.currentTarget.value : row)))}
- />
- }
- >
-
- {t(CORE_ATTENDANCE_LABELS[status as keyof typeof CORE_ATTENDANCE_LABELS])}
+
+
+
+
+
{t("settings.attendanceStatuses")}
+
{t("settings.attendanceHelp")}
+
+
+ {attendanceStatuses().length}
+
+
+
+
+
+
+ {t("settings.status")}
+ {t("common.actions")}
+
+
0}
+ fallback={}
+ >
+
+ {(status, index) => {
+ const meta = () => getAttendanceStatusMeta(status);
+ return (
+
+
+ setAttendanceStatuses((rows) =>
+ rows.map((row, i) => (i === index() ? e.currentTarget.value : row)),
+ )
+ }
+ />
+ }
+ >
+
+
+ {t(CORE_ATTENDANCE_LABELS[status as keyof typeof CORE_ATTENDANCE_LABELS])}
+
+
+ {t("settings.locked")}
+
+
+
+
-
-
-
- )}
-
+ );
+ }}
+
+
-
+
+
-
-
-
{t("settings.gradeBands")}
-
{t("settings.gradeBandsHelp")}
-
-
-
- {(band, index) => (
-
- setGradeBands((rows) => rows.map((row, i) => (i === index() ? { ...row, min: Number(e.currentTarget.value) } : row)))}
- />
- setGradeBands((rows) => rows.map((row, i) => (i === index() ? { ...row, label: e.currentTarget.value } : row)))}
- />
-
-
- )}
-
+
+
+
+
+
{t("settings.gradeBands")}
+
{t("settings.gradeBandsHelp")}
+
+
+ {gradeBands().length}
+
+
+
+
+
+
+ {t("settings.min")}
+ {t("settings.label")}
+ {t("common.actions")}
+
+
0} fallback={}>
+
+ {(band, index) => (
+
+
+ setGradeBands((rows) =>
+ rows.map((row, i) =>
+ i === index() ? { ...row, min: Number(e.currentTarget.value) } : row,
+ ),
+ )
+ }
+ />
+
+ setGradeBands((rows) =>
+ rows.map((row, i) =>
+ i === index() ? { ...row, label: e.currentTarget.value } : row,
+ ),
+ )
+ }
+ />
+
+
+ )}
+
+
-
-
-
-
-
+
+
);
}
+
+function Metric(props: { label: string; value: number }) {
+ return (
+
+
{props.label}
+
{props.value}
+
+ );
+}
+
+function EmptyRows(props: { label: string }) {
+ return (
+
+ {props.label}
+
+ );
+}
diff --git a/src/pages/student-attendance-page.tsx b/src/pages/student-attendance-page.tsx
index 66e572a..e4e7574 100644
--- a/src/pages/student-attendance-page.tsx
+++ b/src/pages/student-attendance-page.tsx
@@ -1,12 +1,15 @@
import { Show, Suspense, createResource, createSignal } from "solid-js";
import { getUserAttendance } from "@/api/getUserAttendance";
import { formatApiError } from "@/api/client";
+import type { PersonRef } from "@/api/types";
import { AttendanceReportView } from "@/components/attendance/attendance-report-view";
import { RouteGuard } from "@/components/layout/route-guard";
import { PageHeader } from "@/components/layout/page-header";
import { UserSearchSelect } from "@/components/users/user-search-select";
import { Button } from "@/components/ui/button";
+import { ErrorAlert } from "@/components/ui/error-alert";
import { PageSpinner } from "@/components/ui/page-spinner";
+import { personLabel } from "@/lib/person";
import { useT } from "@/stores/preferences-context";
export default function StudentAttendancePage() {
@@ -20,8 +23,10 @@ export default function StudentAttendancePage() {
function StudentAttendanceContent() {
const t = useT();
const [userId, setUserId] = createSignal("");
+ const [selectedUser, setSelectedUser] = createSignal(null);
const [lookupId, setLookupId] = createSignal(null);
- const [report] = createResource(lookupId, async (id) => {
+ const [lookupLabel, setLookupLabel] = createSignal("");
+ const [report, { refetch }] = createResource(lookupId, async (id) => {
if (!id) return null;
return getUserAttendance(id);
});
@@ -42,6 +47,7 @@ function StudentAttendanceContent() {
const id = userId().trim();
if (!id) return;
setLookupId(id);
+ setLookupLabel(personLabel(selectedUser()) === "—" ? id : personLabel(selectedUser()));
}}
>
-
+
- {formatApiError(report.error)}
+ void refetch()} />
@@ -68,7 +75,7 @@ function StudentAttendanceContent() {
{(r) => (
- {t("attendance.forUser", { user: lookupId() ?? "" })}
+ {t("attendance.forUser", { user: lookupLabel() || lookupId() || "" })}
diff --git a/src/pages/student-marks-page.tsx b/src/pages/student-marks-page.tsx
index 21619ea..c92c08e 100644
--- a/src/pages/student-marks-page.tsx
+++ b/src/pages/student-marks-page.tsx
@@ -1,12 +1,15 @@
import { Show, Suspense, createResource, createSignal } from "solid-js";
import { getUserMarks } from "@/api/getUserMarks";
import { formatApiError } from "@/api/client";
+import type { PersonRef } from "@/api/types";
import { MarksReportView } from "@/components/marks/marks-report-view";
import { RouteGuard } from "@/components/layout/route-guard";
import { PageHeader } from "@/components/layout/page-header";
import { UserSearchSelect } from "@/components/users/user-search-select";
import { Button } from "@/components/ui/button";
+import { ErrorAlert } from "@/components/ui/error-alert";
import { PageSpinner } from "@/components/ui/page-spinner";
+import { personLabel } from "@/lib/person";
import { useT } from "@/stores/preferences-context";
export default function StudentMarksPage() {
@@ -20,8 +23,10 @@ export default function StudentMarksPage() {
function StudentMarksContent() {
const t = useT();
const [userId, setUserId] = createSignal("");
+ const [selectedUser, setSelectedUser] = createSignal(null);
const [lookupId, setLookupId] = createSignal(null);
- const [report] = createResource(lookupId, async (id) => {
+ const [lookupLabel, setLookupLabel] = createSignal("");
+ const [report, { refetch }] = createResource(lookupId, async (id) => {
if (!id) return null;
return getUserMarks(id);
});
@@ -47,6 +52,7 @@ function StudentMarksContent() {
const id = userId().trim();
if (!id) return;
setLookupId(id);
+ setLookupLabel(personLabel(selectedUser()) === "—" ? id : personLabel(selectedUser()));
}}
>
-
+
-
- {formatApiError(report.error)}
-
+ void refetch()} />
@@ -75,7 +80,7 @@ function StudentMarksContent() {
{(r) => (
- {t("marks.forUser", { user: lookupId() ?? "" })}
+ {t("marks.forUser", { user: lookupLabel() || lookupId() || "" })}
diff --git a/src/pages/terms-page.tsx b/src/pages/terms-page.tsx
index 6907199..703b910 100644
--- a/src/pages/terms-page.tsx
+++ b/src/pages/terms-page.tsx
@@ -1,5 +1,4 @@
-import { For, Show, Suspense, createSignal } from "solid-js";
-import { createResource } from "solid-js";
+import { For, Show, Suspense, createResource, createSignal } from "solid-js";
import { deleteTermById } from "@/api/deleteTermById";
import { getTerms } from "@/api/getTerms";
import { patchTermById } from "@/api/patchTermById";
@@ -11,11 +10,15 @@ import { PageHeader } from "@/components/layout/page-header";
import { Alert } from "@/components/ui/alert";
import { Button } from "@/components/ui/button";
import { ConfirmDialog } from "@/components/ui/confirm-dialog";
+import { DataTableEmpty, DataTableFrame, DataTableSkeleton } from "@/components/ui/data-table";
import { DatePicker } from "@/components/ui/date-picker";
-import { IconEdit, IconTrash } from "@/components/ui/icons";
+import { ErrorAlert } from "@/components/ui/error-alert";
+import { IconEdit, IconPlus, IconTrash } from "@/components/ui/icons";
import { Input } from "@/components/ui/input";
import { Label } from "@/components/ui/label";
-import { PageSpinner } from "@/components/ui/page-spinner";
+import { SidePanel } from "@/components/ui/side-panel";
+import { Table, TableBody, TableCell, TableHead, TableHeader, TableRow } from "@/components/ui/table";
+import { TableRowActions } from "@/components/ui/table-row-actions";
import { formatDateTime } from "@/lib/format";
import { usePreferences, useT } from "@/stores/preferences-context";
@@ -49,6 +52,7 @@ function TermsContent() {
const t = useT();
const { locale } = usePreferences();
const [terms, { refetch }] = createResource(() => getTerms());
+ const [panelOpen, setPanelOpen] = createSignal(false);
const [name, setName] = createSignal("");
const [starts, setStarts] = createSignal("");
const [ends, setEnds] = createSignal("");
@@ -62,6 +66,12 @@ function TermsContent() {
setStarts("");
setEnds("");
setEditing(null);
+ setError("");
+ };
+
+ const openCreate = () => {
+ resetForm();
+ setPanelOpen(true);
};
const startEdit = (term: Term) => {
@@ -69,6 +79,8 @@ function TermsContent() {
setStarts(dateInputFromMs(term.starts_at));
setEnds(dateInputFromMs(term.ends_at));
setEditing(term);
+ setError("");
+ setPanelOpen(true);
};
const save = async (e: SubmitEvent) => {
@@ -93,6 +105,7 @@ function TermsContent() {
await postTerm({ name: name().trim(), starts_at, ends_at });
}
resetForm();
+ setPanelOpen(false);
await refetch();
} catch (err) {
setError(formatApiError(err));
@@ -109,73 +122,110 @@ function TermsContent() {
/
{t("terms.title")}
-
+
+
+ {t("terms.create")}
+
+ }
+ />
- {error() &&
{error()}}
+
+ {error()}
+
- {editing() ? t("terms.edit") : t("terms.create")}
-