ui creation

This commit is contained in:
Первов Артем
2026-06-17 09:46:52 +03:00
commit 2c4aef1185
41 changed files with 6251 additions and 0 deletions

20
src/auth/authContext.ts Normal file
View File

@@ -0,0 +1,20 @@
import { createContext, useContext } from 'react';
import type { AuthState } from './keycloak';
export type AuthContextValue = AuthState & {
login: () => Promise<void>;
logout: () => Promise<void>;
};
export const AuthContext = createContext<AuthContextValue | null>(null);
/** Дает компонентам доступ к данным пользователя и действиям login/logout. */
export function useAuth(): AuthContextValue {
const context = useContext(AuthContext);
if (!context) {
throw new Error('useAuth must be used within AuthProvider');
}
return context;
}