From 451977ff17bb4e9dbe537876e954ca30a0725efd Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Burak=20Boduro=C4=9Flu?= <80620802+burakboduroglu@users.noreply.github.com> Date: Sat, 19 Sep 2026 15:25:05 +0300 Subject: [PATCH] =?UTF-8?q?feat:=20=F0=9F=A7=AD=20a=20setup=20checklist=20?= =?UTF-8?q?for=20a=20new=20school's=20admin=20-=20SetupChecklistPanel=20on?= =?UTF-8?q?=20the=20admin=20board:=20academic=20year,=20teachers,=20=20=20?= =?UTF-8?q?students,=20classes=20and=20courses,=20each=20ticked=20by=20a?= =?UTF-8?q?=20real=20limit=3D1=20total=20and=20=20=20linking=20to=20where?= =?UTF-8?q?=20it=20is=20added;=20teacher/student=20counts=20use=20the=20ro?= =?UTF-8?q?le=20filter=20=20=20on=20/users/search=20-=20a=20failed=20read?= =?UTF-8?q?=20shows=20"could=20not=20check"=20instead=20of=20claiming=20ei?= =?UTF-8?q?ther=20way;=20=20=20steps=20of=20a=20switched-off=20module=20ar?= =?UTF-8?q?e=20left=20out=20-=20the=20panel=20hides=20once=20every=20step?= =?UTF-8?q?=20is=20done=20(checked=20live:=20the=20demo=20school=20=20=20i?= =?UTF-8?q?s=20fully=20set=20up,=20so=20its=20board=20shows=20none)=20-=20?= =?UTF-8?q?dashboard=20test=20for=20the=20checklist;=20dashboard=20rule=20?= =?UTF-8?q?records=20it?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .claude/skills/dashboard-design/SKILL.md | 4 + .../dashboard/setup-checklist-panel.tsx | 92 +++++++++++++++++++ src/i18n/messages.ts | 30 ++++++ src/pages/dashboard-page.test.tsx | 14 +++ src/pages/dashboard-page.tsx | 10 ++ 5 files changed, 150 insertions(+) create mode 100644 src/components/dashboard/setup-checklist-panel.tsx diff --git a/.claude/skills/dashboard-design/SKILL.md b/.claude/skills/dashboard-design/SKILL.md index c028518..7f0017e 100644 --- a/.claude/skills/dashboard-design/SKILL.md +++ b/.claude/skills/dashboard-design/SKILL.md @@ -64,3 +64,7 @@ Reference: `src/pages/dashboard-page.tsx`. The homepage is a **read-only status - **Parent homework:** `ChildHomeworkPanel` reads the selected child's `/homework/report/{user}` (overdue / due this week) with no links — a parent cannot open the course-scoped homework page. +- **Admin setup checklist:** `SetupChecklistPanel` ticks five steps (academic + year, teachers, students, classes, courses) by real `limit=1` totals, links + each to where it is added, shows a failed read as "could not check", and + hides itself once every step is done. Module-off steps are left out. diff --git a/src/components/dashboard/setup-checklist-panel.tsx b/src/components/dashboard/setup-checklist-panel.tsx new file mode 100644 index 0000000..7e68fc9 --- /dev/null +++ b/src/components/dashboard/setup-checklist-panel.tsx @@ -0,0 +1,92 @@ +import { For, Show } from "solid-js"; +import { Link } from "@tanstack/solid-router"; +import { createResource } from "@/lib/create-resource"; +import { getAcademicYears } from "@/api/academic-years"; +import { getClasses } from "@/api/classes"; +import { getCourses } from "@/api/courses"; +import { getUserSearch } from "@/api/users"; +import { IconCheck, IconChevronRight } from "@/components/ui/icons"; +import { cn } from "@/lib/cn"; +import type { MessageKey } from "@/i18n/messages"; +import { useT } from "@/stores/preferences-context"; + +type Step = { + id: string; + labelKey: MessageKey; + to: string; + module?: string; + /** How many exist now; the step is done at one or more. */ + count: () => Promise; +}; + +const STEPS: Step[] = [ + { id: "year", labelKey: "setup.academicYear", to: "/management/academic-years", count: async () => (await getAcademicYears({ limit: 1 })).total }, + { id: "teachers", labelKey: "setup.teachers", to: "/management/teachers", count: async () => (await getUserSearch("", undefined, "teacher", { limit: 1 })).total }, + { id: "students", labelKey: "setup.students", to: "/management/students", count: async () => (await getUserSearch("", undefined, "student", { limit: 1 })).total }, + { id: "classes", labelKey: "setup.classes", to: "/management/classes", module: "classes", count: async () => (await getClasses({ limit: 1 })).total }, + { id: "courses", labelKey: "setup.courses", to: "/courses", module: "courses", count: async () => (await getCourses({ limit: 1 })).total }, +]; + +/** + * ADM "school setup": the five things a new school needs before the rest of + * the app has anything to show, each ticked by a real count (at least one + * exists) and linking to where it is added. A read that fails leaves its step + * unknown rather than claiming it done or missing. Once every step is done + * the panel steps aside. + */ +export function SetupChecklistPanel(props: { moduleOn: (module: string) => boolean }) { + const t = useT(); + const [status] = createResource(async () => { + const steps = STEPS.filter((step) => !step.module || props.moduleOn(step.module)); + return Promise.all( + steps.map(async (step) => ({ step, done: await step.count().then((total) => total > 0).catch(() => null) })), + ); + }); + const doneCount = () => (status() ?? []).filter((row) => row.done === true).length; + const allDone = () => (status() ?? []).length > 0 && doneCount() === status()!.length; + + return ( + +
+
+

{t("setup.title")}

+ {t("setup.progress", { done: doneCount(), total: status()!.length })} +
+
    + + {(row) => ( +
  1. + + + + {t(row.step.labelKey)} + + {row.done === true ? t("setup.done") : row.done === false ? t("setup.todo") : t("setup.unknown")} + + + + +
  2. + )} +
    +
+
+
+ ); +} diff --git a/src/i18n/messages.ts b/src/i18n/messages.ts index 3c88954..93389c3 100644 --- a/src/i18n/messages.ts +++ b/src/i18n/messages.ts @@ -616,6 +616,16 @@ export type MessageKey = | "common.deleted" | "common.saved" | "common.loadAll" + | "setup.title" + | "setup.progress" + | "setup.academicYear" + | "setup.teachers" + | "setup.students" + | "setup.classes" + | "setup.courses" + | "setup.done" + | "setup.todo" + | "setup.unknown" | "homeworkQueue.title" | "homeworkQueue.toGradeTotal" | "homeworkQueue.missing" @@ -2789,6 +2799,16 @@ const en: Dict = { "common.deleted": "Deleted.", "common.saved": "Saved successfully.", "common.loadAll": "Load all", + "setup.title": "School setup", + "setup.progress": "{done} of {total} done", + "setup.academicYear": "Academic year", + "setup.teachers": "Teachers", + "setup.students": "Students", + "setup.classes": "Classes", + "setup.courses": "Courses", + "setup.done": "Done", + "setup.todo": "Not added yet", + "setup.unknown": "Could not check", "homeworkQueue.title": "Homework waiting on you", "homeworkQueue.toGradeTotal": "{count} to grade", "homeworkQueue.missing": "{count} not handed in", @@ -4964,6 +4984,16 @@ const tr: Dict = { "common.deleted": "Silindi.", "common.saved": "Başarıyla kaydedildi.", "common.loadAll": "Tümünü yükle", + "setup.title": "Okul kurulumu", + "setup.progress": "{total} adımdan {done} tamam", + "setup.academicYear": "Eğitim yılı", + "setup.teachers": "Öğretmenler", + "setup.students": "Öğrenciler", + "setup.classes": "Şubeler", + "setup.courses": "Dersler", + "setup.done": "Tamam", + "setup.todo": "Henüz eklenmedi", + "setup.unknown": "Kontrol edilemedi", "homeworkQueue.title": "Seni bekleyen ödevler", "homeworkQueue.toGradeTotal": "{count} notlanacak", "homeworkQueue.missing": "{count} teslim etmedi", diff --git a/src/pages/dashboard-page.test.tsx b/src/pages/dashboard-page.test.tsx index 30e2dbe..74a9da1 100644 --- a/src/pages/dashboard-page.test.tsx +++ b/src/pages/dashboard-page.test.tsx @@ -205,6 +205,9 @@ vi.mock("@/api/classes", () => ({ getClassesByUserId: async () => page([]), getClasses: async () => page([]), })); +vi.mock("@/api/academic-years", () => ({ + getAcademicYears: async () => page([{ id: "y-1", name: "2026-2027" }]), +})); vi.mock("@/api/users", () => ({ getUsers: async () => page([]), getUserSearch: async () => page([]), @@ -380,3 +383,14 @@ test("a teacher sees which of their homework is waiting on them, in plain senten expect(within(panel).getByText(/1 not handed in · 2 waiting for a grade|1 teslim etmedi · 2 not bekliyor/)).toBeTruthy(); expect(within(panel).getByText(/2 to grade|2 notlanacak/)).toBeTruthy(); }); + +test("an admin sees what school setup still needs, ticked by real counts", async () => { + renderDashboard("admin"); + + const panel = await screen.findByRole("region", { name: /School setup|Okul kurulumu/ }); + const step = (name: RegExp) => within(panel).getByText(name).closest("a")!; + expect(step(/Academic year|Eğitim yılı/).textContent).toMatch(/Done|Tamam/); + expect(step(/^(Courses|Dersler)$/).textContent).toMatch(/Done|Tamam/); + expect(step(/^(Teachers|Öğretmenler)$/).textContent).toMatch(/Not added yet|Henüz eklenmedi/); + expect(within(panel).getByText(/2 of 5 done|5 adımdan 2 tamam/)).toBeTruthy(); +}); diff --git a/src/pages/dashboard-page.tsx b/src/pages/dashboard-page.tsx index 6bb5024..54d3b84 100644 --- a/src/pages/dashboard-page.tsx +++ b/src/pages/dashboard-page.tsx @@ -33,6 +33,7 @@ import { CommandSearchField } from "@/components/dashboard/command-search-field" import { QuickLinkColumn, type QuickLinkRow } from "@/components/dashboard/quick-link-column"; import { ChildHomeworkPanel } from "@/components/dashboard/child-homework-panel"; import { HomeworkQueuePanel } from "@/components/dashboard/homework-queue-panel"; +import { SetupChecklistPanel } from "@/components/dashboard/setup-checklist-panel"; import { TodayLessonsPanel } from "@/components/dashboard/today-lessons-panel"; import { StatTile } from "@/components/dashboard/stat-tile"; import { @@ -750,6 +751,15 @@ function DashboardContent() { + {/* ADM setup: what a new school still needs, ticked by real counts; + it disappears once every step is done. Its own Suspense so the + board never waits on it. */} + + + + + + }>