Inicjalna wersja systemu zarządzania rezerwacjami (RMS)

SPA zbudowane w React 19 + Vite 8 z pełnym zestawem funkcjonalności:
autentykacja z 2FA, kreator rezerwacji, panel admina, analityka,
GraphQL (Apollo Client + SchemaLink), React Query, Storybook,
testy jednostkowe (Vitest + RTL) i e2e (Playwright).
This commit is contained in:
Krzysztof Cieślik
2026-06-21 06:08:47 +02:00
commit f436d87ca5
99 changed files with 18696 additions and 0 deletions

View File

@@ -0,0 +1,22 @@
// [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 <Navigate to="/login" state={{ from: location }} replace />;
}
if (allowedRoles && !allowedRoles.includes(user.role)) {
const fallback = user.role === 'admin' ? '/admin' : '/dashboard';
return <Navigate to={fallback} replace />;
}
return <Outlet />;
};
export default ProtectedRoute;