import { createContext, useContext } from "react"; import type { User } from "../types.ts"; export interface AuthContextType { user: User | null; isAuthenticated: boolean; isLoading: boolean; login: (username: string, password: string) => Promise; logout: () => void; updateUser: (user: User) => void; } export const AuthContext = createContext( undefined, ); export const useAuth = () => { const context = useContext(AuthContext); if (!context) { throw new Error("useAuth must be used within AuthProvider"); } return context; };