feat(admin): sync page title to admin shell via context
This commit is contained in:
@@ -1,6 +1,8 @@
|
||||
'use client';
|
||||
|
||||
import { useEffect } from 'react';
|
||||
import { getPage } from './registry.js';
|
||||
import { useAdminPageTitle } from './components/AdminPageTitleContext.js';
|
||||
import './pages/DashboardPage.client.js';
|
||||
import './pages/UsersPage.client.js';
|
||||
import './pages/RolesPage.client.js';
|
||||
@@ -9,10 +11,16 @@ import './widgets/index.client.js';
|
||||
|
||||
export default function AdminPageClient({ params, user, widgetData }) {
|
||||
const parts = params?.admin || [];
|
||||
const [first, second, third] = parts;
|
||||
const [first] = parts;
|
||||
|
||||
const slug = first || 'dashboard';
|
||||
const page = getPage(slug) || getPage('dashboard');
|
||||
const { setTitle } = useAdminPageTitle();
|
||||
|
||||
useEffect(() => {
|
||||
if (page?.title) setTitle(page.title);
|
||||
}, [page?.title]);
|
||||
|
||||
if (!page) return null;
|
||||
|
||||
const { Component } = page;
|
||||
|
||||
@@ -2,7 +2,7 @@ import AdminShell from './components/AdminShell.js';
|
||||
import AdminPageClient from './AdminPage.client.js';
|
||||
import { protectAdmin } from './protect.js';
|
||||
import { buildNavigationSections } from './navigation.js';
|
||||
import { collectWidgetData, getPage } from './registry.js';
|
||||
import { collectWidgetData } from './registry.js';
|
||||
import { logoutAction } from '@zen/core/features/auth/actions';
|
||||
import { getAppName } from '@zen/core';
|
||||
import './widgets/index.server.js';
|
||||
@@ -14,8 +14,6 @@ export default async function AdminPage({ params }) {
|
||||
|
||||
const widgetData = await collectWidgetData();
|
||||
const navigationSections = buildNavigationSections('/');
|
||||
const slug = resolvedParams?.admin?.[0] || 'dashboard';
|
||||
const currentPageTitle = getPage(slug)?.title;
|
||||
|
||||
return (
|
||||
<AdminShell
|
||||
@@ -23,7 +21,6 @@ export default async function AdminPage({ params }) {
|
||||
onLogout={logoutAction}
|
||||
appName={appName}
|
||||
navigationSections={navigationSections}
|
||||
currentPageTitle={currentPageTitle}
|
||||
>
|
||||
<AdminPageClient
|
||||
params={resolvedParams}
|
||||
|
||||
Reference in New Issue
Block a user