website refactor
This commit is contained in:
@@ -1,24 +1,18 @@
|
||||
import { notFound } from 'next/navigation';
|
||||
import { TeamDetailPageQuery } from '@/lib/page-queries/page-queries/TeamDetailPageQuery';
|
||||
import { TeamDetailViewDataBuilder } from '@/lib/builders/view-data/TeamDetailViewDataBuilder';
|
||||
import { TeamDetailPageQuery } from '@/lib/page-queries/TeamDetailPageQuery';
|
||||
import { TeamDetailPageClient } from './TeamDetailPageClient';
|
||||
|
||||
export default async function Page({ params }: { params: { id: string } }) {
|
||||
const result = await TeamDetailPageQuery.execute(params.id);
|
||||
|
||||
switch (result.status) {
|
||||
case 'ok':
|
||||
const viewData = TeamDetailViewDataBuilder.build(result.dto);
|
||||
return <TeamDetailPageClient viewData={viewData} />;
|
||||
case 'notFound':
|
||||
notFound();
|
||||
case 'redirect':
|
||||
// This would typically use redirect() from next/navigation
|
||||
// but we need to handle it at the page level
|
||||
return null;
|
||||
case 'error':
|
||||
// For now, treat errors as not found
|
||||
// In production, you might want a proper error page
|
||||
if (result.isErr()) {
|
||||
const error = result.getError();
|
||||
if (error === 'notFound') {
|
||||
notFound();
|
||||
}
|
||||
// For other errors, treat as not found for now
|
||||
notFound();
|
||||
}
|
||||
}
|
||||
|
||||
return <TeamDetailPageClient viewData={result.unwrap()} />;
|
||||
}
|
||||
|
||||
@@ -4,6 +4,7 @@ import { Trophy } from 'lucide-react';
|
||||
import { redirect } from 'next/navigation';
|
||||
import { routes } from '@/lib/routing/RouteConfig';
|
||||
import { TeamLeaderboardPageWrapper } from './TeamLeaderboardPageWrapper';
|
||||
import { TeamSummaryViewModel } from '@/lib/view-models/TeamSummaryViewModel';
|
||||
|
||||
// ============================================================================
|
||||
// MAIN PAGE COMPONENT
|
||||
@@ -21,7 +22,7 @@ export default async function TeamLeaderboardPage() {
|
||||
let error = null;
|
||||
|
||||
if (result.isOk()) {
|
||||
data = result.unwrap();
|
||||
data = result.unwrap().map(t => new TeamSummaryViewModel(t));
|
||||
} else {
|
||||
const domainError = result.getError();
|
||||
error = new Error(domainError.message);
|
||||
@@ -52,4 +53,4 @@ export default async function TeamLeaderboardPage() {
|
||||
}}
|
||||
/>
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
import { notFound } from 'next/navigation';
|
||||
import { TeamsPageQuery } from '@/lib/page-queries/page-queries/TeamsPageQuery';
|
||||
import { TeamsPageQuery } from '@/lib/page-queries/TeamsPageQuery';
|
||||
import { TeamsPageClient } from './TeamsPageClient';
|
||||
|
||||
export default async function Page() {
|
||||
|
||||
Reference in New Issue
Block a user