49 lines
2.0 KiB
JavaScript
49 lines
2.0 KiB
JavaScript
import { lazy, Suspense } from 'react';
|
|
import { Route, Routes, Navigate } from 'react-router-dom';
|
|
import { GrLayout } from './layout/GrLayout';
|
|
|
|
// Lazy loading views
|
|
const RegistrationsView = lazy(() => import('./views/RegistrationsView'));
|
|
const ContractsView = lazy(() => import('./views/ContractsView'));
|
|
const SettingsView = lazy(() => import('./views/SettingsView'));
|
|
const LoginView = lazy(() => import('./views/LoginView'));
|
|
const InternalRegistrationView = lazy(() => import('./views/InternalDriverRegistrationView').then(m => ({ default: m.InternalDriverRegistrationView })));
|
|
|
|
// Loading component
|
|
const GrLoader = () => (
|
|
<div className="flex h-screen w-screen items-center justify-center bg-[var(--gr-panel-empty)]">
|
|
<div className="flex flex-col items-center gap-6">
|
|
<div className="relative">
|
|
<div className="w-16 h-16 bg-[var(--gr-primary)] rounded-2xl flex items-center justify-center shadow-lg animate-pulse">
|
|
<span className="text-white font-black text-xl">GR</span>
|
|
</div>
|
|
</div>
|
|
<div className="flex flex-col items-center gap-1">
|
|
<span className="text-[var(--gr-primary)] text-[10px] font-black uppercase tracking-[0.3em]">Cockpit GR</span>
|
|
<span className="text-slate-600 text-[8px] font-bold uppercase tracking-widest">Carregando...</span>
|
|
</div>
|
|
</div>
|
|
</div>
|
|
);
|
|
|
|
export const GrRoutes = () => {
|
|
return (
|
|
<Suspense fallback={<GrLoader />}>
|
|
<Routes>
|
|
<Route element={<GrLayout />}>
|
|
<Route path="cadastros" element={<RegistrationsView />} />
|
|
<Route path="cadastros/novo" element={<InternalRegistrationView />} />
|
|
<Route path="contratos" element={<ContractsView />} />
|
|
<Route path="configuracoes" element={<SettingsView />} />
|
|
|
|
<Route index element={<Navigate to="/plataforma/gr/cadastros" replace />} />
|
|
<Route path="*" element={<Navigate to="/plataforma/gr/cadastros" replace />} />
|
|
</Route>
|
|
</Routes>
|
|
</Suspense>
|
|
);
|
|
};
|
|
|
|
// Export LoginView separately
|
|
export { LoginView };
|