// [REQ F1] System uwierzytelniania – ochrona tras, przekierowanie niezalogowanych do /login // [REQ T3] React Router – Outlet + Navigate, zachowanie ścieżki powrotu w location.state import { Navigate, Outlet, useLocation } from 'react-router-dom'; import { useAuth } from '../context/AuthContext'; const ProtectedRoute = ({ allowedRoles }) => { const { user } = useAuth(); const location = useLocation(); if (!user) { return ; } if (allowedRoles && !allowedRoles.includes(user.role)) { const fallback = user.role === 'admin' ? '/admin' : '/dashboard'; return ; } return ; }; export default ProtectedRoute;