Fusionne l'espace admin dans l'espace membre : connexion unique
- 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
This commit is contained in:
4 files changed
+26
-27
No files matched your search
+11
-13
@@ -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 <main style={{ minHeight: '60vh' }} />;
|
||||
if (!user || user.role !== 'admin') {
|
||||
return (
|
||||
<main>
|
||||
<LoginSection kicker="Espace admin" title="Administration du Business Club" />
|
||||
</main>
|
||||
);
|
||||
}
|
||||
|
||||
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() {
|
||||
</div>
|
||||
);
|
||||
}
|
||||
|
||||
// Legacy /admin bookmarks: everyone now logs in from a single entry point.
|
||||
export default function Admin() {
|
||||
return <Navigate to="/espace-membre" replace />;
|
||||
}
|
||||
@@ -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 <main style={{ minHeight: '60vh' }} />;
|
||||
if (!user || user.role !== 'member') return <main><LoginSection /></main>;
|
||||
if (!user) return <main><LoginSection /></main>;
|
||||
if (user.role === 'admin') return <AdminShell />;
|
||||
return <main><Portal /></main>;
|
||||
}
|
||||
|
||||
export { LoginSection };
|
||||
Reference in new issue
Block a user