29 lines
687 B
TypeScript
29 lines
687 B
TypeScript
import { ReactNode } from 'react';
|
|
|
|
export interface User {
|
|
id: number;
|
|
email: string;
|
|
first_name: string;
|
|
last_name: string;
|
|
is_admin: boolean;
|
|
}
|
|
|
|
export interface AuthResponse {
|
|
access_token: string;
|
|
token_type: string;
|
|
user?: User;
|
|
}
|
|
|
|
export interface AuthContextType {
|
|
user: User | null;
|
|
loading: boolean;
|
|
isAdmin: boolean;
|
|
authChecked: boolean;
|
|
login: (email: string, password: string) => Promise<boolean>;
|
|
logout: () => void;
|
|
}
|
|
|
|
export function AuthProvider({ children }: { children: ReactNode }): React.ReactElement;
|
|
export function AdminProtected({ children }: { children: ReactNode }): React.ReactElement;
|
|
export function useAuth(): AuthContextType;
|