import React, { useEffect, useState } from 'react'; import { Navigate, Route, Routes, useNavigate} from 'react-router-dom'; import './css/App.css'; import Home from './pages/Home'; import ErrorBoundary from './util/ErrorBoundary'; import Sidebar, { SidebarMenu } from './components/Sidebar'; import UserControls from './components/UserControls'; import { useLoginContext } from './structures/UserContext'; import Login from './pages/Login'; import { get, setSession, setSettings } from './util/Util'; import PrivateRoute from './structures/PrivateRoute'; import { UnauthedRoute } from './structures/UnauthedRoute'; import Users from './pages/Users'; import Admin from './pages/Admin'; import TitledPage from './components/TitledPage'; import Register from './pages/Register'; function App() { const [user, updateUser] = useLoginContext(); const [loading, setLoading] = useState(true); const navigate = useNavigate(); useEffect(() => { (async () => { const settings = await get('/api/settings'); setSettings(settings.data); const result = await get('/api/user'); if (result.status === 200) { setSession(result.data); updateUser(); } setLoading(false); if (result.data?.twoFactor) return navigate('/login/verify'); })(); }, []); const menuItems = [ { to: '/home', label: 'Home', items: [{ to: '/profile', label: 'Profile', relative: true }] }, { to: '/users', label: 'Users' }, { to: '/admin', label: 'Admin' } ]; if (loading) return null; return (
{user ?
: null}
} /> } /> } /> } /> } /> } />

Made with ❤️ by Navy.gif  |  CSS by D3vision

); } export default App;