import React from 'react' import { BrowserRouter as Router, Routes, Route, Navigate } from 'react-router-dom' import { AuthProvider, useAuth } from './context/AuthContext' import Navigation from './components/Navigation' import LoginPage from './pages/LoginPage' import Dashboard from './pages/Dashboard' import ProfilePage from './pages/ProfilePage' import ExercisesPage from './pages/ExercisesPage' import ClubsPage from './pages/ClubsPage' // Protected Route Component function ProtectedRoute({ children }) { const { isAuthenticated, loading } = useAuth() if (loading) { return (
) } return isAuthenticated ? ( <> {children} ) : } // Public Route Component (redirect to dashboard if already logged in) function PublicRoute({ children }) { const { isAuthenticated, loading } = useAuth() if (loading) { return (
) } return !isAuthenticated ? children : } function AppRoutes() { return ( {/* Public Routes */} } /> {/* Protected Routes */} } /> } /> } /> } /> {/* Catch all - redirect to dashboard or login */} } /> ) } function App() { return ( ) } export default App