feat: router with RJSF workflows and access management UI

This commit is contained in:
Jonas Miederer 2026-09-12 07:36:05 +02:00
parent 46ecab00db
commit 62d01b5097
15 changed files with 948 additions and 144 deletions

55
frontend/src/auth.tsx Normal file
View file

@ -0,0 +1,55 @@
import {
createContext,
useCallback,
useContext,
useEffect,
useState,
type ReactNode,
} from "react";
import { api, type Me } from "./api";
interface Auth {
me: Me | null;
loading: boolean;
refresh: () => Promise<void>;
logout: () => Promise<void>;
}
const AuthContext = createContext<Auth>({
me: null,
loading: true,
refresh: async () => {},
logout: async () => {},
});
export function AuthProvider({ children }: { children: ReactNode }) {
const [me, setMe] = useState<Me | null>(null);
const [loading, setLoading] = useState(true);
const refresh = useCallback(async () => {
try {
setMe(await api.me());
} finally {
setLoading(false);
}
}, []);
const logout = useCallback(async () => {
await api.logout();
setMe(null);
}, []);
useEffect(() => {
void refresh();
}, [refresh]);
return (
<AuthContext.Provider value={{ me, loading, refresh, logout }}>
{children}
</AuthContext.Provider>
);
}
export function useAuth(): Auth {
return useContext(AuthContext);
}