mirror of
https://github.com/Motion-Games/MotionWebStudio.git
synced 2026-04-21 17:10:54 +02:00
17 lines
487 B
TypeScript
17 lines
487 B
TypeScript
import React from 'react';
|
|
import { Navigate } from 'react-router-dom';
|
|
import { useAuth } from '../context/AuthContext';
|
|
|
|
export const ProtectedRoute: React.FC<React.PropsWithChildren> = ({ children }) => {
|
|
const { user, loading } = useAuth();
|
|
|
|
if (loading) {
|
|
return <div className="min-h-screen flex items-center justify-center bg-gray-50 text-primary">Betöltés...</div>;
|
|
}
|
|
|
|
if (!user) {
|
|
return <Navigate to="/auth/login" replace />;
|
|
}
|
|
|
|
return <>{children}</>;
|
|
}; |