import { createContext, useContext } from 'react'; import type { User } from '../api/types'; export interface AuthContextValue { user: User | null; token: string | null; loading: boolean; login: (token: string, user: User) => void; logout: () => void; } export const AuthContext = createContext(undefined); export function useAuth() { const ctx = useContext(AuthContext); if (!ctx) throw new Error('useAuth must be used within AuthProvider'); return ctx; }