feat(ui): Dashboard als Startseite für Verantwortliche + einstellbar
Root-Route "/" und Catch-all landeten bisher immer auf /objekte, Login-Weiterleitung (Verantwortliche -> Dashboard) war der einzige Pfad dorthin. Jetzt zentrale startseitenPfad()-Logik überall genutzt, zusätzlich per Dropdown in der Sidebar einstellbar (automatisch/ Dashboard/Objekte), Präferenz in localStorage. Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01CVgbozhYmuEhiEJHffRXCV
This commit is contained in:
@@ -4,6 +4,7 @@ import { useNavigate } from "react-router-dom";
|
||||
import { apiRequest } from "../api/client";
|
||||
import { useAuth } from "../auth/AuthContext";
|
||||
import type { Me } from "../api/types";
|
||||
import { startseitenPfad } from "../settings/startseite";
|
||||
|
||||
const VERANTWORTLICH_ROLLEN = ["administration", "materialverantwortlicher", "leitungsverantwortlicher"];
|
||||
|
||||
@@ -26,7 +27,7 @@ export function LoginPage() {
|
||||
// selbst /auth/me abfragen statt auf den Context zu warten.
|
||||
const me = await apiRequest<Me>("/auth/me");
|
||||
const istVerantwortlich = me.rollen.some((r) => VERANTWORTLICH_ROLLEN.includes(r));
|
||||
navigate(istVerantwortlich ? "/dashboard" : "/objekte");
|
||||
navigate(startseitenPfad(istVerantwortlich));
|
||||
} catch {
|
||||
setFehler("Login oder Passwort falsch");
|
||||
} finally {
|
||||
|
||||
Reference in New Issue
Block a user