aboutsummaryrefslogtreecommitdiffstats
path: root/panel/src/components/PrivateRoute.jsx
diff options
context:
space:
mode:
Diffstat (limited to 'panel/src/components/PrivateRoute.jsx')
-rw-r--r--panel/src/components/PrivateRoute.jsx24
1 files changed, 9 insertions, 15 deletions
diff --git a/panel/src/components/PrivateRoute.jsx b/panel/src/components/PrivateRoute.jsx
index 2160f74..e2c502d 100644
--- a/panel/src/components/PrivateRoute.jsx
+++ b/panel/src/components/PrivateRoute.jsx
@@ -1,17 +1,11 @@
-import { BrowserRouter as Router, Route, Routes } from 'react-router-dom';
-import LoginPage from '../pages/LoginPage';
-import Dashboard from '../pages/Dashboard'; // Assuming you have a Dashboard component
+import React from 'react';
+import { Navigate, Outlet } from 'react-router-dom';
+import { useAuth } from '../contexts/AuthContext';
-function App() {
- return (
- <Router>
- <Routes>
- <Route path="/login" element={<LoginPage />} />
- <Route path="/dashboard" element={<Dashboard />} />
- {/* Other routes */}
- </Routes>
- </Router>
- );
-}
+const PrivateRoute = () => {
+ const { currentUser } = useAuth();
-export default App;
+ return currentUser ? <Outlet /> : <Navigate to="/login" />;
+};
+
+export default PrivateRoute;