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. */} + + + + + + }>