import React from 'react'; import { Navigate } from 'react-router-dom'; import { useAuth } from '../context/AuthContext'; interface PrivateRouteProps { children: React.ReactNode; } const PrivateRoute: React.FC = ({ children }) => { const { isAuthenticated, loading } = useAuth(); if (loading) { return (
Loading...
); } return isAuthenticated ? <>{children} : ; }; const styles: { [key: string]: React.CSSProperties } = { container: { display: 'flex', justifyContent: 'center', alignItems: 'center', minHeight: '100vh', backgroundColor: '#f5f5f5', }, spinner: { fontSize: '18px', color: '#666', }, }; export default PrivateRoute;