diff --git a/apps/website/app/leagues/[id]/schedule/page.tsx b/apps/website/app/leagues/[id]/schedule/page.tsx
index 9ea007522..e09ac0860 100644
--- a/apps/website/app/leagues/[id]/schedule/page.tsx
+++ b/apps/website/app/leagues/[id]/schedule/page.tsx
@@ -1,111 +1,31 @@
-import { PageWrapper } from '@/components/shared/state/PageWrapper';
+import { LeagueSchedulePageQuery } from '@/lib/page-queries/page-queries/LeagueSchedulePageQuery';
import { LeagueScheduleTemplate } from '@/templates/LeagueScheduleTemplate';
-import { PageDataFetcher } from '@/lib/page/PageDataFetcher';
-import { LeagueService } from '@/lib/services/leagues/LeagueService';
-import { LeaguesApiClient } from '@/lib/api/leagues/LeaguesApiClient';
-import { DriversApiClient } from '@/lib/api/drivers/DriversApiClient';
-import { SponsorsApiClient } from '@/lib/api/sponsors/SponsorsApiClient';
-import { RacesApiClient } from '@/lib/api/races/RacesApiClient';
-import { EnhancedErrorReporter } from '@/lib/infrastructure/EnhancedErrorReporter';
-import { ConsoleLogger } from '@/lib/infrastructure/logging/ConsoleLogger';
-import { getWebsiteApiBaseUrl } from '@/lib/config/apiBaseUrl';
import { notFound } from 'next/navigation';
-import { LeagueScheduleViewModel, LeagueScheduleRaceViewModel } from '@/lib/view-models/LeagueScheduleViewModel';
-import type { LeagueScheduleDTO } from '@/lib/types/generated/LeagueScheduleDTO';
-import type { RaceDTO } from '@/lib/types/generated/RaceDTO';
interface Props {
params: { id: string };
}
-function mapRaceDtoToViewModel(race: RaceDTO): LeagueScheduleRaceViewModel {
- const scheduledAt = race.date ? new Date(race.date) : new Date(0);
- const now = new Date();
- const isPast = scheduledAt.getTime() < now.getTime();
- const isUpcoming = !isPast;
+export default async function LeagueSchedulePage({ params }: Props) {
+ const leagueId = params.id;
- return {
- id: race.id,
- name: race.name,
- scheduledAt,
- isPast,
- isUpcoming,
- status: isPast ? 'completed' : 'scheduled',
- track: undefined,
- car: undefined,
- sessionType: undefined,
- isRegistered: undefined,
- };
-}
-
-function mapScheduleDtoToViewModel(dto: LeagueScheduleDTO): LeagueScheduleViewModel {
- const races = dto.races.map(mapRaceDtoToViewModel);
- return new LeagueScheduleViewModel(races);
-}
-
-export default async function Page({ params }: Props) {
- // Validate params
- if (!params.id) {
+ if (!leagueId) {
notFound();
}
- // Fetch data using PageDataFetcher.fetchManual for multiple dependencies
- const data = await PageDataFetcher.fetchManual(async () => {
- // Create dependencies
- const baseUrl = getWebsiteApiBaseUrl();
- const logger = new ConsoleLogger();
- const errorReporter = new EnhancedErrorReporter(logger, {
- showUserNotifications: true,
- logToConsole: true,
- reportToExternal: process.env.NODE_ENV === 'production',
- });
+ const result = await LeagueSchedulePageQuery.execute(leagueId);
- // Create API clients
- const leaguesApiClient = new LeaguesApiClient(baseUrl, errorReporter, logger);
- const driversApiClient = new DriversApiClient(baseUrl, errorReporter, logger);
- const sponsorsApiClient = new SponsorsApiClient(baseUrl, errorReporter, logger);
- const racesApiClient = new RacesApiClient(baseUrl, errorReporter, logger);
-
- // Create service
- const service = new LeagueService(
- leaguesApiClient,
- driversApiClient,
- sponsorsApiClient,
- racesApiClient
- );
-
- // Fetch data
- const result = await service.getLeagueSchedule(params.id);
- if (!result) {
- throw new Error('League schedule not found');
+ if (result.isErr()) {
+ const error = result.getError();
+ if (error.type === 'notFound') {
+ notFound();
}
- return mapScheduleDtoToViewModel(result);
- });
-
- if (!data) {
- notFound();
+ // For serverError, show the template with empty data
+ return
- Only league admins can access settings.
- Manage your league configurationAdmin Access Required
- League Settings
-
Manage sponsorship slots and review requests
-
- {displayRaces.length} {displayRaces.length === 1 ? 'race' : 'races'}
+
+ Upcoming and completed races for this season
No {filter} races Schedule your first race to get started No Races Scheduled The race schedule will appear here once events are added. {carLabel} {sessionTypeLabel}
- {race.scheduledAt.toLocaleDateString('en-US', {
- month: 'short',
- day: 'numeric',
- year: 'numeric',
- })}
-
- {race.scheduledAt.toLocaleTimeString([], {
- hour: '2-digit',
- minute: '2-digit',
- })}
- View Results →
+ Manage your league configuration and preferences
+ Basic league details {viewData.league.name} {viewData.league.visibility} {viewData.league.description} {new Date(viewData.league.createdAt).toLocaleDateString()} {viewData.league.ownerId} League rules and limits Max Drivers {viewData.config.maxDrivers} Require Approval {viewData.config.requireApproval ? 'Yes' : 'No'} Allow Late Join {viewData.config.allowLateJoin ? 'Yes' : 'No'} Scoring Preset {viewData.config.scoringPresetId}
+ Form-based editing and ownership transfer functionality will be implemented in future updates.
+
+ Manage sponsorship slots and review requests
+ Available sponsorship opportunities No sponsorship slots available {slot.description} Sponsored by {slot.sponsoredBy.name} Pending and processed sponsorship applications No sponsorship requests
+ Interactive management features for approving requests and managing slots will be implemented in future updates.
+
+ Financial overview and transaction history
+ Current Balance
+ {formatCurrency(viewData.balance)}
+ Recent financial activity No transactions yet
+ {transaction.description}
+ = 0 ? 'text-performance-green' : 'text-red-400'
+ }`}>
+ {transaction.amount >= 0 ? '+' : '-'}{formatCurrency(transaction.amount)}
+
+ Interactive withdrawal and export features will be implemented in future updates.
+ Race Schedule
+ {trackLabel}
- {isUpcoming && !isRegistered && (
-
- Upcoming
-
- )}
- {isUpcoming && isRegistered && (
-
- ✓ Registered
-
- )}
- {isPast && (
-
- Completed
-
- )}
- {race.name}
+
+ {race.status === 'completed' ? 'Completed' : 'Scheduled'}
+
League Settings
+ League Information
+ Configuration
+ Settings Management
+ Sponsorships
+ Sponsorship Slots
+ {slot.name}
+
+ {slot.isAvailable ? 'Available' : 'Taken'}
+
+ Sponsorship Requests
+ Sponsorship Management
+ League Wallet
+ Transaction History
+ Wallet Management
+