fix(layout): handle localized routes in page title logic
This commit is contained in:
@@ -14,8 +14,11 @@ const Layout: React.FC<LayoutProps> = ({ children }) => {
|
|||||||
const pathname = usePathname();
|
const pathname = usePathname();
|
||||||
|
|
||||||
const getPageTitle = (path: string) => {
|
const getPageTitle = (path: string) => {
|
||||||
if (path === "/") return "Overview";
|
const pathSegments = path.split("/").filter(Boolean);
|
||||||
|
|
||||||
|
if (pathSegments.length <= 1) return "Overview";
|
||||||
|
const purePath = `/${pathSegments.slice(1).join("/")}`;
|
||||||
|
|
||||||
const titles: Record<string, string> = {
|
const titles: Record<string, string> = {
|
||||||
"/users": "Users",
|
"/users": "Users",
|
||||||
"/settings": "Settings",
|
"/settings": "Settings",
|
||||||
@@ -24,7 +27,8 @@ const Layout: React.FC<LayoutProps> = ({ children }) => {
|
|||||||
"/events": "Worship & Events",
|
"/events": "Worship & Events",
|
||||||
};
|
};
|
||||||
|
|
||||||
return titles[path] || "Dashboard";
|
return titles[purePath] || "Dashboard";
|
||||||
|
|
||||||
};
|
};
|
||||||
|
|
||||||
return (
|
return (
|
||||||
@@ -42,11 +46,11 @@ const Layout: React.FC<LayoutProps> = ({ children }) => {
|
|||||||
<div
|
<div
|
||||||
className={`flex min-h-screen flex-col transition-all duration-300 md:pl-64`}
|
className={`flex min-h-screen flex-col transition-all duration-300 md:pl-64`}
|
||||||
>
|
>
|
||||||
<Header
|
<Header
|
||||||
onMenuClick={() => setSidebarOpen(!sidebarOpen)}
|
onMenuClick={() => setSidebarOpen(!sidebarOpen)}
|
||||||
pageTitle={getPageTitle(pathname)}
|
pageTitle={getPageTitle(pathname)}
|
||||||
/>
|
/>
|
||||||
|
|
||||||
<main className="animate-in fade-in flex-1 p-4 duration-500 md:p-8">
|
<main className="animate-in fade-in flex-1 p-4 duration-500 md:p-8">
|
||||||
{children}
|
{children}
|
||||||
</main>
|
</main>
|
||||||
|
|||||||
Reference in New Issue
Block a user