- Le menu public n'affiche plus « Espace admin » — un seul lien « Espace membre » pour tous les comptes - /espace-membre devient le point de connexion unique : après connexion, le contenu affiché dépend du rôle du compte (portail membre avec header du site, ou back-office admin plein écran avec sa propre barre latérale) - Admin.jsx exporte désormais AdminShell (coquille admin authentifiée, sans logique de connexion) réutilisée par Espace.jsx ; l'export par défaut devient une redirection de /admin vers /espace-membre pour ne pas casser d'anciens liens - App.jsx masque le header/footer public uniquement quand un admin est affiché sur /espace-membre (ou sur l'ancienne route /admin) Vérifié : navigation sans lien admin, /admin redirige, connexion membre → portail avec header, connexion admin → back-office sans header ; 34 tests e2e toujours au vert. Co-Authored-By: Claude Fable 5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01Fkg15RCxNgUys4ru73He2o
42 lines
1.5 KiB
React
42 lines
1.5 KiB
React
import { Routes, Route, useLocation } from 'react-router-dom';
|
|
import { useEffect } from 'react';
|
|
import Header from './components/Header.jsx';
|
|
import Footer from './components/Footer.jsx';
|
|
import Home from './pages/Home.jsx';
|
|
import Annuaire from './pages/Annuaire.jsx';
|
|
import Association from './pages/Association.jsx';
|
|
import Espace from './pages/Espace.jsx';
|
|
import Admin from './pages/Admin.jsx';
|
|
import { useAuth } from './lib/AuthContext.jsx';
|
|
|
|
export default function App() {
|
|
const location = useLocation();
|
|
const { user } = useAuth();
|
|
// The admin backend (shown inside /espace-membre once an admin logs in)
|
|
// uses its own full-height sidebar layout, without the public header/footer.
|
|
const isAdminBackend =
|
|
location.pathname.startsWith('/admin') ||
|
|
(location.pathname === '/espace-membre' && user?.role === 'admin');
|
|
|
|
useEffect(() => {
|
|
window.scrollTo(0, 0);
|
|
}, [location.pathname]);
|
|
|
|
return (
|
|
<div style={{ minHeight: '100vh', display: 'flex', flexDirection: 'column' }}>
|
|
{!isAdminBackend && <Header />}
|
|
<div style={{ flex: 1 }}>
|
|
<Routes>
|
|
<Route path="/" element={<Home />} />
|
|
<Route path="/annuaire" element={<Annuaire />} />
|
|
<Route path="/association" element={<Association />} />
|
|
<Route path="/espace-membre" element={<Espace />} />
|
|
<Route path="/admin/*" element={<Admin />} />
|
|
<Route path="*" element={<Home />} />
|
|
</Routes>
|
|
</div>
|
|
{!isAdminBackend && <Footer />}
|
|
</div>
|
|
);
|
|
}
|