feat: fixed logo and made login a "separate" page

This commit is contained in:
2025-09-01 16:53:07 -06:00
parent ec2d7d6637
commit af323aade7
4 changed files with 52 additions and 26 deletions

View File

@@ -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 : <Navigate to="/login" replace />;
}
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 (
<Routes>
<Route path="/login" element={<LoginPage />} />
<Route path="*" element={<Navigate to="/login" replace />} />
</Routes>
);
}
// === RUTAS PRIVADAS (con shell) ===
return (
<>
<AppHeader
zone="private"
currentPage={currentView} // <-- show this in the header
leftOffset={mainLeft} // <-- keep title clear of the drawer
currentPage={currentView}
leftOffset={mainLeft}
/>
<MenuDrawerPrivate
onSelect={(value) => {
// normalize any custom route keys
setCurrentView(value);
}}
onSelect={(value) => setCurrentView(value)}
onExpandedChange={(expanded) => setDrawerExpanded(expanded)}
/>
@@ -59,23 +64,26 @@ export default function App() {
}}
>
<Routes>
<Route path="/login" element={<LoginPage />} />
{/* Si ya está autenticado, /login redirige al dashboard */}
<Route path="/login" element={<Navigate to="/" replace />} />
<Route
path="/"
element={
<PrivateRoute>
{zone === 'public' && currentView === 'Dashboard' && <Dashboard />}
{zone === 'public' && currentView === '/Users/UserManagement' && <UserManagement />}
{zone === 'public' && currentView === '/ProductsManagement/CatalogManagement/ProductCollections' && <FurnitureVariantManagement />}
</PrivateRoute>
<>
{currentView === 'Dashboard' && <Dashboard />}
{currentView === '/Users/UserManagement' && <UserManagement />}
{currentView === '/ProductsManagement/CatalogManagement/ProductCollections' && (
<FurnitureVariantManagement />
)}
</>
}
/>
</Routes>
</Box>
<Box sx={{ height: 64 }} />
<Footer zone={zone} />
<Footer zone="private" />
</>
);
}
}