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:
@@ -0,0 +1,30 @@
|
||||
export type StartseitePraeferenz = "auto" | "dashboard" | "objekte";
|
||||
|
||||
const SPEICHER_KEY = "mabea-startseite";
|
||||
|
||||
export function gespeichertePraeferenz(): StartseitePraeferenz {
|
||||
try {
|
||||
const wert = localStorage.getItem(SPEICHER_KEY);
|
||||
if (wert === "dashboard" || wert === "objekte") return wert;
|
||||
} catch {
|
||||
// localStorage evtl. blockiert - "auto" als Fallback
|
||||
}
|
||||
return "auto";
|
||||
}
|
||||
|
||||
export function praeferenzSpeichern(praeferenz: StartseitePraeferenz): void {
|
||||
try {
|
||||
if (praeferenz === "auto") localStorage.removeItem(SPEICHER_KEY);
|
||||
else localStorage.setItem(SPEICHER_KEY, praeferenz);
|
||||
} catch {
|
||||
// Speichern optional
|
||||
}
|
||||
}
|
||||
|
||||
/** "auto" = bisheriges Verhalten (Verantwortliche -> Dashboard, sonst Objekte). */
|
||||
export function startseitenPfad(istVerantwortlich: boolean): string {
|
||||
const praeferenz = gespeichertePraeferenz();
|
||||
if (praeferenz === "dashboard" && istVerantwortlich) return "/dashboard";
|
||||
if (praeferenz === "objekte") return "/objekte";
|
||||
return istVerantwortlich ? "/dashboard" : "/objekte";
|
||||
}
|
||||
Reference in New Issue
Block a user