diff --git a/web/src/App.jsx b/web/src/App.jsx index 6555443..19d1bbc 100644 --- a/web/src/App.jsx +++ b/web/src/App.jsx @@ -7,10 +7,16 @@ 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 isAdmin = location.pathname.startsWith('/admin'); + 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); @@ -18,7 +24,7 @@ export default function App() { return (
- {!isAdmin &&
} + {!isAdminBackend &&
}
} /> @@ -29,7 +35,7 @@ export default function App() { } />
- {!isAdmin &&
); } diff --git a/web/src/components/Header.jsx b/web/src/components/Header.jsx index a37eebf..4ede010 100644 --- a/web/src/components/Header.jsx +++ b/web/src/components/Header.jsx @@ -29,14 +29,6 @@ export default function Header() { Annuaire L'association Espace membre - - - Espace admin - diff --git a/web/src/pages/Admin.jsx b/web/src/pages/Admin.jsx index 89d669a..df7aae0 100644 --- a/web/src/pages/Admin.jsx +++ b/web/src/pages/Admin.jsx @@ -1,8 +1,7 @@ import { useEffect, useState } from 'react'; -import { Link } from 'react-router-dom'; +import { Link, Navigate } from 'react-router-dom'; import { useAuth } from '../lib/AuthContext.jsx'; import { api, dateParts, statutLabel } from '../lib/api.js'; -import { LoginSection } from './Espace.jsx'; import { MembersTab, RencontresTab, InscriptionsTab } from '../components/admin/AdminTabs.jsx'; import { CategoriesTab, ContenuTab } from '../components/admin/AdminContent.jsx'; @@ -86,19 +85,13 @@ function Dashboard() { ); } -export default function Admin() { - const { user, loading, logout } = useAuth(); +// Rendered inside /espace-membre once a logged-in user is confirmed as +// admin (see Espace.jsx). Assumes an authenticated admin user — no auth +// gate here, the caller already checked it. +export function AdminShell() { + const { user, logout } = useAuth(); const [tab, setTab] = useState('dashboard'); - if (loading) return
; - if (!user || user.role !== 'admin') { - return ( -
- -
- ); - } - const current = TABS.find((t) => t.key === tab); const today = new Date().toLocaleDateString('fr-FR', { weekday: 'long', day: 'numeric', month: 'long', year: 'numeric' }); @@ -150,3 +143,8 @@ export default function Admin() { ); } + +// Legacy /admin bookmarks: everyone now logs in from a single entry point. +export default function Admin() { + return ; +} diff --git a/web/src/pages/Espace.jsx b/web/src/pages/Espace.jsx index 781025e..ae696d8 100644 --- a/web/src/pages/Espace.jsx +++ b/web/src/pages/Espace.jsx @@ -2,6 +2,7 @@ import { useEffect, useState } from 'react'; import { useAuth } from '../lib/AuthContext.jsx'; import { api, seasonLabel } from '../lib/api.js'; import ImageSlot from '../components/ImageSlot.jsx'; +import { AdminShell } from './Admin.jsx'; function LoginSection({ title = 'Gérez votre présence au Club', kicker = 'Espace membre' }) { const { login } = useAuth(); @@ -266,12 +267,14 @@ function Portal() { ); } +// Single login entry point for both members and admins. Once authenticated, +// the content shown depends on the account's role — the URL and the login +// form never differ. export default function Espace() { const { user, loading } = useAuth(); if (loading) return
; - if (!user || user.role !== 'member') return
; + if (!user) return
; + if (user.role === 'admin') return ; return
; } - -export { LoginSection };