Update page title in Root.jsx
This commit is contained in:
@@ -1,19 +1,37 @@
|
||||
import React from 'react';
|
||||
import { Outlet } from 'react-router-dom';
|
||||
import {Outlet, useLocation} from 'react-router-dom';
|
||||
import Sidebar from '@/common/components/Sidebar';
|
||||
import ProfileMenu from '@/common/components/ProfileMenu';
|
||||
|
||||
const getPageTitle = (pathname) => {
|
||||
switch (pathname) {
|
||||
case '/dashboard':
|
||||
return 'Dashboard';
|
||||
case '/servers':
|
||||
return 'Servers';
|
||||
case '/settings':
|
||||
return 'Settings';
|
||||
case '/admin/users':
|
||||
return 'User Management';
|
||||
default:
|
||||
return 'Dashboard';
|
||||
}
|
||||
};
|
||||
|
||||
const Root = () => {
|
||||
const location = useLocation();
|
||||
const pageTitle = getPageTitle(location.pathname);
|
||||
|
||||
return (
|
||||
<div className="layout">
|
||||
<Sidebar />
|
||||
<Sidebar/>
|
||||
<div className="main">
|
||||
<header className="topbar">
|
||||
<h3>Dashboard</h3>
|
||||
<h3>{pageTitle}</h3>
|
||||
<div className="grow"></div>
|
||||
<ProfileMenu />
|
||||
<ProfileMenu/>
|
||||
</header>
|
||||
<Outlet />
|
||||
<Outlet/>
|
||||
</div>
|
||||
</div>
|
||||
);
|
||||
|
Reference in New Issue
Block a user