2023-08-31 16:11:47 +00:00
|
|
|
import { BrowserRouter, Route, Routes, Navigate } from 'react-router-dom';
|
|
|
|
import { Layout } from './pages/Layout';
|
|
|
|
import { Dashboard } from './pages/Dashboard';
|
|
|
|
import { Login } from './pages/Login';
|
|
|
|
import { Monitor } from './pages/Monitor';
|
|
|
|
import { Website } from './pages/Website';
|
|
|
|
import { Settings } from './pages/Settings';
|
|
|
|
import { Servers } from './pages/Servers';
|
2023-09-03 13:05:22 +00:00
|
|
|
import { useUserStore } from './store/user';
|
|
|
|
import { Register } from './pages/Register';
|
2023-08-31 13:17:57 +00:00
|
|
|
|
|
|
|
function App() {
|
2023-09-03 13:05:22 +00:00
|
|
|
const { info } = useUserStore();
|
|
|
|
|
2023-08-31 13:17:57 +00:00
|
|
|
return (
|
|
|
|
<div className="App">
|
2023-08-31 16:11:47 +00:00
|
|
|
<BrowserRouter>
|
|
|
|
<Routes>
|
2023-09-03 13:05:22 +00:00
|
|
|
{info && (
|
|
|
|
<Route element={<Layout />}>
|
|
|
|
<Route path="/dashboard" element={<Dashboard />} />
|
|
|
|
<Route path="/monitor" element={<Monitor />} />
|
|
|
|
<Route path="/website" element={<Website />} />
|
|
|
|
<Route path="/servers" element={<Servers />} />
|
|
|
|
<Route path="/settings" element={<Settings />} />
|
|
|
|
</Route>
|
|
|
|
)}
|
2023-08-31 16:11:47 +00:00
|
|
|
|
|
|
|
<Route path="/login" element={<Login />} />
|
2023-09-03 13:05:22 +00:00
|
|
|
<Route path="/register" element={<Register />} />
|
2023-08-31 16:11:47 +00:00
|
|
|
|
|
|
|
<Route
|
|
|
|
path="*"
|
2023-09-03 13:05:22 +00:00
|
|
|
element={
|
|
|
|
<Navigate to={info ? '/dashboard' : '/login'} replace={true} />
|
|
|
|
}
|
2023-08-31 16:11:47 +00:00
|
|
|
/>
|
|
|
|
</Routes>
|
|
|
|
</BrowserRouter>
|
2023-08-31 13:17:57 +00:00
|
|
|
</div>
|
|
|
|
);
|
|
|
|
}
|
|
|
|
|
|
|
|
export default App;
|