import React, { Suspense, lazy } from 'react'; import { BrowserRouter as Router, Navigate, Route, Routes, useLocation } from 'react-router-dom'; import { AuthProvider, useAuth } from './context/AuthContext'; import AppLayout from './components/Layout/AppLayout'; import Loader from './components/common/Loader'; const Login = lazy(() => import('./components/Auth/Login')); const Register = lazy(() => import('./components/Auth/Register')); const Dashboard = lazy(() => import('./components/Layout/Dashboard')); const SubmissionList = lazy(() => import('./components/Submission/SubmissionList')); const ProtectedRoute = ({ children }) => { const { isAuthenticated, loading } = useAuth(); const location = useLocation(); if (loading) { return ; } if (!isAuthenticated) { return ; } return {children}; }; const PublicRoute = ({ children }) => { const { isAuthenticated, loading } = useAuth(); const location = useLocation(); if (loading) { return ; } if (isAuthenticated) { const redirectTo = location.state?.from?.pathname ?? '/dashboard'; return ; } return
{children}
; }; function App() { return ( }> )} /> )} /> )} /> )} /> } /> } /> ); } export default App;