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

@@ -0,0 +1,36 @@
import { Result } from '@/lib/contracts/Result';
import { LeagueService } from '@/lib/services/leagues/LeagueService';
import { LeaguesApiClient } from '@/lib/api/leagues/LeaguesApiClient';
import { ConsoleErrorReporter } from '@/lib/infrastructure/logging/ConsoleErrorReporter';
import { ConsoleLogger } from '@/lib/infrastructure/logging/ConsoleLogger';
import type { CreateLeagueInputDTO } from '@/lib/types/generated/CreateLeagueInputDTO';
/**
* CreateLeagueMutation
*
* Framework-agnostic mutation for league creation.
* Can be called from Server Actions or other contexts.
*/
export class CreateLeagueMutation {
private service: LeagueService;
constructor() {
// Manual wiring for serverless
const baseUrl = process.env.NEXT_PUBLIC_API_URL || '';
const errorReporter = new ConsoleErrorReporter();
const logger = new ConsoleLogger();
const apiClient = new LeaguesApiClient(baseUrl, errorReporter, logger);
this.service = new LeagueService(apiClient);
}
async createLeague(input: CreateLeagueInputDTO): Promise<Result<void, string>> {
try {
await this.service.createLeague(input);
return Result.ok(undefined);
} catch (error) {
console.error('createLeague failed:', error);
return Result.err('Failed to create league');
}
}
}

View File

@@ -0,0 +1,57 @@
import { Result } from '@/lib/contracts/Result';
import { ProtestService } from '@/lib/services/protests/ProtestService';
import { ProtestsApiClient } from '@/lib/api/protests/ProtestsApiClient';
import { ConsoleErrorReporter } from '@/lib/infrastructure/logging/ConsoleErrorReporter';
import { ConsoleLogger } from '@/lib/infrastructure/logging/ConsoleLogger';
import type { ApplyPenaltyCommandDTO } from '@/lib/types/generated/ApplyPenaltyCommandDTO';
import type { RequestProtestDefenseCommandDTO } from '@/lib/types/generated/RequestProtestDefenseCommandDTO';
/**
* ProtestReviewMutation
*
* Framework-agnostic mutation for protest review operations.
* Can be called from Server Actions or other contexts.
*/
export class ProtestReviewMutation {
private service: ProtestService;
constructor() {
// Manual wiring for serverless
const baseUrl = process.env.NEXT_PUBLIC_API_URL || '';
const errorReporter = new ConsoleErrorReporter();
const logger = new ConsoleLogger();
const apiClient = new ProtestsApiClient(baseUrl, errorReporter, logger);
this.service = new ProtestService(apiClient);
}
async applyPenalty(input: ApplyPenaltyCommandDTO): Promise<Result<void, string>> {
try {
await this.service.applyPenalty(input);
return Result.ok(undefined);
} catch (error) {
console.error('applyPenalty failed:', error);
return Result.err('Failed to apply penalty');
}
}
async requestDefense(input: RequestProtestDefenseCommandDTO): Promise<Result<void, string>> {
try {
await this.service.requestDefense(input);
return Result.ok(undefined);
} catch (error) {
console.error('requestDefense failed:', error);
return Result.err('Failed to request defense');
}
}
async reviewProtest(input: { protestId: string; stewardId: string; decision: string; decisionNotes: string }): Promise<Result<void, string>> {
try {
await this.service.reviewProtest(input as any);
return Result.ok(undefined);
} catch (error) {
console.error('reviewProtest failed:', error);
return Result.err('Failed to review protest');
}
}
}

View File

