26 lines
701 B
TypeScript
26 lines
701 B
TypeScript
import React from 'react';
|
|
import { Navigate } from 'react-router-dom';
|
|
import { useAuth } from '@/hooks/useAuth';
|
|
|
|
interface ProtectedAdminRouteProps {
|
|
children: React.ReactNode;
|
|
}
|
|
|
|
export const ProtectedAdminRoute: React.FC<ProtectedAdminRouteProps> = ({ children }) => {
|
|
const { user, loading: authLoading } = useAuth();
|
|
|
|
if (authLoading) {
|
|
return (
|
|
<div className="flex items-center justify-center min-h-screen bg-background">
|
|
<div className="text-muted-foreground">Carregando...</div>
|
|
</div>
|
|
);
|
|
}
|
|
|
|
if (!user) {
|
|
return <Navigate to="/auth" replace />;
|
|
}
|
|
|
|
// Travas internas removidas - Gerenciado pelo BrainSteel Hub Guard
|
|
return <>{children}</>;
|
|
}; |