24 lines
500 B
TypeScript
24 lines
500 B
TypeScript
/**
|
|
* Auth Context
|
|
* Authentication context - separated for Fast Refresh compatibility
|
|
*/
|
|
|
|
import { createContext } from "react";
|
|
import type { AuthResponse } from "@/api";
|
|
|
|
export interface User {
|
|
username: string;
|
|
role?: string;
|
|
}
|
|
|
|
export interface AuthContextType {
|
|
token: string | null;
|
|
user: User | null;
|
|
isAuthenticated: boolean;
|
|
login: (response: AuthResponse) => void;
|
|
logout: () => void;
|
|
}
|
|
|
|
export const AuthContext = createContext<AuthContextType | undefined>(undefined);
|
|
|