refactor(admin): extract page titles into a shared constants file
This commit is contained in:
@@ -5,7 +5,8 @@ import { Menu, MenuButton, MenuItem, MenuItems, Transition } from '@headlessui/r
|
||||
import { ChevronDownIcon, User03Icon, DashboardSquare03Icon } from '@zen/core/shared/icons';
|
||||
import { UserAvatar } from '@zen/core/shared/components';
|
||||
import { useRouter, usePathname } from 'next/navigation';
|
||||
import { getPage, getPages } from '../registry.js';
|
||||
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 = [] }) => {
|
||||
@@ -39,20 +40,20 @@ const AdminTop = ({ isMobileMenuOpen, setIsMobileMenuOpen, user, onLogout, appNa
|
||||
const crumbs = [{ icon: DashboardSquare03Icon, href: '/admin/dashboard' }];
|
||||
const after = pathname.replace(/^\/admin\/?/, '');
|
||||
if (!after) {
|
||||
crumbs.push({ label: getPage('dashboard')?.title });
|
||||
crumbs.push({ label: PAGE_TITLES.dashboard });
|
||||
return crumbs;
|
||||
}
|
||||
|
||||
const segments = after.split('/').filter(Boolean);
|
||||
if (!segments.length || (segments[0] === 'dashboard' && segments.length === 1)) {
|
||||
crumbs.push({ label: getPage('dashboard')?.title });
|
||||
crumbs.push({ label: PAGE_TITLES.dashboard });
|
||||
return crumbs;
|
||||
}
|
||||
|
||||
const [first, second] = segments;
|
||||
|
||||
if (first === 'profile') {
|
||||
crumbs.push({ label: getPage('profile')?.title });
|
||||
crumbs.push({ label: PAGE_TITLES.profile });
|
||||
return crumbs;
|
||||
}
|
||||
|
||||
|
||||
@@ -1,12 +1,13 @@
|
||||
'use client';
|
||||
|
||||
import { registerPage } from '../registry.js';
|
||||
import { PAGE_TITLES } from './titles.js';
|
||||
import DashboardPage from './DashboardPage.client.js';
|
||||
import UsersPage from './UsersPage.client.js';
|
||||
import RolesPage from './RolesPage.client.js';
|
||||
import ProfilePage from './ProfilePage.client.js';
|
||||
|
||||
registerPage({ slug: 'dashboard', Component: DashboardPage, title: 'Tableau de bord' });
|
||||
registerPage({ slug: 'users', Component: UsersPage, title: 'Utilisateurs' });
|
||||
registerPage({ slug: 'roles', Component: RolesPage, title: 'Rôles' });
|
||||
registerPage({ slug: 'profile', Component: ProfilePage, title: 'Mon profil' });
|
||||
registerPage({ slug: 'dashboard', Component: DashboardPage, title: PAGE_TITLES.dashboard });
|
||||
registerPage({ slug: 'users', Component: UsersPage, title: PAGE_TITLES.users });
|
||||
registerPage({ slug: 'roles', Component: RolesPage, title: PAGE_TITLES.roles });
|
||||
registerPage({ slug: 'profile', Component: ProfilePage, title: PAGE_TITLES.profile });
|
||||
|
||||
@@ -0,0 +1,6 @@
|
||||
export const PAGE_TITLES = {
|
||||
dashboard: 'Tableau de bord',
|
||||
profile: 'Mon profil',
|
||||
users: 'Utilisateurs',
|
||||
roles: 'Rôles',
|
||||
};
|
||||
Reference in New Issue
Block a user