refactor(admin): generalize breadcrumb fallback to handle unknown single-segment routes
This commit is contained in:
@@ -54,17 +54,15 @@ const AdminTop = ({ isMobileMenuOpen, setIsMobileMenuOpen, user, onLogout, appNa
|
|||||||
return crumbs;
|
return crumbs;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (first === 'profile') {
|
|
||||||
crumbs.push({ label: pageTitle });
|
|
||||||
return crumbs;
|
|
||||||
}
|
|
||||||
|
|
||||||
const allItems = navigationSections.flatMap(s => s.items);
|
const allItems = navigationSections.flatMap(s => s.items);
|
||||||
const navItem = allItems.find(item => item.href.replace('/admin/', '').split('/')[0] === first);
|
const navItem = allItems.find(item => item.href.replace('/admin/', '').split('/')[0] === first);
|
||||||
const hasSubPage = segments.length > 1;
|
const hasSubPage = segments.length > 1;
|
||||||
|
|
||||||
if (navItem) {
|
if (navItem) {
|
||||||
crumbs.push({ label: navItem.name, href: hasSubPage ? navItem.href : undefined });
|
crumbs.push({ label: navItem.name, href: hasSubPage ? navItem.href : undefined });
|
||||||
|
} else if (!hasSubPage) {
|
||||||
|
crumbs.push({ label: pageTitle });
|
||||||
|
return crumbs;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (second === 'new') {
|
if (second === 'new') {
|
||||||
|
|||||||
Reference in New Issue
Block a user