refactor(admin): migrate page titles from static map to self-registering pages
This commit is contained in:
@@ -6,7 +6,6 @@ import { ChevronDownIcon, User03Icon, DashboardSquare03Icon } from '@zen/core/sh
|
||||
import { UserAvatar } from '@zen/core/shared/components';
|
||||
import { useRouter, usePathname } from 'next/navigation';
|
||||
import { getPages } from '../registry.js';
|
||||
import { PAGE_TITLES } from '../pages/titles.js';
|
||||
import { useTheme, getThemeIcon } from '@zen/core/themes';
|
||||
|
||||
const AdminTop = ({ isMobileMenuOpen, setIsMobileMenuOpen, user, onLogout, appName = 'ZEN', navigationSections = [] }) => {
|
||||
@@ -36,24 +35,26 @@ const AdminTop = ({ isMobileMenuOpen, setIsMobileMenuOpen, user, onLogout, appNa
|
||||
const ThemeIcon = getThemeIcon(theme, systemIsDark);
|
||||
const themeLabel = theme === 'light' ? 'Mode clair' : theme === 'dark' ? 'Mode sombre' : 'Thème système';
|
||||
|
||||
const getPageTitle = (s) => getPages().find(p => p.slug === s)?.title ?? s;
|
||||
|
||||
const buildBreadcrumbs = () => {
|
||||
const crumbs = [{ icon: DashboardSquare03Icon, href: '/admin/dashboard' }];
|
||||
const after = pathname.replace(/^\/admin\/?/, '');
|
||||
if (!after) {
|
||||
crumbs.push({ label: PAGE_TITLES.dashboard });
|
||||
crumbs.push({ label: getPageTitle('dashboard') });
|
||||
return crumbs;
|
||||
}
|
||||
|
||||
const segments = after.split('/').filter(Boolean);
|
||||
if (!segments.length || (segments[0] === 'dashboard' && segments.length === 1)) {
|
||||
crumbs.push({ label: PAGE_TITLES.dashboard });
|
||||
crumbs.push({ label: getPageTitle('dashboard') });
|
||||
return crumbs;
|
||||
}
|
||||
|
||||
const [first, second] = segments;
|
||||
|
||||
if (first === 'profile') {
|
||||
crumbs.push({ label: PAGE_TITLES.profile });
|
||||
crumbs.push({ label: getPageTitle('profile') });
|
||||
return crumbs;
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user