feat(admin): pass current page title from server to AdminTop via props

This commit is contained in:
2026-04-22 17:52:48 -04:00
parent c41172a397
commit 7c92f34245
3 changed files with 10 additions and 8 deletions
+4 -6
View File
@@ -8,7 +8,7 @@ import { useRouter, usePathname } from 'next/navigation';
import { getPages } from '../registry.js';
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 = [], currentPageTitle }) => {
const router = useRouter();
const pathname = usePathname();
@@ -35,26 +35,24 @@ 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: getPageTitle('dashboard') });
crumbs.push({ label: currentPageTitle });
return crumbs;
}
const segments = after.split('/').filter(Boolean);
if (!segments.length || (segments[0] === 'dashboard' && segments.length === 1)) {
crumbs.push({ label: getPageTitle('dashboard') });
crumbs.push({ label: currentPageTitle });
return crumbs;
}
const [first, second] = segments;
if (first === 'profile') {
crumbs.push({ label: getPageTitle('profile') });
crumbs.push({ label: currentPageTitle });
return crumbs;
}