initial commit

This commit is contained in:
2025-11-21 17:31:18 -06:00
commit 87cb54a17d
2451 changed files with 508075 additions and 0 deletions

35
web/src/hooks/useAuth.js Normal file
View File

@@ -0,0 +1,35 @@
import { useState, useEffect } from 'react';
import { auth } from '../utils/api';
export function useAuth() {
const [user, setUser] = useState(null);
const [loading, setLoading] = useState(true);
useEffect(() => {
checkAuth();
}, []);
const checkAuth = async () => {
try {
const userData = await auth.getMe();
setUser(userData);
} catch (error) {
setUser(null);
} finally {
setLoading(false);
}
};
const logout = async () => {
try {
await auth.logout();
} catch (error) {
console.error('Logout error:', error);
} finally {
setUser(null);
}
};
return { user, loading, logout, refresh: checkAuth };
}