import { lazy, Suspense } from 'react';
import { BrowserRouter as Router, Routes, Route, Navigate } from 'react-router-dom';
import { PortalHome } from '@/features/portal';
import AuthProvider, { useAuthContext } from '@/components/shared/AuthProvider';
import { Building, Zap } from 'lucide-react';
import { LoadingOverlay } from '@/components/shared/LoadingOverlay';
import { useGlobalLoading } from '@/hooks/useGlobalLoading';
// Lazy loading feature components
const FleetLogin = lazy(() => import('@/features/fleet').then(m => ({ default: m.FleetLogin })));
const FleetDashboard = lazy(() => import('@/features/fleet').then(m => ({ default: m.FleetDashboard })));
const HRLogin = lazy(() => import('@/features/rh').then(m => ({ default: m.HRLogin })));
const HRDashboard = lazy(() => import('@/features/rh').then(m => ({ default: m.HRDashboard })));
const PontoPage = lazy(() => import('@/features/rh').then(m => ({ default: m.PontoPage })));
const LoginPage = lazy(() => import('@/features/auth/login/LoginPage').then(m => ({ default: m.LoginPage })));
const FinanceLogin = lazy(() => import('@/features/auth/login-finance/LoginPage').then(m => ({ default: m.LoginPage })));
const FleetV2App = lazy(() => import('@/features/fleet-v2').then(m => ({ default: m.FleetV2App })));
const FinanceiroV2App = lazy(() => import('@/features/financeiro-v2').then(m => ({ default: m.FinanceiroV2App })));
const PrafrotRoutes = lazy(() => import('@/features/prafrot/routes').then(m => ({ default: m.PrafrotRoutes })));
const PrafrotLogin = lazy(() => import('@/features/prafrot/views/LoginView'));
const TableDebug = lazy(() => import('@/features/prafrot/views/TableDebug'));
const PlaygroundView = lazy(() => import('@/features/dev-tools/views/PlaygroundView'));
const WorkspaceLayout = lazy(() => import('@/features/workspace').then(m => ({ default: m.WorkspaceLayout })));
// Loading component
const PageLoader = () => (
);
/**
* Componente de proteção de rotas.
* Redireciona para o login se o usuário não estiver autenticado.
*/
const ProtectedRoute = ({ children, loginPath = '/plataforma/auth/login', environment = 'global' }) => {
const { user, loading, isAuthorized } = useAuthContext();
if (loading) return ;
if (!user || !isAuthorized(environment)) return ;
return children;
};
function App() {
return (
}>
{/* Portal Home - System Selection */}
} />
{/* 🔧 COMPONENT LABORATORY - Design System Testing */}
}>
} />
{/* Auth Login - Explícitos */}
} />
} />
{/* Fleet Management Management (Legacy) */}
} />
} />
} />
{/* HR Management (Legacy) */}
} />
} />
} />
} />
{/* Fleet V2 Environment - Protegido */}
} />
{/* Financeiro V2 Environment - Protegido */}
} />
{/* Prafrot Environment */}
} />
} />
} />
{/* Workspace Environment - Novo Ambiente Modernizado */}
} />
{/* Fallback */}
} />
);
}
// Wrapper component to use the hook inside the provider context if needed,
// though here it's at the top level so we just need to import the store.
const LoadingOverlayWrapper = () => {
const { isLoading, loadingMessage } = useGlobalLoading();
return ;
};
export default App;