website refactor

This commit is contained in:
2026-01-14 02:02:24 +01:00
parent 8d7c709e0c
commit 4522d41aef
291 changed files with 12763 additions and 9309 deletions

View File

@@ -1,4 +1,5 @@
import { headers } from 'next/headers';
import { redirect } from 'next/navigation';
import { createRouteGuard } from '@/lib/auth/createRouteGuard';
interface SponsorLayoutProps {
@@ -16,11 +17,14 @@ export default async function SponsorLayout({ children }: SponsorLayoutProps) {
const pathname = headerStore.get('x-pathname') || '/';
const guard = createRouteGuard();
await guard.enforce({ pathname });
const result = await guard.enforce({ pathname });
if (result.type === 'redirect') {
redirect(result.to);
}
return (
<div className="min-h-screen bg-deep-graphite">
{children}
</div>
);
}
}

View File

@@ -1,16 +1,26 @@
import { notFound } from 'next/navigation';
import { PageWrapper } from '@/components/shared/state/PageWrapper';
import { SponsorLeagueDetailTemplate } from '@/templates/SponsorLeagueDetailTemplate';
import { PageDataFetcher } from '@/lib/page/PageDataFetcher';
import { SPONSOR_SERVICE_TOKEN } from '@/lib/di/tokens';
import type { SponsorService } from '@/lib/services/sponsors/SponsorService';
import { SponsorsApiClient } from '@/lib/api/sponsors/SponsorsApiClient';
import { EnhancedErrorReporter } from '@/lib/infrastructure/EnhancedErrorReporter';
import { ConsoleLogger } from '@/lib/infrastructure/logging/ConsoleLogger';
import { getWebsiteApiBaseUrl } from '@/lib/config/apiBaseUrl';
export default async function Page({ params }: { params: { id: string } }) {
const data = await PageDataFetcher.fetch<SponsorService, 'getLeagueDetail'>(
SPONSOR_SERVICE_TOKEN,
'getLeagueDetail',
params.id
);
// Manual wiring: create dependencies
const baseUrl = getWebsiteApiBaseUrl();
const logger = new ConsoleLogger();
const errorReporter = new EnhancedErrorReporter(logger, {
showUserNotifications: true,
logToConsole: true,
reportToExternal: process.env.NODE_ENV === 'production',
});
// Create API client
const apiClient = new SponsorsApiClient(baseUrl, errorReporter, logger);
// Fetch data
const data = await apiClient.getLeagueDetail(params.id);
if (!data) notFound();

View File

@@ -1,15 +1,26 @@
import { PageWrapper } from '@/components/shared/state/PageWrapper';
import { SponsorLeaguesTemplate } from '@/templates/SponsorLeaguesTemplate';
import { PageDataFetcher } from '@/lib/page/PageDataFetcher';
import { SPONSOR_SERVICE_TOKEN } from '@/lib/di/tokens';
import { SponsorService } from '@/lib/services/sponsors/SponsorService';
import { SponsorsApiClient } from '@/lib/api/sponsors/SponsorsApiClient';
import { EnhancedErrorReporter } from '@/lib/infrastructure/EnhancedErrorReporter';
import { ConsoleLogger } from '@/lib/infrastructure/logging/ConsoleLogger';
import { getWebsiteApiBaseUrl } from '@/lib/config/apiBaseUrl';
import { AvailableLeaguesViewModel } from '@/lib/view-models/AvailableLeaguesViewModel';
export default async function Page() {
const leaguesData = await PageDataFetcher.fetch<SponsorService, 'getAvailableLeagues'>(
SPONSOR_SERVICE_TOKEN,
'getAvailableLeagues'
);
// Manual wiring: create dependencies
const baseUrl = getWebsiteApiBaseUrl();
const logger = new ConsoleLogger();
const errorReporter = new EnhancedErrorReporter(logger, {
showUserNotifications: true,
logToConsole: true,
reportToExternal: process.env.NODE_ENV === 'production',
});
// Create API client
const apiClient = new SponsorsApiClient(baseUrl, errorReporter, logger);
// Fetch data
const leaguesData = await apiClient.getAvailableLeagues();
// Process data with view model to calculate stats
if (!leaguesData) {