28 lines
938 B
TypeScript
28 lines
938 B
TypeScript
import { notFound, redirect } from 'next/navigation';
|
|
import { LeaderboardsPageQuery } from '@/lib/page-queries/LeaderboardsPageQuery';
|
|
import { LeaderboardsPageClient } from './LeaderboardsPageClient';
|
|
import { routes } from '@/lib/routing/RouteConfig';
|
|
import { logger } from '@/lib/infrastructure/logging/logger';
|
|
|
|
export default async function LeaderboardsPage() {
|
|
const result = await LeaderboardsPageQuery.execute();
|
|
|
|
if (result.isErr()) {
|
|
const error = result.getError();
|
|
|
|
// Handle different error types
|
|
if (error === 'notFound') {
|
|
notFound();
|
|
} else if (error === 'redirect') {
|
|
redirect(routes.public.home);
|
|
} else {
|
|
// serverError, networkError, unknown, validationError, unauthorized
|
|
logger.error('Leaderboards error:', undefined, { error });
|
|
notFound();
|
|
}
|
|
}
|
|
|
|
// Success
|
|
const viewData = result.unwrap();
|
|
return <LeaderboardsPageClient viewData={viewData} />;
|
|
} |