docs
This commit is contained in:
@@ -1,17 +1,31 @@
|
||||
import { notFound } from 'next/navigation';
|
||||
import { PageWrapper } from '@/components/shared/state/PageWrapper';
|
||||
import { DashboardTemplate } from '@/templates/DashboardTemplate';
|
||||
import { PageDataFetcher } from '@/lib/page/PageDataFetcher';
|
||||
import { DASHBOARD_SERVICE_TOKEN } from '@/lib/di/tokens';
|
||||
import type { DashboardService } from '@/lib/services/dashboard/DashboardService';
|
||||
import { notFound, redirect } from 'next/navigation';
|
||||
import { DashboardPageQuery } from '@/lib/page-queries/DashboardPageQuery';
|
||||
import { DashboardPageClient } from './DashboardPageClient';
|
||||
import { buildDashboardViewData } from './DashboardViewDataBuilder';
|
||||
|
||||
export default async function DashboardPage() {
|
||||
const data = await PageDataFetcher.fetch<DashboardService, 'getDashboardOverview'>(
|
||||
DASHBOARD_SERVICE_TOKEN,
|
||||
'getDashboardOverview'
|
||||
);
|
||||
const result = await DashboardPageQuery.execute();
|
||||
|
||||
if (!data) notFound();
|
||||
|
||||
return <PageWrapper data={data} Template={DashboardTemplate} />;
|
||||
// Handle result based on status
|
||||
switch (result.status) {
|
||||
case 'ok':
|
||||
const viewModelData = result.data;
|
||||
|
||||
// Build SSR ViewData directly from ViewModelData
|
||||
const ssrViewData = buildDashboardViewData(viewModelData);
|
||||
|
||||
// Pass both ViewData (for SSR) and ViewModelData (for client enhancement)
|
||||
return <DashboardPageClient initialViewData={ssrViewData} dto={viewModelData} />;
|
||||
|
||||
case 'notFound':
|
||||
notFound();
|
||||
|
||||
case 'redirect':
|
||||
redirect(result.destination);
|
||||
|
||||
case 'error':
|
||||
// For now, treat as notFound. Could also show error page
|
||||
console.error('Dashboard error:', result.error);
|
||||
notFound();
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user