website refactor
This commit is contained in:
@@ -1,7 +1,6 @@
|
||||
import { notFound, redirect } from 'next/navigation';
|
||||
import { DashboardPageQuery } from '@/lib/page-queries/DashboardPageQuery';
|
||||
import { DashboardPageQuery } from '@/lib/page-queries/page-queries/DashboardPageQuery';
|
||||
import { DashboardPageClient } from './DashboardPageClient';
|
||||
import { buildDashboardViewData } from './DashboardViewDataBuilder';
|
||||
|
||||
export default async function DashboardPage() {
|
||||
const result = await DashboardPageQuery.execute();
|
||||
@@ -9,23 +8,18 @@ export default async function DashboardPage() {
|
||||
// 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} />;
|
||||
// Pass Page DTO to client component
|
||||
return <DashboardPageClient pageDto={result.dto} />;
|
||||
|
||||
case 'notFound':
|
||||
notFound();
|
||||
|
||||
case 'redirect':
|
||||
redirect(result.destination);
|
||||
redirect(result.to);
|
||||
|
||||
case 'error':
|
||||
// For now, treat as notFound. Could also show error page
|
||||
console.error('Dashboard error:', result.error);
|
||||
console.error('Dashboard error:', result.errorId);
|
||||
notFound();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user