chore: Initial commit of Opencord base state

This commit is contained in:
Jannis Braun
2026-02-18 02:49:21 +01:00
commit 4fd17084a5
124 changed files with 17955 additions and 0 deletions
+24
View File
@@ -0,0 +1,24 @@
import { useEffect } from 'react';
import { useNavigate } from 'react-router-dom';
import { useAuthStore } from '../stores/authStore';
export function useAuth() {
const token = useAuthStore((s) => s.token);
const user = useAuthStore((s) => s.user);
const isLoading = useAuthStore((s) => s.isLoading);
const loadUser = useAuthStore((s) => s.loadUser);
const navigate = useNavigate();
useEffect(() => {
if (!token) {
navigate('/login');
return;
}
if (!user && !isLoading) {
loadUser();
}
}, [token, user, isLoading, loadUser, navigate]);
return { user, isLoading, isAuthenticated: !!token };
}