forge
Explore
Log in

Don't you dare go Hollow

✨ school identity is the uuid

Browse files at this commit

a3eb98c6c92d543d92e6ec2187f308002f1e3bb5Ahmet Kaan GümüşParent: a72b005
  • feat
    • ✨ school identity is the uuid
Show full message
feat: ✨ school identity is the uuid

- register picks an active school from GET /auth/schools; an empty list disables submit
- builder routes, list, and school API calls use the school id
- slug field, slug limits, and the slug-collision error are gone
README.mdmodified+1 -1
@@ -53,7 +53,7 @@ Open [http://localhost:5173](http://localhost:5173) in your browser.
5353
5454 > **Proxy Note**: Vite proxies `/api/*` and WebSocket connections to `BACKEND_ORIGIN`, preserving HttpOnly session cookies across same-origin calls. Local development defaults to `https://hezarfen-backend.dizey.sh`, so `bun run dev` works without a backend process on the laptop; use `BACKEND_ORIGIN=http://127.0.0.1:7656 bun run dev` to target one locally. The production Bun server gets its co-located loopback default from the image and can be overridden through `hezarfen_frontend.env` (see "Run in a container" below).
5555
56-> **Dev auto sign-in**: for local testing, put `VITE_DEV_AUTOLOGIN_USERNAME` and `VITE_DEV_AUTOLOGIN_PASSWORD` (optionally `VITE_DEV_AUTOLOGIN_SCHOOL`, a school slug) in `.env.local`, which git ignores. `bun run dev` then signs in on the first `401`; logging out turns it off for that tab. It lives in `src/lib/dev-auto-login.ts` behind `import.meta.env.DEV`, so `vite build` drops it and the credentials never reach `dist/`.
56+> **Dev auto sign-in**: for local testing, put `VITE_DEV_AUTOLOGIN_USERNAME` and `VITE_DEV_AUTOLOGIN_PASSWORD` (optionally `VITE_DEV_AUTOLOGIN_SCHOOL`, a school uuid) in `.env.local`, which git ignores. `bun run dev` then signs in on the first `401`; logging out turns it off for that tab. It lives in `src/lib/dev-auto-login.ts` behind `import.meta.env.DEV`, so `vite build` drops it and the credentials never reach `dist/`.
5757
5858 > **Demo sign-in**: set `VITE_DEMO_LOGIN_USERNAME` and `VITE_DEMO_LOGIN_PASSWORD` at build time and the login page opens filled with them, plus a one-click "Demo hesabıyla gir" button (`src/lib/demo-login.ts`). Unlike the dev auto sign-in these values are bundled into `dist/`, so set them only for a demo school's build.
5959
docs/auth/role-scope-matrix.mdmodified+1 -1
@@ -47,7 +47,7 @@ route and a school session is 401 here, so these pages carry their own
4747 |---|---|
4848 | `/builder/login` | Operator sign-in (linked from the school login footer) |
4949 | `/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 |
50+| `/builder/schools/:id` | Rename/status, module switchboard (per module + per package), admin password reset, enter as admin |
5151
5252 ## Primary Navigation per Role
5353
docs/ui/figma-migration-coverage.mdmodified+1 -1
@@ -162,7 +162,7 @@ Rules the captures follow:
162162 | `/profile/:userId` | ADM-29 Kullanıcı Profili | Captured from the running app |
163163 | `/builder/login` | BLD-01 Operatör Girişi | Builder session only; linked from the SYS-01/login footer |
164164 | `/builder` | BLD-02 Okullar, BLD-02a Yeni Okul | Create, suspend/activate, delete |
165-| `/builder/schools/:slug` | BLD-03 Okul Detayı, BLD-03a Okula Gir | Module switchboard, password reset, enter as admin |
165+| `/builder/schools/:id` | BLD-03 Okul Detayı, BLD-03a Okula Gir | Module switchboard, password reset, enter as admin |
166166
167167 ## Figma features blocked by product or backend scope
168168
e2e/auth-shell.spec.tsmodified+9 -2
@@ -1,17 +1,24 @@
11 import { expect, test } from "@playwright/test";
22
3-const school = process.env.E2E_SCHOOL_SLUG ?? "demo";
3+const schoolId = process.env.E2E_SCHOOL_ID;
44 const username = process.env.E2E_ADMIN_USERNAME ?? "admin";
55 const password = process.env.E2E_ADMIN_PASSWORD ?? "admin123";
66
77 test("sign-in reaches the authenticated shell with keyboard-accessible navigation", async ({ page }) => {
88 await page.goto("/login");
99 await expect(page.locator("#login-username")).toBeVisible();
10- await page.locator("#login-school").fill(school);
1110 await page.locator("#login-username").fill(username);
1211 await page.locator("#login-password").fill(password);
1312 await page.locator("form").getByRole("button", { name: /log in|sign in|giriş yap/i }).click();
1413
14+ const chooser = page.getByRole("heading", { name: /choose your school|okulunu seç/i });
15+ const shell = page.getByRole("main");
16+ await expect(chooser.or(shell)).toBeVisible();
17+ if (await chooser.isVisible()) {
18+ if (!schoolId) throw new Error("login returned a school chooser; set E2E_SCHOOL_ID to the school uuid");
19+ await page.getByRole("button", { name: schoolId }).click();
20+ }
21+
1522 await expect(page).toHaveURL(/\/$/);
1623 await expect(page.getByRole("main")).toBeVisible();
1724
src/api/__tests__/auth/auth.test.tsmodified+17 -3
@@ -1,4 +1,5 @@
11 import { afterEach, describe, expect, it, vi } from "vitest";
2+import { getRegisterSchools } from "../../auth";
23 import { postLogin } from "../../auth";
34 import { postLogout } from "../../auth";
45 import { postRegister } from "../../auth";
@@ -27,13 +28,14 @@ describe("auth API", () => {
2728 const mockUser = { id: "u1", username: "test" };
2829 mockFetchSuccess(mockUser);
2930
30- const result = await postSelectSchool({ school: "demo" });
31+ const school = "019732e3-7b00-7000-8000-00000000dead";
32+ const result = await postSelectSchool({ school });
3133 expect(result).toEqual(mockUser);
3234
3335 const [url, init] = lastFetchCall();
3436 expect(url).toBe("/api/auth/school");
3537 expect(init?.method).toBe("POST");
36- expect(init?.body).toBe(JSON.stringify({ school: "demo" }));
38+ expect(init?.body).toBe(JSON.stringify({ school }));
3739 });
3840
3941 it("postLogout calls /auth/logout", async () => {
@@ -50,7 +52,7 @@ describe("auth API", () => {
5052 const mockResponse = { username: "newuser", role: "student" };
5153 mockFetchSuccess(mockResponse);
5254
53- const data = { school: "demo", username: "newuser", password: "password" };
55+ const data = { school: "019732e3-7b00-7000-8000-00000000dead", username: "newuser", password: "password" };
5456 const result = await postRegister(data);
5557 expect(result).toEqual(mockResponse);
5658
@@ -59,4 +61,16 @@ describe("auth API", () => {
5961 expect(init?.method).toBe("POST");
6062 expect(init?.body).toBe(JSON.stringify(data));
6163 });
64+
65+ it("getRegisterSchools reads active schools for the register picker", async () => {
66+ const schools = [{ id: "019732e3-7b00-7000-8000-00000000dead", name: "Hezarfen" }];
67+ mockFetchSuccess(schools);
68+
69+ const result = await getRegisterSchools();
70+ expect(result).toEqual(schools);
71+
72+ const [url, init] = lastFetchCall();
73+ expect(url).toBe("/api/auth/schools");
74+ expect(init?.method).toBe("GET");
75+ });
6276 });
src/api/__tests__/contract/helpers/live-client.tsmodified+18 -4
@@ -21,6 +21,20 @@ const TIMEOUT_MS = 10_000;
2121 const MAX_RATE_LIMIT_RETRIES = 12;
2222 let cookie = "";
2323
24+const SCHOOL_UUID = /^[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}$/i;
25+
26+/** School cookie is `session=<uuid>.<token>`; operator cookie stays `session=builder.<token>`. */
27+function sessionCookie(raw: string): string | null {
28+ const pair = raw.split(";")[0] ?? "";
29+ if (!pair.startsWith("session=")) return null;
30+ const value = pair.slice("session=".length);
31+ const dot = value.indexOf(".");
32+ if (dot <= 0 || dot === value.length - 1) return null;
33+ const prefix = value.slice(0, dot);
34+ if (prefix === "builder" || SCHOOL_UUID.test(prefix)) return pair;
35+ return null;
36+}
37+
2438 type Init = { method?: string; body?: unknown; headers?: Record<string, string> };
2539
2640 function retryDelayMs(response: Response, attempt: number): number {
@@ -59,8 +73,8 @@ export async function api(path: string, init: Init = {}): Promise<Response> {
5973
6074 const setCookies = res!.headers.getSetCookie?.() ?? [];
6175 for (const raw of setCookies) {
62- const pair = raw.split(";")[0];
63- if (pair.startsWith("session=")) cookie = pair;
76+ const pair = sessionCookie(raw);
77+ if (pair) cookie = pair;
6478 }
6579 return res!;
6680 }
@@ -77,7 +91,7 @@ export async function json<T>(path: string, init: Init = {}): Promise<T> {
7791
7892 /** Log in as the seeded admin; the session cookie lands in the jar. */
7993 export async function loginAdmin(): Promise<void> {
80- const result = await json<{ id: string } | { schools: Array<{ slug: string }> }>("/auth/login", {
94+ const result = await json<{ id: string } | { schools: Array<{ id: string }> }>("/auth/login", {
8195 method: "POST",
8296 body: {
8397 username: env.ADMIN_USERNAME ?? "admin",
@@ -85,7 +99,7 @@ export async function loginAdmin(): Promise<void> {
8599 },
86100 });
87101 if ("schools" in result) {
88- const school = env.SCHOOL_SLUG ?? result.schools[0]?.slug;
102+ const school = env.SCHOOL_ID ?? result.schools[0]?.id;
89103 if (!school) throw new Error("POST /auth/login returned an empty school choice list");
90104 await json("/auth/school", { method: "POST", body: { school } });
91105 }
src/api/__tests__/schools/schools.test.tsmodified+27 -26
@@ -1,10 +1,10 @@
11 import { afterEach, describe, expect, it, vi } from "vitest";
2-import { deleteSchoolBySlug } from "../../schools";
2+import { deleteSchool } from "../../schools";
33 import { deleteSchoolModule } from "../../schools";
4-import { getSchoolBySlug } from "../../schools";
4+import { getSchool } from "../../schools";
55 import { getSchoolModules } from "../../schools";
66 import { getSchools } from "../../schools";
7-import { patchSchoolBySlug } from "../../schools";
7+import { patchSchool } from "../../schools";
88 import { patchSchoolModules } from "../../schools";
99 import { postSchool } from "../../schools";
1010 import { postSchoolAdminPassword } from "../../schools";
@@ -12,7 +12,8 @@ import { postSchoolEnter } from "../../schools";
1212 import { postSchoolModule } from "../../schools";
1313 import { lastFetchCall, mockFetch204, mockFetchSuccess } from "../helpers/mock-fetch";
1414
15-const school = { slug: "ata-koleji", name: "Ata Koleji", status: "active", created_at: 1, modules: ["courses"] };
15+const schoolId = "019732e3-7b00-7000-8000-00000000dead";
16+const school = { id: schoolId, name: "Ata Koleji", status: "active", created_at: 1, modules: ["courses"] };
1617 const modules = { enabled: ["courses"], disabled: ["exams"] };
1718
1819 describe("schools API", () => {
@@ -31,19 +32,19 @@ describe("schools API", () => {
3132 expect(init?.method).toBe("GET");
3233 });
3334
34- it("getSchoolBySlug reads /schools/{slug}", async () => {
35+ it("getSchool reads /schools/{id}", async () => {
3536 mockFetchSuccess(school);
3637
37- await getSchoolBySlug("ata-koleji");
38+ await getSchool(schoolId);
3839
3940 const [url, init] = lastFetchCall();
40- expect(url).toBe("/api/schools/ata-koleji");
41+ expect(url).toBe(`/api/schools/${schoolId}`);
4142 expect(init?.method).toBe("GET");
4243 });
4344
4445 it("postSchool posts the school and its first admin", async () => {
4546 mockFetchSuccess(school, 201);
46- const body = { slug: "ata-koleji", name: "Ata Koleji", admin_username: "admin", admin_password: "secret123", modules: ["courses"] };
47+ const body = { name: "Ata Koleji", admin_username: "admin", admin_password: "secret123", modules: ["courses"] };
4748
4849 await postSchool(body);
4950
@@ -53,34 +54,34 @@ describe("schools API", () => {
5354 expect(init?.body).toBe(JSON.stringify(body));
5455 });
5556
56- it("patchSchoolBySlug patches name and status", async () => {
57+ it("patchSchool patches name and status", async () => {
5758 mockFetchSuccess({ ...school, status: "suspended" });
5859
59- await patchSchoolBySlug("ata-koleji", { status: "suspended" });
60+ await patchSchool(schoolId, { status: "suspended" });
6061
6162 const [url, init] = lastFetchCall();
62- expect(url).toBe("/api/schools/ata-koleji");
63+ expect(url).toBe(`/api/schools/${schoolId}`);
6364 expect(init?.method).toBe("PATCH");
6465 expect(init?.body).toBe(JSON.stringify({ status: "suspended" }));
6566 });
6667
67- it("deleteSchoolBySlug deletes /schools/{slug}", async () => {
68+ it("deleteSchool deletes /schools/{id}", async () => {
6869 mockFetch204();
6970
70- await deleteSchoolBySlug("ata-koleji");
71+ await deleteSchool(schoolId);
7172
7273 const [url, init] = lastFetchCall();
73- expect(url).toBe("/api/schools/ata-koleji");
74+ expect(url).toBe(`/api/schools/${schoolId}`);
7475 expect(init?.method).toBe("DELETE");
7576 });
7677
7778 it("postSchoolAdminPassword re-keys an admin", async () => {
7879 mockFetch204();
7980
80- await postSchoolAdminPassword("ata-koleji", { username: "admin", password: "newsecret" });
81+ await postSchoolAdminPassword(schoolId, { username: "admin", password: "newsecret" });
8182
8283 const [url, init] = lastFetchCall();
83- expect(url).toBe("/api/schools/ata-koleji/admin-password");
84+ expect(url).toBe(`/api/schools/${schoolId}/admin-password`);
8485 expect(init?.method).toBe("POST");
8586 expect(init?.body).toBe(JSON.stringify({ username: "admin", password: "newsecret" }));
8687 });
@@ -88,10 +89,10 @@ describe("schools API", () => {
8889 it("postSchoolEnter enters as a named admin", async () => {
8990 mockFetchSuccess({ id: "u1", username: "admin", role: "admin" });
9091
91- await postSchoolEnter("ata-koleji", { username: "admin" });
92+ await postSchoolEnter(schoolId, { username: "admin" });
9293
9394 const [url, init] = lastFetchCall();
94- expect(url).toBe("/api/schools/ata-koleji/enter");
95+ expect(url).toBe(`/api/schools/${schoolId}/enter`);
9596 expect(init?.method).toBe("POST");
9697 expect(init?.body).toBe(JSON.stringify({ username: "admin" }));
9798 });
@@ -99,11 +100,11 @@ describe("schools API", () => {
99100 it("getSchoolModules reads both halves of the catalog", async () => {
100101 mockFetchSuccess(modules);
101102
102- const result = await getSchoolModules("ata-koleji");
103+ const result = await getSchoolModules(schoolId);
103104 expect(result).toEqual(modules);
104105
105106 const [url, init] = lastFetchCall();
106- expect(url).toBe("/api/schools/ata-koleji/modules");
107+ expect(url).toBe(`/api/schools/${schoolId}/modules`);
107108 expect(init?.method).toBe("GET");
108109 });
109110
@@ -111,10 +112,10 @@ describe("schools API", () => {
111112 mockFetchSuccess(modules);
112113 const body = { enable: ["exams"], disable_packages: ["ai"] };
113114
114- await patchSchoolModules("ata-koleji", body);
115+ await patchSchoolModules(schoolId, body);
115116
116117 const [url, init] = lastFetchCall();
117- expect(url).toBe("/api/schools/ata-koleji/modules");
118+ expect(url).toBe(`/api/schools/${schoolId}/modules`);
118119 expect(init?.method).toBe("PATCH");
119120 expect(init?.body).toBe(JSON.stringify(body));
120121 });
@@ -122,20 +123,20 @@ describe("schools API", () => {
122123 it("postSchoolModule enables one module", async () => {
123124 mockFetchSuccess(modules);
124125
125- await postSchoolModule("ata-koleji", "exams");
126+ await postSchoolModule(schoolId, "exams");
126127
127128 const [url, init] = lastFetchCall();
128- expect(url).toBe("/api/schools/ata-koleji/modules/exams");
129+ expect(url).toBe(`/api/schools/${schoolId}/modules/exams`);
129130 expect(init?.method).toBe("POST");
130131 });
131132
132133 it("deleteSchoolModule disables one module", async () => {
133134 mockFetchSuccess(modules);
134135
135- await deleteSchoolModule("ata-koleji", "exams");
136+ await deleteSchoolModule(schoolId, "exams");
136137
137138 const [url, init] = lastFetchCall();
138- expect(url).toBe("/api/schools/ata-koleji/modules/exams");
139+ expect(url).toBe(`/api/schools/${schoolId}/modules/exams`);
139140 expect(init?.method).toBe("DELETE");
140141 });
141142 });
src/api/auth/getRegisterSchools.tsadded+7 -0
@@ -0,0 +1,7 @@
1+import { client } from "../client";
2+import type { SchoolChoice } from "./postLogin";
3+
4+/** Active schools a new account can join. Unauthenticated, same as register. */
5+export function getRegisterSchools(signal?: AbortSignal): Promise<SchoolChoice[]> {
6+ return client<SchoolChoice[]>("/auth/schools", { signal });
7+}
src/api/auth/index.tsmodified+1 -0
@@ -2,3 +2,4 @@ export * from "./postLogin";
22 export * from "./postLogout";
33 export * from "./postRegister";
44 export * from "./postSelectSchool";
5+export * from "./getRegisterSchools";
src/api/auth/postLogin.tsmodified+1 -1
@@ -7,7 +7,7 @@ export type LoginBody = {
77 };
88
99 export type SchoolChoice = {
10- slug: string;
10+ id: string;
1111 name: string;
1212 };
1313
src/api/client/client.tsmodified+0 -4
@@ -133,10 +133,6 @@ const API_ERROR_MESSAGES: Record<string, Record<Locale, string>> = {
133133 tr: "Tekrarlanan müsaitlikler birbiriyle çakışıyor.",
134134 },
135135 // Builder surface (web/builder.rs, tenant.rs) — byte-exact.
136- "school slug already taken": {
137- en: "That school code is already taken.",
138- tr: "Bu okul kodu zaten kullanılıyor.",
139- },
140136 "that account is not an admin of this school": {
141137 en: "That account exists but is not an admin of this school.",
142138 tr: "Bu hesap var ama bu okulun yöneticisi değil.",
src/api/client/types.tsmodified+1 -4
@@ -188,7 +188,7 @@ export type SchoolStatus = "active" | "suspended";
188188
189189 /** One school of the deployment, as the builder surface sees it. */
190190 export type School = {
191- slug: string;
191+ id: string;
192192 name: string;
193193 /** A suspended school refuses every one of its own users, login included. */
194194 status: SchoolStatus;
@@ -831,11 +831,8 @@ export type Limits = {
831831 max_username_len: number;
832832 username_separators: string[];
833833 reserved_usernames: string[];
834- reserved_slugs: string[];
835834 min_password_len: number;
836835 max_password_len: number;
837- min_slug_len: number;
838- max_slug_len: number;
839836 max_school_name_len: number;
840837 max_name_len: number;
841838 max_display_name_len: number;
src/api/schools/deleteSchool.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 deleteSchool(id: string): Promise<void> {
5+ return client<void>(`/schools/${encodeURIComponent(id)}`, { method: "DELETE" });
6+}
src/api/schools/deleteSchoolBySlug.tsdeleted+0 -6
@@ -1,6 +0,0 @@
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.tsmodified+2 -2
@@ -1,8 +1,8 @@
11 import { client } from "../client";
22 import type { SchoolModules } from "../client";
33
4-export function deleteSchoolModule(slug: string, module: string): Promise<SchoolModules> {
5- return client<SchoolModules>(`/schools/${encodeURIComponent(slug)}/modules/${encodeURIComponent(module)}`, {
4+export function deleteSchoolModule(id: string, module: string): Promise<SchoolModules> {
5+ return client<SchoolModules>(`/schools/${encodeURIComponent(id)}/modules/${encodeURIComponent(module)}`, {
66 method: "DELETE",
77 });
88 }
src/api/schools/getSchool.tsadded+6 -0
@@ -0,0 +1,6 @@
1+import { client } from "../client";
2+import type { School } from "../client";
3+
4+export function getSchool(id: string, signal?: AbortSignal): Promise<School> {
5+ return client<School>(`/schools/${encodeURIComponent(id)}`, { signal });
6+}
src/api/schools/getSchoolBySlug.tsdeleted+0 -6
@@ -1,6 +0,0 @@
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.tsmodified+2 -2
@@ -1,6 +1,6 @@
11 import { client } from "../client";
22 import type { SchoolModules } from "../client";
33
4-export function getSchoolModules(slug: string, signal?: AbortSignal): Promise<SchoolModules> {
5- return client<SchoolModules>(`/schools/${encodeURIComponent(slug)}/modules`, { signal });
4+export function getSchoolModules(id: string, signal?: AbortSignal): Promise<SchoolModules> {
5+ return client<SchoolModules>(`/schools/${encodeURIComponent(id)}/modules`, { signal });
66 }
src/api/schools/index.tsmodified+3 -3
@@ -1,8 +1,8 @@
11 export * from "./getSchools";
2-export * from "./getSchoolBySlug";
2+export * from "./getSchool";
33 export * from "./postSchool";
4-export * from "./patchSchoolBySlug";
5-export * from "./deleteSchoolBySlug";
4+export * from "./patchSchool";
5+export * from "./deleteSchool";
66 export * from "./postSchoolAdminPassword";
77 export * from "./postSchoolEnter";
88 export * from "./getSchoolModules";
src/api/schools/patchSchool.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 patchSchool(id: string, body: UpdateSchoolBody): Promise<School> {
10+ return client<School>(`/schools/${encodeURIComponent(id)}`, { method: "PATCH", body });
11+}
src/api/schools/patchSchoolBySlug.tsdeleted+0 -11
@@ -1,11 +0,0 @@
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.tsmodified+2 -2
@@ -9,6 +9,6 @@ export type PatchSchoolModulesBody = {
99 };
1010
1111 // 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 });
12+export function patchSchoolModules(id: string, body: PatchSchoolModulesBody): Promise<SchoolModules> {
13+ return client<SchoolModules>(`/schools/${encodeURIComponent(id)}/modules`, { method: "PATCH", body });
1414 }
src/api/schools/postSchool.tsmodified+0 -2
@@ -2,8 +2,6 @@ import { client } from "../client";
22 import type { School } from "../client";
33
44 export type CreateSchoolBody = {
5- /** Immutable once taken: names the school's database, blobs and cookie prefix. */
6- slug: string;
75 name: string;
86 admin_username: string;
97 admin_password: string;
src/api/schools/postSchoolAdminPassword.tsmodified+2 -2
@@ -6,6 +6,6 @@ export type SchoolAdminPasswordBody = {
66 };
77
88 // 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 });
9+export function postSchoolAdminPassword(id: string, body: SchoolAdminPasswordBody): Promise<void> {
10+ return client<void>(`/schools/${encodeURIComponent(id)}/admin-password`, { method: "POST", body });
1111 }
src/api/schools/postSchoolEnter.tsmodified+2 -2
@@ -3,6 +3,6 @@ import type { User } from "../client";
33
44 // Support access: swaps the builder cookie for an ordinary session of one of
55 // 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 });
6+export function postSchoolEnter(id: string, body: { username: string }): Promise<User> {
7+ return client<User>(`/schools/${encodeURIComponent(id)}/enter`, { method: "POST", body });
88 }
src/api/schools/postSchoolModule.tsmodified+2 -2
@@ -1,8 +1,8 @@
11 import { client } from "../client";
22 import type { SchoolModules } from "../client";
33
4-export function postSchoolModule(slug: string, module: string): Promise<SchoolModules> {
5- return client<SchoolModules>(`/schools/${encodeURIComponent(slug)}/modules/${encodeURIComponent(module)}`, {
4+export function postSchoolModule(id: string, module: string): Promise<SchoolModules> {
5+ return client<SchoolModules>(`/schools/${encodeURIComponent(id)}/modules/${encodeURIComponent(module)}`, {
66 method: "POST",
77 });
88 }
src/components/builder/create-school-panel.tsxmodified+0 -10
@@ -13,8 +13,6 @@ import { Label } from "@/components/ui/label";
1313 import { SidePanel } from "@/components/ui/side-panel";
1414 import { useT } from "@/stores/preferences-context";
1515
16-const SLUG_PATTERN = "[a-z0-9][a-z0-9-]+";
17-
1816 /** Creates a school with its first admin and, optionally, a hand-picked module set. */
1917 export function CreateSchoolPanel(props: { open: boolean; onOpenChange: (open: boolean) => void; onCreated: (school: School) => void }) {
2018 const t = useT();
@@ -23,7 +21,6 @@ export function CreateSchoolPanel(props: { open: boolean; onOpenChange: (open: b
2321 () => props.open || undefined,
2422 () => getLimits().catch(() => null),
2523 );
26- const [slug, setSlug] = createSignal("");
2724 const [name, setName] = createSignal("");
2825 const [adminUsername, setAdminUsername] = createSignal("");
2926 const [adminPassword, setAdminPassword] = createSignal("");
@@ -33,7 +30,6 @@ export function CreateSchoolPanel(props: { open: boolean; onOpenChange: (open: b
3330 const [pending, setPending] = createSignal(false);
3431
3532 const reset = () => {
36- setSlug("");
3733 setName("");
3834 setAdminUsername("");
3935 setAdminPassword("");
@@ -50,7 +46,6 @@ export function CreateSchoolPanel(props: { open: boolean; onOpenChange: (open: b
5046 setPending(true);
5147 try {
5248 const school = await postSchool({
53- slug: slug().trim(),
5449 name: name().trim(),
5550 admin_username: adminUsername().trim(),
5651 admin_password: adminPassword(),
@@ -83,11 +78,6 @@ export function CreateSchoolPanel(props: { open: boolean; onOpenChange: (open: b
8378 <Alert variant="destructive">{error()}</Alert>
8479 </Show>
8580 <div class="grid gap-4 sm:grid-cols-2">
86- <div class="space-y-1.5">
87- <Label for="school-slug">{t("builder.slug")}</Label>
88- <Input id="school-slug" class="rounded-lg" required pattern={SLUG_PATTERN} minlength={limits()?.user.min_slug_len ?? 2} maxlength={limits()?.user.max_slug_len ?? 32} value={slug()} onInput={(e) => setSlug(e.currentTarget.value.toLowerCase())} />
89- <p class="text-xs text-text-subtle">{t("builder.slugHint")}</p>
90- </div>
9181 <div class="space-y-1.5">
9282 <Label for="school-name">{t("builder.schoolName")}</Label>
9383 <Input id="school-name" class="rounded-lg" required maxlength={limits()?.user.max_school_name_len ?? 120} value={name()} onInput={(e) => setName(e.currentTarget.value)} />
src/components/builder/school-admin-access-panel.tsxmodified+3 -3
@@ -16,7 +16,7 @@ export type AdminAccessMode = "enter" | "password";
1616 * re-keys the admin and revokes every session it held.
1717 */
1818 export function SchoolAdminAccessPanel(props: {
19- slug: string;
19+ id: string;
2020 mode: AdminAccessMode | null;
2121 onClose: () => void;
2222 onEntered: () => void;
@@ -40,11 +40,11 @@ export function SchoolAdminAccessPanel(props: {
4040 setPending(true);
4141 try {
4242 if (props.mode === "enter") {
43- await postSchoolEnter(props.slug, { username: username().trim() });
43+ await postSchoolEnter(props.id, { username: username().trim() });
4444 reset();
4545 props.onEntered();
4646 } else {
47- await postSchoolAdminPassword(props.slug, { username: username().trim(), password: password() });
47+ await postSchoolAdminPassword(props.id, { username: username().trim(), password: password() });
4848 reset();
4949 props.onPasswordReset();
5050 }
src/i18n/locales/en.tsmodified+1 -4
@@ -524,8 +524,6 @@ export const en: Dict = {
524524 "builder.statusSuspended": "Suspended",
525525 "builder.createSchool": "New school",
526526 "builder.createSchoolHint": "Creates the school's database and its first admin in one step.",
527- "builder.slug": "School code",
528- "builder.slugHint": "Lowercase letters, digits and hyphens. Cannot be changed later.",
529527 "builder.schoolName": "School name",
530528 "builder.adminUsername": "Admin username",
531529 "builder.adminPassword": "Admin password",
@@ -784,7 +782,7 @@ export const en: Dict = {
784782 "auth.register": "Create account",
785783 "auth.username": "Username",
786784 "auth.school": "School",
787- "auth.schoolHint": "{min}–{max} characters",
785+ "auth.noSchoolOpen": "No school is open for registration.",
788786 "auth.password": "Password",
789787 "auth.noAccount": "New here?",
790788 "auth.hasAccount": "Already registered?",
@@ -803,7 +801,6 @@ export const en: Dict = {
803801 "auth.hidePassword": "Hide password",
804802 "auth.showConfirmPassword": "Show password confirmation",
805803 "auth.hideConfirmPassword": "Hide password confirmation",
806- "auth.schoolCodeHint": "The school code your school gave you (not the school's name): lowercase letters, digits and hyphens, {min}–{max} characters.",
807804 "auth.passwordMinHint": "At least {min} characters.",
808805 "auth.passwordTooShort": "The password needs at least {min} characters.",
809806 "auth.welcomeBack": "Good to see you again",
src/i18n/locales/tr.tsmodified+1 -4
@@ -520,8 +520,6 @@ export const tr: Dict = {
520520 "builder.statusSuspended": "Askıda",
521521 "builder.createSchool": "Yeni okul",
522522 "builder.createSchoolHint": "Okulun veritabanını ve ilk yöneticisini tek adımda oluşturur.",
523- "builder.slug": "Okul kodu",
524- "builder.slugHint": "Küçük harf, rakam ve tire. Sonradan değiştirilemez.",
525523 "builder.schoolName": "Okul adı",
526524 "builder.adminUsername": "Yönetici kullanıcı adı",
527525 "builder.adminPassword": "Yönetici şifresi",
@@ -780,7 +778,7 @@ export const tr: Dict = {
780778 "auth.register": "Hesap oluştur",
781779 "auth.username": "Kullanıcı adı",
782780 "auth.school": "Okul",
783- "auth.schoolHint": "{min}–{max} karakter",
781+ "auth.noSchoolOpen": "Kayıta açık bir okul yok.",
784782 "auth.password": "Şifre",
785783 "auth.noAccount": "Yeni misin?",
786784 "auth.hasAccount": "Zaten kayıtlı mısın?",
@@ -799,7 +797,6 @@ export const tr: Dict = {
799797 "auth.hidePassword": "Şifreyi gizle",
800798 "auth.showConfirmPassword": "Şifre onayını göster",
801799 "auth.hideConfirmPassword": "Şifre onayını gizle",
802- "auth.schoolCodeHint": "Okulunun sana ilettiği okul kodu (okul adı değil): küçük harf, rakam ve tire, {min}–{max} karakter.",
803800 "auth.passwordMinHint": "En az {min} karakter.",
804801 "auth.passwordTooShort": "Şifre en az {min} karakter olmalı.",
805802 "auth.welcomeBack": "Seni yeniden görmek güzel",
src/i18n/messages.tsmodified+1 -4
@@ -487,8 +487,6 @@ export type MessageKey =
487487 | "builder.statusSuspended"
488488 | "builder.createSchool"
489489 | "builder.createSchoolHint"
490- | "builder.slug"
491- | "builder.slugHint"
492490 | "builder.schoolName"
493491 | "builder.adminUsername"
494492 | "builder.adminPassword"
@@ -771,7 +769,7 @@ export type MessageKey =
771769 | "auth.register"
772770 | "auth.username"
773771 | "auth.school"
774- | "auth.schoolHint"
772+ | "auth.noSchoolOpen"
775773 | "auth.password"
776774 | "auth.noAccount"
777775 | "auth.hasAccount"
@@ -790,7 +788,6 @@ export type MessageKey =
790788 | "auth.hidePassword"
791789 | "auth.showConfirmPassword"
792790 | "auth.hideConfirmPassword"
793- | "auth.schoolCodeHint"
794791 | "auth.passwordMinHint"
795792 | "auth.passwordTooShort"
796793 | "auth.welcomeBack"
src/lib/dev-auto-login.tsmodified+2 -2
@@ -6,7 +6,7 @@ const SKIP_KEY = "hezarfen:dev-auto-login-off";
66 /**
77 * Development-only sign-in with credentials from `.env.local`
88 * (`VITE_DEV_AUTOLOGIN_USERNAME`, `VITE_DEV_AUTOLOGIN_PASSWORD`, optional
9- * `VITE_DEV_AUTOLOGIN_SCHOOL`). `import.meta.env.DEV` is a build-time false in
9+ * `VITE_DEV_AUTOLOGIN_SCHOOL`, a school uuid). `import.meta.env.DEV` is a build-time false in
1010 * `vite build`, so the whole body is dropped from production bundles.
1111 * An explicit logout turns it off for the rest of the tab.
1212 */
@@ -18,7 +18,7 @@ export async function devAutoLogin(): Promise<User | null> {
1818 try {
1919 const result = await postLogin({ username, password });
2020 if (!("schools" in result)) return result;
21- const school = import.meta.env.VITE_DEV_AUTOLOGIN_SCHOOL || result.schools[0]?.slug;
21+ const school = import.meta.env.VITE_DEV_AUTOLOGIN_SCHOOL || result.schools[0]?.id;
2222 return school ? await postSelectSchool({ school }) : null;
2323 } catch (err) {
2424 console.warn("Dev auto-login failed:", err);
src/pages/builder-school-detail-page.tsxmodified+14 -14
@@ -3,11 +3,11 @@ import { createResource } from "@/lib/create-resource";
33 import { useNavigate, useParams } from "@tanstack/solid-router";
44 import { getModulesCatalog } from "@/api/modules";
55 import {
6- deleteSchoolBySlug,
6+ deleteSchool,
77 deleteSchoolModule,
8- getSchoolBySlug,
8+ getSchool,
99 getSchoolModules,
10- patchSchoolBySlug,
10+ patchSchool,
1111 patchSchoolModules,
1212 postSchoolModule,
1313 } from "@/api/schools";
@@ -51,12 +51,12 @@ function BuilderSchoolDetailContent() {
5151 const { locale } = usePreferences();
5252 const auth = useAuth();
5353 const navigate = useNavigate();
54- const params = useParams({ from: "/builder/schools/$slug" });
55- const slug = () => params().slug;
54+ const params = useParams({ from: "/builder/schools/$id" });
55+ const id = () => params().id;
5656
57- const [school, { refetch: refetchSchool }] = createResource(slug, (value) => getSchoolBySlug(value));
57+ const [school, { refetch: refetchSchool }] = createResource(id, (value) => getSchool(value));
5858 const [catalog] = createResource(() => getModulesCatalog());
59- const [modules] = createResource(slug, (value) => getSchoolModules(value));
59+ const [modules] = createResource(id, (value) => getSchoolModules(value));
6060
6161 // The switchboard owns a local copy: each switch is one write whose response
6262 // is the school's whole new set, so there is nothing to refetch.
@@ -105,7 +105,7 @@ function BuilderSchoolDetailContent() {
105105 event.preventDefault();
106106 setEditError("");
107107 try {
108- await patchSchoolBySlug(slug(), { name: name().trim(), status: status() });
108+ await patchSchool(id(), { name: name().trim(), status: status() });
109109 setEditOpen(false);
110110 await refetchSchool();
111111 setFlash(t("common.saved"));
@@ -127,7 +127,7 @@ function BuilderSchoolDetailContent() {
127127 <PageHeader
128128 eyebrow={t("builder.schools")}
129129 title={current().name}
130- description={`${current().slug} · ${t("builder.createdAt")}: ${formatDateTime(current().created_at, locale())}`}
130+ description={`${current().id} · ${t("builder.createdAt")}: ${formatDateTime(current().created_at, locale())}`}
131131 actions={
132132 <div class="flex flex-wrap items-center gap-2">
133133 <SchoolStatusBadge status={current().status} />
@@ -180,10 +180,10 @@ function BuilderSchoolDetailContent() {
180180 enabled={enabled()}
181181 disabled={modulesSaving()}
182182 onToggle={(module, next) =>
183- void writeModules(() => (next ? postSchoolModule(slug(), module) : deleteSchoolModule(slug(), module)))
183+ void writeModules(() => (next ? postSchoolModule(id(), module) : deleteSchoolModule(id(), module)))
184184 }
185185 onTogglePackage={(pkg, next) =>
186- void writeModules(() => patchSchoolModules(slug(), next ? { enable_packages: [pkg] } : { disable_packages: [pkg] }))
186+ void writeModules(() => patchSchoolModules(id(), next ? { enable_packages: [pkg] } : { disable_packages: [pkg] }))
187187 }
188188 />
189189 )}
@@ -223,7 +223,7 @@ function BuilderSchoolDetailContent() {
223223 </SidePanel>
224224
225225 <SchoolAdminAccessPanel
226- slug={slug()}
226+ id={id()}
227227 mode={accessMode()}
228228 onClose={() => setAccessMode(null)}
229229 onPasswordReset={() => {
@@ -244,10 +244,10 @@ function BuilderSchoolDetailContent() {
244244 title={t("builder.deleteSchool")}
245245 description={t("builder.deleteSchoolWarning")}
246246 variant="destructive"
247- summary={school() ? `${school()!.name} · ${school()!.slug}` : ""}
247+ summary={school() ? `${school()!.name} · ${school()!.id}` : ""}
248248 onConfirm={async () => {
249249 try {
250- await deleteSchoolBySlug(slug());
250+ await deleteSchool(id());
251251 void navigate({ to: "/builder" });
252252 } catch (err) {
253253 setError(formatApiError(err));
src/pages/builder-schools-page.tsxmodified+13 -11
@@ -2,7 +2,7 @@ import { Show, Suspense, createMemo, createSignal } from "solid-js";
22 import { createResource } from "@/lib/create-resource";
33 import { useNavigate } from "@tanstack/solid-router";
44 import type { ColumnDef } from "@tanstack/solid-table";
5-import { deleteSchoolBySlug, getSchools, patchSchoolBySlug } from "@/api/schools";
5+import { deleteSchool, getSchools, patchSchool } from "@/api/schools";
66 import { formatApiError, type School } from "@/api/client";
77 import { BuilderGuard } from "@/components/builder/builder-guard";
88 import { BuilderHeader } from "@/components/builder/builder-header";
@@ -42,12 +42,12 @@ function BuilderSchoolsContent() {
4242 const [error, setError] = createSignal("");
4343 const [flash, setFlash] = createFlash();
4444
45- const open = (school: School) => void navigate({ to: "/builder/schools/$slug", params: { slug: school.slug } });
45+ const open = (school: School) => void navigate({ to: "/builder/schools/$id", params: { id: school.id } });
4646
4747 const setStatus = async (school: School, status: School["status"]) => {
4848 setError("");
4949 try {
50- await patchSchoolBySlug(school.slug, { status });
50+ await patchSchool(school.id, { status });
5151 await refetch();
5252 setFlash(t("common.saved"));
5353 } catch (err) {
@@ -59,12 +59,14 @@ function BuilderSchoolsContent() {
5959 {
6060 accessorKey: "name",
6161 header: t("builder.schoolName"),
62- cell: (cell) => <span class="font-medium">{cell.row.original.name}</span>,
63- },
64- {
65- accessorKey: "slug",
66- header: t("builder.slug"),
67- cell: (cell) => <span class="mono text-sm">{cell.row.original.slug}</span>,
62+ cell: (cell) => (
63+ <span class="block min-w-0">
64+ <span class="block font-medium">{cell.row.original.name}</span>
65+ <span class="block truncate font-mono text-xs text-text-subtle" title={cell.row.original.id}>
66+ {cell.row.original.id.slice(0, 8)}
67+ </span>
68+ </span>
69+ ),
6870 },
6971 {
7072 accessorKey: "status",
@@ -157,12 +159,12 @@ function BuilderSchoolsContent() {
157159 title={t("builder.deleteSchool")}
158160 description={t("builder.deleteSchoolWarning")}
159161 variant="destructive"
160- summary={deleteTarget() ? `${deleteTarget()!.name} · ${deleteTarget()!.slug}` : ""}
162+ summary={deleteTarget() ? `${deleteTarget()!.name} · ${deleteTarget()!.id}` : ""}
161163 onConfirm={async () => {
162164 const school = deleteTarget();
163165 if (!school) return;
164166 try {
165- await deleteSchoolBySlug(school.slug);
167+ await deleteSchool(school.id);
166168 await refetch();
167169 setFlash(t("common.deleted"));
168170 } catch (err) {
src/pages/login-page.test.tsxmodified+3 -3
@@ -54,8 +54,8 @@ test("logs in without a school and completes the multi-school selection", async
5454 postLogin.mockResolvedValue({
5555 username: "ada",
5656 schools: [
57- { slug: "alpha", name: "Alpha School" },
58- { slug: "beta", name: "Beta School" },
57+ { id: "019732e3-7b00-7000-8000-00000000dead", name: "Alpha School" },
58+ { id: "019732e3-7b00-7000-8000-00000000beef", name: "Beta School" },
5959 ],
6060 });
6161 postSelectSchool.mockResolvedValue({ id: "u1", username: "ada", role: "student" });
@@ -74,7 +74,7 @@ test("logs in without a school and completes the multi-school selection", async
7474 fireEvent.click(screen.getByText("Alpha School").closest("button")!);
7575
7676 await waitFor(() => {
77- expect(postSelectSchool).toHaveBeenCalledWith({ school: "alpha" });
77+ expect(postSelectSchool).toHaveBeenCalledWith({ school: "019732e3-7b00-7000-8000-00000000dead" });
7878 expect(refresh).toHaveBeenCalledOnce();
7979 expect(navigate).toHaveBeenCalledWith({ to: "/" });
8080 });
src/pages/login-page.tsxmodified+3 -3
@@ -205,14 +205,14 @@ function LoginForm() {
205205 variant="outline"
206206 class="h-auto w-full justify-start px-4 py-3 text-left"
207207 disabled={pending()}
208- onClick={() => void handleSchoolSelect(school.slug)}
208+ onClick={() => void handleSchoolSelect(school.id)}
209209 >
210210 <IconSchool class="h-5 w-5 shrink-0 text-primary-text" />
211211 <span class="min-w-0 flex-1">
212212 <span class="block truncate font-semibold text-text-strong">{school.name}</span>
213- <span class="block truncate text-xs font-normal text-text-subtle">{school.slug}</span>
213+ <span class="block truncate text-xs font-normal text-text-subtle">{school.id}</span>
214214 </span>
215- <Show when={selectingSchool() === school.slug}>
215+ <Show when={selectingSchool() === school.id}>
216216 <span class="text-xs font-normal text-text-subtle">{t("common.loading")}</span>
217217 </Show>
218218 </Button>
src/pages/register-page.tsxmodified+20 -23
@@ -1,13 +1,14 @@
11 import { Link, useNavigate } from "@tanstack/solid-router";
2-import { createSignal, Show } from "solid-js";
2+import { For, Show, createSignal } from "solid-js";
33 import { createResource } from "@/lib/create-resource";
4-import { postRegister } from "@/api/auth";
4+import { getRegisterSchools, postRegister } from "@/api/auth";
55 import { getLimits } from "@/api/limits";
66 import { formatApiError } from "@/api/client";
77 import { AuthPageShell } from "@/components/auth/auth-page-shell";
88 import { Button } from "@/components/ui/button";
99 import { Input } from "@/components/ui/input";
1010 import { Label } from "@/components/ui/label";
11+import { Select } from "@/components/ui/select";
1112 import { GuestGuard } from "@/components/layout/guest-guard";
1213 import { IconEye, IconEyeOff } from "@/components/ui/icons";
1314 import { useT } from "@/stores/preferences-context";
@@ -34,8 +35,8 @@ function RegisterForm() {
3435 const [error, setError] = createSignal("");
3536 const [pending, setPending] = createSignal(false);
3637 const [limits] = createResource(() => getLimits().catch(() => null));
37- const minSchoolSlugLength = () => limits()?.user.min_slug_len ?? 2;
38- const maxSchoolSlugLength = () => limits()?.user.max_slug_len ?? 32;
38+ const [schools] = createResource(() => getRegisterSchools());
39+ const noSchoolOpen = () => schools.state === "ready" && !schools.error && (schools() ?? []).length === 0;
3940 const minPasswordLength = () => limits()?.user.min_password_len ?? 6;
4041 // Inline checks wait until the reader has left the field (or, for the
4142 // confirmation, typed as many characters as the password) so they never
@@ -53,13 +54,10 @@ function RegisterForm() {
5354 const handleSubmit = async (e: SubmitEvent) => {
5455 e.preventDefault();
5556 const s = school().trim();
57+ if (!s) return;
5658 const u = username().trim();
5759 const p = password();
5860 const cp = confirmPassword();
59- if (s.length < minSchoolSlugLength() || s.length > maxSchoolSlugLength()) {
60- setError(t("auth.schoolHint", { min: minSchoolSlugLength(), max: maxSchoolSlugLength() }));
61- return;
62- }
6361 const userLimits = limits()?.user;
6462 if (userLimits && (u.length < userLimits.min_username_len || u.length > userLimits.max_username_len)) {
6563 setError(t("auth.usernameHint"));
@@ -97,24 +95,23 @@ function RegisterForm() {
9795 <form class="space-y-5" onSubmit={handleSubmit}>
9896 <div class="space-y-2">
9997 <Label for="register-school">{t("auth.school")}</Label>
100- <Input
98+ <Select
10199 id="register-school"
102100 class="h-9"
103- autocapitalize="none"
104- autocomplete="off"
105- spellcheck={false}
106- minlength={minSchoolSlugLength()}
107- maxlength={maxSchoolSlugLength()}
108101 required
109- aria-describedby="register-school-hint"
102+ disabled={schools.loading || noSchoolOpen() || Boolean(schools.error)}
110103 value={school()}
111- // A school code (slug) is lowercase; folding here saves a
112- // round trip for "Ata-Koleji".
113- onInput={(e) => setSchool(e.currentTarget.value.toLowerCase())}
114- />
115- <p id="register-school-hint" class="text-xs text-text-subtle">
116- {t("auth.schoolCodeHint", { min: minSchoolSlugLength(), max: maxSchoolSlugLength() })}
117- </p>
104+ onChange={(e) => setSchool(e.currentTarget.value)}
105+ >
106+ <option value="">{t("auth.chooseSchoolTitle")}</option>
107+ <For each={schools() ?? []}>{(item) => <option value={item.id}>{item.name}</option>}</For>
108+ </Select>
109+ <Show when={noSchoolOpen()}>
110+ <p class="text-sm text-text-subtle">{t("auth.noSchoolOpen")}</p>
111+ </Show>
112+ <Show when={schools.error}>
113+ <p class="text-sm text-destructive-text">{formatApiError(schools.error)}</p>
114+ </Show>
118115 </div>
119116
120117 <div class="space-y-2">
@@ -206,7 +203,7 @@ function RegisterForm() {
206203 <p class="rounded-md bg-destructive/10 px-3 py-2 text-sm text-destructive-text">{error()}</p>
207204 )}
208205
209- <Button type="submit" class="h-9 w-full text-sm" disabled={pending()}>
206+ <Button type="submit" class="h-9 w-full text-sm" disabled={pending() || schools.loading || noSchoolOpen() || Boolean(schools.error) || !school()}>
210207 {pending() ? t("common.loading") : t("auth.register")}
211208 </Button>
212209 </form>
src/routes/router.tsxmodified+1 -1
@@ -542,7 +542,7 @@ const builderSchoolsRoute = createRoute({
542542
543543 const builderSchoolDetailRoute = createRoute({
544544 getParentRoute: () => rootRoute,
545- path: "/builder/schools/$slug",
545+ path: "/builder/schools/$id",
546546 component: BuilderSchoolDetailPage,
547547 });
548548
src/vite-env.d.tsmodified+1 -0
@@ -4,6 +4,7 @@ interface ImportMetaEnv {
44 /** Dev-only auto sign-in (see src/lib/dev-auto-login.ts); set in .env.local, never committed. */
55 readonly VITE_DEV_AUTOLOGIN_USERNAME?: string;
66 readonly VITE_DEV_AUTOLOGIN_PASSWORD?: string;
7+ /** Optional school uuid when login returns a choice list. */
78 readonly VITE_DEV_AUTOLOGIN_SCHOOL?: string;
89 /** Demo account prefilled on the login page (see src/lib/demo-login.ts); bundled when set. */
910 readonly VITE_DEMO_LOGIN_USERNAME?: string;