refactor(admin): use registry titles for breadcrumb labels

This commit is contained in:
2026-04-22 17:39:24 -04:00
parent aeab10c1d2
commit 5feceb09f2
2 changed files with 11 additions and 5 deletions
+10 -4
View File
@@ -5,7 +5,7 @@ import { Menu, MenuButton, MenuItem, MenuItems, Transition } from '@headlessui/r
import { ChevronDownIcon, User03Icon, DashboardSquare03Icon } from '@zen/core/shared/icons'; import { ChevronDownIcon, User03Icon, DashboardSquare03Icon } from '@zen/core/shared/icons';
import { UserAvatar } from '@zen/core/shared/components'; import { UserAvatar } from '@zen/core/shared/components';
import { useRouter, usePathname } from 'next/navigation'; import { useRouter, usePathname } from 'next/navigation';
import { getPages } from '../registry.js'; import { getPage, getPages } from '../registry.js';
import { useTheme, getThemeIcon } from '@zen/core/themes'; import { useTheme, getThemeIcon } from '@zen/core/themes';
const AdminTop = ({ isMobileMenuOpen, setIsMobileMenuOpen, user, onLogout, appName = 'ZEN', navigationSections = [] }) => { const AdminTop = ({ isMobileMenuOpen, setIsMobileMenuOpen, user, onLogout, appName = 'ZEN', navigationSections = [] }) => {
@@ -38,15 +38,21 @@ const AdminTop = ({ isMobileMenuOpen, setIsMobileMenuOpen, user, onLogout, appNa
const buildBreadcrumbs = () => { const buildBreadcrumbs = () => {
const crumbs = [{ icon: DashboardSquare03Icon, href: '/admin/dashboard' }]; const crumbs = [{ icon: DashboardSquare03Icon, href: '/admin/dashboard' }];
const after = pathname.replace(/^\/admin\/?/, ''); const after = pathname.replace(/^\/admin\/?/, '');
if (!after) return crumbs; if (!after) {
crumbs.push({ label: getPage('dashboard')?.title });
return crumbs;
}
const segments = after.split('/').filter(Boolean); const segments = after.split('/').filter(Boolean);
if (!segments.length || (segments[0] === 'dashboard' && segments.length === 1)) return crumbs; if (!segments.length || (segments[0] === 'dashboard' && segments.length === 1)) {
crumbs.push({ label: getPage('dashboard')?.title });
return crumbs;
}
const [first, second] = segments; const [first, second] = segments;
if (first === 'profile') { if (first === 'profile') {
crumbs.push({ label: 'Mon profil' }); crumbs.push({ label: getPage('profile')?.title });
return crumbs; return crumbs;
} }
+1 -1
View File
@@ -9,4 +9,4 @@ import ProfilePage from './ProfilePage.client.js';
registerPage({ slug: 'dashboard', Component: DashboardPage, title: 'Tableau de bord' }); registerPage({ slug: 'dashboard', Component: DashboardPage, title: 'Tableau de bord' });
registerPage({ slug: 'users', Component: UsersPage, title: 'Utilisateurs' }); registerPage({ slug: 'users', Component: UsersPage, title: 'Utilisateurs' });
registerPage({ slug: 'roles', Component: RolesPage, title: 'Rôles' }); registerPage({ slug: 'roles', Component: RolesPage, title: 'Rôles' });
registerPage({ slug: 'profile', Component: ProfilePage, title: 'Profil' }); registerPage({ slug: 'profile', Component: ProfilePage, title: 'Mon profil' });