Aethel Bot OSS repository!
aethel.xyz
bot
fun
ai
discord
discord-bot
aethel
1import { Routes, Route, Navigate } from 'react-router-dom';
2import { useAuthStore } from './stores/authStore';
3import LandingPage from './pages/LandingPage';
4import LoginPage from './pages/LoginPage';
5import StatusPage from './pages/StatusPage';
6import PrivacyPage from './pages/PrivacyPage';
7import TermsPage from './pages/TermsPage';
8import DashboardPage from './pages/DashboardPage';
9import TodosPage from './pages/TodosPage';
10import ApiKeysPage from './pages/ApiKeysPage';
11import RemindersPage from './pages/RemindersPage';
12import Layout from './components/Layout';
13import { useEffect } from 'react';
14
15function App() {
16 const { isAuthenticated, checkAuth } = useAuthStore();
17
18 useEffect(() => {
19 checkAuth();
20 }, []);
21
22 return (
23 <Routes>
24 {/* Public routes */}
25 <Route
26 path="/"
27 element={<LandingPage />}
28 />
29 <Route
30 path="/login"
31 element={
32 isAuthenticated ? (
33 <Navigate
34 to="/dashboard"
35 replace
36 />
37 ) : (
38 <LoginPage />
39 )
40 }
41 />
42 <Route
43 path="/status"
44 element={<StatusPage />}
45 />
46 <Route
47 path="/legal/privacy"
48 element={<PrivacyPage />}
49 />
50 <Route
51 path="/legal/terms"
52 element={<TermsPage />}
53 />
54
55 {/* Protected routes */}
56 {isAuthenticated ? (
57 <Route
58 path="/*"
59 element={
60 <Layout>
61 <Routes>
62 <Route
63 path="/dashboard"
64 element={<DashboardPage />}
65 />
66 <Route
67 path="/todos"
68 element={<TodosPage />}
69 />
70 <Route
71 path="/reminders"
72 element={<RemindersPage />}
73 />
74 <Route
75 path="/api-keys"
76 element={<ApiKeysPage />}
77 />
78 <Route
79 path="*"
80 element={
81 <Navigate
82 to="/dashboard"
83 replace
84 />
85 }
86 />
87 </Routes>
88 </Layout>
89 }
90 />
91 ) : (
92 <Route
93 path="*"
94 element={
95 <Navigate
96 to="/"
97 replace
98 />
99 }
100 />
101 )}
102 </Routes>
103 );
104}
105
106export default App;