diff --git a/src/App.tsx b/src/App.tsx index eea1522..30eaaee 100644 --- a/src/App.tsx +++ b/src/App.tsx @@ -1,12 +1,12 @@ import { BrowserRouter, Navigate, Route, Routes } from 'react-router-dom'; import { AuthProvider } from './context/AuthContext'; import { LoginForm } from './routes/Login/LoginForm'; -import { Authenticated } from './routes/Login/Authenticated'; +import { Authenticated } from './components/Authenticated'; import { Dashboard } from './routes/Authenticated/Dashboard/Dashboard'; import { Apps } from './routes/Authenticated/Apps/Apps'; import { AppDetail } from './routes/Authenticated/Apps/App'; import { Servers } from './routes/Authenticated/Servers/Servers'; -import { Server} from './routes/Authenticated/Servers/Server'; +import { Server } from './routes/Authenticated/Servers/Server'; function App() { return ( @@ -17,53 +17,14 @@ function App() { } /> {/* Protected routes */} - - - - } - /> - - - - - } - /> - - - - - } - /> - - - - - } - /> - - - - - } - /> - - {/* Redirect root to dashboard */} - } /> + }> + } /> + } /> + } /> + } /> + } /> + } /> + {/* 404 catch-all */} } /> diff --git a/src/components/Authenticated.tsx b/src/components/Authenticated.tsx new file mode 100644 index 0000000..a66b1f1 --- /dev/null +++ b/src/components/Authenticated.tsx @@ -0,0 +1,24 @@ +import React from 'react'; +import { Navigate, Outlet } from 'react-router-dom'; +import { useAuth } from '../context/AuthContext'; + +export const Authenticated: React.FC = () => { + const { isAuthenticated, loading } = useAuth(); + + console.log('🛡️ ProtectedRoute:', { isAuthenticated, loading }); + + if (loading) { + return ( +
+

Loading...

+
+ ); + } + + return isAuthenticated ? : ; +}; \ No newline at end of file diff --git a/src/components/Header/Header.tsx b/src/components/Header/Header.tsx index ca9d399..ac9240c 100644 --- a/src/components/Header/Header.tsx +++ b/src/components/Header/Header.tsx @@ -18,8 +18,9 @@ export const Header: React.FC = ({ children }) => { return(
- {/*

navigate('/dashboard')} className="logo">Coop Cloud

*/} - +

navigate('/dashboard')} className="logo"> + +