@@ -0,0 +1,66 @@
import { Result } from '@/lib/contracts/Result';
import { LeagueService } from '@/lib/services/leagues/LeagueService';
import { LeaguesApiClient } from '@/lib/api/leagues/LeaguesApiClient';
import { ConsoleErrorReporter } from '@/lib/infrastructure/logging/ConsoleErrorReporter';
import { ConsoleLogger } from '@/lib/infrastructure/logging/ConsoleLogger';
import type { MembershipRole } from '@/lib/types/MembershipRole';
/**
* RosterAdminMutation
*
* Framework-agnostic mutation for roster administration operations.
* Can be called from Server Actions or other contexts.
*/
export class RosterAdminMutation {
private service: LeagueService;
constructor() {
// Manual wiring for serverless
const baseUrl = process.env.NEXT_PUBLIC_API_URL || '';
const errorReporter = new ConsoleErrorReporter();
const logger = new ConsoleLogger();
const apiClient = new LeaguesApiClient(baseUrl, errorReporter, logger);
this.service = new LeagueService(apiClient);
}
async approveJoinRequest(leagueId: string, joinRequestId: string): Promise<Result<void, string>> {
try {
await this.service.approveJoinRequest(leagueId, joinRequestId);
return Result.ok(undefined);
} catch (error) {
console.error('approveJoinRequest failed:', error);
return Result.err('Failed to approve join request');
}
}
async rejectJoinRequest(leagueId: string, joinRequestId: string): Promise<Result<void, string>> {
try {
await this.service.rejectJoinRequest(leagueId, joinRequestId);
return Result.ok(undefined);
} catch (error) {
console.error('rejectJoinRequest failed:', error);
return Result.err('Failed to reject join request');
}
}
async updateMemberRole(leagueId: string, driverId: string, role: MembershipRole): Promise<Result<void, string>> {
try {
await this.service.updateMemberRole(leagueId, driverId, role);
return Result.ok(undefined);
} catch (error) {
console.error('updateMemberRole failed:', error);
return Result.err('Failed to update member role');
}
}
async removeMember(leagueId: string, driverId: string): Promise<Result<void, string>> {
try {
await this.service.removeMember(leagueId, driverId);
return Result.ok(undefined);
} catch (error) {
console.error('removeMember failed:', error);
return Result.err('Failed to remove member');
}
}
}

View File

@@ -0,0 +1,77 @@
import { Result } from '@/lib/contracts/Result';
import { LeagueService } from '@/lib/services/leagues/LeagueService';
import { LeaguesApiClient } from '@/lib/api/leagues/LeaguesApiClient';
import { ConsoleErrorReporter } from '@/lib/infrastructure/logging/ConsoleErrorReporter';
import { ConsoleLogger } from '@/lib/infrastructure/logging/ConsoleLogger';
import type { CreateLeagueScheduleRaceInputDTO } from '@/lib/types/generated/CreateLeagueScheduleRaceInputDTO';
import type { UpdateLeagueScheduleRaceInputDTO } from '@/lib/types/generated/UpdateLeagueScheduleRaceInputDTO';
/**
* ScheduleAdminMutation
*
* Framework-agnostic mutation for schedule administration operations.
* Can be called from Server Actions or other contexts.
*/
export class ScheduleAdminMutation {
private service: LeagueService;
constructor() {
// Manual wiring for serverless
const baseUrl = process.env.NEXT_PUBLIC_API_URL || '';
const errorReporter = new ConsoleErrorReporter();
const logger = new ConsoleLogger();
const apiClient = new LeaguesApiClient(baseUrl, errorReporter, logger);
this.service = new LeagueService(apiClient);
}
async publishSchedule(leagueId: string, seasonId: string): Promise<Result<void, string>> {
try {
await this.service.publishAdminSchedule(leagueId, seasonId);
return Result.ok(undefined);
} catch (error) {
console.error('publishSchedule failed:', error);
return Result.err('Failed to publish schedule');
}
}
async unpublishSchedule(leagueId: string, seasonId: string): Promise<Result<void, string>> {
try {
await this.service.unpublishAdminSchedule(leagueId, seasonId);
return Result.ok(undefined);
} catch (error) {
console.error('unpublishSchedule failed:', error);
return Result.err('Failed to unpublish schedule');
}
}
async createRace(leagueId: string, seasonId: string, input: { track: string; car: string; scheduledAtIso: string }): Promise<Result<void, string>> {
try {
await this.service.createAdminScheduleRace(leagueId, seasonId, input);
return Result.ok(undefined);
} catch (error) {
console.error('createRace failed:', error);
return Result.err('Failed to create race');
}
}
async updateRace(leagueId: string, seasonId: string, raceId: string, input: Partial<{ track: string; car: string; scheduledAtIso: string }>): Promise<Result<void, string>> {
try {
await this.service.updateAdminScheduleRace(leagueId, seasonId, raceId, input);
return Result.ok(undefined);
} catch (error) {
console.error('updateRace failed:', error);
return Result.err('Failed to update race');
}
}
async deleteRace(leagueId: string, seasonId: string, raceId: string): Promise<Result<void, string>> {
try {
await this.service.deleteAdminScheduleRace(leagueId, seasonId, raceId);
return Result.ok(undefined);
} catch (error) {
console.error('deleteRace failed:', error);
return Result.err('Failed to delete race');
}
}
}