forge
Explore
Log in

Don't you dare go Hollow

🧭 builder console, license modules page, and full role nav coverage

Browse files at this commit

b77456ac760b16e7e6b8b83986e45e486ff33533Burak BoduroğluParent: 2bb150c
  • feat
    • 🧭 builder console, license modules page, and full role nav coverage
Show full message
feat: 🧭 builder console, license modules page, and full role nav coverage
- builder (operator) surface: /builder/login, school list with create,
  suspend/activate and delete, school detail with rename/status, module
  switchboard per module and per package, admin password reset and enter
- builder and schools API domains with vitest coverage; builder session
  lives in its own BuilderProvider/BuilderGuard, apart from school auth
- /management/modules: read-only license view for admins over GET /modules
  and the catalog; dashboard modules quick-link shows real package counts
- 409 module dependency errors and builder conflicts render localized text
- sidebar exposes every backed page per role and module: courses, terms,
  events, notes, questions, whiteboards, appointments, meals, messages,
  student marks/pomodoro lookups, work log for admin
- parent Absence / Exam results / Study plan open /students/{tab} instead
  of coming-soon; study tab reads GET /pomodoro/{user}, one child auto-opens
- work log page no longer excludes admin, matching the backend and role matrix
- role matrix documents the builder surface and new parent routes
docs/auth/role-scope-matrix.mdmodified+24 -2
@@ -29,6 +29,25 @@
29 | Settings `/management/settings` | ❌ | ❌ | βœ… | βœ… |29 | Settings `/management/settings` | ❌ | ❌ | βœ… | βœ… |
30 | Terms `/management/terms` | ❌ | ❌ | βœ… | βœ… |30 | Terms `/management/terms` | ❌ | ❌ | βœ… | βœ… |
31 | User management `/admin/users` | ❌ | ❌ | ❌ | βœ… |31 | User management `/admin/users` | ❌ | ❌ | ❌ | βœ… |
32+| License & modules `/management/modules` (read-only) | ❌ | ❌ | ❌ | βœ… |
33+| Student pomodoro lookup `/management/pomodoros` | ❌ | βœ… | βœ… | βœ… |
34+
35+Parent pages: `/students` (progress report) plus `/students/attendance`,
36+`/students/exams`, `/students/study` β€” the same page opening a linked child on
37+that tab. Study reads `GET /pomodoro/{user}` (parent link), shown only when the
38+school has the `pomodoro` module.
39+
40+## Builder (Operator) Surface
41+
42+Not a school role. A builder session (`builder.` cookie) is 401 on every school
43+route and a school session is 401 here, so these pages carry their own
44+`BuilderProvider`/`BuilderGuard` instead of `RouteGuard`.
45+
46+| Page | Purpose |
47+|---|---|
48+| `/builder/login` | Operator sign-in (linked from the school login footer) |
49+| `/builder` | School list: create (with first admin + module set), suspend/activate, delete |
50+| `/builder/schools/:slug` | Rename/status, module switchboard (per module + per package), admin password reset, enter as admin |
32 51
33 ## Primary Navigation per Role52 ## Primary Navigation per Role
34 53
@@ -44,8 +63,11 @@
44 | Meals `/meals` | ❌ | ❌ | ❌ | ❌ | βœ… |63 | Meals `/meals` | ❌ | ❌ | ❌ | ❌ | βœ… |
45 64
46 Primary destinations stay compact. Every role-valid list page is also exposed65 Primary destinations stay compact. Every role-valid list page is also exposed
47-in the grouped sidebar/mobile drawer; Education and Community are collapsible.66+in the grouped sidebar/mobile drawer, gated by the school's modules:
48-Appointments is directly available there for every role. Detail pages remain67+courses, notes, questions, events, meals, appointments and messages for every
68+role the backend serves them to; terms, student marks/pomodoro lookups and the
69+work log for staff; license modules for admin. Appointments is directly
70+available there for every role. Detail pages remain
49 reachable from their parent lists, and Guide remains in the account menu.71 reachable from their parent lists, and Guide remains in the account menu.
50 72
51 ## Dashboard Scope per Role73 ## Dashboard Scope per Role
src/api/__tests__/builder/builder.test.tsadded+44 -0
@@ -0,0 +1,44 @@
1+import { afterEach, describe, expect, it, vi } from "vitest";
2+import { getBuilderMe } from "../../builder";
3+import { postBuilderLogin } from "../../builder";
4+import { postBuilderLogout } from "../../builder";
5+import { lastFetchCall, mockFetch204, mockFetchSuccess } from "../helpers/mock-fetch";
6+
7+describe("builder API", () => {
8+ afterEach(() => {
9+ vi.restoreAllMocks();
10+ });
11+
12+ it("postBuilderLogin posts credentials to /builder/login", async () => {
13+ const builder = { id: "b1", username: "operator" };
14+ mockFetchSuccess(builder);
15+
16+ const result = await postBuilderLogin({ username: "operator", password: "correct horse" });
17+ expect(result).toEqual(builder);
18+
19+ const [url, init] = lastFetchCall();
20+ expect(url).toBe("/api/builder/login");
21+ expect(init?.method).toBe("POST");
22+ expect(init?.body).toBe(JSON.stringify({ username: "operator", password: "correct horse" }));
23+ });
24+
25+ it("postBuilderLogout posts to /builder/logout", async () => {
26+ mockFetch204();
27+
28+ await postBuilderLogout();
29+
30+ const [url, init] = lastFetchCall();
31+ expect(url).toBe("/api/builder/logout");
32+ expect(init?.method).toBe("POST");
33+ });
34+
35+ it("getBuilderMe reads /builder/me", async () => {
36+ mockFetchSuccess({ id: "b1", username: "operator" });
37+
38+ await getBuilderMe();
39+
40+ const [url, init] = lastFetchCall();
41+ expect(url).toBe("/api/builder/me");
42+ expect(init?.method).toBe("GET");
43+ });
44+});
src/api/__tests__/schools/schools.test.tsadded+141 -0
@@ -0,0 +1,141 @@
1+import { afterEach, describe, expect, it, vi } from "vitest";
2+import { deleteSchoolBySlug } from "../../schools";
3+import { deleteSchoolModule } from "../../schools";
4+import { getSchoolBySlug } from "../../schools";
5+import { getSchoolModules } from "../../schools";
6+import { getSchools } from "../../schools";
7+import { patchSchoolBySlug } from "../../schools";
8+import { patchSchoolModules } from "../../schools";
9+import { postSchool } from "../../schools";
10+import { postSchoolAdminPassword } from "../../schools";
11+import { postSchoolEnter } from "../../schools";
12+import { postSchoolModule } from "../../schools";
13+import { lastFetchCall, mockFetch204, mockFetchSuccess } from "../helpers/mock-fetch";
14+
15+const school = { slug: "ata-koleji", name: "Ata Koleji", status: "active", created_at: 1, modules: ["courses"] };
16+const modules = { enabled: ["courses"], disabled: ["exams"] };
17+
18+describe("schools API", () => {
19+ afterEach(() => {
20+ vi.restoreAllMocks();
21+ });
22+
23+ it("getSchools pages /schools", async () => {
24+ mockFetchSuccess({ items: [school], total: 1, limit: 20, offset: 0 });
25+
26+ const result = await getSchools({ limit: 20, offset: 0 });
27+ expect(result.items).toEqual([school]);
28+
29+ const [url, init] = lastFetchCall();
30+ expect(url).toBe("/api/schools?limit=20&offset=0");
31+ expect(init?.method).toBe("GET");
32+ });
33+
34+ it("getSchoolBySlug reads /schools/{slug}", async () => {
35+ mockFetchSuccess(school);
36+
37+ await getSchoolBySlug("ata-koleji");
38+
39+ const [url, init] = lastFetchCall();
40+ expect(url).toBe("/api/schools/ata-koleji");
41+ expect(init?.method).toBe("GET");
42+ });
43+
44+ it("postSchool posts the school and its first admin", async () => {
45+ mockFetchSuccess(school, 201);
46+ const body = { slug: "ata-koleji", name: "Ata Koleji", admin_username: "admin", admin_password: "secret123", modules: ["courses"] };
47+
48+ await postSchool(body);
49+
50+ const [url, init] = lastFetchCall();
51+ expect(url).toBe("/api/schools");
52+ expect(init?.method).toBe("POST");
53+ expect(init?.body).toBe(JSON.stringify(body));
54+ });
55+
56+ it("patchSchoolBySlug patches name and status", async () => {
57+ mockFetchSuccess({ ...school, status: "suspended" });
58+
59+ await patchSchoolBySlug("ata-koleji", { status: "suspended" });
60+
61+ const [url, init] = lastFetchCall();
62+ expect(url).toBe("/api/schools/ata-koleji");
63+ expect(init?.method).toBe("PATCH");
64+ expect(init?.body).toBe(JSON.stringify({ status: "suspended" }));
65+ });
66+
67+ it("deleteSchoolBySlug deletes /schools/{slug}", async () => {
68+ mockFetch204();
69+
70+ await deleteSchoolBySlug("ata-koleji");
71+
72+ const [url, init] = lastFetchCall();
73+ expect(url).toBe("/api/schools/ata-koleji");
74+ expect(init?.method).toBe("DELETE");
75+ });
76+
77+ it("postSchoolAdminPassword re-keys an admin", async () => {
78+ mockFetch204();
79+
80+ await postSchoolAdminPassword("ata-koleji", { username: "admin", password: "newsecret" });
81+
82+ const [url, init] = lastFetchCall();
83+ expect(url).toBe("/api/schools/ata-koleji/admin-password");
84+ expect(init?.method).toBe("POST");
85+ expect(init?.body).toBe(JSON.stringify({ username: "admin", password: "newsecret" }));
86+ });
87+
88+ it("postSchoolEnter enters as a named admin", async () => {
89+ mockFetchSuccess({ id: "u1", username: "admin", role: "admin" });
90+
91+ await postSchoolEnter("ata-koleji", { username: "admin" });
92+
93+ const [url, init] = lastFetchCall();
94+ expect(url).toBe("/api/schools/ata-koleji/enter");
95+ expect(init?.method).toBe("POST");
96+ expect(init?.body).toBe(JSON.stringify({ username: "admin" }));
97+ });
98+
99+ it("getSchoolModules reads both halves of the catalog", async () => {
100+ mockFetchSuccess(modules);
101+
102+ const result = await getSchoolModules("ata-koleji");
103+ expect(result).toEqual(modules);
104+
105+ const [url, init] = lastFetchCall();
106+ expect(url).toBe("/api/schools/ata-koleji/modules");
107+ expect(init?.method).toBe("GET");
108+ });
109+
110+ it("patchSchoolModules re-sells the shelf in one write", async () => {
111+ mockFetchSuccess(modules);
112+ const body = { enable: ["exams"], disable_packages: ["ai"] };
113+
114+ await patchSchoolModules("ata-koleji", body);
115+
116+ const [url, init] = lastFetchCall();
117+ expect(url).toBe("/api/schools/ata-koleji/modules");
118+ expect(init?.method).toBe("PATCH");
119+ expect(init?.body).toBe(JSON.stringify(body));
120+ });
121+
122+ it("postSchoolModule enables one module", async () => {
123+ mockFetchSuccess(modules);
124+
125+ await postSchoolModule("ata-koleji", "exams");
126+
127+ const [url, init] = lastFetchCall();
128+ expect(url).toBe("/api/schools/ata-koleji/modules/exams");
129+ expect(init?.method).toBe("POST");
130+ });
131+
132+ it("deleteSchoolModule disables one module", async () => {
133+ mockFetchSuccess(modules);
134+
135+ await deleteSchoolModule("ata-koleji", "exams");
136+
137+ const [url, init] = lastFetchCall();
138+ expect(url).toBe("/api/schools/ata-koleji/modules/exams");
139+ expect(init?.method).toBe("DELETE");
140+ });
141+});
src/api/builder/getBuilderMe.tsadded+6 -0
@@ -0,0 +1,6 @@
1+import { client } from "../client";
2+import type { Builder } from "../client";
3+
4+export function getBuilderMe(signal?: AbortSignal): Promise<Builder> {
5+ return client<Builder>("/builder/me", { signal });
6+}
src/api/builder/index.tsadded+3 -0
@@ -0,0 +1,3 @@
1+export * from "./getBuilderMe";
2+export * from "./postBuilderLogin";
3+export * from "./postBuilderLogout";
src/api/builder/postBuilderLogin.tsadded+13 -0
@@ -0,0 +1,13 @@
1+import { client } from "../client";
2+import type { Builder } from "../client";
3+
4+export type BuilderLoginBody = {
5+ username: string;
6+ password: string;
7+};
8+
9+// Sets a `builder.`-prefixed session cookie, which replaces any school session
10+// in this browser: the two are mutually exclusive (each is 401 on the other side).
11+export function postBuilderLogin(body: BuilderLoginBody): Promise<Builder> {
12+ return client<Builder>("/builder/login", { method: "POST", body });
13+}
src/api/builder/postBuilderLogout.tsadded+5 -0
@@ -0,0 +1,5 @@
1+import { client } from "../client";
2+
3+export function postBuilderLogout(): Promise<void> {
4+ return client<void>("/builder/logout", { method: "POST" });
5+}
src/api/client/client.tsmodified+13 -0
@@ -105,6 +105,19 @@ const API_ERROR_MESSAGES: Record<string, Record<Locale, string>> = {
105 en: "The repeated slots overlap each other.",105 en: "The repeated slots overlap each other.",
106 tr: "Tekrarlanan müsaitlikler birbiriyle çakışıyor.",106 tr: "Tekrarlanan müsaitlikler birbiriyle çakışıyor.",
107 },107 },
108+ // Builder surface (web/builder.rs, tenant.rs) β€” byte-exact.
109+ "school slug already taken": {
110+ en: "That school code is already taken.",
111+ tr: "Bu okul kodu zaten kullanΔ±lΔ±yor.",
112+ },
113+ "that account is not an admin of this school": {
114+ en: "That account exists but is not an admin of this school.",
115+ tr: "Bu hesap var ama bu okulun yâneticisi değil.",
116+ },
117+ "school is suspended": {
118+ en: "This school is suspended.",
119+ tr: "Bu okul askıya alınmış.",
120+ },
108 // Booking/decision conflicts from domain/appointment.rs β€” byte-exact.121 // Booking/decision conflicts from domain/appointment.rs β€” byte-exact.
109 "the slot is already booked": {122 "the slot is already booked": {
110 en: "Someone else booked this time first.",123 en: "Someone else booked this time first.",
src/api/client/types.tsmodified+26 -0
@@ -133,6 +133,32 @@ export type NoteFile = {
133 size: number;133 size: number;
134 };134 };
135 135
136+/** The deployment operator behind a `builder.` session cookie β€” no role, no school. */
137+export type Builder = {
138+ id: string;
139+ username: string;
140+};
141+
142+export type SchoolStatus = "active" | "suspended";
143+
144+/** One school of the deployment, as the builder surface sees it. */
145+export type School = {
146+ slug: string;
147+ name: string;
148+ /** A suspended school refuses every one of its own users, login included. */
149+ status: SchoolStatus;
150+ /** UTC unix-milliseconds. */
151+ created_at: number;
152+ /** Bought modules, sorted by name. */
153+ modules: string[];
154+};
155+
156+/** One school's entitlements, both halves of the catalog. */
157+export type SchoolModules = {
158+ enabled: string[];
159+ disabled: string[];
160+};
161+
136 /** The caller's school entitlements: every switched-on module, sorted by name. */162 /** The caller's school entitlements: every switched-on module, sorted by name. */
137 export type EnabledModules = {163 export type EnabledModules = {
138 enabled: string[];164 enabled: string[];
src/api/schools/deleteSchoolBySlug.tsadded+6 -0
@@ -0,0 +1,6 @@
1+import { client } from "../client";
2+
3+// Destroys the school's data and uploaded files for good.
4+export function deleteSchoolBySlug(slug: string): Promise<void> {
5+ return client<void>(`/schools/${encodeURIComponent(slug)}`, { method: "DELETE" });
6+}
src/api/schools/deleteSchoolModule.tsadded+8 -0
@@ -0,0 +1,8 @@
1+import { client } from "../client";
2+import type { SchoolModules } from "../client";
3+
4+export function deleteSchoolModule(slug: string, module: string): Promise<SchoolModules> {
5+ return client<SchoolModules>(`/schools/${encodeURIComponent(slug)}/modules/${encodeURIComponent(module)}`, {
6+ method: "DELETE",
7+ });
8+}
src/api/schools/getSchoolBySlug.tsadded+6 -0
@@ -0,0 +1,6 @@
1+import { client } from "../client";
2+import type { School } from "../client";
3+
4+export function getSchoolBySlug(slug: string, signal?: AbortSignal): Promise<School> {
5+ return client<School>(`/schools/${encodeURIComponent(slug)}`, { signal });
6+}
src/api/schools/getSchoolModules.tsadded+6 -0
@@ -0,0 +1,6 @@
1+import { client } from "../client";
2+import type { SchoolModules } from "../client";
3+
4+export function getSchoolModules(slug: string, signal?: AbortSignal): Promise<SchoolModules> {
5+ return client<SchoolModules>(`/schools/${encodeURIComponent(slug)}/modules`, { signal });
6+}
src/api/schools/getSchools.tsadded+8 -0
@@ -0,0 +1,8 @@
1+import { client } from "../client";
2+import { normalizePage, pageQuery, type Page, type PageParams } from "../client";
3+import type { School } from "../client";
4+
5+export async function getSchools(params?: PageParams, signal?: AbortSignal): Promise<Page<School>> {
6+ const data = await client<unknown>(`/schools${pageQuery(params)}`, { signal });
7+ return normalizePage<School>(data);
8+}
src/api/schools/index.tsadded+11 -0
@@ -0,0 +1,11 @@
1+export * from "./getSchools";
2+export * from "./getSchoolBySlug";
3+export * from "./postSchool";
4+export * from "./patchSchoolBySlug";
5+export * from "./deleteSchoolBySlug";
6+export * from "./postSchoolAdminPassword";
7+export * from "./postSchoolEnter";
8+export * from "./getSchoolModules";
9+export * from "./patchSchoolModules";
10+export * from "./postSchoolModule";
11+export * from "./deleteSchoolModule";
src/api/schools/patchSchoolBySlug.tsadded+11 -0
@@ -0,0 +1,11 @@
1+import { client } from "../client";
2+import type { School, SchoolStatus } from "../client";
3+
4+export type UpdateSchoolBody = {
5+ name?: string;
6+ status?: SchoolStatus;
7+};
8+
9+export function patchSchoolBySlug(slug: string, body: UpdateSchoolBody): Promise<School> {
10+ return client<School>(`/schools/${encodeURIComponent(slug)}`, { method: "PATCH", body });
11+}
src/api/schools/patchSchoolModules.tsadded+14 -0
@@ -0,0 +1,14 @@
1+import { client } from "../client";
2+import type { SchoolModules } from "../client";
3+
4+export type PatchSchoolModulesBody = {
5+ enable?: string[];
6+ disable?: string[];
7+ enable_packages?: string[];
8+ disable_packages?: string[];
9+};
10+
11+// One atomic re-sell: a 409 names every broken dependency and nothing is written.
12+export function patchSchoolModules(slug: string, body: PatchSchoolModulesBody): Promise<SchoolModules> {
13+ return client<SchoolModules>(`/schools/${encodeURIComponent(slug)}/modules`, { method: "PATCH", body });
14+}
src/api/schools/postSchool.tsadded+16 -0
@@ -0,0 +1,16 @@
1+import { client } from "../client";
2+import type { School } from "../client";
3+
4+export type CreateSchoolBody = {
5+ /** Immutable once taken: names the school's database, blobs and cookie prefix. */
6+ slug: string;
7+ name: string;
8+ admin_username: string;
9+ admin_password: string;
10+ /** Omitted sells the whole catalog. */
11+ modules?: string[];
12+};
13+
14+export function postSchool(body: CreateSchoolBody): Promise<School> {
15+ return client<School>("/schools", { method: "POST", body });
16+}
src/api/schools/postSchoolAdminPassword.tsadded+11 -0
@@ -0,0 +1,11 @@
1+import { client } from "../client";
2+
3+export type SchoolAdminPasswordBody = {
4+ username: string;
5+ password: string;
6+};
7+
8+// Re-keys an admin of that school and revokes every session the account held.
9+export function postSchoolAdminPassword(slug: string, body: SchoolAdminPasswordBody): Promise<void> {
10+ return client<void>(`/schools/${encodeURIComponent(slug)}/admin-password`, { method: "POST", body });
11+}
src/api/schools/postSchoolEnter.tsadded+8 -0
@@ -0,0 +1,8 @@
1+import { client } from "../client";
2+import type { User } from "../client";
3+
4+// Support access: swaps the builder cookie for an ordinary session of one of
5+// the school's admins. Refused (403) on a suspended school.
6+export function postSchoolEnter(slug: string, body: { username: string }): Promise<User> {
7+ return client<User>(`/schools/${encodeURIComponent(slug)}/enter`, { method: "POST", body });
8+}
src/api/schools/postSchoolModule.tsadded+8 -0
@@ -0,0 +1,8 @@
1+import { client } from "../client";
2+import type { SchoolModules } from "../client";
3+
4+export function postSchoolModule(slug: string, module: string): Promise<SchoolModules> {
5+ return client<SchoolModules>(`/schools/${encodeURIComponent(slug)}/modules/${encodeURIComponent(module)}`, {
6+ method: "POST",
7+ });
8+}
src/components/builder/builder-guard.tsxadded+26 -0
@@ -0,0 +1,26 @@
1+import { Navigate } from "@tanstack/solid-router";
2+import { type ParentProps, Show } from "solid-js";
3+import { formatApiError } from "@/api/client";
4+import { ErrorAlert } from "@/components/ui/error-alert";
5+import { PageSpinner } from "@/components/ui/page-spinner";
6+import { useBuilder } from "@/stores/builder-context";
7+
8+/** Renders its children only for a live builder session; otherwise sends the visitor to /builder/login. */
9+export function BuilderGuard(props: ParentProps) {
10+ const session = useBuilder();
11+
12+ return (
13+ <Show when={!session.loading()} fallback={<PageSpinner />}>
14+ <Show
15+ when={session.builder()}
16+ fallback={
17+ <Show when={session.error()} fallback={<Navigate to="/builder/login" />}>
18+ <ErrorAlert message={formatApiError(session.error())} onRetry={session.refresh} />
19+ </Show>
20+ }
21+ >
22+ {props.children}
23+ </Show>
24+ </Show>
25+ );
26+}
src/components/builder/builder-header.tsxadded+33 -0
@@ -0,0 +1,33 @@
1+import { Link, useNavigate } from "@tanstack/solid-router";
2+import { Button } from "@/components/ui/button";
3+import { IconLogout, IconShieldCheck } from "@/components/ui/icons";
4+import { useBuilder } from "@/stores/builder-context";
5+import { useT } from "@/stores/preferences-context";
6+
7+/** The operator strip over every builder page: where you are, who you are, the way out. */
8+export function BuilderHeader() {
9+ const session = useBuilder();
10+ const navigate = useNavigate();
11+ const t = useT();
12+
13+ const logout = async () => {
14+ await session.logout();
15+ void navigate({ to: "/builder/login" });
16+ };
17+
18+ return (
19+ <div class="flex flex-wrap items-center justify-between gap-3 rounded-xl border border-border-line bg-surface-base px-4 py-2.5">
20+ <Link to="/builder" class="flex min-w-0 items-center gap-2 text-sm font-semibold text-text-strong">
21+ <IconShieldCheck class="h-4 w-4 shrink-0 text-primary" />
22+ <span class="truncate">{t("builder.console")}</span>
23+ </Link>
24+ <div class="flex min-w-0 items-center gap-3">
25+ <span class="truncate text-sm text-text-subtle">@{session.builder()?.username}</span>
26+ <Button type="button" variant="outline" size="sm" class="rounded-lg" onClick={() => void logout()}>
27+ <IconLogout class="h-4 w-4" />
28+ {t("builder.logout")}
29+ </Button>
30+ </div>
31+ </div>
32+ );
33+}
src/components/builder/create-school-panel.tsxadded+129 -0
@@ -0,0 +1,129 @@
1+import { Show, createResource, createSignal } from "solid-js";
2+import { getModulesCatalog } from "@/api/modules";
3+import { postSchool } from "@/api/schools";
4+import type { School } from "@/api/client";
5+import { ModuleCatalogGrid } from "@/components/modules/module-catalog-grid";
6+import { formatModuleError } from "@/lib/module-labels";
7+import { Alert } from "@/components/ui/alert";
8+import { Button } from "@/components/ui/button";
9+import { Input } from "@/components/ui/input";
10+import { Label } from "@/components/ui/label";
11+import { SidePanel } from "@/components/ui/side-panel";
12+import { useT } from "@/stores/preferences-context";
13+
14+const SLUG_PATTERN = "[a-z0-9][a-z0-9-]{1,31}";
15+
16+/** Creates a school with its first admin and, optionally, a hand-picked module set. */
17+export function CreateSchoolPanel(props: { open: boolean; onOpenChange: (open: boolean) => void; onCreated: (school: School) => void }) {
18+ const t = useT();
19+ const [catalog] = createResource(() => props.open || undefined, () => getModulesCatalog());
20+ const [slug, setSlug] = createSignal("");
21+ const [name, setName] = createSignal("");
22+ const [adminUsername, setAdminUsername] = createSignal("");
23+ const [adminPassword, setAdminPassword] = createSignal("");
24+ const [everything, setEverything] = createSignal(true);
25+ const [picked, setPicked] = createSignal<string[]>([]);
26+ const [error, setError] = createSignal("");
27+ const [pending, setPending] = createSignal(false);
28+
29+ const reset = () => {
30+ setSlug("");
31+ setName("");
32+ setAdminUsername("");
33+ setAdminPassword("");
34+ setEverything(true);
35+ setPicked([]);
36+ setError("");
37+ };
38+
39+ const packageModules = (pkg: string) => catalog()?.packages.find((entry) => entry.package === pkg)?.modules ?? [];
40+
41+ const submit = async (event: SubmitEvent) => {
42+ event.preventDefault();
43+ setError("");
44+ setPending(true);
45+ try {
46+ const school = await postSchool({
47+ slug: slug().trim(),
48+ name: name().trim(),
49+ admin_username: adminUsername().trim(),
50+ admin_password: adminPassword(),
51+ // Omitted sells the whole catalog; an explicit list is checked for
52+ // missing dependencies before anything is created (409).
53+ modules: everything() ? undefined : picked(),
54+ });
55+ reset();
56+ props.onCreated(school);
57+ } catch (err) {
58+ setError(formatModuleError(err, t));
59+ } finally {
60+ setPending(false);
61+ }
62+ };
63+
64+ return (
65+ <SidePanel
66+ size="wide"
67+ open={props.open}
68+ onOpenChange={(open) => {
69+ props.onOpenChange(open);
70+ if (!open) reset();
71+ }}
72+ title={t("builder.createSchool")}
73+ description={t("builder.createSchoolHint")}
74+ >
75+ <form class="space-y-4" onSubmit={submit}>
76+ <Show when={error()}>
77+ <Alert variant="destructive">{error()}</Alert>
78+ </Show>
79+ <div class="grid gap-4 sm:grid-cols-2">
80+ <div class="space-y-1.5">
81+ <Label for="school-slug">{t("builder.slug")}</Label>
82+ <Input id="school-slug" class="rounded-lg" required pattern={SLUG_PATTERN} minlength={2} maxlength={32} value={slug()} onInput={(e) => setSlug(e.currentTarget.value.toLowerCase())} />
83+ <p class="text-xs text-text-subtle">{t("builder.slugHint")}</p>
84+ </div>
85+ <div class="space-y-1.5">
86+ <Label for="school-name">{t("builder.schoolName")}</Label>
87+ <Input id="school-name" class="rounded-lg" required maxlength={120} value={name()} onInput={(e) => setName(e.currentTarget.value)} />
88+ </div>
89+ <div class="space-y-1.5">
90+ <Label for="school-admin-username">{t("builder.adminUsername")}</Label>
91+ <Input id="school-admin-username" class="rounded-lg" required minlength={3} maxlength={32} autocomplete="off" value={adminUsername()} onInput={(e) => setAdminUsername(e.currentTarget.value)} />
92+ </div>
93+ <div class="space-y-1.5">
94+ <Label for="school-admin-password">{t("builder.adminPassword")}</Label>
95+ <Input id="school-admin-password" class="rounded-lg" type="password" required minlength={6} maxlength={128} autocomplete="new-password" value={adminPassword()} onInput={(e) => setAdminPassword(e.currentTarget.value)} />
96+ </div>
97+ </div>
98+ <label class="flex items-center gap-2 text-sm">
99+ <input type="checkbox" checked={everything()} onChange={(e) => setEverything(e.currentTarget.checked)} />
100+ {t("builder.sellEverything")}
101+ </label>
102+ <Show when={!everything() && catalog()}>
103+ {(value) => (
104+ <ModuleCatalogGrid
105+ stacked
106+ catalog={value()}
107+ enabled={picked()}
108+ onToggle={(module, next) => setPicked((current) => (next ? [...current, module] : current.filter((name) => name !== module)))}
109+ onTogglePackage={(pkg, next) =>
110+ setPicked((current) => {
111+ const modules = packageModules(pkg);
112+ return next ? [...new Set([...current, ...modules])] : current.filter((name) => !modules.includes(name));
113+ })
114+ }
115+ />
116+ )}
117+ </Show>
118+ <div class="flex flex-wrap items-center gap-2">
119+ <Button type="button" variant="outline" class="h-10 rounded-lg" onClick={() => props.onOpenChange(false)}>
120+ {t("common.cancel")}
121+ </Button>
122+ <Button type="submit" class="h-10 rounded-lg" disabled={pending()}>
123+ {t("common.create")}
124+ </Button>
125+ </div>
126+ </form>
127+ </SidePanel>
128+ );
129+}
src/components/builder/school-admin-access-panel.tsxadded+95 -0
@@ -0,0 +1,95 @@
1+import { Show, createSignal } from "solid-js";
2+import { formatApiError } from "@/api/client";
3+import { postSchoolAdminPassword, postSchoolEnter } from "@/api/schools";
4+import { Alert } from "@/components/ui/alert";
5+import { Button } from "@/components/ui/button";
6+import { Input } from "@/components/ui/input";
7+import { Label } from "@/components/ui/label";
8+import { SidePanel } from "@/components/ui/side-panel";
9+import { useT } from "@/stores/preferences-context";
10+
11+export type AdminAccessMode = "enter" | "password";
12+
13+/**
14+ * The two support doors into a school, both naming one of its admins:
15+ * `enter` swaps the builder cookie for that admin's session, `password`
16+ * re-keys the admin and revokes every session it held.
17+ */
18+export function SchoolAdminAccessPanel(props: {
19+ slug: string;
20+ mode: AdminAccessMode | null;
21+ onClose: () => void;
22+ onEntered: () => void;
23+ onPasswordReset: () => void;
24+}) {
25+ const t = useT();
26+ const [username, setUsername] = createSignal("");
27+ const [password, setPassword] = createSignal("");
28+ const [error, setError] = createSignal("");
29+ const [pending, setPending] = createSignal(false);
30+
31+ const reset = () => {
32+ setUsername("");
33+ setPassword("");
34+ setError("");
35+ };
36+
37+ const submit = async (event: SubmitEvent) => {
38+ event.preventDefault();
39+ setError("");
40+ setPending(true);
41+ try {
42+ if (props.mode === "enter") {
43+ await postSchoolEnter(props.slug, { username: username().trim() });
44+ reset();
45+ props.onEntered();
46+ } else {
47+ await postSchoolAdminPassword(props.slug, { username: username().trim(), password: password() });
48+ reset();
49+ props.onPasswordReset();
50+ }
51+ } catch (err) {
52+ setError(formatApiError(err));
53+ } finally {
54+ setPending(false);
55+ }
56+ };
57+
58+ return (
59+ <SidePanel
60+ open={props.mode != null}
61+ onOpenChange={(open) => {
62+ if (!open) {
63+ reset();
64+ props.onClose();
65+ }
66+ }}
67+ title={props.mode === "enter" ? t("builder.enterSchool") : t("builder.resetAdminPassword")}
68+ description={props.mode === "enter" ? t("builder.enterSchoolHint") : t("builder.resetAdminPasswordHint")}
69+ >
70+ <form class="space-y-4" onSubmit={submit}>
71+ <Show when={error()}>
72+ <Alert variant="destructive">{error()}</Alert>
73+ </Show>
74+ <div class="space-y-1.5">
75+ <Label for="school-access-username">{t("builder.adminUsername")}</Label>
76+ <Input id="school-access-username" class="rounded-lg" required minlength={3} maxlength={32} autocomplete="off" value={username()} onInput={(e) => setUsername(e.currentTarget.value)} />
77+ </div>
78+ <Show when={props.mode === "password"}>
79+ <div class="space-y-1.5">
80+ <Label for="school-access-password">{t("builder.newPassword")}</Label>
81+ <Input id="school-access-password" class="rounded-lg" type="password" required minlength={6} maxlength={128} autocomplete="new-password" value={password()} onInput={(e) => setPassword(e.currentTarget.value)} />
82+ </div>
83+ </Show>
84+ <div class="flex flex-wrap items-center gap-2">
85+ <Button type="button" variant="outline" class="h-10 rounded-lg" onClick={props.onClose}>
86+ {t("common.cancel")}
87+ </Button>
88+ <Button type="submit" class="h-10 rounded-lg" disabled={pending()}>
89+ {props.mode === "enter" ? t("builder.enterSchool") : t("builder.resetAdminPassword")}
90+ </Button>
91+ </div>
92+ </form>
93+ </SidePanel>
94+ );
95+}
src/components/builder/school-status-badge.tsxadded+12 -0
@@ -0,0 +1,12 @@
1+import type { SchoolStatus } from "@/api/client";
2+import { Badge } from "@/components/ui/badge";
3+import { useT } from "@/stores/preferences-context";
4+
5+export function SchoolStatusBadge(props: { status: SchoolStatus }) {
6+ const t = useT();
7+ return (
8+ <Badge variant={props.status === "active" ? "success" : "warning"} class="rounded-full">
9+ {props.status === "active" ? t("builder.statusActive") : t("builder.statusSuspended")}
10+ </Badge>
11+ );
12+}
src/components/layout/nav-items.test.tsmodified+60 -16
@@ -16,7 +16,7 @@ test("invalid role destinations stay hidden", () => {
16 expect(visibleNavItems("parent").map((item) => item.to)).not.toContain("/management/staff-work");16 expect(visibleNavItems("parent").map((item) => item.to)).not.toContain("/management/staff-work");
17 });17 });
18 18
19-test("admin's sidebar mirrors the Figma Operasyon / Yapay zekΓ’ / Kurum tree", () => {19+test("admin's sidebar keeps the Figma Operasyon / Yapay zekΓ’ / Kurum tree plus every backed page", () => {
20 expect(20 expect(
21 visibleNavGroups("admin").map((group) => ({21 visibleNavGroups("admin").map((group) => ({
22 id: group.id,22 id: group.id,
@@ -29,10 +29,20 @@ test("admin's sidebar mirrors the Figma Operasyon / Yapay zekΓ’ / Kurum tree", (
29 "students-roster",29 "students-roster",
30 "teachers-roster",30 "teachers-roster",
31 "class-groups",31 "class-groups",
32+ "courses",
33+ "terms",
32 "schedule",34 "schedule",
35+ "events",
33 "student-attendance",36 "student-attendance",
37+ "student-marks",
38+ "student-pomodoros",
39+ "homework",
34 "exams",40 "exams",
35 "question-bank",41 "question-bank",
42+ "questions",
43+ "notes",
44+ "whiteboards",
45+ "appointments",
36 "mock-exams",46 "mock-exams",
37 "optical-reading",47 "optical-reading",
38 "payments-collection",48 "payments-collection",
@@ -41,46 +51,62 @@ test("admin's sidebar mirrors the Figma Operasyon / Yapay zekΓ’ / Kurum tree", (
41 { id: "ai", items: ["hezarfen-zeka", "celebi", "sound-studio"] },51 { id: "ai", items: ["hezarfen-zeka", "celebi", "sound-studio"] },
42 {52 {
43 id: "institution",53 id: "institution",
44- items: ["reports", "license-modules", "users", "data-protection", "school-meals", "staff-work", "settings"],54+ items: ["reports", "license-modules", "users", "data-protection", "school-meals", "staff-work", "work", "settings"],
45 },55 },
46 ]);56 ]);
47 });57 });
48 58
49 test("manager sees the same admin tree minus the admin-only entries", () => {59 test("manager sees the same admin tree minus the admin-only entries", () => {
50 const institution = visibleNavGroups("manager").find((group) => group.id === "institution");60 const institution = visibleNavGroups("manager").find((group) => group.id === "institution");
51- expect(institution?.items.map((item) => item.id)).toEqual(["reports", "school-meals", "staff-work", "settings"]);61+ expect(institution?.items.map((item) => item.id)).toEqual(["reports", "school-meals", "staff-work", "work", "settings"]);
52 expect(institution?.items.map((item) => item.id)).not.toContain("license-modules");62 expect(institution?.items.map((item) => item.id)).not.toContain("license-modules");
53 expect(institution?.items.map((item) => item.id)).not.toContain("users");63 expect(institution?.items.map((item) => item.id)).not.toContain("users");
54 expect(institution?.items.map((item) => item.id)).not.toContain("data-protection");64 expect(institution?.items.map((item) => item.id)).not.toContain("data-protection");
55 });65 });
56 66
57-test("teacher's sidebar mirrors the Figma Sınıfım / Yapay zekÒ / Diğer tree", () => {67+test("teacher's sidebar keeps the Figma Sınıfım / Yapay zekÒ / Diğer tree plus every backed page", () => {
58 expect(68 expect(
59 visibleNavGroups("teacher").map((group) => ({69 visibleNavGroups("teacher").map((group) => ({
60 id: group.id,70 id: group.id,
61 items: group.items.map((item) => item.id),71 items: group.items.map((item) => item.id),
62 })),72 })),
63 ).toEqual([73 ).toEqual([
64- { id: "my-classroom", items: ["my-classes", "my-schedule", "student-attendance", "homework", "exams", "whiteboards"] },74+ {
75+ id: "my-classroom",
76+ items: [
77+ "my-classes",
78+ "my-schedule",
79+ "courses",
80+ "student-attendance",
81+ "student-marks",
82+ "student-pomodoros",
83+ "homework",
84+ "exams",
85+ "question-bank",
86+ "questions",
87+ "notes",
88+ "whiteboards",
89+ ],
90+ },
65 { id: "ai", items: ["student-analysis", "pending-approvals", "question-generation", "sound-studio"] },91 { id: "ai", items: ["student-analysis", "pending-approvals", "question-generation", "sound-studio"] },
66- { id: "other", items: ["parent-communication", "work", "settings-teacher"] },92+ { id: "other", items: ["parent-communication", "appointments", "events", "meals", "work", "settings-teacher"] },
67 ]);93 ]);
68 });94 });
69 95
70-test("student's sidebar mirrors the Figma Γ‡alışma / Yapay zekΓ’ / Diğer tree", () => {96+test("student's sidebar keeps the Figma Γ‡alışma / Yapay zekΓ’ / Diğer tree plus every backed page", () => {
71 expect(97 expect(
72 visibleNavGroups("student").map((group) => ({98 visibleNavGroups("student").map((group) => ({
73 id: group.id,99 id: group.id,
74 items: group.items.map((item) => item.id),100 items: group.items.map((item) => item.id),
75 })),101 })),
76 ).toEqual([102 ).toEqual([
77- { id: "study", items: ["study-plan", "topic-mastery", "exam-results", "my-homework", "whiteboards", "pomodoro"] },103+ { id: "study", items: ["study-plan", "topic-mastery", "exam-results", "my-homework", "courses", "notes", "questions", "whiteboards", "pomodoro"] },
78 { id: "ai", items: ["celebi", "sound-studio"] },104 { id: "ai", items: ["celebi", "sound-studio"] },
79- { id: "other", items: ["calendar", "settings-student"] },105+ { id: "other", items: ["calendar", "events", "messages", "appointments", "meals", "settings-student"] },
80 ]);106 ]);
81 });107 });
82 108
83-test("parent's sidebar mirrors the Figma Γ–ΔŸrencim / Kurum tree", () => {109+test("parent's sidebar keeps the Figma Γ–ΔŸrencim / Kurum tree plus every backed page", () => {
84 expect(110 expect(
85 visibleNavGroups("parent").map((group) => ({111 visibleNavGroups("parent").map((group) => ({
86 id: group.id,112 id: group.id,
@@ -88,18 +114,36 @@ test("parent's sidebar mirrors the Figma Γ–ΔŸrencim / Kurum tree", () => {
88 })),114 })),
89 ).toEqual([115 ).toEqual([
90 { id: "my-student", items: ["progress-report", "absence", "child-exam-results", "child-study-plan"] },116 { id: "my-student", items: ["progress-report", "absence", "child-exam-results", "child-study-plan"] },
91- { id: "institution", items: ["payment-statement", "appointments", "settings-parent"] },117+ { id: "institution", items: ["payment-statement", "appointments", "messages", "calendar", "events", "meals", "settings-parent"] },
92 ]);118 ]);
93 });119 });
94 120
95-test("appointments is a parent-only sidebar entry, matching the Figma parent screen", () => {121+test("appointments and meals are reachable from every role's sidebar", () => {
96- expect(visibleNavGroups("parent").flatMap((g) => g.items).map((i) => i.to)).toContain("/appointments");122+ for (const role of ["student", "parent", "teacher", "manager", "admin"] as const) {
97- for (const role of ["student", "teacher", "manager", "admin"] as const) {123+ const paths = visibleNavGroups(role).flatMap((g) => g.items.map((i) => i.to));
98- const paths = [...primaryNavItems(role).map((i) => i.to), ...visibleNavGroups(role).flatMap((g) => g.items.map((i) => i.to))];124+ expect(paths).toContain("/appointments");
99- expect(paths).not.toContain("/appointments");125+ expect(paths).toContain("/meals");
100 }126 }
101 });127 });
102 128
129+test("parent's child entries open the progress page on their own tab, not a placeholder", () => {
130+ const items = visibleNavGroups("parent").flatMap((g) => g.items);
131+ expect(items.filter((i) => i.soon).map((i) => i.id)).toEqual([]);
132+ expect(routeNavItem("/students/attendance", "parent")?.id).toBe("absence");
133+ expect(routeNavItem("/students/exams", "parent")?.id).toBe("child-exam-results");
134+ expect(routeNavItem("/students/study", "parent")?.id).toBe("child-study-plan");
135+ expect(routeNavItem("/students", "parent")?.id).toBe("progress-report");
136+});
137+
138+test("license modules is a real admin page and the work log includes admin", () => {
139+ const admin = visibleNavGroups("admin").flatMap((g) => g.items);
140+ const licenseModules = admin.find((i) => i.id === "license-modules");
141+ expect(licenseModules?.to).toBe("/management/modules");
142+ expect(licenseModules?.soon).toBeFalsy();
143+ expect(admin.map((i) => i.to)).toContain("/work");
144+ expect(visibleNavGroups("manager").flatMap((g) => g.items).map((i) => i.id)).not.toContain("license-modules");
145+});
146+
103 test("entries with no backend yet are flagged soon and route to the shared placeholder", () => {147 test("entries with no backend yet are flagged soon and route to the shared placeholder", () => {
104 const hezarfenZeka = visibleNavGroups("admin")148 const hezarfenZeka = visibleNavGroups("admin")
105 .flatMap((g) => g.items)149 .flatMap((g) => g.items)
src/components/layout/nav-items.tsmodified+39 -5
@@ -2,8 +2,10 @@ import type { Component } from "solid-js";
2 import type { Role } from "@/api/client";2 import type { Role } from "@/api/client";
3 import {3 import {
4 IconArchive,4 IconArchive,
5+ IconBook,
5 IconBotSquare,6 IconBotSquare,
6 IconBriefcase,7 IconBriefcase,
8+ IconCalendar,
7 IconCalendarDays,9 IconCalendarDays,
8 IconChalkboardTeacher,10 IconChalkboardTeacher,
9 IconChart,11 IconChart,
@@ -16,6 +18,7 @@ import {
16 IconHomework,18 IconHomework,
17 IconHome,19 IconHome,
18 IconMessage,20 IconMessage,
21+ IconNote,
19 IconPackage,22 IconPackage,
20 IconReportAnalytics,23 IconReportAnalytics,
21 IconScan,24 IconScan,
@@ -97,10 +100,20 @@ const ADMIN_GROUPS: NavGroup[] = [
97 { id: "students-roster", to: "/coming-soon/ogrenciler", labelKey: "nav.studentsRoster", Icon: IconUsers, soon: true, minRole: "manager" },100 { id: "students-roster", to: "/coming-soon/ogrenciler", labelKey: "nav.studentsRoster", Icon: IconUsers, soon: true, minRole: "manager" },
98 { id: "teachers-roster", to: "/coming-soon/ogretmenler", labelKey: "nav.teachersRoster", Icon: IconChalkboardTeacher, soon: true, minRole: "manager" },101 { id: "teachers-roster", to: "/coming-soon/ogretmenler", labelKey: "nav.teachersRoster", Icon: IconChalkboardTeacher, soon: true, minRole: "manager" },
99 { id: "class-groups", to: "/management/classes", labelKey: "nav.classGroups", Icon: IconSchool, minRole: "teacher" },102 { id: "class-groups", to: "/management/classes", labelKey: "nav.classGroups", Icon: IconSchool, minRole: "teacher" },
103+ { id: "courses", to: "/courses", labelKey: "nav.courses", Icon: IconBook, module: "courses" },
104+ { id: "terms", to: "/management/terms", labelKey: "nav.terms", Icon: IconCalendar, minRole: "manager" },
100 { id: "schedule", to: "/calendar", labelKey: "nav.schedule", Icon: IconCalendarDays, minRole: "manager" },105 { id: "schedule", to: "/calendar", labelKey: "nav.schedule", Icon: IconCalendarDays, minRole: "manager" },
106+ { id: "events", to: "/events", labelKey: "nav.events", Icon: IconCalendarDays, module: "events" },
101 { id: "student-attendance", to: "/management/student-attendance", labelKey: "nav.attendance", Icon: IconClipboardCheck, minRole: "teacher", module: "attendance" },107 { id: "student-attendance", to: "/management/student-attendance", labelKey: "nav.attendance", Icon: IconClipboardCheck, minRole: "teacher", module: "attendance" },
108+ { id: "student-marks", to: "/management/student-marks", labelKey: "nav.studentMarks", Icon: IconChart, minRole: "teacher", module: "marks" },
109+ { id: "student-pomodoros", to: "/management/pomodoros", labelKey: "nav.studentPomodoro", Icon: IconClock, minRole: "teacher", module: "pomodoro" },
110+ { id: "homework", to: "/homework", labelKey: "nav.homework", Icon: IconHomework, module: "homework" },
102 { id: "exams", to: "/exams", labelKey: "nav.exams", Icon: IconExam, minRole: "teacher", module: "exams" },111 { id: "exams", to: "/exams", labelKey: "nav.exams", Icon: IconExam, minRole: "teacher", module: "exams" },
103 { id: "question-bank", to: "/question-bank", labelKey: "nav.questionBank", Icon: IconArchive, minRole: "teacher", module: "bank_questions" },112 { id: "question-bank", to: "/question-bank", labelKey: "nav.questionBank", Icon: IconArchive, minRole: "teacher", module: "bank_questions" },
113+ { id: "questions", to: "/questions", labelKey: "nav.questions", Icon: IconHelpCircle, module: "questions" },
114+ { id: "notes", to: "/notes", labelKey: "nav.notes", Icon: IconNote, module: "notes" },
115+ { id: "whiteboards", to: "/whiteboards", labelKey: "nav.whiteboards", Icon: IconEdit, module: "boards" },
116+ { id: "appointments", to: "/appointments", labelKey: "nav.appointments", Icon: IconClock, module: "appointments" },
104 { id: "mock-exams", to: "/coming-soon/deneme-sinavlari", labelKey: "nav.mockExams", Icon: IconTarget, soon: true, minRole: "manager" },117 { id: "mock-exams", to: "/coming-soon/deneme-sinavlari", labelKey: "nav.mockExams", Icon: IconTarget, soon: true, minRole: "manager" },
105 { id: "optical-reading", to: "/coming-soon/optik-okuma", labelKey: "nav.opticalReading", Icon: IconScan, soon: true, minRole: "manager" },118 { id: "optical-reading", to: "/coming-soon/optik-okuma", labelKey: "nav.opticalReading", Icon: IconScan, soon: true, minRole: "manager" },
106 { id: "payments-collection", to: "/management/payments", labelKey: "nav.payments", Icon: IconReportAnalytics, minRole: "manager", module: "payments" },119 { id: "payments-collection", to: "/management/payments", labelKey: "nav.payments", Icon: IconReportAnalytics, minRole: "manager", module: "payments" },
@@ -122,11 +135,12 @@ const ADMIN_GROUPS: NavGroup[] = [
122 Icon: IconUserCog,135 Icon: IconUserCog,
123 items: [136 items: [
124 { id: "reports", to: "/coming-soon/raporlar", labelKey: "nav.reports", Icon: IconChartPie, soon: true, minRole: "manager" },137 { id: "reports", to: "/coming-soon/raporlar", labelKey: "nav.reports", Icon: IconChartPie, soon: true, minRole: "manager" },
125- { id: "license-modules", to: "/coming-soon/lisans-modulleri", labelKey: "nav.licenseModules", Icon: IconPackage, soon: true, minRole: "admin" },138+ { id: "license-modules", to: "/management/modules", labelKey: "nav.licenseModules", Icon: IconPackage, minRole: "admin" },
126 { id: "users", to: "/admin/users", labelKey: "nav.users", Icon: IconUserCog, minRole: "admin" },139 { id: "users", to: "/admin/users", labelKey: "nav.users", Icon: IconUserCog, minRole: "admin" },
127 { id: "data-protection", to: "/coming-soon/kvkk-denetim", labelKey: "nav.dataProtection", Icon: IconShieldCheck, soon: true, minRole: "admin" },140 { id: "data-protection", to: "/coming-soon/kvkk-denetim", labelKey: "nav.dataProtection", Icon: IconShieldCheck, soon: true, minRole: "admin" },
128 { id: "school-meals", to: "/meals", labelKey: "nav.schoolMeals", Icon: IconUtensils, minRole: "manager", module: "meals" },141 { id: "school-meals", to: "/meals", labelKey: "nav.schoolMeals", Icon: IconUtensils, minRole: "manager", module: "meals" },
129 { id: "staff-work", to: "/management/staff-work", labelKey: "nav.staffWork", Icon: IconBriefcase, minRole: "manager", module: "work" },142 { id: "staff-work", to: "/management/staff-work", labelKey: "nav.staffWork", Icon: IconBriefcase, minRole: "manager", module: "work" },
143+ { id: "work", to: "/work", labelKey: "nav.work", Icon: IconClock, minRole: "teacher", module: "work" },
130 { id: "settings", to: "/management/settings", labelKey: "nav.settings", Icon: IconSettings, minRole: "manager" },144 { id: "settings", to: "/management/settings", labelKey: "nav.settings", Icon: IconSettings, minRole: "manager" },
131 ],145 ],
132 },146 },
@@ -140,9 +154,15 @@ const TEACHER_GROUPS: NavGroup[] = [
140 items: [154 items: [
141 { id: "my-classes", to: "/management/classes", labelKey: "nav.myClasses", Icon: IconSchool },155 { id: "my-classes", to: "/management/classes", labelKey: "nav.myClasses", Icon: IconSchool },
142 { id: "my-schedule", to: "/calendar", labelKey: "nav.mySchedule", Icon: IconCalendarDays },156 { id: "my-schedule", to: "/calendar", labelKey: "nav.mySchedule", Icon: IconCalendarDays },
157+ { id: "courses", to: "/courses", labelKey: "nav.courses", Icon: IconBook, module: "courses" },
143 { id: "student-attendance", to: "/management/student-attendance", labelKey: "nav.attendance", Icon: IconClipboardCheck, module: "attendance" },158 { id: "student-attendance", to: "/management/student-attendance", labelKey: "nav.attendance", Icon: IconClipboardCheck, module: "attendance" },
159+ { id: "student-marks", to: "/management/student-marks", labelKey: "nav.studentMarks", Icon: IconChart, module: "marks" },
160+ { id: "student-pomodoros", to: "/management/pomodoros", labelKey: "nav.studentPomodoro", Icon: IconClock, module: "pomodoro" },
144 { id: "homework", to: "/homework", labelKey: "nav.homework", Icon: IconHomework, module: "homework" },161 { id: "homework", to: "/homework", labelKey: "nav.homework", Icon: IconHomework, module: "homework" },
145 { id: "exams", to: "/exams", labelKey: "nav.exams", Icon: IconExam, module: "exams" },162 { id: "exams", to: "/exams", labelKey: "nav.exams", Icon: IconExam, module: "exams" },
163+ { id: "question-bank", to: "/question-bank", labelKey: "nav.questionBank", Icon: IconArchive, module: "bank_questions" },
164+ { id: "questions", to: "/questions", labelKey: "nav.questions", Icon: IconHelpCircle, module: "questions" },
165+ { id: "notes", to: "/notes", labelKey: "nav.notes", Icon: IconNote, module: "notes" },
146 { id: "whiteboards", to: "/whiteboards", labelKey: "nav.whiteboards", Icon: IconEdit, module: "boards" },166 { id: "whiteboards", to: "/whiteboards", labelKey: "nav.whiteboards", Icon: IconEdit, module: "boards" },
147 ],167 ],
148 },168 },
@@ -163,7 +183,10 @@ const TEACHER_GROUPS: NavGroup[] = [
163 Icon: IconMessage,183 Icon: IconMessage,
164 items: [184 items: [
165 { id: "parent-communication", to: "/messages", labelKey: "nav.parentCommunication", Icon: IconMessage, module: "messages" },185 { id: "parent-communication", to: "/messages", labelKey: "nav.parentCommunication", Icon: IconMessage, module: "messages" },
166- { id: "work", to: "/work", labelKey: "nav.work", Icon: IconClock, minRole: "teacher", maxRole: "manager", module: "work" },186+ { id: "appointments", to: "/appointments", labelKey: "nav.appointments", Icon: IconClock, module: "appointments" },
187+ { id: "events", to: "/events", labelKey: "nav.events", Icon: IconCalendarDays, module: "events" },
188+ { id: "meals", to: "/meals", labelKey: "nav.meals", Icon: IconUtensils, module: "meals" },
189+ { id: "work", to: "/work", labelKey: "nav.work", Icon: IconBriefcase, minRole: "teacher", module: "work" },
167 settingsAction("settings-teacher"),190 settingsAction("settings-teacher"),
168 ],191 ],
169 },192 },
@@ -179,6 +202,9 @@ const STUDENT_GROUPS: NavGroup[] = [
179 { id: "topic-mastery", to: "/marks", labelKey: "nav.topicMastery", Icon: IconChart, exactRole: "student", module: "marks" },202 { id: "topic-mastery", to: "/marks", labelKey: "nav.topicMastery", Icon: IconChart, exactRole: "student", module: "marks" },
180 { id: "exam-results", to: "/exams", labelKey: "nav.examResults", Icon: IconExam, module: "exams" },203 { id: "exam-results", to: "/exams", labelKey: "nav.examResults", Icon: IconExam, module: "exams" },
181 { id: "my-homework", to: "/homework", labelKey: "nav.myHomework", Icon: IconHomework, module: "homework" },204 { id: "my-homework", to: "/homework", labelKey: "nav.myHomework", Icon: IconHomework, module: "homework" },
205+ { id: "courses", to: "/courses", labelKey: "nav.courses", Icon: IconBook, module: "courses" },
206+ { id: "notes", to: "/notes", labelKey: "nav.notes", Icon: IconNote, module: "notes" },
207+ { id: "questions", to: "/questions", labelKey: "nav.questions", Icon: IconHelpCircle, module: "questions" },
182 { id: "whiteboards", to: "/whiteboards", labelKey: "nav.whiteboards", Icon: IconEdit, module: "boards" },208 { id: "whiteboards", to: "/whiteboards", labelKey: "nav.whiteboards", Icon: IconEdit, module: "boards" },
183 { id: "pomodoro", to: "/pomodoro", labelKey: "nav.pomodoro", Icon: IconClock, exactRole: "student", module: "pomodoro" },209 { id: "pomodoro", to: "/pomodoro", labelKey: "nav.pomodoro", Icon: IconClock, exactRole: "student", module: "pomodoro" },
184 ],210 ],
@@ -195,6 +221,10 @@ const STUDENT_GROUPS: NavGroup[] = [
195 Icon: IconCalendarDays,221 Icon: IconCalendarDays,
196 items: [222 items: [
197 { id: "calendar", to: "/calendar", labelKey: "nav.mySchedule", Icon: IconCalendarDays },223 { id: "calendar", to: "/calendar", labelKey: "nav.mySchedule", Icon: IconCalendarDays },
224+ { id: "events", to: "/events", labelKey: "nav.events", Icon: IconCalendarDays, module: "events" },
225+ { id: "messages", to: "/messages", labelKey: "nav.messages", Icon: IconMessage, module: "messages" },
226+ { id: "appointments", to: "/appointments", labelKey: "nav.appointments", Icon: IconClock, module: "appointments" },
227+ { id: "meals", to: "/meals", labelKey: "nav.meals", Icon: IconUtensils, module: "meals" },
198 settingsAction("settings-student"),228 settingsAction("settings-student"),
199 ],229 ],
200 },230 },
@@ -207,9 +237,9 @@ const PARENT_GROUPS: NavGroup[] = [
207 Icon: IconUsers,237 Icon: IconUsers,
208 items: [238 items: [
209 { id: "progress-report", to: "/students", labelKey: "nav.progressReport", Icon: IconReportAnalytics, exactRole: "parent" },239 { id: "progress-report", to: "/students", labelKey: "nav.progressReport", Icon: IconReportAnalytics, exactRole: "parent" },
210- { id: "absence", to: "/coming-soon/devamsizlik", labelKey: "nav.absence", Icon: IconClipboardCheck, soon: true },240+ { id: "absence", to: "/students/attendance", labelKey: "nav.absence", Icon: IconClipboardCheck, exactRole: "parent", module: "attendance" },
211- { id: "child-exam-results", to: "/coming-soon/sinav-sonuclari-veli", labelKey: "nav.childExamResults", Icon: IconExam, soon: true },241+ { id: "child-exam-results", to: "/students/exams", labelKey: "nav.childExamResults", Icon: IconExam, exactRole: "parent", module: "marks" },
212- { id: "child-study-plan", to: "/coming-soon/calisma-plani", labelKey: "nav.childStudyPlan", Icon: IconClock, soon: true },242+ { id: "child-study-plan", to: "/students/study", labelKey: "nav.childStudyPlan", Icon: IconClock, exactRole: "parent", module: "pomodoro" },
213 ],243 ],
214 },244 },
215 {245 {
@@ -219,6 +249,10 @@ const PARENT_GROUPS: NavGroup[] = [
219 items: [249 items: [
220 { id: "payment-statement", to: "/payments", labelKey: "nav.payments", Icon: IconReportAnalytics, exactRole: "parent", module: "payments" },250 { id: "payment-statement", to: "/payments", labelKey: "nav.payments", Icon: IconReportAnalytics, exactRole: "parent", module: "payments" },
221 { id: "appointments", to: "/appointments", labelKey: "nav.appointmentsAndCommunication", Icon: IconClock, exactRole: "parent", module: "appointments" },251 { id: "appointments", to: "/appointments", labelKey: "nav.appointmentsAndCommunication", Icon: IconClock, exactRole: "parent", module: "appointments" },
252+ { id: "messages", to: "/messages", labelKey: "nav.messages", Icon: IconMessage, module: "messages" },
253+ { id: "calendar", to: "/calendar", labelKey: "nav.mySchedule", Icon: IconCalendarDays },
254+ { id: "events", to: "/events", labelKey: "nav.events", Icon: IconCalendarDays, module: "events" },
255+ { id: "meals", to: "/meals", labelKey: "nav.meals", Icon: IconUtensils, module: "meals" },
222 settingsAction("settings-parent"),256 settingsAction("settings-parent"),
223 ],257 ],
224 },258 },
src/components/modules/module-catalog-grid.tsxadded+112 -0
@@ -0,0 +1,112 @@
1+import { For, Show } from "solid-js";
2+import type { ModuleCatalog } from "@/api/client";
3+import { Badge } from "@/components/ui/badge";
4+import { moduleLabel, packageLabel } from "@/lib/module-labels";
5+import { useT } from "@/stores/preferences-context";
6+
7+/**
8+ * The deployment catalog grouped by package, each module marked on/off for one
9+ * school. Read-only without `onToggle` (a school admin's view); with it, every
10+ * module row becomes a switch (the builder's switchboard).
11+ */
12+export function ModuleCatalogGrid(props: {
13+ catalog: ModuleCatalog;
14+ enabled: readonly string[];
15+ onToggle?: (module: string, next: boolean) => void;
16+ onTogglePackage?: (pkg: string, next: boolean) => void;
17+ disabled?: boolean;
18+ /** One column regardless of viewport β€” for narrow hosts like a SidePanel. */
19+ stacked?: boolean;
20+}) {
21+ const t = useT();
22+ const isOn = (module: string) => props.enabled.includes(module);
23+ const requiresOf = (module: string) => props.catalog.modules.find((entry) => entry.module === module)?.requires ?? [];
24+
25+ return (
26+ <div class={props.stacked ? "grid gap-4" : "grid gap-4 md:grid-cols-2"}>
27+ <For each={props.catalog.packages}>
28+ {(pkg) => {
29+ const onCount = () => pkg.modules.filter(isOn).length;
30+ return (
31+ <section class="data-shell space-y-3 p-4">
32+ <div class="flex items-center justify-between gap-3">
33+ <div class="min-w-0">
34+ <h2 class="truncate font-semibold text-text-strong">{packageLabel(pkg.package, t)}</h2>
35+ <p class="text-xs text-text-subtle">{t("modules.enabledCount", { on: String(onCount()), total: String(pkg.modules.length) })}</p>
36+ </div>
37+ <Show when={props.onTogglePackage}>
38+ {(toggle) => (
39+ <div class="flex shrink-0 gap-2">
40+ <button
41+ type="button"
42+ class="rounded-md px-2 py-1 text-xs font-medium text-primary hover:bg-muted/60 disabled:opacity-50"
43+ disabled={props.disabled || onCount() === pkg.modules.length}
44+ onClick={() => toggle()(pkg.package, true)}
45+ >
46+ {t("modules.enableAll")}
47+ </button>
48+ <button
49+ type="button"
50+ class="rounded-md px-2 py-1 text-xs font-medium text-muted-foreground hover:bg-muted/60 disabled:opacity-50"
51+ disabled={props.disabled || onCount() === 0}
52+ onClick={() => toggle()(pkg.package, false)}
53+ >
54+ {t("modules.disableAll")}
55+ </button>
56+ </div>
57+ )}
58+ </Show>
59+ </div>
60+ <ul class="divide-y divide-border-hairline">
61+ <For each={pkg.modules}>
62+ {(module) => (
63+ <li class="flex items-center justify-between gap-3 py-2">
64+ <div class="min-w-0">
65+ <p class="truncate text-sm font-medium text-foreground">{moduleLabel(module, t)}</p>
66+ <Show when={requiresOf(module).length > 0}>
67+ <p class="truncate text-xs text-text-subtle">
68+ {t("modules.requires")}: {requiresOf(module).map((name) => moduleLabel(name, t)).join(", ")}
69+ </p>
70+ </Show>
71+ </div>
72+ <Show
73+ when={props.onToggle}
74+ fallback={
75+ <Badge variant={isOn(module) ? "success" : "secondary"} class="shrink-0 rounded-full">
76+ {isOn(module) ? t("modules.on") : t("modules.off")}
77+ </Badge>
78+ }
79+ >
80+ {(toggle) => (
81+ <label class="relative shrink-0 cursor-pointer" title={moduleLabel(module, t)}>
82+ <input
83+ type="checkbox"
84+ class="peer sr-only"
85+ aria-label={moduleLabel(module, t)}
86+ checked={isOn(module)}
87+ disabled={props.disabled}
88+ onChange={(event) => {
89+ const next = event.currentTarget.checked;
90+ // The switch shows `enabled`, not the click: snap back
91+ // now and let a successful write move it, so a refused
92+ // (409) toggle never leaves it in the wrong position.
93+ event.currentTarget.checked = isOn(module);
94+ toggle()(module, next);
95+ }}
96+ />
97+ <span class="block h-6 w-10 rounded-full bg-input ring-1 ring-inset ring-black/5 transition-colors peer-checked:bg-primary peer-disabled:opacity-60 peer-focus-visible:ring-2 peer-focus-visible:ring-ring dark:ring-white/10" />
98+ <span class="pointer-events-none absolute left-1 top-1 h-4 w-4 rounded-full bg-white shadow-sm transition-transform peer-checked:translate-x-4" />
99+ </label>
100+ )}
101+ </Show>
102+ </li>
103+ )}
104+ </For>
105+ </ul>
106+ </section>
107+ );
108+ }}
109+ </For>
110+ </div>
111+ );
112+}
src/components/pomodoro/pomodoro-log-view.tsxadded+39 -0
@@ -0,0 +1,39 @@
1+import { createMemo } from "solid-js";
2+import type { ColumnDef } from "@tanstack/solid-table";
3+import type { PomodoroLog, PomodoroSession } from "@/api/client";
4+import { DataTable } from "@/components/ui/data-table";
5+import { formatDateTime, formatDurationClock } from "@/lib/format";
6+import { usePreferences, useT } from "@/stores/preferences-context";
7+
8+/** A student's pomodoro log: lifetime focus total over the paged stint list. */
9+export function PomodoroLogView(props: { log: PomodoroLog }) {
10+ const t = useT();
11+ const { locale } = usePreferences();
12+ const columns = createMemo<ColumnDef<PomodoroSession>[]>(() => [
13+ {
14+ accessorKey: "started_at",
15+ header: t("pomodoro.startedAt"),
16+ cell: (cell) => <span class="mono whitespace-nowrap">{formatDateTime(cell.row.original.started_at, locale())}</span>,
17+ },
18+ {
19+ accessorKey: "finished_at",
20+ header: t("pomodoro.finishedAt"),
21+ cell: (cell) => <span class="mono whitespace-nowrap">{formatDateTime(cell.row.original.finished_at, locale())}</span>,
22+ },
23+ {
24+ accessorKey: "duration_ms",
25+ header: t("pomodoro.duration"),
26+ cell: (cell) => <span class="mono tabular-nums">{formatDurationClock(cell.row.original.duration_ms)}</span>,
27+ },
28+ ]);
29+
30+ return (
31+ <div class="space-y-4">
32+ <div class="detail-metric-card">
33+ <p class="text-xs font-medium uppercase tracking-[0.08em] text-muted-foreground">{t("pomodoro.total")}</p>
34+ <p class="mono mt-2 text-3xl font-semibold tabular-nums">{formatDurationClock(props.log.total_focus_ms)}</p>
35+ </div>
36+ <DataTable columns={columns()} data={props.log.items} empty={t("pomodoro.empty")} enablePagination pageSize={10} />
37+ </div>
38+ );
39+}
src/i18n/messages.tsmodified+216 -0
@@ -305,6 +305,78 @@ export type MessageKey =
305 | "comingSoon.description"305 | "comingSoon.description"
306 | "comingSoon.emptyTitle"306 | "comingSoon.emptyTitle"
307 | "comingSoon.emptyDescription"307 | "comingSoon.emptyDescription"
308+ | "builder.console"
309+ | "builder.logout"
310+ | "builder.loginTitle"
311+ | "builder.loginSubtitle"
312+ | "builder.backToSchoolLogin"
313+ | "builder.operatorLogin"
314+ | "builder.statusActive"
315+ | "builder.statusSuspended"
316+ | "builder.createSchool"
317+ | "builder.createSchoolHint"
318+ | "builder.slug"
319+ | "builder.slugHint"
320+ | "builder.schoolName"
321+ | "builder.adminUsername"
322+ | "builder.adminPassword"
323+ | "builder.sellEverything"
324+ | "builder.schools"
325+ | "builder.schoolsSubtitle"
326+ | "builder.status"
327+ | "builder.modules"
328+ | "builder.createdAt"
329+ | "builder.suspend"
330+ | "builder.activate"
331+ | "builder.noSchools"
332+ | "builder.deleteSchool"
333+ | "builder.deleteSchoolWarning"
334+ | "builder.enterSchool"
335+ | "builder.enterSchoolHint"
336+ | "builder.enterSuspendedHint"
337+ | "builder.resetAdminPassword"
338+ | "builder.resetAdminPasswordHint"
339+ | "builder.newPassword"
340+ | "builder.passwordResetDone"
341+ | "builder.modulesHint"
342+ | "builder.editSchool"
343+ | "builder.editSchoolHint"
344+ | "builder.suspendHint"
345+ | "modules.subtitle"
346+ | "modules.readOnlyHint"
347+ | "modules.enabledCount"
348+ | "modules.enableAll"
349+ | "modules.disableAll"
350+ | "modules.requires"
351+ | "modules.on"
352+ | "modules.off"
353+ | "modules.conflictRequires"
354+ | "modules.conflictRequiredBy"
355+ | "module.appointments"
356+ | "module.attendance"
357+ | "module.bank_questions"
358+ | "module.boards"
359+ | "module.chatbot"
360+ | "module.classes"
361+ | "module.course_notes"
362+ | "module.courses"
363+ | "module.events"
364+ | "module.exams"
365+ | "module.homework"
366+ | "module.marks"
367+ | "module.meals"
368+ | "module.messages"
369+ | "module.notes"
370+ | "module.payments"
371+ | "module.pomodoro"
372+ | "module.questions"
373+ | "module.sessions"
374+ | "module.subjects"
375+ | "module.work"
376+ | "package.academics"
377+ | "package.ai"
378+ | "package.communication"
379+ | "package.operations"
308 | "nav.darkMode"380 | "nav.darkMode"
309 | "rightPanel.messagesTitle"381 | "rightPanel.messagesTitle"
310 | "rightPanel.calendarTitle"382 | "rightPanel.calendarTitle"
@@ -2015,6 +2087,78 @@ const en: Dict = {
2015 "comingSoon.description": "This module is on its way β€” there is nothing to show here yet.",2087 "comingSoon.description": "This module is on its way β€” there is nothing to show here yet.",
2016 "comingSoon.emptyTitle": "Not available yet",2088 "comingSoon.emptyTitle": "Not available yet",
2017 "comingSoon.emptyDescription": "This part of Hezarfen is still being built. Check back soon.",2089 "comingSoon.emptyDescription": "This part of Hezarfen is still being built. Check back soon.",
2090+ "builder.console": "Operator console",
2091+ "builder.logout": "Sign out",
2092+ "builder.loginTitle": "Operator sign-in",
2093+ "builder.loginSubtitle": "Manage the schools on this deployment.",
2094+ "builder.backToSchoolLogin": "Back to school sign-in",
2095+ "builder.operatorLogin": "Operator sign-in",
2096+ "builder.statusActive": "Active",
2097+ "builder.statusSuspended": "Suspended",
2098+ "builder.createSchool": "New school",
2099+ "builder.createSchoolHint": "Creates the school's database and its first admin in one step.",
2100+ "builder.slug": "School code",
2101+ "builder.slugHint": "Lowercase letters, digits and hyphens. Cannot be changed later.",
2102+ "builder.schoolName": "School name",
2103+ "builder.adminUsername": "Admin username",
2104+ "builder.adminPassword": "Admin password",
2105+ "builder.sellEverything": "Enable every module in the catalog",
2106+ "builder.schools": "Schools",
2107+ "builder.schoolsSubtitle": "Every school on this deployment",
2108+ "builder.status": "Status",
2109+ "builder.modules": "Modules",
2110+ "builder.createdAt": "Created",
2111+ "builder.suspend": "Suspend",
2112+ "builder.activate": "Activate",
2113+ "builder.noSchools": "No schools yet.",
2114+ "builder.deleteSchool": "Delete school",
2115+ "builder.deleteSchoolWarning": "All of this school's data and uploaded files are destroyed for good. This cannot be undone.",
2116+ "builder.enterSchool": "Enter school",
2117+ "builder.enterSchoolHint": "Signs this browser in as one of the school's admins for support. Your operator session ends.",
2118+ "builder.enterSuspendedHint": "A suspended school cannot be entered.",
2119+ "builder.resetAdminPassword": "Reset admin password",
2120+ "builder.resetAdminPasswordHint": "Sets a new password for an admin of this school and signs that account out everywhere.",
2121+ "builder.newPassword": "New password",
2122+ "builder.passwordResetDone": "Password reset. That admin's sessions were revoked.",
2123+ "builder.modulesHint": "Changes apply on the school's very next request.",
2124+ "builder.editSchool": "Edit school",
2125+ "builder.editSchoolHint": "Rename the school or change its status.",
2126+ "builder.suspendHint": "Suspension is immediate: every user of the school is refused, login included.",
2127+ "modules.subtitle": "The modules your school has, grouped by package.",
2128+ "modules.readOnlyHint": "Modules are enabled or disabled by your Hezarfen provider.",
2129+ "modules.enabledCount": "{on} of {total} enabled",
2130+ "modules.enableAll": "Enable all",
2131+ "modules.disableAll": "Disable all",
2132+ "modules.requires": "Requires",
2133+ "modules.on": "On",
2134+ "modules.conflictRequires": "{module} needs {needed}, which is not enabled.",
2135+ "modules.conflictRequiredBy": "{module} cannot be turned off: {dependents} depend on it.",
2136+ "modules.off": "Off",
2137+ "module.appointments": "Appointments",
2138+ "module.attendance": "Attendance",
2139+ "module.bank_questions": "Question bank",
2140+ "module.boards": "Board",
2141+ "module.chatbot": "Γ‡elebi assistant",
2142+ "module.classes": "Classes",
2143+ "module.course_notes": "Course notes",
2144+ "module.courses": "Courses",
2145+ "module.events": "Events",
2146+ "module.exams": "Exams",
2147+ "module.homework": "Homework",
2148+ "module.marks": "Marks",
2149+ "module.meals": "Meals",
2150+ "module.messages": "Messages",
2151+ "module.notes": "Notebook",
2152+ "module.payments": "Payments",
2153+ "module.pomodoro": "Pomodoro",
2154+ "module.questions": "Question pool",
2155+ "module.sessions": "Lesson sessions",
2156+ "module.subjects": "Subjects",
2157+ "module.work": "Shift",
2158+ "package.academics": "Academics",
2159+ "package.ai": "AI",
2160+ "package.communication": "Communication",
2161+ "package.operations": "Operations",
2018 "nav.darkMode": "Dark mode",2162 "nav.darkMode": "Dark mode",
2019 "parents.title": "My Students",2163 "parents.title": "My Students",
2020 "parents.subtitle": "Review academic records for the students linked to your account.",2164 "parents.subtitle": "Review academic records for the students linked to your account.",
@@ -3713,6 +3857,78 @@ const tr: Dict = {
3713 "comingSoon.description": "Bu modΓΌl hazΔ±rlanΔ±yor β€” henΓΌz gΓΆsterecek bir şey yok.",3857 "comingSoon.description": "Bu modΓΌl hazΔ±rlanΔ±yor β€” henΓΌz gΓΆsterecek bir şey yok.",
3714 "comingSoon.emptyTitle": "Henüz kullanıma açık değil",3858 "comingSoon.emptyTitle": "Henüz kullanıma açık değil",
3715 "comingSoon.emptyDescription": "Hezarfen'in bu bΓΆlΓΌmΓΌ hΓ’lΓ’ hazΔ±rlanΔ±yor. YakΔ±nda tekrar bakΔ±n.",3859 "comingSoon.emptyDescription": "Hezarfen'in bu bΓΆlΓΌmΓΌ hΓ’lΓ’ hazΔ±rlanΔ±yor. YakΔ±nda tekrar bakΔ±n.",
3860+ "builder.console": "OperatΓΆr konsolu",
3861+ "builder.logout": "Γ‡Δ±kış yap",
3862+ "builder.loginTitle": "Operatâr girişi",
3863+ "builder.loginSubtitle": "Bu kurulumdaki okullarΔ± yΓΆnet.",
3864+ "builder.backToSchoolLogin": "Okul girişine dân",
3865+ "builder.operatorLogin": "Operatâr girişi",
3866+ "builder.statusActive": "Aktif",
3867+ "builder.statusSuspended": "AskΔ±da",
3868+ "builder.createSchool": "Yeni okul",
3869+ "builder.createSchoolHint": "Okulun veritabanını ve ilk yâneticisini tek adımda oluşturur.",
3870+ "builder.slug": "Okul kodu",
3871+ "builder.slugHint": "Küçük harf, rakam ve tire. Sonradan değiştirilemez.",
3872+ "builder.schoolName": "Okul adΔ±",
3873+ "builder.adminUsername": "YΓΆnetici kullanΔ±cΔ± adΔ±",
3874+ "builder.adminPassword": "Yânetici şifresi",
3875+ "builder.sellEverything": "Katalogdaki tΓΌm modΓΌlleri aΓ§",
3876+ "builder.schools": "Okullar",
3877+ "builder.schoolsSubtitle": "Bu kurulumdaki tΓΌm okullar",
3878+ "builder.status": "Durum",
3879+ "builder.modules": "ModΓΌller",
3880+ "builder.createdAt": "Oluşturulma",
3881+ "builder.suspend": "AskΔ±ya al",
3882+ "builder.activate": "Aktifleştir",
3883+ "builder.noSchools": "HenΓΌz okul yok.",
3884+ "builder.deleteSchool": "Okulu sil",
3885+ "builder.deleteSchoolWarning": "Bu okulun tΓΌm verileri ve yΓΌklenen dosyalarΔ± kalΔ±cΔ± olarak silinir. Geri alΔ±namaz.",
3886+ "builder.enterSchool": "Okula gir",
3887+ "builder.enterSchoolHint": "Destek iΓ§in bu tarayΔ±cΔ±da okulun bir yΓΆneticisi olarak oturum aΓ§ar. OperatΓΆr oturumun kapanΔ±r.",
3888+ "builder.enterSuspendedHint": "AskΔ±daki bir okula girilemez.",
3889+ "builder.resetAdminPassword": "Yânetici şifresini sıfırla",
3890+ "builder.resetAdminPasswordHint": "Bu okulun bir yâneticisine yeni şifre verir ve o hesabın tüm oturumlarını kapatır.",
3891+ "builder.newPassword": "Yeni şifre",
3892+ "builder.passwordResetDone": "Şifre sıfırlandı. O yâneticinin oturumları kapatıldı.",
3893+ "builder.modulesHint": "Değişiklikler okulun bir sonraki isteğinde geçerli olur.",
3894+ "builder.editSchool": "Okulu dΓΌzenle",
3895+ "builder.editSchoolHint": "Okulun adını veya durumunu değiştir.",
3896+ "builder.suspendHint": "Askıya alma anında geçerlidir: okulun tüm kullanıcıları, giriş dahil, reddedilir.",
3897+ "modules.subtitle": "Okulunun sahip olduğu modüller, paketlere gâre.",
3898+ "modules.readOnlyHint": "Modüller Hezarfen sağlayıcın tarafından açılır veya kapatılır.",
3899+ "modules.enabledCount": "{total} modΓΌlden {on} aΓ§Δ±k",
3900+ "modules.enableAll": "Hepsini aΓ§",
3901+ "modules.disableAll": "Hepsini kapat",
3902+ "modules.requires": "Gerektirir",
3903+ "modules.on": "AΓ§Δ±k",
3904+ "modules.conflictRequires": "{module} iΓ§in {needed} aΓ§Δ±k olmalΔ±.",
3905+ "modules.conflictRequiredBy": "{module} kapatılamaz: {dependents} buna bağlı.",
3906+ "modules.off": "KapalΔ±",
3907+ "module.appointments": "Randevular",
3908+ "module.attendance": "Yoklama",
3909+ "module.bank_questions": "Soru bankasΔ±",
3910+ "module.boards": "Tahta",
3911+ "module.chatbot": "Γ‡elebi asistanΔ±",
3912+ "module.classes": "SΔ±nΔ±flar",
3913+ "module.course_notes": "Ders notlarΔ±",
3914+ "module.courses": "Dersler",
3915+ "module.events": "Etkinlikler",
3916+ "module.exams": "SΔ±navlar",
3917+ "module.homework": "Γ–devler",
3918+ "module.marks": "Notlar",
3919+ "module.meals": "Yemekler",
3920+ "module.messages": "Mesajlar",
3921+ "module.notes": "Defter",
3922+ "module.payments": "Γ–demeler",
3923+ "module.pomodoro": "Pomodoro",
3924+ "module.questions": "Soru havuzu",
3925+ "module.sessions": "Ders oturumlarΔ±",
3926+ "module.subjects": "Konular",
3927+ "module.work": "Mesai",
3928+ "package.academics": "Akademik",
3929+ "package.ai": "Yapay zekΓ’",
3930+ "package.communication": "İletişim",
3931+ "package.operations": "Operasyon",
3716 "nav.darkMode": "KaranlΔ±k mod",3932 "nav.darkMode": "KaranlΔ±k mod",
3717 "parents.title": "Γ–ΔŸrencilerim",3933 "parents.title": "Γ–ΔŸrencilerim",
3718 "parents.subtitle": "Size bağlı âğrencilerin akademik kayıtlarını inceleyin.",3934 "parents.subtitle": "Size bağlı âğrencilerin akademik kayıtlarını inceleyin.",
src/lib/module-labels.test.tsadded+22 -0
@@ -0,0 +1,22 @@
1+import { ApiError } from "@/api/client";
2+import { formatModuleError, moduleLabel } from "@/lib/module-labels";
3+
4+const t = (key: string, params?: Record<string, string>) =>
5+ params ? `${key}(${Object.entries(params).map(([k, v]) => `${k}=${v}`).join(",")})` : key;
6+
7+test("unknown modules fall back to their wire name", () => {
8+ expect(moduleLabel("kantin", t)).toBe("kantin");
9+ expect(moduleLabel("exams", t)).toBe("module.exams");
10+});
11+
12+test("a missing-requirement 409 names every violation with localized modules", () => {
13+ const err = new ApiError(409, "conflict: exams requires courses, which is not enabled; exams requires subjects, which is not enabled");
14+ expect(formatModuleError(err, t)).toBe(
15+ "modules.conflictRequires(module=module.exams,needed=module.courses) modules.conflictRequires(module=module.exams,needed=module.subjects)",
16+ );
17+});
18+
19+test("a required-by 409 lists the dependents", () => {
20+ const err = new ApiError(409, "courses is required by exams, subjects");
21+ expect(formatModuleError(err, t)).toBe("modules.conflictRequiredBy(module=module.courses,dependents=module.exams, module.subjects)");
22+});
src/lib/module-labels.tsadded+69 -0
@@ -0,0 +1,69 @@
1+import { ApiError, formatApiError } from "@/api/client";
2+import type { MessageKey } from "@/i18n/messages";
3+
4+type Translate = (key: MessageKey, params?: Record<string, string>) => string;
5+
6+const MODULE_KEYS: Record<string, MessageKey> = {
7+ appointments: "module.appointments",
8+ attendance: "module.attendance",
9+ bank_questions: "module.bank_questions",
10+ boards: "module.boards",
11+ chatbot: "module.chatbot",
12+ classes: "module.classes",
13+ course_notes: "module.course_notes",
14+ courses: "module.courses",
15+ events: "module.events",
16+ exams: "module.exams",
17+ homework: "module.homework",
18+ marks: "module.marks",
19+ meals: "module.meals",
20+ messages: "module.messages",
21+ notes: "module.notes",
22+ payments: "module.payments",
23+ pomodoro: "module.pomodoro",
24+ questions: "module.questions",
25+ sessions: "module.sessions",
26+ subjects: "module.subjects",
27+ work: "module.work",
28+};
29+
30+const PACKAGE_KEYS: Record<string, MessageKey> = {
31+ academics: "package.academics",
32+ ai: "package.ai",
33+ communication: "package.communication",
34+ operations: "package.operations",
35+};
36+
37+/** Localized module name; a module newer than this table falls back to its wire name. */
38+export function moduleLabel(module: string, t: Translate): string {
39+ const key = MODULE_KEYS[module];
40+ return key ? t(key) : module;
41+}
42+
43+export function packageLabel(pkg: string, t: Translate): string {
44+ const key = PACKAGE_KEYS[pkg];
45+ return key ? t(key) : pkg;
46+}
47+
48+/**
49+ * A module write refused with 409 names its broken dependencies in fixed
50+ * English (module.rs `validate`, builder.rs `refuse_if_needed`); render them
51+ * with localized module names instead of the generic error line.
52+ */
53+export function formatModuleError(err: unknown, t: Translate): string {
54+ if (err instanceof ApiError && err.status === 409) {
55+ const text = err.message.replace(/^conflict:\s*/i, "");
56+ const missing = [...text.matchAll(/([a-z_]+) requires ([a-z_]+), which is not enabled/g)];
57+ if (missing.length > 0) {
58+ return missing
59+ .map((match) => t("modules.conflictRequires", { module: moduleLabel(match[1], t), needed: moduleLabel(match[2], t) }))
60+ .join(" ");
61+ }
62+ const requiredBy = text.match(/^([a-z_]+) is required by ([a-z_, ]+)$/);
63+ if (requiredBy) {
64+ const dependents = requiredBy[2].split(",").map((name) => moduleLabel(name.trim(), t)).join(", ");
65+ return t("modules.conflictRequiredBy", { module: moduleLabel(requiredBy[1], t), dependents });
66+ }
67+ }
68+ return formatApiError(err);
69+}
src/pages/builder-login-page.tsxadded+123 -0
@@ -0,0 +1,123 @@
1+import { Link, Navigate, useNavigate } from "@tanstack/solid-router";
2+import { Show, createSignal } from "solid-js";
3+import { postBuilderLogin } from "@/api/builder";
4+import { ApiError, formatApiError, formatApiErrorMessage } from "@/api/client";
5+import { LogoMark } from "@/components/brand/logo-mark";
6+import { Button } from "@/components/ui/button";
7+import { Input } from "@/components/ui/input";
8+import { Label } from "@/components/ui/label";
9+import { PageSpinner } from "@/components/ui/page-spinner";
10+import { useAuth } from "@/stores/auth-context";
11+import { BuilderProvider, useBuilder } from "@/stores/builder-context";
12+import { useT } from "@/stores/preferences-context";
13+
14+// Backend BuilderCredentials bounds (hezarfen_backend src/web/builder.rs).
15+const MIN_USERNAME_LEN = 3;
16+const MAX_USERNAME_LEN = 32;
17+const MIN_PASSWORD_LEN = 6;
18+const MAX_PASSWORD_LEN = 128;
19+
20+export default function BuilderLoginPage() {
21+ return (
22+ <BuilderProvider>
23+ <BuilderLoginGate />
24+ </BuilderProvider>
25+ );
26+}
27+
28+function BuilderLoginGate() {
29+ const session = useBuilder();
30+ return (
31+ <Show when={!session.loading()} fallback={<PageSpinner />}>
32+ <Show when={!session.builder()} fallback={<Navigate to="/builder" />}>
33+ <BuilderLoginForm />
34+ </Show>
35+ </Show>
36+ );
37+}
38+
39+function BuilderLoginForm() {
40+ const auth = useAuth();
41+ const session = useBuilder();
42+ const navigate = useNavigate();
43+ const t = useT();
44+ const [username, setUsername] = createSignal("");
45+ const [password, setPassword] = createSignal("");
46+ const [error, setError] = createSignal("");
47+ const [pending, setPending] = createSignal(false);
48+
49+ const submit = async (event: SubmitEvent) => {
50+ event.preventDefault();
51+ setError("");
52+ setPending(true);
53+ try {
54+ await postBuilderLogin({ username: username().trim(), password: password() });
55+ // The builder cookie replaced any school session this browser held.
56+ await auth.refresh();
57+ session.refresh();
58+ void navigate({ to: "/builder" });
59+ } catch (err) {
60+ setError(
61+ err instanceof ApiError && err.status === 401
62+ ? formatApiErrorMessage("invalid credentials")
63+ : formatApiError(err),
64+ );
65+ } finally {
66+ setPending(false);
67+ }
68+ };
69+
70+ return (
71+ <div class="flex min-h-[70vh] items-center justify-center">
72+ <div class="w-full max-w-[420px] rounded-xl border border-border-line bg-surface-base px-6 pb-8 pt-9 shadow-[0_10px_24px_-4px_rgba(0,0,0,0.10)] sm:px-10">
73+ <div class="mb-8 text-center">
74+ <div class="mx-auto mb-5 flex h-12 w-12 items-center justify-center text-text-strong">
75+ <LogoMark size={44} />
76+ </div>
77+ <h1 class="text-2xl font-semibold tracking-[-0.025em] text-text-strong">{t("builder.loginTitle")}</h1>
78+ <p class="mt-2 text-sm text-text-subtle">{t("builder.loginSubtitle")}</p>
79+ </div>
80+ <form class="space-y-[18px]" onSubmit={submit}>
81+ <div class="space-y-2">
82+ <Label for="builder-username">{t("auth.username")}</Label>
83+ <Input
84+ id="builder-username"
85+ class="h-9"
86+ autocomplete="username"
87+ required
88+ minlength={MIN_USERNAME_LEN}
89+ maxlength={MAX_USERNAME_LEN}
90+ value={username()}
91+ onInput={(e) => setUsername(e.currentTarget.value)}
92+ />
93+ </div>
94+ <div class="space-y-2">
95+ <Label for="builder-password">{t("auth.password")}</Label>
96+ <Input
97+ id="builder-password"
98+ class="h-9"
99+ type="password"
100+ autocomplete="current-password"
101+ required
102+ minlength={MIN_PASSWORD_LEN}
103+ maxlength={MAX_PASSWORD_LEN}
104+ value={password()}
105+ onInput={(e) => setPassword(e.currentTarget.value)}
106+ />
107+ </div>
108+ <Show when={error()}>
109+ <p class="rounded-md bg-destructive/10 px-3 py-2 text-sm text-destructive">{error()}</p>
110+ </Show>
111+ <Button type="submit" class="h-9 w-full text-sm" disabled={pending()}>
112+ {t("auth.login")}
113+ </Button>
114+ </form>
115+ <p class="mt-8 border-t border-border-hairline pt-6 text-center text-sm text-text-subtle">
116+ <Link to="/login" class="font-semibold text-primary underline-offset-4 hover:underline">
117+ {t("builder.backToSchoolLogin")}
118+ </Link>
119+ </p>
120+ </div>
121+ </div>
122+ );
123+}
src/pages/builder-school-detail-page.tsxadded+254 -0
@@ -0,0 +1,254 @@
1+import { Show, Suspense, createEffect, createResource, createSignal } from "solid-js";
2+import { useNavigate, useParams } from "@tanstack/solid-router";
3+import { getModulesCatalog } from "@/api/modules";
4+import {
5+ deleteSchoolBySlug,
6+ deleteSchoolModule,
7+ getSchoolBySlug,
8+ getSchoolModules,
9+ patchSchoolBySlug,
10+ patchSchoolModules,
11+ postSchoolModule,
12+} from "@/api/schools";
13+import { formatApiError, type SchoolStatus } from "@/api/client";
14+import { PageHeader } from "@/components/layout/page-header";
15+import { BuilderGuard } from "@/components/builder/builder-guard";
16+import { BuilderHeader } from "@/components/builder/builder-header";
17+import { SchoolAdminAccessPanel, type AdminAccessMode } from "@/components/builder/school-admin-access-panel";
18+import { SchoolStatusBadge } from "@/components/builder/school-status-badge";
19+import { ModuleCatalogGrid } from "@/components/modules/module-catalog-grid";
20+import { formatModuleError } from "@/lib/module-labels";
21+import { Alert } from "@/components/ui/alert";
22+import { Button } from "@/components/ui/button";
23+import { ConfirmDialog } from "@/components/ui/confirm-dialog";
24+import { ErrorAlert } from "@/components/ui/error-alert";
25+import { IconEdit, IconExternalLink, IconLock, IconTrash } from "@/components/ui/icons";
26+import { Input } from "@/components/ui/input";
27+import { Label } from "@/components/ui/label";
28+import { PageSpinner } from "@/components/ui/page-spinner";
29+import { Select } from "@/components/ui/select";
30+import { SidePanel } from "@/components/ui/side-panel";
31+import { createFlash } from "@/lib/flash";
32+import { formatDateTime } from "@/lib/format";
33+import { useAuth } from "@/stores/auth-context";
34+import { BuilderProvider } from "@/stores/builder-context";
35+import { usePreferences, useT } from "@/stores/preferences-context";
36+
37+export default function BuilderSchoolDetailPage() {
38+ return (
39+ <BuilderProvider>
40+ <BuilderGuard>
41+ <BuilderSchoolDetailContent />
42+ </BuilderGuard>
43+ </BuilderProvider>
44+ );
45+}
46+
47+function BuilderSchoolDetailContent() {
48+ const t = useT();
49+ const { locale } = usePreferences();
50+ const auth = useAuth();
51+ const navigate = useNavigate();
52+ const params = useParams({ from: "/builder/schools/$slug" });
53+ const slug = () => params().slug;
54+
55+ const [school, { refetch: refetchSchool }] = createResource(slug, (value) => getSchoolBySlug(value));
56+ const [catalog] = createResource(() => getModulesCatalog());
57+ const [modules] = createResource(slug, (value) => getSchoolModules(value));
58+
59+ // The switchboard owns a local copy: each switch is one write whose response
60+ // is the school's whole new set, so there is nothing to refetch.
61+ const [enabled, setEnabled] = createSignal<string[]>([]);
62+ createEffect(() => {
63+ const value = modules();
64+ if (value) setEnabled(value.enabled);
65+ });
66+ const [modulesSaving, setModulesSaving] = createSignal(false);
67+ const [modulesError, setModulesError] = createSignal("");
68+
69+ const [editOpen, setEditOpen] = createSignal(false);
70+ const [name, setName] = createSignal("");
71+ const [status, setStatus] = createSignal<SchoolStatus>("active");
72+ const [editError, setEditError] = createSignal("");
73+ const [accessMode, setAccessMode] = createSignal<AdminAccessMode | null>(null);
74+ const [deleteOpen, setDeleteOpen] = createSignal(false);
75+ const [error, setError] = createSignal("");
76+ const [flash, setFlash] = createFlash();
77+
78+ const writeModules = async (write: () => Promise<{ enabled: string[] }>) => {
79+ if (modulesSaving()) return;
80+ setModulesSaving(true);
81+ setModulesError("");
82+ try {
83+ const next = await write();
84+ setEnabled(next.enabled);
85+ } catch (err) {
86+ // A 409 names the broken dependency; the switch stays where it was.
87+ setModulesError(formatModuleError(err, t));
88+ } finally {
89+ setModulesSaving(false);
90+ }
91+ };
92+
93+ const openEdit = () => {
94+ const current = school();
95+ if (!current) return;
96+ setName(current.name);
97+ setStatus(current.status);
98+ setEditError("");
99+ setEditOpen(true);
100+ };
101+
102+ const saveEdit = async (event: SubmitEvent) => {
103+ event.preventDefault();
104+ setEditError("");
105+ try {
106+ await patchSchoolBySlug(slug(), { name: name().trim(), status: status() });
107+ setEditOpen(false);
108+ await refetchSchool();
109+ setFlash(t("common.saved"));
110+ } catch (err) {
111+ setEditError(formatApiError(err));
112+ }
113+ };
114+
115+ return (
116+ <div class="space-y-6">
117+ <BuilderHeader />
118+ <Suspense fallback={<PageSpinner />}>
119+ <Show when={school.error}>
120+ <ErrorAlert message={formatApiError(school.error)} onRetry={() => void refetchSchool()} />
121+ </Show>
122+ <Show when={!school.error && school()}>
123+ {(current) => (
124+ <>
125+ <PageHeader
126+ eyebrow={t("builder.schools")}
127+ title={current().name}
128+ description={`${current().slug} Β· ${t("builder.createdAt")}: ${formatDateTime(current().created_at, locale())}`}
129+ actions={
130+ <div class="flex flex-wrap items-center gap-2">
131+ <SchoolStatusBadge status={current().status} />
132+ <Button type="button" variant="outline" size="sm" class="rounded-lg" onClick={openEdit}>
133+ <IconEdit class="h-4 w-4" />
134+ {t("common.edit")}
135+ </Button>
136+ <Button type="button" variant="outline" size="sm" class="rounded-lg" onClick={() => setAccessMode("password")}>
137+ <IconLock class="h-4 w-4" />
138+ {t("builder.resetAdminPassword")}
139+ </Button>
140+ <Button type="button" size="sm" class="rounded-lg" disabled={current().status === "suspended"} title={current().status === "suspended" ? t("builder.enterSuspendedHint") : undefined} onClick={() => setAccessMode("enter")}>
141+ <IconExternalLink class="h-4 w-4" />
142+ {t("builder.enterSchool")}
143+ </Button>
144+ <Button type="button" variant="destructive" size="sm" class="rounded-lg" onClick={() => setDeleteOpen(true)}>
145+ <IconTrash class="h-4 w-4" />
146+ {t("common.delete")}
147+ </Button>
148+ </div>
149+ }
150+ />
151+ <Show when={flash()}>
152+ <Alert variant="success">{flash()}</Alert>
153+ </Show>
154+ <Show when={error()}>
155+ <Alert variant="destructive">{error()}</Alert>
156+ </Show>
157+
158+ <section class="space-y-3">
159+ <div>
160+ <h2 class="font-semibold text-text-strong">{t("builder.modules")}</h2>
161+ <p class="text-sm text-text-subtle">{t("builder.modulesHint")}</p>
162+ </div>
163+ <Show when={modulesError()}>
164+ <Alert variant="destructive">{modulesError()}</Alert>
165+ </Show>
166+ <Show when={modules.error || catalog.error}>
167+ <ErrorAlert message={formatApiError(modules.error ?? catalog.error)} />
168+ </Show>
169+ <Show when={!modules.error && !catalog.error && catalog()}>
170+ {(value) => (
171+ <ModuleCatalogGrid
172+ catalog={value()}
173+ enabled={enabled()}
174+ disabled={modulesSaving()}
175+ onToggle={(module, next) =>
176+ void writeModules(() => (next ? postSchoolModule(slug(), module) : deleteSchoolModule(slug(), module)))
177+ }
178+ onTogglePackage={(pkg, next) =>
179+ void writeModules(() => patchSchoolModules(slug(), next ? { enable_packages: [pkg] } : { disable_packages: [pkg] }))
180+ }
181+ />
182+ )}
183+ </Show>
184+ </section>
185+ </>
186+ )}
187+ </Show>
188+ </Suspense>
189+
190+ <SidePanel open={editOpen()} onOpenChange={setEditOpen} title={t("builder.editSchool")} description={t("builder.editSchoolHint")}>
191+ <form class="space-y-4" onSubmit={saveEdit}>
192+ <Show when={editError()}>
193+ <Alert variant="destructive">{editError()}</Alert>
194+ </Show>
195+ <div class="space-y-1.5">
196+ <Label for="school-edit-name">{t("builder.schoolName")}</Label>
197+ <Input id="school-edit-name" class="rounded-lg" required maxlength={120} value={name()} onInput={(e) => setName(e.currentTarget.value)} />
198+ </div>
199+ <div class="space-y-1.5">
200+ <Label for="school-edit-status">{t("builder.status")}</Label>
201+ <Select id="school-edit-status" value={status()} onChange={(e) => setStatus(e.currentTarget.value as SchoolStatus)}>
202+ <option value="active">{t("builder.statusActive")}</option>
203+ <option value="suspended">{t("builder.statusSuspended")}</option>
204+ </Select>
205+ <p class="text-xs text-text-subtle">{t("builder.suspendHint")}</p>
206+ </div>
207+ <div class="flex flex-wrap items-center gap-2">
208+ <Button type="button" variant="outline" class="h-10 rounded-lg" onClick={() => setEditOpen(false)}>
209+ {t("common.cancel")}
210+ </Button>
211+ <Button type="submit" class="h-10 rounded-lg">
212+ {t("common.save")}
213+ </Button>
214+ </div>
215+ </form>
216+ </SidePanel>
217+
218+ <SchoolAdminAccessPanel
219+ slug={slug()}
220+ mode={accessMode()}
221+ onClose={() => setAccessMode(null)}
222+ onPasswordReset={() => {
223+ setAccessMode(null);
224+ setFlash(t("builder.passwordResetDone"));
225+ }}
226+ onEntered={async () => {
227+ setAccessMode(null);
228+ // The builder cookie is gone; this browser is now that admin.
229+ await auth.refresh();
230+ void navigate({ to: "/" });
231+ }}
232+ />
233+
234+ <ConfirmDialog
235+ open={deleteOpen()}
236+ onOpenChange={setDeleteOpen}
237+ title={t("builder.deleteSchool")}
238+ description={t("builder.deleteSchoolWarning")}
239+ variant="destructive"
240+ summary={school() ? `${school()!.name} Β· ${school()!.slug}` : ""}
241+ onConfirm={async () => {
242+ try {
243+ await deleteSchoolBySlug(slug());
244+ void navigate({ to: "/builder" });
245+ } catch (err) {
246+ setError(formatApiError(err));
247+ } finally {
248+ setDeleteOpen(false);
249+ }
250+ }}
251+ />
252+ </div>
253+ );
254+}
src/pages/builder-schools-page.tsxadded+175 -0
@@ -0,0 +1,175 @@
1+import { Show, Suspense, createMemo, createResource, createSignal } from "solid-js";
2+import { useNavigate } from "@tanstack/solid-router";
3+import type { ColumnDef } from "@tanstack/solid-table";
4+import { deleteSchoolBySlug, getSchools, patchSchoolBySlug } from "@/api/schools";
5+import { formatApiError, type School } from "@/api/client";
6+import { BuilderGuard } from "@/components/builder/builder-guard";
7+import { BuilderHeader } from "@/components/builder/builder-header";
8+import { CreateSchoolPanel } from "@/components/builder/create-school-panel";
9+import { SchoolStatusBadge } from "@/components/builder/school-status-badge";
10+import { Alert } from "@/components/ui/alert";
11+import { Button } from "@/components/ui/button";
12+import { ConfirmDialog } from "@/components/ui/confirm-dialog";
13+import { DataTable, DataTableSkeleton } from "@/components/ui/data-table";
14+import { ErrorAlert } from "@/components/ui/error-alert";
15+import { IconEye, IconLock, IconPlus, IconRotateCcw, IconTrash } from "@/components/ui/icons";
16+import { TableRowActions } from "@/components/ui/table-row-actions";
17+import { createFlash } from "@/lib/flash";
18+import { formatDateTime } from "@/lib/format";
19+import { BuilderProvider } from "@/stores/builder-context";
20+import { usePreferences, useT } from "@/stores/preferences-context";
21+
22+const SCHOOL_PAGE_SIZE = 15;
23+
24+export default function BuilderSchoolsPage() {
25+ return (
26+ <BuilderProvider>
27+ <BuilderGuard>
28+ <BuilderSchoolsContent />
29+ </BuilderGuard>
30+ </BuilderProvider>
31+ );
32+}
33+
34+function BuilderSchoolsContent() {
35+ const t = useT();
36+ const { locale } = usePreferences();
37+ const navigate = useNavigate();
38+ const [list, { refetch }] = createResource(async () => (await getSchools()).items);
39+ const [createOpen, setCreateOpen] = createSignal(false);
40+ const [deleteTarget, setDeleteTarget] = createSignal<School | null>(null);
41+ const [error, setError] = createSignal("");
42+ const [flash, setFlash] = createFlash();
43+
44+ const open = (school: School) => void navigate({ to: "/builder/schools/$slug", params: { slug: school.slug } });
45+
46+ const setStatus = async (school: School, status: School["status"]) => {
47+ setError("");
48+ try {
49+ await patchSchoolBySlug(school.slug, { status });
50+ await refetch();
51+ setFlash(t("common.saved"));
52+ } catch (err) {
53+ setError(formatApiError(err));
54+ }
55+ };
56+
57+ const columns = createMemo<ColumnDef<School>[]>(() => [
58+ {
59+ accessorKey: "name",
60+ header: t("builder.schoolName"),
61+ cell: (cell) => <span class="font-medium">{cell.row.original.name}</span>,
62+ },
63+ {
64+ accessorKey: "slug",
65+ header: t("builder.slug"),
66+ cell: (cell) => <span class="mono text-sm">{cell.row.original.slug}</span>,
67+ },
68+ {
69+ accessorKey: "status",
70+ header: t("builder.status"),
71+ cell: (cell) => <SchoolStatusBadge status={cell.row.original.status} />,
72+ },
73+ {
74+ id: "modules",
75+ header: t("builder.modules"),
76+ meta: { align: "right", cellClass: "mono tabular-nums" },
77+ cell: (cell) => cell.row.original.modules.length,
78+ },
79+ {
80+ accessorKey: "created_at",
81+ header: t("builder.createdAt"),
82+ cell: (cell) => <span class="mono text-sm">{formatDateTime(cell.row.original.created_at, locale())}</span>,
83+ },
84+ {
85+ id: "actions",
86+ header: t("common.actions"),
87+ meta: { headerClass: "w-[110px] min-w-[110px] max-w-[110px] h-[45px] text-center whitespace-nowrap" },
88+ cell: (cell) => (
89+ <TableRowActions
90+ label={t("common.actions")}
91+ actions={[
92+ { label: t("common.view"), icon: <IconEye class="h-4 w-4" />, onSelect: () => open(cell.row.original) },
93+ cell.row.original.status === "active"
94+ ? { label: t("builder.suspend"), icon: <IconLock class="h-4 w-4" />, onSelect: () => void setStatus(cell.row.original, "suspended") }
95+ : { label: t("builder.activate"), icon: <IconRotateCcw class="h-4 w-4" />, onSelect: () => void setStatus(cell.row.original, "active") },
96+ { label: t("common.delete"), icon: <IconTrash class="h-4 w-4" />, destructive: true, onSelect: () => setDeleteTarget(cell.row.original) },
97+ ]}
98+ />
99+ ),
100+ },
101+ ]);
102+
103+ return (
104+ <div class="space-y-6">
105+ <BuilderHeader />
106+ <Show when={flash()}>
107+ <Alert variant="success">{flash()}</Alert>
108+ </Show>
109+ <Show when={error()}>
110+ <Alert variant="destructive">{error()}</Alert>
111+ </Show>
112+
113+ <section class="data-shell space-y-4 p-4">
114+ <Suspense fallback={<DataTableSkeleton columns={5} rows={6} />}>
115+ <Show when={list.error}>
116+ <ErrorAlert message={formatApiError(list.error)} onRetry={() => void refetch()} />
117+ </Show>
118+ <Show when={!list.error}>
119+ <DataTable
120+ title={t("builder.schools")}
121+ description={t("builder.schoolsSubtitle")}
122+ actions={
123+ <Button type="button" size="sm" class="min-w-[7.5rem] rounded-lg" onClick={() => setCreateOpen(true)}>
124+ <IconPlus class="h-4 w-4" />
125+ {t("builder.createSchool")}
126+ </Button>
127+ }
128+ columns={columns()}
129+ data={list() ?? []}
130+ tableClass="min-w-176"
131+ empty={t("builder.noSchools")}
132+ filterColumn="name"
133+ enablePagination
134+ pageSize={SCHOOL_PAGE_SIZE}
135+ onRowClick={open}
136+ />
137+ </Show>
138+ </Suspense>
139+ </section>
140+
141+ <CreateSchoolPanel
142+ open={createOpen()}
143+ onOpenChange={setCreateOpen}
144+ onCreated={(school) => {
145+ setCreateOpen(false);
146+ setFlash(t("common.created"));
147+ void refetch();
148+ open(school);
149+ }}
150+ />
151+
152+ <ConfirmDialog
153+ open={deleteTarget() != null}
154+ onOpenChange={(value) => !value && setDeleteTarget(null)}
155+ title={t("builder.deleteSchool")}
156+ description={t("builder.deleteSchoolWarning")}
157+ variant="destructive"
158+ summary={deleteTarget() ? `${deleteTarget()!.name} Β· ${deleteTarget()!.slug}` : ""}
159+ onConfirm={async () => {
160+ const school = deleteTarget();
161+ if (!school) return;
162+ try {
163+ await deleteSchoolBySlug(school.slug);
164+ await refetch();
165+ setFlash(t("common.deleted"));
166+ } catch (err) {
167+ setError(formatApiError(err));
168+ } finally {
169+ setDeleteTarget(null);
170+ }
171+ }}
172+ />
173+ </div>
174+ );
175+}
src/pages/coming-soon-page.tsxmodified+0 -4
@@ -18,7 +18,6 @@ const COMING_SOON_LABELS: Record<string, MessageKey> = {
18 "deneme-sinavlari": "nav.mockExams",18 "deneme-sinavlari": "nav.mockExams",
19 "optik-okuma": "nav.opticalReading",19 "optik-okuma": "nav.opticalReading",
20 raporlar: "nav.reports",20 raporlar: "nav.reports",
21- "lisans-modulleri": "nav.licenseModules",
22 "kvkk-denetim": "nav.dataProtection",21 "kvkk-denetim": "nav.dataProtection",
23 ogrenciler: "nav.studentsRoster",22 ogrenciler: "nav.studentsRoster",
24 ogretmenler: "nav.teachersRoster",23 ogretmenler: "nav.teachersRoster",
@@ -26,9 +25,6 @@ const COMING_SOON_LABELS: Record<string, MessageKey> = {
26 "bekleyen-onaylar": "nav.pendingApprovals",25 "bekleyen-onaylar": "nav.pendingApprovals",
27 "soru-uretimi": "nav.questionGeneration",26 "soru-uretimi": "nav.questionGeneration",
28 "calisma-programim": "nav.studyPlan",27 "calisma-programim": "nav.studyPlan",
29- devamsizlik: "nav.absence",
30- "sinav-sonuclari-veli": "nav.childExamResults",
31- "calisma-plani": "nav.childStudyPlan",
32 };28 };
33 29
34 export default function ComingSoonPage() {30 export default function ComingSoonPage() {
src/pages/dashboard-page.test.tsxmodified+4 -0
@@ -35,6 +35,10 @@ const DAY = 24 * 60 * 60 * 1000;
35 const page = <T,>(items: T[]) => ({ items, total: items.length, limit: 50, offset: 0 });35 const page = <T,>(items: T[]) => ({ items, total: items.length, limit: 50, offset: 0 });
36 const course = { id: "course-1", title: "Algebra", capacity: 24 };36 const course = { id: "course-1", title: "Algebra", capacity: 24 };
37 37
38+vi.mock("@/stores/modules-context", () => ({
39+ useModules: () => ({ enabled: () => null, isEnabled: () => true, refresh: () => {} }),
40+}));
41+vi.mock("@/api/modules", () => ({ getModulesCatalog: async () => ({ modules: [], packages: [] }) }));
38 vi.mock("@/api/time/getTime", () => ({ getTime: async () => ({ now }) }));42 vi.mock("@/api/time/getTime", () => ({ getTime: async () => ({ now }) }));
39 vi.mock("@/api/courses", () => ({43 vi.mock("@/api/courses", () => ({
40 getCourses: async () => page([course]),44 getCourses: async () => page([course]),
src/pages/dashboard-page.tsxmodified+32 -1
@@ -37,6 +37,7 @@ import {
37 IconSearch,37 IconSearch,
38 IconUsers,38 IconUsers,
39 IconUtensils,39 IconUtensils,
40+ IconPackage,
40 } from "@/components/ui/icons";41 } from "@/components/ui/icons";
41 import { PageSpinner } from "@/components/ui/page-spinner";42 import { PageSpinner } from "@/components/ui/page-spinner";
42 import type { MessageKey } from "@/i18n/messages";43 import type { MessageKey } from "@/i18n/messages";
@@ -44,7 +45,10 @@ import { cn } from "@/lib/cn";
44 import { formatDateTime } from "@/lib/format";45 import { formatDateTime } from "@/lib/format";
45 import { formatTry } from "@/lib/meals";46 import { formatTry } from "@/lib/meals";
46 import { personLabel } from "@/lib/person";47 import { personLabel } from "@/lib/person";
48+import { packageLabel } from "@/lib/module-labels";
47 import { hasMinRole } from "@/lib/roles";49 import { hasMinRole } from "@/lib/roles";
50+import { getModulesCatalog } from "@/api/modules";
51+import { useModules } from "@/stores/modules-context";
48 import { useAuth } from "@/stores/auth-context";52 import { useAuth } from "@/stores/auth-context";
49 import { usePreferences, useT } from "@/stores/preferences-context";53 import { usePreferences, useT } from "@/stores/preferences-context";
50 54
@@ -310,6 +314,28 @@ function DashboardContent() {
310 })),314 })),
311 );315 );
312 316
317+ // The school's own entitlements per package: the catalog is deploy-constant,
318+ // the enabled set is already in the shell's modules context.
319+ const schoolModules = useModules();
320+ const [moduleCatalog] = createResource(
321+ () => (isAdminHome() ? true : null),
322+ () => getModulesCatalog().catch(() => null),
323+ );
324+ const moduleQuickLinks = createMemo<QuickLinkRow[]>(() => {
325+ const catalog = moduleCatalog();
326+ const enabled = schoolModules.enabled();
327+ if (!catalog || !enabled) return [];
328+ return catalog.packages.map((pkg) => {
329+ const on = pkg.modules.filter((module) => enabled.includes(module));
330+ return {
331+ id: pkg.package,
332+ primary: packageLabel(pkg.package, t),
333+ secondary: `${on.length}/${pkg.modules.length}`,
334+ Icon: IconPackage,
335+ };
336+ });
337+ });
338+
313 // Hero search. `/users/search` is the only search endpoint the app has, so339 // Hero search. `/users/search` is the only search endpoint the app has, so
314 // this box only ever finds students β€” it never claims to search classes,340 // this box only ever finds students β€” it never claims to search classes,
315 // exams, or modules the way the Figma copy does.341 // exams, or modules the way the Figma copy does.
@@ -685,7 +711,12 @@ function DashboardContent() {
685 empty={t("dashboard.quicklinks.empty")}711 empty={t("dashboard.quicklinks.empty")}
686 onOpen={(row) => navigate({ to: "/management/classes/$id", params: { id: row.id } })}712 onOpen={(row) => navigate({ to: "/management/classes/$id", params: { id: row.id } })}
687 />713 />
688- <ComingSoonPanel class="text-left" title={t("dashboard.quicklinks.modules")} />714+ <QuickLinkColumn
715+ title={t("dashboard.quicklinks.modules")}
716+ rows={moduleQuickLinks()}
717+ empty={t("dashboard.quicklinks.empty")}
718+ onOpen={() => navigate({ to: "/management/modules" })}
719+ />
689 </div>720 </div>
690 </header>721 </header>
691 </Show>722 </Show>
src/pages/license-modules-page.tsxadded+43 -0
@@ -0,0 +1,43 @@
1+import { Show, Suspense, createResource } from "solid-js";
2+import { getModules, getModulesCatalog } from "@/api/modules";
3+import { formatApiError } from "@/api/client";
4+import { PageHeader } from "@/components/layout/page-header";
5+import { RouteGuard } from "@/components/layout/route-guard";
6+import { ModuleCatalogGrid } from "@/components/modules/module-catalog-grid";
7+import { Alert } from "@/components/ui/alert";
8+import { ErrorAlert } from "@/components/ui/error-alert";
9+import { PageSpinner } from "@/components/ui/page-spinner";
10+import { useT } from "@/stores/preferences-context";
11+
12+export default function LicenseModulesPage() {
13+ return (
14+ <RouteGuard minRole="admin">
15+ <LicenseModulesContent />
16+ </RouteGuard>
17+ );
18+}
19+
20+// Read-only: a school sees what it bought. Selling a module is the operator's
21+// act on the builder surface (/builder), never a school admin's.
22+function LicenseModulesContent() {
23+ const t = useT();
24+ const [data, { refetch }] = createResource(async () => {
25+ const [catalog, mine] = await Promise.all([getModulesCatalog(), getModules()]);
26+ return { catalog, enabled: mine.enabled };
27+ });
28+
29+ return (
30+ <div class="space-y-6">
31+ <PageHeader eyebrow={t("nav.group.institution")} title={t("nav.licenseModules")} description={t("modules.subtitle")} />
32+ <Alert variant="info">{t("modules.readOnlyHint")}</Alert>
33+ <Suspense fallback={<PageSpinner />}>
34+ <Show when={data.error}>
35+ <ErrorAlert message={formatApiError(data.error)} onRetry={() => void refetch()} />
36+ </Show>
37+ <Show when={!data.error && data()}>
38+ {(value) => <ModuleCatalogGrid catalog={value().catalog} enabled={value().enabled} />}
39+ </Show>
40+ </Suspense>
41+ </div>
42+ );
43+}
src/pages/login-page.tsxmodified+5 -0
@@ -154,6 +154,11 @@ function LoginForm() {
154 {t("auth.register")}154 {t("auth.register")}
155 </Link>155 </Link>
156 </p>156 </p>
157+ <p class="mt-3 text-center text-xs text-text-subtle">
158+ <Link to="/builder/login" class="underline-offset-4 hover:text-foreground hover:underline">
159+ {t("builder.operatorLogin")}
160+ </Link>
161+ </p>
157 </div>162 </div>
158 </div>163 </div>
159 );164 );
src/pages/my-students-page.tsxmodified+61 -11
@@ -1,27 +1,39 @@
1 import { For, Match, Show, Suspense, Switch, createEffect, createMemo, createResource, createSignal, type Component } from "solid-js";1 import { For, Match, Show, Suspense, Switch, createEffect, createMemo, createResource, createSignal, type Component } from "solid-js";
2-import { useNavigate } from "@tanstack/solid-router";2+import { useLocation, useNavigate } from "@tanstack/solid-router";
3 import type { ColumnDef } from "@tanstack/solid-table";3 import type { ColumnDef } from "@tanstack/solid-table";
4 import { getClassesByUserId } from "@/api/classes";4 import { getClassesByUserId } from "@/api/classes";
5 import { getMyStudents } from "@/api/parents";5 import { getMyStudents } from "@/api/parents";
6+import { getPomodoroByUser } from "@/api/pomodoro";
6 import { getUserMarks } from "@/api/reports";7 import { getUserMarks } from "@/api/reports";
7 import { getUserAttendance } from "@/api/reports";8 import { getUserAttendance } from "@/api/reports";
8-import type { MarksReport, PersonRef } from "@/api/client";9+import { formatApiError, type MarksReport, type PersonRef } from "@/api/client";
9 import { HomeworkReportView } from "@/components/homework/homework-report-view";10 import { HomeworkReportView } from "@/components/homework/homework-report-view";
10 import { RouteGuard } from "@/components/layout/route-guard";11 import { RouteGuard } from "@/components/layout/route-guard";
11 import { PageHeader } from "@/components/layout/page-header";12 import { PageHeader } from "@/components/layout/page-header";
12 import { EmptyState } from "@/components/ui/empty-state";13 import { EmptyState } from "@/components/ui/empty-state";
14+import { ErrorAlert } from "@/components/ui/error-alert";
13 import { PageSpinner } from "@/components/ui/page-spinner";15 import { PageSpinner } from "@/components/ui/page-spinner";
14 import { SidePanel } from "@/components/ui/side-panel";16 import { SidePanel } from "@/components/ui/side-panel";
15 import { Button } from "@/components/ui/button";17 import { Button } from "@/components/ui/button";
16 import { DataTable, DataTableEmpty } from "@/components/ui/data-table";18 import { DataTable, DataTableEmpty } from "@/components/ui/data-table";
17 import { personLabel } from "@/lib/person";19 import { personLabel } from "@/lib/person";
18 import { useT } from "@/stores/preferences-context";20 import { useT } from "@/stores/preferences-context";
19-import { IconChart, IconChevronRight, IconClipboardCheck, IconExam, IconExternalLink, IconHomework, IconMessage } from "@/components/ui/icons";21+import { IconChart, IconChevronRight, IconClipboardCheck, IconClock, IconExam, IconExternalLink, IconHomework, IconMessage } from "@/components/ui/icons";
20 import { MarksReportView } from "@/components/marks/marks-report-view";22 import { MarksReportView } from "@/components/marks/marks-report-view";
21 import { AttendanceReportView } from "@/components/attendance/attendance-report-view";23 import { AttendanceReportView } from "@/components/attendance/attendance-report-view";
24+import { PomodoroLogView } from "@/components/pomodoro/pomodoro-log-view";
25+import { useModules } from "@/stores/modules-context";
22 import { examKindLabel } from "@/lib/exam-labels";26 import { examKindLabel } from "@/lib/exam-labels";
23 27
24-type StudentTab = "marks" | "attendance" | "exams" | "homework";28+type StudentTab = "marks" | "attendance" | "exams" | "homework" | "study";
29+
30+// /students opens a child on the progress report; the parent sidebar's
31+// DevamsΔ±zlΔ±k / SΔ±nav sonuΓ§larΔ± / Γ‡alışma planΔ± entries are the same page
32+// landing on another tab (/students/attendance, /students/exams, /students/study).
33+function tabFromPath(pathname: string): StudentTab {
34+ const segment = pathname.split("/")[2];
35+ return segment === "attendance" || segment === "exams" || segment === "study" ? segment : "marks";
36+}
25 type CourseRow = MarksReport["courses"][number];37 type CourseRow = MarksReport["courses"][number];
26 type ExamRow = CourseRow["results"][number] & { courseTitle: string };38 type ExamRow = CourseRow["results"][number] & { courseTitle: string };
27 39
@@ -41,7 +53,18 @@ export default function MyStudentsPage() {
41 function MyStudentsContent() {53 function MyStudentsContent() {
42 const t = useT();54 const t = useT();
43 const [list] = createResource(async () => (await getMyStudents()).items);55 const [list] = createResource(async () => (await getMyStudents()).items);
56+ const location = useLocation();
44 const [selectedStudent, setSelectedStudent] = createSignal<PersonRef | null>(null);57 const [selectedStudent, setSelectedStudent] = createSignal<PersonRef | null>(null);
58+ const routeTab = () => tabFromPath(location().pathname);
59+ // A parent with a single linked child has nothing to pick: open that child
60+ // once, so a sidebar tab entry lands straight on its data.
61+ let autoOpened = false;
62+ createEffect(() => {
63+ const items = list();
64+ if (autoOpened || !items || items.length !== 1) return;
65+ autoOpened = true;
66+ setSelectedStudent(items[0]);
67+ });
45 68
46 return (69 return (
47 <div class="space-y-6">70 <div class="space-y-6">
@@ -73,14 +96,15 @@ function MyStudentsContent() {
73 </Show>96 </Show>
74 </Suspense>97 </Suspense>
75 98
76- <StudentDetailPanel student={selectedStudent()} onClose={() => setSelectedStudent(null)} />99+ <StudentDetailPanel student={selectedStudent()} initialTab={routeTab()} onClose={() => setSelectedStudent(null)} />
77 </div>100 </div>
78 );101 );
79 }102 }
80 103
81-function StudentDetailPanel(props: { student: PersonRef | null; onClose: () => void }) {104+function StudentDetailPanel(props: { student: PersonRef | null; initialTab: StudentTab; onClose: () => void }) {
82 const t = useT();105 const t = useT();
83 const navigate = useNavigate();106 const navigate = useNavigate();
107+ const modules = useModules();
84 const [activeTab, setActiveTab] = createSignal<StudentTab>("marks");108 const [activeTab, setActiveTab] = createSignal<StudentTab>("marks");
85 109
86 const [marksRes] = createResource(110 const [marksRes] = createResource(
@@ -99,8 +123,24 @@ function StudentDetailPanel(props: { student: PersonRef | null; onClose: () => v
99 );123 );
100 const studentClass = () => classesRes()?.[0] ?? null;124 const studentClass = () => classesRes()?.[0] ?? null;
101 125
126+ // Fetched only once the tab is opened: the pomodoro nest can be switched
127+ // off per school, and the other tabs must not pay for it.
128+ const [studyError, setStudyError] = createSignal("");
129+ const [pomodoroRes] = createResource(
130+ () => (activeTab() === "study" ? props.student?.id : undefined),
131+ async (id) => {
132+ setStudyError("");
133+ try {
134+ return await getPomodoroByUser(id, { limit: 50 });
135+ } catch (err) {
136+ setStudyError(formatApiError(err));
137+ return null;
138+ }
139+ },
140+ );
141+
102 createEffect(() => {142 createEffect(() => {
103- if (props.student?.id) setActiveTab("marks");143+ if (props.student?.id) setActiveTab(props.initialTab);
104 });144 });
105 145
106 const report = () => marksRes() ?? null;146 const report = () => marksRes() ?? null;
@@ -147,12 +187,13 @@ function StudentDetailPanel(props: { student: PersonRef | null; onClose: () => v
147 // Ordered to match the Figma per-child screen set (Gelişim raporu β†’187 // Ordered to match the Figma per-child screen set (Gelişim raporu β†’
148 // DevamsΔ±zlΔ±k β†’ SΔ±nav sonuΓ§larΔ±); "Γ–devler" has no Figma screen of its own188 // DevamsΔ±zlΔ±k β†’ SΔ±nav sonuΓ§larΔ±); "Γ–devler" has no Figma screen of its own
149 // but is kept β€” real, working functionality with nowhere else to live.189 // but is kept β€” real, working functionality with nowhere else to live.
150- const tabs: Array<{ key: StudentTab; icon: Component<{ class?: string }>; label: string }> = [190+ const tabs = createMemo<Array<{ key: StudentTab; icon: Component<{ class?: string }>; label: string }>>(() => [
151 { key: "marks", icon: IconChart, label: t("nav.progressReport") },191 { key: "marks", icon: IconChart, label: t("nav.progressReport") },
152 { key: "attendance", icon: IconClipboardCheck, label: t("nav.attendance") },192 { key: "attendance", icon: IconClipboardCheck, label: t("nav.attendance") },
153- { key: "exams", icon: IconExam, label: t("nav.examResults") },193+ { key: "exams", icon: IconExam, label: t("nav.childExamResults") },
154 { key: "homework", icon: IconHomework, label: t("nav.homework") },194 { key: "homework", icon: IconHomework, label: t("nav.homework") },
155- ];195+ ...(modules.isEnabled("pomodoro") ? [{ key: "study" as const, icon: IconClock, label: t("nav.childStudyPlan") }] : []),
196+ ]);
156 197
157 return (198 return (
158 <SidePanel open={!!props.student} onOpenChange={(open) => !open && props.onClose()} title={props.student ? personLabel(props.student) : ""} description={`@${props.student?.username}`}>199 <SidePanel open={!!props.student} onOpenChange={(open) => !open && props.onClose()} title={props.student ? personLabel(props.student) : ""} description={`@${props.student?.username}`}>
@@ -198,7 +239,7 @@ function StudentDetailPanel(props: { student: PersonRef | null; onClose: () => v
198 </Button>239 </Button>
199 </div>240 </div>
200 <div class="flex flex-wrap gap-2">241 <div class="flex flex-wrap gap-2">
201- <For each={tabs}>242+ <For each={tabs()}>
202 {(tab) => {243 {(tab) => {
203 const Icon = tab.icon;244 const Icon = tab.icon;
204 return (245 return (
@@ -233,6 +274,15 @@ function StudentDetailPanel(props: { student: PersonRef | null; onClose: () => v
233 </Show>274 </Show>
234 </Match>275 </Match>
235 276
277+ <Match when={activeTab() === "study"}>
278+ <Show when={studyError()}>
279+ <ErrorAlert message={studyError()} />
280+ </Show>
281+ <Show when={pomodoroRes()}>
282+ {(log) => <PomodoroLogView log={log()} />}
283+ </Show>
284+ </Match>
285+
236 <Match when={activeTab() === "attendance"}>286 <Match when={activeTab() === "attendance"}>
237 <Show when={attendanceRes()} fallback={<PageSpinner />}>287 <Show when={attendanceRes()} fallback={<PageSpinner />}>
238 <AttendanceReportView report={attendanceRes()!} />288 <AttendanceReportView report={attendanceRes()!} />
src/pages/student-pomodoro-page.tsxmodified+4 -30
@@ -2,18 +2,18 @@ import { Show, createMemo, createResource, createSignal } from "solid-js";
2 import type { ColumnDef } from "@tanstack/solid-table";2 import type { ColumnDef } from "@tanstack/solid-table";
3 import { getPomodoroByUser } from "@/api/pomodoro";3 import { getPomodoroByUser } from "@/api/pomodoro";
4 import { getUserSearch } from "@/api/users";4 import { getUserSearch } from "@/api/users";
5-import type { PersonRef, PomodoroSession } from "@/api/client";5+import type { PersonRef } from "@/api/client";
6 import { ApiError, formatApiError } from "@/api/client";6 import { ApiError, formatApiError } from "@/api/client";
7 import { RouteGuard } from "@/components/layout/route-guard";7 import { RouteGuard } from "@/components/layout/route-guard";
8+import { PomodoroLogView } from "@/components/pomodoro/pomodoro-log-view";
8 import { Alert } from "@/components/ui/alert";9 import { Alert } from "@/components/ui/alert";
9 import { DataTable, DataTableSkeleton } from "@/components/ui/data-table";10 import { DataTable, DataTableSkeleton } from "@/components/ui/data-table";
10 import { ErrorAlert } from "@/components/ui/error-alert";11 import { ErrorAlert } from "@/components/ui/error-alert";
11 import { IconEye } from "@/components/ui/icons";12 import { IconEye } from "@/components/ui/icons";
12 import { SidePanel } from "@/components/ui/side-panel";13 import { SidePanel } from "@/components/ui/side-panel";
13 import { TableRowActions } from "@/components/ui/table-row-actions";14 import { TableRowActions } from "@/components/ui/table-row-actions";
14-import { formatDateTime, formatDurationClock } from "@/lib/format";
15 import { personLabel } from "@/lib/person";15 import { personLabel } from "@/lib/person";
16-import { usePreferences, useT } from "@/stores/preferences-context";16+import { useT } from "@/stores/preferences-context";
17 17
18 const PAGE_SIZE = 10;18 const PAGE_SIZE = 10;
19 19
@@ -27,7 +27,6 @@ export default function StudentPomodoroPage() {
27 27
28 function StudentPomodoroContent() {28 function StudentPomodoroContent() {
29 const t = useT();29 const t = useT();
30- const { locale } = usePreferences();
31 const [viewUser, setViewUser] = createSignal<PersonRef | null>(null);30 const [viewUser, setViewUser] = createSignal<PersonRef | null>(null);
32 const [error, setError] = createSignal("");31 const [error, setError] = createSignal("");
33 32
@@ -98,23 +97,6 @@ function StudentPomodoroContent() {
98 ),97 ),
99 },98 },
100 ]);99 ]);
101- const logColumns = createMemo<ColumnDef<PomodoroSession>[]>(() => [
102- {
103- accessorKey: "started_at",
104- header: t("pomodoro.startedAt"),
105- cell: (cell) => <span class="mono whitespace-nowrap">{formatDateTime(cell.row.original.started_at, locale())}</span>,
106- },
107- {
108- accessorKey: "finished_at",
109- header: t("pomodoro.finishedAt"),
110- cell: (cell) => <span class="mono whitespace-nowrap">{formatDateTime(cell.row.original.finished_at, locale())}</span>,
111- },
112- {
113- accessorKey: "duration_ms",
114- header: t("pomodoro.duration"),
115- cell: (cell) => <span class="mono tabular-nums">{formatDurationClock(cell.row.original.duration_ms)}</span>,
116- },
117- ]);
118 100
119 return (101 return (
120 <div class="space-y-6">102 <div class="space-y-6">
@@ -163,15 +145,7 @@ function StudentPomodoroContent() {
163 <p class="text-sm text-muted-foreground">{t("common.loading")}</p>145 <p class="text-sm text-muted-foreground">{t("common.loading")}</p>
164 </Show>146 </Show>
165 <Show when={log()}>147 <Show when={log()}>
166- {(p) => (148+ {(p) => <PomodoroLogView log={p()} />}
167- <div class="space-y-4">
168- <div class="detail-metric-card">
169- <p class="text-xs font-medium uppercase tracking-[0.08em] text-muted-foreground">{t("pomodoro.total")}</p>
170- <p class="mono mt-2 text-3xl font-semibold tabular-nums">{formatDurationClock(p().total_focus_ms)}</p>
171- </div>
172- <DataTable columns={logColumns()} data={p().items} empty={t("pomodoro.empty")} enablePagination pageSize={10} />
173- </div>
174- )}
175 </Show>149 </Show>
176 </div>150 </div>
177 </SidePanel>151 </SidePanel>
src/pages/work-log-page.tsxmodified+1 -1
@@ -22,7 +22,7 @@ const WORK_PAGE_SIZE = 15;
22 22
23 export default function WorkLogPage() {23 export default function WorkLogPage() {
24 return (24 return (
25- <RouteGuard minRole="teacher" maxRole="manager">25+ <RouteGuard minRole="teacher">
26 <WorkLogContent />26 <WorkLogContent />
27 </RouteGuard>27 </RouteGuard>
28 );28 );
src/routes/router.tsxmodified+55 -4
@@ -68,6 +68,10 @@ const PaymentStatementPage = lazyRoute(() => import("@/pages/payment-statement-p
68 const WhiteboardsPage = lazyRoute(() => import("@/pages/whiteboards-page"));68 const WhiteboardsPage = lazyRoute(() => import("@/pages/whiteboards-page"));
69 const WhiteboardPage = lazyRoute(() => import("@/pages/whiteboard-page"));69 const WhiteboardPage = lazyRoute(() => import("@/pages/whiteboard-page"));
70 const ComingSoonPage = lazyRoute(() => import("@/pages/coming-soon-page"));70 const ComingSoonPage = lazyRoute(() => import("@/pages/coming-soon-page"));
71+const LicenseModulesPage = lazyRoute(() => import("@/pages/license-modules-page"));
72+const BuilderLoginPage = lazyRoute(() => import("@/pages/builder-login-page"));
73+const BuilderSchoolsPage = lazyRoute(() => import("@/pages/builder-schools-page"));
74+const BuilderSchoolDetailPage = lazyRoute(() => import("@/pages/builder-school-detail-page"));
71 75
72 function RootComponent() {76 function RootComponent() {
73 return (77 return (
@@ -325,6 +329,24 @@ const myStudentsRoute = createRoute({
325 component: MyStudentsPage,329 component: MyStudentsPage,
326 });330 });
327 331
332+const myStudentsAttendanceRoute = createRoute({
333+ getParentRoute: () => rootRoute,
334+ path: "/students/attendance",
335+ component: MyStudentsPage,
336+});
337+
338+const myStudentsExamsRoute = createRoute({
339+ getParentRoute: () => rootRoute,
340+ path: "/students/exams",
341+ component: MyStudentsPage,
342+});
343+
344+const myStudentsStudyRoute = createRoute({
345+ getParentRoute: () => rootRoute,
346+ path: "/students/study",
347+ component: MyStudentsPage,
348+});
349+
328 const questionsRoute = createRoute({350 const questionsRoute = createRoute({
329 getParentRoute: () => rootRoute,351 getParentRoute: () => rootRoute,
330 path: "/questions",352 path: "/questions",
@@ -391,6 +413,32 @@ const whiteboardRoute = createRoute({
391 component: WhiteboardPage,413 component: WhiteboardPage,
392 });414 });
393 415
416+const licenseModulesRoute = createRoute({
417+ getParentRoute: () => rootRoute,
418+ path: "/management/modules",
419+ component: LicenseModulesPage,
420+});
421+
422+// The vendor surface: a builder session, not a school user, so none of these
423+// render the school shell's sidebar (there is no school user to draw it for).
424+const builderLoginRoute = createRoute({
425+ getParentRoute: () => rootRoute,
426+ path: "/builder/login",
427+ component: BuilderLoginPage,
428+});
429+
430+const builderSchoolsRoute = createRoute({
431+ getParentRoute: () => rootRoute,
432+ path: "/builder",
433+ component: BuilderSchoolsPage,
434+});
435+
436+const builderSchoolDetailRoute = createRoute({
437+ getParentRoute: () => rootRoute,
438+ path: "/builder/schools/$slug",
439+ component: BuilderSchoolDetailPage,
440+});
441+
394 // One route per Figma menu entry with no backend yet β€” each gets its own URL442 // One route per Figma menu entry with no backend yet β€” each gets its own URL
395 // (so breadcrumbs, back and direct links behave normally) but all render the443 // (so breadcrumbs, back and direct links behave normally) but all render the
396 // same "not ready" page. Slugs are read back by coming-soon-page.tsx.444 // same "not ready" page. Slugs are read back by coming-soon-page.tsx.
@@ -400,7 +448,6 @@ const COMING_SOON_SLUGS = [
400 "deneme-sinavlari",448 "deneme-sinavlari",
401 "optik-okuma",449 "optik-okuma",
402 "raporlar",450 "raporlar",
403- "lisans-modulleri",
404 "kvkk-denetim",451 "kvkk-denetim",
405 "ogrenciler",452 "ogrenciler",
406 "ogretmenler",453 "ogretmenler",
@@ -408,9 +455,6 @@ const COMING_SOON_SLUGS = [
408 "bekleyen-onaylar",455 "bekleyen-onaylar",
409 "soru-uretimi",456 "soru-uretimi",
410 "calisma-programim",457 "calisma-programim",
411- "devamsizlik",
412- "sinav-sonuclari-veli",
413- "calisma-plani",
414 ] as const;458 ] as const;
415 459
416 const comingSoonRoutes = COMING_SOON_SLUGS.map((slug) =>460 const comingSoonRoutes = COMING_SOON_SLUGS.map((slug) =>
@@ -457,6 +501,9 @@ const routeTree = rootRoute.addChildren([
457 adminUserDetailRoute,501 adminUserDetailRoute,
458 guideRoute,502 guideRoute,
459 myStudentsRoute,503 myStudentsRoute,
504+ myStudentsAttendanceRoute,
505+ myStudentsExamsRoute,
506+ myStudentsStudyRoute,
460 questionsRoute,507 questionsRoute,
461 questionDetailRoute,508 questionDetailRoute,
462 calendarRoute,509 calendarRoute,
@@ -468,6 +515,10 @@ const routeTree = rootRoute.addChildren([
468 paymentStatementRoute,515 paymentStatementRoute,
469 whiteboardsRoute,516 whiteboardsRoute,
470 whiteboardRoute,517 whiteboardRoute,
518+ licenseModulesRoute,
519+ builderLoginRoute,
520+ builderSchoolsRoute,
521+ builderSchoolDetailRoute,
471 myProfileRoute,522 myProfileRoute,
472 userProfileRoute,523 userProfileRoute,
473 ...comingSoonRoutes,524 ...comingSoonRoutes,
src/stores/builder-context.tsxadded+54 -0
@@ -0,0 +1,54 @@
1+import { type Accessor, type ParentProps, createContext, createResource, useContext } from "solid-js";
2+import { getBuilderMe, postBuilderLogout } from "@/api/builder";
3+import { ApiError, type Builder } from "@/api/client";
4+
5+type BuilderContextValue = {
6+ /** undefined while resolving, null when this browser holds no builder session. */
7+ builder: Accessor<Builder | null | undefined>;
8+ loading: Accessor<boolean>;
9+ error: Accessor<unknown>;
10+ refresh: () => void;
11+ logout: () => Promise<void>;
12+};
13+
14+const BuilderContext = createContext<BuilderContextValue>();
15+
16+/**
17+ * The deployment operator's session. Separate from AuthProvider on purpose: a
18+ * builder cookie is 401 on every school route and a school cookie is 401 here,
19+ * so the two never describe the same browser at once.
20+ */
21+export function BuilderProvider(props: ParentProps) {
22+ let failure: unknown = null;
23+ const [me, { refetch, mutate }] = createResource(async () => {
24+ failure = null;
25+ try {
26+ return await getBuilderMe();
27+ } catch (err) {
28+ if (!(err instanceof ApiError && err.status === 401)) failure = err;
29+ return null;
30+ }
31+ });
32+
33+ const value: BuilderContextValue = {
34+ builder: () => me(),
35+ loading: () => me.loading,
36+ error: () => (me() === null ? failure : null),
37+ refresh: () => void refetch(),
38+ logout: async () => {
39+ try {
40+ await postBuilderLogout();
41+ } finally {
42+ mutate(null);
43+ }
44+ },
45+ };
46+
47+ return <BuilderContext.Provider value={value}>{props.children}</BuilderContext.Provider>;
48+}
49+
50+export function useBuilder(): BuilderContextValue {
51+ const ctx = useContext(BuilderContext);
52+ if (!ctx) throw new Error("useBuilder must be used within BuilderProvider");
53+ return ctx;
54+}