website refactor
This commit is contained in:
39
apps/website/lib/services/leagues/LeagueScheduleService.ts
Normal file
39
apps/website/lib/services/leagues/LeagueScheduleService.ts
Normal file
@@ -0,0 +1,39 @@
|
||||
import { Result } from '@/lib/contracts/Result';
|
||||
import { Service } from '@/lib/contracts/services/Service';
|
||||
import { LeagueScheduleApiDto } from '@/lib/types/tbd/LeagueScheduleApiDto';
|
||||
|
||||
export class LeagueScheduleService implements Service {
|
||||
async getScheduleData(leagueId: string): Promise<Result<LeagueScheduleApiDto, never>> {
|
||||
// Mock data since backend not implemented
|
||||
const mockData: LeagueScheduleApiDto = {
|
||||
leagueId,
|
||||
races: [
|
||||
{
|
||||
id: 'race-1',
|
||||
name: 'Round 1 - Monza',
|
||||
date: '2024-10-15T14:00:00Z',
|
||||
track: 'Monza Circuit',
|
||||
car: 'Ferrari SF90',
|
||||
sessionType: 'Race',
|
||||
},
|
||||
{
|
||||
id: 'race-2',
|
||||
name: 'Round 2 - Silverstone',
|
||||
date: '2024-10-22T13:00:00Z',
|
||||
track: 'Silverstone Circuit',
|
||||
car: 'Mercedes W10',
|
||||
sessionType: 'Race',
|
||||
},
|
||||
{
|
||||
id: 'race-3',
|
||||
name: 'Round 3 - Spa-Francorchamps',
|
||||
date: '2024-10-29T12:00:00Z',
|
||||
track: 'Circuit de Spa-Francorchamps',
|
||||
car: 'Red Bull RB15',
|
||||
sessionType: 'Race',
|
||||
},
|
||||
],
|
||||
};
|
||||
return Result.ok(mockData);
|
||||
}
|
||||
}
|
||||
@@ -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);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,59 @@
|
||||
import { Result } from '@/lib/contracts/Result';
|
||||
import { Service } from '@/lib/contracts/services/Service';
|
||||
import { LeagueSponsorshipsApiDto } from '@/lib/types/tbd/LeagueSponsorshipsApiDto';
|
||||
|
||||
export class LeagueSponsorshipsService implements Service {
|
||||
async getSponsorshipsData(leagueId: string): Promise<Result<LeagueSponsorshipsApiDto, never>> {
|
||||
// Mock data since backend not implemented
|
||||
const mockData: LeagueSponsorshipsApiDto = {
|
||||
leagueId,
|
||||
league: {
|
||||
id: leagueId,
|
||||
name: 'Mock League',
|
||||
description: 'A league with sponsorship opportunities',
|
||||
},
|
||||
sponsorshipSlots: [
|
||||
{
|
||||
id: 'slot-1',
|
||||
name: 'Main Sponsor',
|
||||
description: 'Primary sponsorship slot',
|
||||
price: 5000,
|
||||
currency: 'USD',
|
||||
isAvailable: false,
|
||||
sponsoredBy: {
|
||||
id: 'sponsor-1',
|
||||
name: 'Acme Racing',
|
||||
logoUrl: 'https://example.com/logo.png',
|
||||
},
|
||||
},
|
||||
{
|
||||
id: 'slot-2',
|
||||
name: 'Helmet Sponsor',
|
||||
description: 'Helmet branding sponsorship',
|
||||
price: 2000,
|
||||
currency: 'USD',
|
||||
isAvailable: true,
|
||||
},
|
||||
{
|
||||
id: 'slot-3',
|
||||
name: 'Car Sponsor',
|
||||
description: 'Car livery sponsorship',
|
||||
price: 3000,
|
||||
currency: 'USD',
|
||||
isAvailable: true,
|
||||
},
|
||||
],
|
||||
sponsorshipRequests: [
|
||||
{
|
||||
id: 'request-1',
|
||||
slotId: 'slot-2',
|
||||
sponsorId: 'sponsor-2',
|
||||
sponsorName: 'SpeedWorks',
|
||||
requestedAt: '2024-10-01T10:00:00Z',
|
||||
status: 'pending',
|
||||
},
|
||||
],
|
||||
};
|
||||
return Result.ok(mockData);
|
||||
}
|
||||
}
|
||||
@@ -1,40 +1,49 @@
|
||||
import { WalletsApiClient } from '@/lib/api/wallets/WalletsApiClient';
|
||||
import type { LeagueWalletDTO, WithdrawRequestDTO, WithdrawResponseDTO } from '@/lib/api/wallets/WalletsApiClient';
|
||||
import { Result } from '@/lib/contracts/Result';
|
||||
import { Service } from '@/lib/contracts/services/Service';
|
||||
import { LeagueWalletApiDto } from '@/lib/types/tbd/LeagueWalletApiDto';
|
||||
|
||||
/**
|
||||
* LeagueWalletService - DTO Only
|
||||
*
|
||||
* Returns raw API DTOs. No ViewModels or UX logic.
|
||||
* All client-side presentation logic must be handled by hooks/components.
|
||||
*/
|
||||
export class LeagueWalletService {
|
||||
constructor(
|
||||
private readonly apiClient: WalletsApiClient
|
||||
) {}
|
||||
|
||||
/**
|
||||
* Get wallet for a league
|
||||
*/
|
||||
async getWalletForLeague(leagueId: string): Promise<LeagueWalletDTO> {
|
||||
return this.apiClient.getLeagueWallet(leagueId);
|
||||
}
|
||||
|
||||
/**
|
||||
* Withdraw from league wallet
|
||||
*/
|
||||
async withdraw(
|
||||
leagueId: string,
|
||||
amount: number,
|
||||
currency: string,
|
||||
seasonId: string,
|
||||
destinationAccount: string
|
||||
): Promise<WithdrawResponseDTO> {
|
||||
const payload: WithdrawRequestDTO = {
|
||||
amount,
|
||||
currency,
|
||||
seasonId,
|
||||
destinationAccount,
|
||||
export class LeagueWalletService implements Service {
|
||||
async getWalletData(leagueId: string): Promise<Result<LeagueWalletApiDto, never>> {
|
||||
// Mock data since backend not implemented
|
||||
const mockData: LeagueWalletApiDto = {
|
||||
leagueId,
|
||||
balance: 15750.00,
|
||||
currency: 'USD',
|
||||
transactions: [
|
||||
{
|
||||
id: 'txn-1',
|
||||
type: 'sponsorship',
|
||||
amount: 5000.00,
|
||||
description: 'Main sponsorship from Acme Racing',
|
||||
createdAt: '2024-10-01T10:00:00Z',
|
||||
status: 'completed',
|
||||
},
|
||||
{
|
||||
id: 'txn-2',
|
||||
type: 'prize',
|
||||
amount: 2500.00,
|
||||
description: 'Prize money from championship',
|
||||
createdAt: '2024-09-15T14:30:00Z',
|
||||
status: 'completed',
|
||||
},
|
||||
{
|
||||
id: 'txn-3',
|
||||
type: 'withdrawal',
|
||||
amount: -1200.00,
|
||||
description: 'Equipment purchase',
|
||||
createdAt: '2024-09-10T09:15:00Z',
|
||||
status: 'completed',
|
||||
},
|
||||
{
|
||||
id: 'txn-4',
|
||||
type: 'deposit',
|
||||
amount: 5000.00,
|
||||
description: 'Entry fees from season registration',
|
||||
createdAt: '2024-08-01T12:00:00Z',
|
||||
status: 'completed',
|
||||
},
|
||||
],
|
||||
};
|
||||
return this.apiClient.withdrawFromLeagueWallet(leagueId, payload);
|
||||
return Result.ok(mockData);
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user