🚀 Initial commit: Versão atual do TrackSteel APP

This commit is contained in:
2026-03-18 21:17:53 +00:00
commit bde410c9ad
633 changed files with 108150 additions and 0 deletions
+28
View File
@@ -0,0 +1,28 @@
import React from 'react';
import { Navigate } from 'react-router-dom';
import { useAuth } from '@/hooks/useAuth';
import { useUserRole } from '@/hooks/useUserRole';
interface ProtectedAdminRouteProps {
children: React.ReactNode;
}
export const ProtectedAdminRoute: React.FC<ProtectedAdminRouteProps> = ({ children }) => {
const { user, loading } = useAuth();
const { isAdmin, loading: roleLoading } = useUserRole();
if (loading || roleLoading) {
return <div>Carregando...</div>;
}
if (!user) {
return <Navigate to="/auth" replace />;
}
if (!isAdmin) {
return <Navigate to="/dashboard" replace />;
}
return <>{children}</>;
};