diff --git a/public/Logo.png b/public/Logo.png new file mode 100644 index 0000000..95e03f5 Binary files /dev/null and b/public/Logo.png differ diff --git a/src/App.jsx b/src/App.jsx index a1d32db..9ca1440 100644 --- a/src/App.jsx +++ b/src/App.jsx @@ -1,4 +1,3 @@ -// App.jsx import { useState } from 'react'; import { Box, useMediaQuery } from '@mui/material'; import { useTheme } from '@mui/material/styles'; @@ -16,33 +15,39 @@ const DRAWER_EXPANDED = OPEN_WIDTH; const DRAWER_COLLAPSED = MINI_WIDTH; const APPBAR_HEIGHT = 64; -function PrivateRoute({ children }) { - const { user } = useAuth(); - return user ? children : ; -} - export default function App() { const theme = useTheme(); const isMobile = useMediaQuery('(max-width:900px)'); - const [zone] = useState('public'); const [drawerExpanded, setDrawerExpanded] = useState(true); const [currentView, setCurrentView] = useState('Dashboard'); + const { user, initializing } = useAuth(); const mainLeft = isMobile ? 0 : (drawerExpanded ? DRAWER_EXPANDED : DRAWER_COLLAPSED); + // Evita flicker mientras se restaura sesión + if (initializing) return null; + + // === RUTAS PÚBLICAS (sin shell) === + if (!user) { + return ( + + } /> + } /> + + ); + } + + // === RUTAS PRIVADAS (con shell) === return ( <> { - // normalize any custom route keys - setCurrentView(value); - }} + onSelect={(value) => setCurrentView(value)} onExpandedChange={(expanded) => setDrawerExpanded(expanded)} /> @@ -59,23 +64,26 @@ export default function App() { }} > - } /> + {/* Si ya está autenticado, /login redirige al dashboard */} + } /> - {zone === 'public' && currentView === 'Dashboard' && } - {zone === 'public' && currentView === '/Users/UserManagement' && } - {zone === 'public' && currentView === '/ProductsManagement/CatalogManagement/ProductCollections' && } - + <> + {currentView === 'Dashboard' && } + {currentView === '/Users/UserManagement' && } + {currentView === '/ProductsManagement/CatalogManagement/ProductCollections' && ( + + )} + } /> -