feat: Implementación módulos Empresas, Plantas, Tipos y Estados Bobina
Backend API: - Implementado CRUD completo para Empresas (DE001-DE004): - EmpresaRepository, EmpresaService, EmpresasController. - Lógica de creación/eliminación de saldos iniciales en EmpresaService. - Transacciones y registro en tablas _H. - Verificación de permisos específicos. - Implementado CRUD completo para Plantas de Impresión (IP001-IP004): - PlantaRepository, PlantaService, PlantasController. - Transacciones y registro en tablas _H. - Verificación de permisos. - Implementado CRUD completo para Tipos de Bobina (IB006-IB009): - TipoBobinaRepository, TipoBobinaService, TiposBobinaController. - Transacciones y registro en tablas _H. - Verificación de permisos. - Implementado CRUD completo para Estados de Bobina (IB010-IB013): - EstadoBobinaRepository, EstadoBobinaService, EstadosBobinaController. - Transacciones y registro en tablas _H. - Verificación de permisos. Frontend React: - Módulo Empresas: - empresaService.ts para interactuar con la API. - EmpresaFormModal.tsx para crear/editar empresas. - GestionarEmpresasPage.tsx con tabla, filtro, paginación y menú de acciones. - Integración con el hook usePermissions para control de acceso. - Módulo Plantas de Impresión: - plantaService.ts. - PlantaFormModal.tsx. - GestionarPlantasPage.tsx con tabla, filtro, paginación y acciones. - Integración con usePermissions. - Módulo Tipos de Bobina: - tipoBobinaService.ts. - TipoBobinaFormModal.tsx. - GestionarTiposBobinaPage.tsx con tabla, filtro, paginación y acciones. - Integración con usePermissions. - Módulo Estados de Bobina: - estadoBobinaService.ts. - EstadoBobinaFormModal.tsx. - GestionarEstadosBobinaPage.tsx con tabla, filtro, paginación y acciones. - Integración con usePermissions. - Navegación: - Añadidas sub-pestañas y rutas para los nuevos módulos dentro de "Distribución" (Empresas) e "Impresión" (Plantas, Tipos Bobina, Estados Bobina). - Creado ImpresionIndexPage.tsx para la navegación interna del módulo de Impresión. Correcciones: - Corregido el uso de CommitAsync/RollbackAsync a Commit/Rollback síncronos en PlantaService.cs debido a que IDbTransaction no los soporta asíncronamente.
This commit is contained in:
@@ -17,12 +17,18 @@ import CanillasPage from '../pages/Distribucion/CanillasPage';
|
||||
import DistribuidoresPage from '../pages/Distribucion/DistribuidoresPage';
|
||||
import PublicacionesPage from '../pages/Distribucion/PublicacionesPage';
|
||||
import OtrosDestinosPage from '../pages/Distribucion/OtrosDestinosPage';
|
||||
import ZonasPage from '../pages/Distribucion/ZonasPage';
|
||||
import EmpresasPage from '../pages/Distribucion/EmpresasPage';
|
||||
import GestionarZonasPage from '../pages/Distribucion/GestionarZonasPage';
|
||||
import GestionarEmpresasPage from '../pages/Distribucion/GestionarEmpresasPage';
|
||||
|
||||
// Impresión
|
||||
import ImpresionIndexPage from '../pages/Impresion/ImpresionIndexPage';
|
||||
import GestionarPlantasPage from '../pages/Impresion/GestionarPlantasPage';
|
||||
import GestionarTiposBobinaPage from '../pages/Impresion/GestionarTiposBobinaPage';
|
||||
import GestionarEstadosBobinaPage from '../pages/Impresion/GestionarEstadosBobinaPage';
|
||||
|
||||
// Contables
|
||||
import ContablesIndexPage from '../pages/Contables/ContablesIndexPage';
|
||||
import GestionarTiposPagoPage from '../pages/Contables/GestionarTiposPagoPage'; // Asumiendo que lo moviste aquí
|
||||
import GestionarTiposPagoPage from '../pages/Contables/GestionarTiposPagoPage';
|
||||
|
||||
// --- ProtectedRoute y PublicRoute SIN CAMBIOS ---
|
||||
const ProtectedRoute: React.FC<{ children: JSX.Element }> = ({ children }) => {
|
||||
@@ -31,7 +37,7 @@ const ProtectedRoute: React.FC<{ children: JSX.Element }> = ({ children }) => {
|
||||
if (isLoading) return null;
|
||||
if (!isAuthenticated) {
|
||||
// console.log("ProtectedRoute: Not authenticated, redirecting to /login");
|
||||
return <Navigate to="/login" replace />;
|
||||
return <Navigate to="/login" replace />;
|
||||
}
|
||||
// console.log("ProtectedRoute: Authenticated, rendering children");
|
||||
return children;
|
||||
@@ -51,53 +57,61 @@ const PublicRoute: React.FC<{ children: JSX.Element }> = ({ children }) => {
|
||||
|
||||
const MainLayoutWrapper: React.FC = () => (
|
||||
<MainLayout>
|
||||
<Outlet />
|
||||
<Outlet />
|
||||
</MainLayout>
|
||||
);
|
||||
|
||||
// Placeholder simple
|
||||
const PlaceholderPage: React.FC<{ moduleName: string }> = ({ moduleName }) => (
|
||||
<Typography variant="h5" sx={{ p:2 }}>Página Principal del Módulo: {moduleName}</Typography>
|
||||
<Typography variant="h5" sx={{ p: 2 }}>Página Principal del Módulo: {moduleName}</Typography>
|
||||
);
|
||||
|
||||
const AppRoutes = () => {
|
||||
return (
|
||||
<BrowserRouter>
|
||||
<Routes> {/* Un solo <Routes> de nivel superior */}
|
||||
<Route path="/login" element={<PublicRoute><LoginPage /></PublicRoute>} />
|
||||
return (
|
||||
<BrowserRouter>
|
||||
<Routes> {/* Un solo <Routes> de nivel superior */}
|
||||
<Route path="/login" element={<PublicRoute><LoginPage /></PublicRoute>} />
|
||||
|
||||
{/* Rutas Protegidas que usan el MainLayout */}
|
||||
<Route
|
||||
path="/" // La ruta padre para todas las secciones protegidas
|
||||
element={
|
||||
<ProtectedRoute>
|
||||
<MainLayoutWrapper/>
|
||||
</ProtectedRoute>
|
||||
}
|
||||
>
|
||||
{/* Rutas Protegidas que usan el MainLayout */}
|
||||
<Route
|
||||
path="/" // La ruta padre para todas las secciones protegidas
|
||||
element={
|
||||
<ProtectedRoute>
|
||||
<MainLayoutWrapper />
|
||||
</ProtectedRoute>
|
||||
}
|
||||
>
|
||||
{/* Rutas hijas que se renderizarán en el Outlet de MainLayoutWrapper */}
|
||||
<Route index element={<HomePage />} /> {/* Para la ruta exacta "/" */}
|
||||
|
||||
{/* Módulo de Distribución (anidado) */}
|
||||
<Route path="distribucion" element={<DistribucionIndexPage />}>
|
||||
<Route index element={<Navigate to="es-canillas" replace />} />
|
||||
<Route path="es-canillas" element={<ESCanillasPage />} />
|
||||
<Route path="control-devoluciones" element={<ControlDevolucionesPage />} />
|
||||
<Route path="es-distribuidores" element={<ESDistribuidoresPage />} />
|
||||
<Route path="salidas-otros-destinos" element={<SalidasOtrosDestinosPage />} />
|
||||
<Route path="canillas" element={<CanillasPage />} />
|
||||
<Route path="distribuidores" element={<DistribuidoresPage />} />
|
||||
<Route path="publicaciones" element={<PublicacionesPage />} />
|
||||
<Route path="otros-destinos" element={<OtrosDestinosPage />} />
|
||||
<Route path="zonas" element={<ZonasPage />} />
|
||||
<Route path="empresas" element={<EmpresasPage />} />
|
||||
<Route index element={<Navigate to="es-canillas" replace />} />
|
||||
<Route path="es-canillas" element={<ESCanillasPage />} />
|
||||
<Route path="control-devoluciones" element={<ControlDevolucionesPage />} />
|
||||
<Route path="es-distribuidores" element={<ESDistribuidoresPage />} />
|
||||
<Route path="salidas-otros-destinos" element={<SalidasOtrosDestinosPage />} />
|
||||
<Route path="canillas" element={<CanillasPage />} />
|
||||
<Route path="distribuidores" element={<DistribuidoresPage />} />
|
||||
<Route path="publicaciones" element={<PublicacionesPage />} />
|
||||
<Route path="otros-destinos" element={<OtrosDestinosPage />} />
|
||||
<Route path="zonas" element={<GestionarZonasPage />} />
|
||||
<Route path="empresas" element={<GestionarEmpresasPage />} />
|
||||
</Route>
|
||||
|
||||
{/* Módulo Contable (anidado) */}
|
||||
<Route path="contables" element={<ContablesIndexPage />}>
|
||||
<Route index element={<Navigate to="tipos-pago" replace />} />
|
||||
<Route path="tipos-pago" element={<GestionarTiposPagoPage />} />
|
||||
{/* Futuras sub-rutas de contables aquí */}
|
||||
<Route index element={<Navigate to="tipos-pago" replace />} />
|
||||
<Route path="tipos-pago" element={<GestionarTiposPagoPage />} />
|
||||
{/* Futuras sub-rutas de contables aquí */}
|
||||
</Route>
|
||||
|
||||
{/* Módulo de Impresión (anidado) */}
|
||||
<Route path="impresion" element={<ImpresionIndexPage />}>
|
||||
<Route index element={<Navigate to="plantas" replace />} />
|
||||
<Route path="plantas" element={<GestionarPlantasPage />} />
|
||||
<Route path="tipos-bobina" element={<GestionarTiposBobinaPage />} />
|
||||
<Route path="estados-bobina" element={<GestionarEstadosBobinaPage />} />
|
||||
</Route>
|
||||
|
||||
{/* Otros Módulos Principales (estos son "finales", no tienen más hijos) */}
|
||||
@@ -108,18 +122,18 @@ return (
|
||||
|
||||
{/* Ruta catch-all DENTRO del layout protegido */}
|
||||
<Route path="*" element={<Navigate to="/" replace />} />
|
||||
</Route> {/* Cierre de la ruta padre "/" */}
|
||||
</Route> {/* Cierre de la ruta padre "/" */}
|
||||
|
||||
{/* Podrías tener un catch-all global aquí si una ruta no coincide EN ABSOLUTO,
|
||||
{/* Podrías tener un catch-all global aquí si una ruta no coincide EN ABSOLUTO,
|
||||
pero el path="*" dentro de la ruta "/" ya debería manejar la mayoría de los casos
|
||||
después de un login exitoso.
|
||||
Si un usuario no autenticado intenta una ruta inválida, ProtectedRoute lo manda a /login.
|
||||
*/}
|
||||
{/* <Route path="*" element={<Navigate to="/login" replace />} /> */}
|
||||
{/* <Route path="*" element={<Navigate to="/login" replace />} /> */}
|
||||
|
||||
</Routes>
|
||||
</BrowserRouter>
|
||||
);
|
||||
</Routes>
|
||||
</BrowserRouter>
|
||||
);
|
||||
};
|
||||
|
||||
export default AppRoutes;
|
||||
Reference in New Issue
Block a user