import type { AuthState } from "../../api"; const authStorageKey = "train-watcher-auth"; export function loadAuth(): AuthState | null { const raw = localStorage.getItem(authStorageKey); if (!raw) return null; try { return JSON.parse(raw) as AuthState; } catch { localStorage.removeItem(authStorageKey); return null; } } export function saveAuth(auth: AuthState) { localStorage.setItem(authStorageKey, JSON.stringify(auth)); } export function clearAuth() { localStorage.removeItem(authStorageKey); }