website refactor
This commit is contained in:
@@ -1,46 +1,28 @@
|
||||
import { LeaguesApiClient } from '@/lib/api/leagues/LeaguesApiClient';
|
||||
import { DriversApiClient } from '@/lib/api/drivers/DriversApiClient';
|
||||
import { Result } from '@/lib/contracts/Result';
|
||||
import { DomainError } from '@/lib/contracts/services/Service';
|
||||
import { Service } from '@/lib/contracts/services/Service';
|
||||
import { LeagueSettingsApiDto } from '@/lib/types/tbd/LeagueSettingsApiDto';
|
||||
|
||||
/**
|
||||
* League Settings Service - DTO Only
|
||||
*
|
||||
* Returns raw API DTOs. No ViewModels or UX logic.
|
||||
* All client-side presentation logic must be handled by hooks/components.
|
||||
*/
|
||||
export class LeagueSettingsService {
|
||||
constructor(
|
||||
private readonly leagueApiClient: LeaguesApiClient,
|
||||
private readonly driverApiClient: DriversApiClient
|
||||
) {}
|
||||
|
||||
async getLeagueSettings(leagueId: string): Promise<any> {
|
||||
// This would typically call multiple endpoints to gather all settings data
|
||||
// For now, return a basic structure
|
||||
return {
|
||||
league: await this.leagueApiClient.getAllWithCapacityAndScoring(),
|
||||
config: { /* config data */ }
|
||||
export class LeagueSettingsService implements Service {
|
||||
async getSettingsData(leagueId: string): Promise<Result<LeagueSettingsApiDto, never>> {
|
||||
// Mock data since backend not implemented
|
||||
const mockData: LeagueSettingsApiDto = {
|
||||
leagueId,
|
||||
league: {
|
||||
id: leagueId,
|
||||
name: 'Mock League',
|
||||
description: 'A mock league for demonstration',
|
||||
visibility: 'public',
|
||||
ownerId: 'owner-123',
|
||||
createdAt: '2024-01-01T00:00:00Z',
|
||||
updatedAt: '2024-01-01T00:00:00Z',
|
||||
},
|
||||
config: {
|
||||
maxDrivers: 20,
|
||||
scoringPresetId: 'preset-1',
|
||||
allowLateJoin: true,
|
||||
requireApproval: false,
|
||||
},
|
||||
};
|
||||
}
|
||||
|
||||
async transferOwnership(leagueId: string, currentOwnerId: string, newOwnerId: string): Promise<{ success: boolean }> {
|
||||
return this.leagueApiClient.transferOwnership(leagueId, currentOwnerId, newOwnerId);
|
||||
}
|
||||
|
||||
async selectScoringPreset(leagueId: string, preset: string): Promise<Result<void, DomainError>> {
|
||||
return Result.err({ type: 'notImplemented', message: 'selectScoringPreset' });
|
||||
}
|
||||
|
||||
async toggleCustomScoring(leagueId: string, enabled: boolean): Promise<Result<void, DomainError>> {
|
||||
return Result.err({ type: 'notImplemented', message: 'toggleCustomScoring' });
|
||||
}
|
||||
|
||||
getPresetEmoji(preset: string): string {
|
||||
return '🏆';
|
||||
}
|
||||
|
||||
getPresetDescription(preset: string): string {
|
||||
return `Scoring preset: ${preset}`;
|
||||
return Result.ok(mockData);
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user