forge
Explore
Log in

Don't you dare go Hollow

🧭 a setup checklist for a new school's admin

Browse files at this commit

451977ff17bb4e9dbe537876e954ca30a0725efdBurak BoduroğluParent: 6716a73
  • feat
    • 🧭 a setup checklist for a new school's admin
Show full message
feat: 🧭 a setup checklist for a new school's admin
- SetupChecklistPanel on the admin board: academic year, teachers,
  students, classes and courses, each ticked by a real limit=1 total and
  linking to where it is added; teacher/student counts use the role filter
  on /users/search
- a failed read shows "could not check" instead of claiming either way;
  steps of a switched-off module are left out
- the panel hides once every step is done (checked live: the demo school
  is fully set up, so its board shows none)
- dashboard test for the checklist; dashboard rule records it
.claude/skills/dashboard-design/SKILL.mdmodified+4 -0
@@ -64,3 +64,7 @@ Reference: `src/pages/dashboard-page.tsx`. The homepage is a **read-only status
64 - **Parent homework:** `ChildHomeworkPanel` reads the selected child's64 - **Parent homework:** `ChildHomeworkPanel` reads the selected child's
65 `/homework/report/{user}` (overdue / due this week) with no links — a parent65 `/homework/report/{user}` (overdue / due this week) with no links — a parent
66 cannot open the course-scoped homework page.66 cannot open the course-scoped homework page.
67+- **Admin setup checklist:** `SetupChecklistPanel` ticks five steps (academic
68+ year, teachers, students, classes, courses) by real `limit=1` totals, links
69+ each to where it is added, shows a failed read as "could not check", and
70+ hides itself once every step is done. Module-off steps are left out.
src/components/dashboard/setup-checklist-panel.tsxadded+92 -0
@@ -0,0 +1,92 @@
1+import { For, Show } from "solid-js";
2+import { Link } from "@tanstack/solid-router";
3+import { createResource } from "@/lib/create-resource";
4+import { getAcademicYears } from "@/api/academic-years";
5+import { getClasses } from "@/api/classes";
6+import { getCourses } from "@/api/courses";
7+import { getUserSearch } from "@/api/users";
8+import { IconCheck, IconChevronRight } from "@/components/ui/icons";
9+import { cn } from "@/lib/cn";
10+import type { MessageKey } from "@/i18n/messages";
11+import { useT } from "@/stores/preferences-context";
12+
13+type Step = {
14+ id: string;
15+ labelKey: MessageKey;
16+ to: string;
17+ module?: string;
18+ /** How many exist now; the step is done at one or more. */
19+ count: () => Promise<number>;
20+};
21+
22+const STEPS: Step[] = [
23+ { id: "year", labelKey: "setup.academicYear", to: "/management/academic-years", count: async () => (await getAcademicYears({ limit: 1 })).total },
24+ { id: "teachers", labelKey: "setup.teachers", to: "/management/teachers", count: async () => (await getUserSearch("", undefined, "teacher", { limit: 1 })).total },
25+ { id: "students", labelKey: "setup.students", to: "/management/students", count: async () => (await getUserSearch("", undefined, "student", { limit: 1 })).total },
26+ { id: "classes", labelKey: "setup.classes", to: "/management/classes", module: "classes", count: async () => (await getClasses({ limit: 1 })).total },
27+ { id: "courses", labelKey: "setup.courses", to: "/courses", module: "courses", count: async () => (await getCourses({ limit: 1 })).total },
28+];
29+
30+/**
31+ * ADM "school setup": the five things a new school needs before the rest of
32+ * the app has anything to show, each ticked by a real count (at least one
33+ * exists) and linking to where it is added. A read that fails leaves its step
34+ * unknown rather than claiming it done or missing. Once every step is done
35+ * the panel steps aside.
36+ */
37+export function SetupChecklistPanel(props: { moduleOn: (module: string) => boolean }) {
38+ const t = useT();
39+ const [status] = createResource(async () => {
40+ const steps = STEPS.filter((step) => !step.module || props.moduleOn(step.module));
41+ return Promise.all(
42+ steps.map(async (step) => ({ step, done: await step.count().then((total) => total > 0).catch(() => null) })),
43+ );
44+ });
45+ const doneCount = () => (status() ?? []).filter((row) => row.done === true).length;
46+ const allDone = () => (status() ?? []).length > 0 && doneCount() === status()!.length;
47+
48+ return (
49+ <Show when={status() && !allDone()}>
50+ <section class="flex flex-col gap-3 rounded-xl border border-border-line bg-surface-base p-4" aria-labelledby="setup-heading">
51+ <div class="flex items-baseline justify-between gap-2">
52+ <h2 id="setup-heading" class="text-base font-semibold tracking-tight text-text-strong">{t("setup.title")}</h2>
53+ <span class="text-xs font-medium text-muted-foreground">{t("setup.progress", { done: doneCount(), total: status()!.length })}</span>
54+ </div>
55+ <ol class="grid gap-2 sm:grid-cols-2 lg:grid-cols-5">
56+ <For each={status()}>
57+ {(row) => (
58+ <li>
59+ <Link
60+ to={row.step.to as never}
61+ class={cn(
62+ "flex h-full items-center gap-2.5 rounded-lg border px-3 py-2.5 text-sm outline-hidden transition-colors hover:bg-muted/40 focus-visible:ring-2 focus-visible:ring-ring",
63+ row.done ? "border-success/30 text-muted-foreground" : "border-border-line text-text-default",
64+ )}
65+ >
66+ <span
67+ class={cn(
68+ "flex h-5 w-5 shrink-0 items-center justify-center rounded-full border",
69+ row.done ? "border-success bg-success text-white" : "border-border-line",
70+ )}
71+ aria-hidden="true"
72+ >
73+ <Show when={row.done}>
74+ <IconCheck class="h-3 w-3" />
75+ </Show>
76+ </span>
77+ <span class="min-w-0 flex-1">
78+ <span class="block truncate font-medium">{t(row.step.labelKey)}</span>
79+ <span class="block text-xs text-muted-foreground">
80+ {row.done === true ? t("setup.done") : row.done === false ? t("setup.todo") : t("setup.unknown")}
81+ </span>
82+ </span>
83+ <IconChevronRight class="h-4 w-4 shrink-0 text-muted-foreground/60" />
84+ </Link>
85+ </li>
86+ )}
87+ </For>
88+ </ol>
89+ </section>
90+ </Show>
91+ );
92+}
src/i18n/messages.tsmodified+30 -0
@@ -616,6 +616,16 @@ export type MessageKey =
616 | "common.deleted"616 | "common.deleted"
617 | "common.saved"617 | "common.saved"
618 | "common.loadAll"618 | "common.loadAll"
619+ | "setup.title"
620+ | "setup.progress"
621+ | "setup.academicYear"
622+ | "setup.teachers"
623+ | "setup.students"
624+ | "setup.classes"
625+ | "setup.courses"
626+ | "setup.done"
627+ | "setup.todo"
628+ | "setup.unknown"
619 | "homeworkQueue.title"629 | "homeworkQueue.title"
620 | "homeworkQueue.toGradeTotal"630 | "homeworkQueue.toGradeTotal"
621 | "homeworkQueue.missing"631 | "homeworkQueue.missing"
@@ -2789,6 +2799,16 @@ const en: Dict = {
2789 "common.deleted": "Deleted.",2799 "common.deleted": "Deleted.",
2790 "common.saved": "Saved successfully.",2800 "common.saved": "Saved successfully.",
2791 "common.loadAll": "Load all",2801 "common.loadAll": "Load all",
2802+ "setup.title": "School setup",
2803+ "setup.progress": "{done} of {total} done",
2804+ "setup.academicYear": "Academic year",
2805+ "setup.teachers": "Teachers",
2806+ "setup.students": "Students",
2807+ "setup.classes": "Classes",
2808+ "setup.courses": "Courses",
2809+ "setup.done": "Done",
2810+ "setup.todo": "Not added yet",
2811+ "setup.unknown": "Could not check",
2792 "homeworkQueue.title": "Homework waiting on you",2812 "homeworkQueue.title": "Homework waiting on you",
2793 "homeworkQueue.toGradeTotal": "{count} to grade",2813 "homeworkQueue.toGradeTotal": "{count} to grade",
2794 "homeworkQueue.missing": "{count} not handed in",2814 "homeworkQueue.missing": "{count} not handed in",
@@ -4964,6 +4984,16 @@ const tr: Dict = {
4964 "common.deleted": "Silindi.",4984 "common.deleted": "Silindi.",
4965 "common.saved": "Başarıyla kaydedildi.",4985 "common.saved": "Başarıyla kaydedildi.",
4966 "common.loadAll": "Tümünü yükle",4986 "common.loadAll": "Tümünü yükle",
4987+ "setup.title": "Okul kurulumu",
4988+ "setup.progress": "{total} adımdan {done} tamam",
4989+ "setup.academicYear": "Eğitim yılı",
4990+ "setup.teachers": "Öğretmenler",
4991+ "setup.students": "Öğrenciler",
4992+ "setup.classes": "Şubeler",
4993+ "setup.courses": "Dersler",
4994+ "setup.done": "Tamam",
4995+ "setup.todo": "Henüz eklenmedi",
4996+ "setup.unknown": "Kontrol edilemedi",
4967 "homeworkQueue.title": "Seni bekleyen ödevler",4997 "homeworkQueue.title": "Seni bekleyen ödevler",
4968 "homeworkQueue.toGradeTotal": "{count} notlanacak",4998 "homeworkQueue.toGradeTotal": "{count} notlanacak",
4969 "homeworkQueue.missing": "{count} teslim etmedi",4999 "homeworkQueue.missing": "{count} teslim etmedi",
src/pages/dashboard-page.test.tsxmodified+14 -0
@@ -205,6 +205,9 @@ vi.mock("@/api/classes", () => ({
205 getClassesByUserId: async () => page([]),205 getClassesByUserId: async () => page([]),
206 getClasses: async () => page([]),206 getClasses: async () => page([]),
207 }));207 }));
208+vi.mock("@/api/academic-years", () => ({
209+ getAcademicYears: async () => page([{ id: "y-1", name: "2026-2027" }]),
210+}));
208 vi.mock("@/api/users", () => ({211 vi.mock("@/api/users", () => ({
209 getUsers: async () => page([]),212 getUsers: async () => page([]),
210 getUserSearch: async () => page([]),213 getUserSearch: async () => page([]),
@@ -380,3 +383,14 @@ test("a teacher sees which of their homework is waiting on them, in plain senten
380 expect(within(panel).getByText(/1 not handed in · 2 waiting for a grade|1 teslim etmedi · 2 not bekliyor/)).toBeTruthy();383 expect(within(panel).getByText(/1 not handed in · 2 waiting for a grade|1 teslim etmedi · 2 not bekliyor/)).toBeTruthy();
381 expect(within(panel).getByText(/2 to grade|2 notlanacak/)).toBeTruthy();384 expect(within(panel).getByText(/2 to grade|2 notlanacak/)).toBeTruthy();
382 });385 });
386+
387+test("an admin sees what school setup still needs, ticked by real counts", async () => {
388+ renderDashboard("admin");
389+
390+ const panel = await screen.findByRole("region", { name: /School setup|Okul kurulumu/ });
391+ const step = (name: RegExp) => within(panel).getByText(name).closest("a")!;
392+ expect(step(/Academic year|Eğitim yılı/).textContent).toMatch(/Done|Tamam/);
393+ expect(step(/^(Courses|Dersler)$/).textContent).toMatch(/Done|Tamam/);
394+ expect(step(/^(Teachers|Öğretmenler)$/).textContent).toMatch(/Not added yet|Henüz eklenmedi/);
395+ expect(within(panel).getByText(/2 of 5 done|5 adımdan 2 tamam/)).toBeTruthy();
396+});
src/pages/dashboard-page.tsxmodified+10 -0
@@ -33,6 +33,7 @@ import { CommandSearchField } from "@/components/dashboard/command-search-field"
33 import { QuickLinkColumn, type QuickLinkRow } from "@/components/dashboard/quick-link-column";33 import { QuickLinkColumn, type QuickLinkRow } from "@/components/dashboard/quick-link-column";
34 import { ChildHomeworkPanel } from "@/components/dashboard/child-homework-panel";34 import { ChildHomeworkPanel } from "@/components/dashboard/child-homework-panel";
35 import { HomeworkQueuePanel } from "@/components/dashboard/homework-queue-panel";35 import { HomeworkQueuePanel } from "@/components/dashboard/homework-queue-panel";
36+import { SetupChecklistPanel } from "@/components/dashboard/setup-checklist-panel";
36 import { TodayLessonsPanel } from "@/components/dashboard/today-lessons-panel";37 import { TodayLessonsPanel } from "@/components/dashboard/today-lessons-panel";
37 import { StatTile } from "@/components/dashboard/stat-tile";38 import { StatTile } from "@/components/dashboard/stat-tile";
38 import {39 import {
@@ -750,6 +751,15 @@ function DashboardContent() {
750 </div>751 </div>
751 </Show>752 </Show>
752 753
754+ {/* ADM setup: what a new school still needs, ticked by real counts;
755+ it disappears once every step is done. Its own Suspense so the
756+ board never waits on it. */}
757+ <Show when={isAdminHome() && !schoolModules.loading()}>
758+ <Suspense>
759+ <SetupChecklistPanel moduleOn={on} />
760+ </Suspense>
761+ </Show>
762+
753 <Suspense fallback={<PanelSkeleton />}>763 <Suspense fallback={<PanelSkeleton />}>
754 <section class="space-y-3" aria-labelledby="highlights-heading">764 <section class="space-y-3" aria-labelledby="highlights-heading">
755 <div class="flex flex-wrap items-center justify-between gap-2">765 <div class="flex flex-wrap items-center justify-between gap-2">