31 lines
1.2 KiB
TypeScript
31 lines
1.2 KiB
TypeScript
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 result = await DashboardPageQuery.execute();
|
|
|
|
// 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();
|
|
}
|
|
} |