26 lines
798 B
TypeScript
26 lines
798 B
TypeScript
import { notFound, redirect } from 'next/navigation';
|
|
import { DashboardPageQuery } from '@/lib/page-queries/page-queries/DashboardPageQuery';
|
|
import { DashboardTemplate } from '@/templates/DashboardTemplate';
|
|
|
|
export default async function DashboardPage() {
|
|
const result = await DashboardPageQuery.execute();
|
|
|
|
if (result.isErr()) {
|
|
const error = result.getError();
|
|
|
|
// Handle different error types
|
|
if (error === 'notFound') {
|
|
notFound();
|
|
} else if (error === 'redirect') {
|
|
redirect('/');
|
|
} else {
|
|
// serverError, networkError, unknown, validationError, unauthorized
|
|
console.error('Dashboard error:', error);
|
|
notFound();
|
|
}
|
|
}
|
|
|
|
// Success
|
|
const viewData = result.unwrap();
|
|
return <DashboardTemplate viewData={viewData} />;
|
|
} |