website cleanup
This commit is contained in:
@@ -6,6 +6,8 @@ import type { RequestAvatarGenerationOutputDTO } from '../../types/generated/Req
|
||||
import type { UpdateAvatarInputDTO } from '../../types/generated/UpdateAvatarInputDTO';
|
||||
import type { UpdateAvatarOutputDTO } from '../../types/generated/UpdateAvatarOutputDTO';
|
||||
import type { UploadMediaOutputDTO } from '../../types/generated/UploadMediaOutputDTO';
|
||||
import type { ValidateFaceInputDTO } from '../../types/generated/ValidateFaceInputDTO';
|
||||
import type { ValidateFaceOutputDTO } from '../../types/generated/ValidateFaceOutputDTO';
|
||||
import { BaseApiClient } from '../base/BaseApiClient';
|
||||
|
||||
/**
|
||||
@@ -49,4 +51,9 @@ export class MediaApiClient extends BaseApiClient {
|
||||
updateAvatar(input: UpdateAvatarInputDTO): Promise<UpdateAvatarOutputDTO> {
|
||||
return this.put<UpdateAvatarOutputDTO>(`/media/avatar/${input.driverId}`, { avatarUrl: input.avatarUrl });
|
||||
}
|
||||
|
||||
/** Validate face photo for avatar generation */
|
||||
validateFacePhoto(input: ValidateFaceInputDTO): Promise<ValidateFaceOutputDTO> {
|
||||
return this.post<ValidateFaceOutputDTO>('/media/avatar/validate-face', input);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
import { ApplyPenaltyCommandDTO } from '../../types';
|
||||
import { ApplyPenaltyCommandDTO } from '../../types/generated/ApplyPenaltyCommandDTO';
|
||||
|
||||
export type PenaltyType = 'time_penalty' | 'grid_penalty' | 'points_deduction' | 'disqualification' | 'warning' | 'license_points';
|
||||
|
||||
@@ -48,6 +48,7 @@ export class ProtestDecisionCommandModel {
|
||||
raceId,
|
||||
driverId,
|
||||
stewardId,
|
||||
enum: this.penaltyType, // Use penaltyType as enum
|
||||
type: this.penaltyType,
|
||||
value: this.getPenaltyValue(),
|
||||
reason,
|
||||
|
||||
@@ -42,6 +42,7 @@ import { MembershipFeeService } from './payments/MembershipFeeService';
|
||||
import { AuthService } from './auth/AuthService';
|
||||
import { SessionService } from './auth/SessionService';
|
||||
import { ProtestService } from './protests/ProtestService';
|
||||
import { OnboardingService } from './onboarding/OnboardingService';
|
||||
|
||||
/**
|
||||
* ServiceFactory - Composition root for all services
|
||||
@@ -298,10 +299,17 @@ export class ServiceFactory {
|
||||
return new PenaltyService(this.apiClients.penalties);
|
||||
}
|
||||
|
||||
/**
|
||||
* Create OnboardingService instance
|
||||
*/
|
||||
createOnboardingService(): OnboardingService {
|
||||
return new OnboardingService(this.apiClients.media, this.apiClients.drivers);
|
||||
}
|
||||
|
||||
/**
|
||||
* Create LandingService instance (used by server components)
|
||||
*/
|
||||
createLandingService(): LandingService {
|
||||
return new LandingService(this.apiClients.races, this.apiClients.leagues, this.apiClients.teams);
|
||||
return new LandingService(this.apiClients.races, this.apiClients.leagues, this.apiClients.teams, this.apiClients.auth);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -30,6 +30,8 @@ import { SponsorService } from './sponsors/SponsorService';
|
||||
import { SponsorshipService } from './sponsors/SponsorshipService';
|
||||
import { TeamJoinService } from './teams/TeamJoinService';
|
||||
import { TeamService } from './teams/TeamService';
|
||||
import { OnboardingService } from './onboarding/OnboardingService';
|
||||
import { LandingService } from './landing/LandingService';
|
||||
|
||||
export interface Services {
|
||||
raceService: RaceService;
|
||||
@@ -57,6 +59,8 @@ export interface Services {
|
||||
sessionService: SessionService;
|
||||
protestService: ProtestService;
|
||||
penaltyService: PenaltyService;
|
||||
onboardingService: OnboardingService;
|
||||
landingService: LandingService;
|
||||
}
|
||||
|
||||
const queryClient = new QueryClient({
|
||||
@@ -104,6 +108,8 @@ export function ServiceProvider({ children }: ServiceProviderProps) {
|
||||
sessionService: serviceFactory.createSessionService(),
|
||||
protestService: serviceFactory.createProtestService(),
|
||||
penaltyService: serviceFactory.createPenaltyService(),
|
||||
onboardingService: serviceFactory.createOnboardingService(),
|
||||
landingService: serviceFactory.createLandingService(),
|
||||
};
|
||||
}, []);
|
||||
|
||||
|
||||
@@ -1,22 +1,27 @@
|
||||
import { RacesApiClient } from '@/lib/api/races/RacesApiClient';
|
||||
import { LeaguesApiClient } from '@/lib/api/leagues/LeaguesApiClient';
|
||||
import { TeamsApiClient } from '@/lib/api/teams/TeamsApiClient';
|
||||
import { AuthApiClient } from '@/lib/api/auth/AuthApiClient';
|
||||
import type { AllLeaguesWithCapacityDTO } from '@/lib/types/generated/AllLeaguesWithCapacityDTO';
|
||||
import type { GetAllTeamsOutputDTO } from '@/lib/types/generated/GetAllTeamsOutputDTO';
|
||||
import type { RacesPageDataDTO } from '@/lib/types/generated/RacesPageDataDTO';
|
||||
import type { LeagueSummaryDTO } from '@/lib/types/generated/LeagueSummaryDTO';
|
||||
import type { LeagueWithCapacityDTO } from '@/lib/types/generated/LeagueWithCapacityDTO';
|
||||
import type { TeamListItemDTO } from '@/lib/types/generated/TeamListItemDTO';
|
||||
import type { SignupParamsDTO } from '@/lib/types/generated/SignupParamsDTO';
|
||||
import type { AuthSessionDTO } from '@/lib/types/generated/AuthSessionDTO';
|
||||
import { RacesPageViewModel } from '@/lib/view-models/RacesPageViewModel';
|
||||
import { HomeDiscoveryViewModel } from '@/lib/view-models/HomeDiscoveryViewModel';
|
||||
import { LeagueCardViewModel } from '@/lib/view-models/LeagueCardViewModel';
|
||||
import { TeamCardViewModel } from '@/lib/view-models/TeamCardViewModel';
|
||||
import { UpcomingRaceCardViewModel } from '@/lib/view-models/UpcomingRaceCardViewModel';
|
||||
import { EmailSignupViewModel } from '@/lib/view-models/EmailSignupViewModel';
|
||||
|
||||
export class LandingService {
|
||||
constructor(
|
||||
private readonly racesApi: RacesApiClient,
|
||||
private readonly leaguesApi: LeaguesApiClient,
|
||||
private readonly teamsApi: TeamsApiClient,
|
||||
private readonly authApi: AuthApiClient,
|
||||
) {}
|
||||
|
||||
async getHomeDiscovery(): Promise<HomeDiscoveryViewModel> {
|
||||
@@ -29,10 +34,10 @@ export class LandingService {
|
||||
const racesVm = new RacesPageViewModel(racesDto);
|
||||
|
||||
const topLeagues = leaguesDto.leagues.slice(0, 4).map(
|
||||
(league: LeagueSummaryDTO) => new LeagueCardViewModel({
|
||||
(league: LeagueWithCapacityDTO) => new LeagueCardViewModel({
|
||||
id: league.id,
|
||||
name: league.name,
|
||||
description: 'Competitive iRacing league',
|
||||
description: league.description ?? 'Competitive iRacing league',
|
||||
}),
|
||||
);
|
||||
|
||||
@@ -62,4 +67,36 @@ export class LandingService {
|
||||
upcomingRaces,
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Sign up for early access with email
|
||||
* Uses the auth signup endpoint
|
||||
*/
|
||||
async signup(email: string): Promise<EmailSignupViewModel> {
|
||||
try {
|
||||
// Create signup params with default values for early access
|
||||
const signupParams: SignupParamsDTO = {
|
||||
email,
|
||||
password: 'temp_password_' + Math.random().toString(36).substring(7), // Temporary password
|
||||
displayName: email.split('@')[0], // Use email prefix as display name
|
||||
};
|
||||
|
||||
const session: AuthSessionDTO = await this.authApi.signup(signupParams);
|
||||
|
||||
if (session?.user?.userId) {
|
||||
return new EmailSignupViewModel(email, 'Welcome to GridPilot! Check your email to confirm.', 'success');
|
||||
} else {
|
||||
return new EmailSignupViewModel(email, 'Signup successful but session not created.', 'error');
|
||||
}
|
||||
} catch (error: any) {
|
||||
// Handle specific error cases
|
||||
if (error?.status === 429) {
|
||||
return new EmailSignupViewModel(email, 'Too many requests. Please try again later.', 'error');
|
||||
}
|
||||
if (error?.status === 409) {
|
||||
return new EmailSignupViewModel(email, 'This email is already registered.', 'info');
|
||||
}
|
||||
return new EmailSignupViewModel(email, 'Something broke. Try again?', 'error');
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -31,6 +31,7 @@ export class LeagueSettingsService {
|
||||
id: leagueDto.id,
|
||||
name: leagueDto.name,
|
||||
ownerId: leagueDto.ownerId,
|
||||
createdAt: leagueDto.createdAt || new Date().toISOString(),
|
||||
};
|
||||
|
||||
// Get config
|
||||
@@ -101,4 +102,4 @@ export class LeagueSettingsService {
|
||||
throw error;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -29,7 +29,12 @@ export class AvatarService {
|
||||
*/
|
||||
async getAvatar(driverId: string): Promise<AvatarViewModel> {
|
||||
const dto = await this.apiClient.getAvatar(driverId);
|
||||
return new AvatarViewModel(dto);
|
||||
// Convert GetAvatarOutputDTO to AvatarDTO format
|
||||
const avatarDto = {
|
||||
driverId: driverId,
|
||||
avatarUrl: dto.avatarUrl
|
||||
};
|
||||
return new AvatarViewModel(avatarDto);
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
60
apps/website/lib/services/onboarding/OnboardingService.ts
Normal file
60
apps/website/lib/services/onboarding/OnboardingService.ts
Normal file
@@ -0,0 +1,60 @@
|
||||
import { MediaApiClient } from '@/lib/api/media/MediaApiClient';
|
||||
import { DriversApiClient } from '@/lib/api/drivers/DriversApiClient';
|
||||
import { RequestAvatarGenerationInputDTO } from '@/lib/types/generated/RequestAvatarGenerationInputDTO';
|
||||
import { CompleteOnboardingInputDTO } from '@/lib/types/generated/CompleteOnboardingInputDTO';
|
||||
import { RequestAvatarGenerationOutputDTO } from '@/lib/types/generated/RequestAvatarGenerationOutputDTO';
|
||||
import { ValidateFaceInputDTO } from '@/lib/types/generated/ValidateFaceInputDTO';
|
||||
import { ValidateFaceOutputDTO } from '@/lib/types/generated/ValidateFaceOutputDTO';
|
||||
import { RequestAvatarGenerationViewModel } from '@/lib/view-models/RequestAvatarGenerationViewModel';
|
||||
import { CompleteOnboardingViewModel } from '@/lib/view-models/CompleteOnboardingViewModel';
|
||||
import { AvatarGenerationViewModel } from '@/lib/view-models/AvatarGenerationViewModel';
|
||||
|
||||
/**
|
||||
* Onboarding Service
|
||||
*
|
||||
* Handles the complete onboarding flow including avatar generation and profile creation.
|
||||
*/
|
||||
export class OnboardingService {
|
||||
constructor(
|
||||
private readonly mediaApiClient: MediaApiClient,
|
||||
private readonly driversApiClient: DriversApiClient
|
||||
) {}
|
||||
|
||||
/**
|
||||
* Validate face photo using the API
|
||||
*/
|
||||
async validateFacePhoto(photoData: string): Promise<{ isValid: boolean; errorMessage?: string }> {
|
||||
const input: ValidateFaceInputDTO = { imageData: photoData };
|
||||
const dto: ValidateFaceOutputDTO = await this.mediaApiClient.validateFacePhoto(input);
|
||||
return { isValid: dto.isValid, errorMessage: dto.errorMessage };
|
||||
}
|
||||
|
||||
/**
|
||||
* Generate avatars based on face photo and suit color
|
||||
* This method wraps the API call and returns a ViewModel
|
||||
*/
|
||||
async generateAvatars(
|
||||
userId: string,
|
||||
facePhotoData: string,
|
||||
suitColor: string
|
||||
): Promise<AvatarGenerationViewModel> {
|
||||
const input: RequestAvatarGenerationInputDTO = {
|
||||
userId,
|
||||
facePhotoData,
|
||||
suitColor,
|
||||
};
|
||||
|
||||
const dto: RequestAvatarGenerationOutputDTO = await this.mediaApiClient.requestAvatarGeneration(input);
|
||||
return new AvatarGenerationViewModel(dto);
|
||||
}
|
||||
|
||||
/**
|
||||
* Complete onboarding process
|
||||
*/
|
||||
async completeOnboarding(
|
||||
input: CompleteOnboardingInputDTO
|
||||
): Promise<CompleteOnboardingViewModel> {
|
||||
const dto = await this.driversApiClient.completeOnboarding(input);
|
||||
return new CompleteOnboardingViewModel(dto);
|
||||
}
|
||||
}
|
||||
@@ -16,8 +16,22 @@ export class WalletService {
|
||||
/**
|
||||
* Get wallet by driver ID with view model transformation
|
||||
*/
|
||||
async getWallet(driverId: string): Promise<WalletViewModel> {
|
||||
const { wallet, transactions } = await this.apiClient.getWallet(driverId);
|
||||
return new WalletViewModel({ ...wallet, transactions: transactions as FullTransactionDto[] });
|
||||
async getWallet(leagueId?: string): Promise<WalletViewModel> {
|
||||
const { wallet, transactions } = await this.apiClient.getWallet({ leagueId });
|
||||
|
||||
// Convert TransactionDTO to FullTransactionDto format
|
||||
const convertedTransactions: FullTransactionDto[] = transactions.map(t => ({
|
||||
id: t.id,
|
||||
type: t.type as 'sponsorship' | 'membership' | 'withdrawal' | 'prize',
|
||||
description: t.description,
|
||||
amount: t.amount,
|
||||
fee: t.amount * 0.05, // Calculate fee (5%)
|
||||
netAmount: t.amount * 0.95, // Calculate net amount
|
||||
date: new Date(t.createdAt),
|
||||
status: 'completed',
|
||||
referenceId: t.referenceId
|
||||
}));
|
||||
|
||||
return new WalletViewModel({ ...wallet, transactions: convertedTransactions });
|
||||
}
|
||||
}
|
||||
@@ -2,7 +2,11 @@ import { ProtestsApiClient } from '../../api/protests/ProtestsApiClient';
|
||||
import { ProtestViewModel } from '../../view-models/ProtestViewModel';
|
||||
import { RaceViewModel } from '../../view-models/RaceViewModel';
|
||||
import { ProtestDriverViewModel } from '../../view-models/ProtestDriverViewModel';
|
||||
import type { LeagueAdminProtestsDTO, ApplyPenaltyCommandDTO, RequestProtestDefenseCommandDTO, DriverSummaryDTO } from '../../types';
|
||||
import type { LeagueAdminProtestsDTO } from '../../types/generated/LeagueAdminProtestsDTO';
|
||||
import type { ApplyPenaltyCommandDTO } from '../../types/generated/ApplyPenaltyCommandDTO';
|
||||
import type { RequestProtestDefenseCommandDTO } from '../../types/generated/RequestProtestDefenseCommandDTO';
|
||||
import type { ReviewProtestCommandDTO } from '../../types/generated/ReviewProtestCommandDTO';
|
||||
import type { DriverDTO } from '../../types/generated/DriverDTO';
|
||||
|
||||
/**
|
||||
* Protest Service
|
||||
@@ -45,8 +49,11 @@ export class ProtestService {
|
||||
if (!protest) return null;
|
||||
|
||||
const race = Object.values(dto.racesById)[0];
|
||||
const protestingDriver = dto.driversById[protest.protestingDriverId];
|
||||
const accusedDriver = dto.driversById[protest.accusedDriverId];
|
||||
|
||||
// Cast to the correct type for indexing
|
||||
const driversById = dto.driversById as unknown as Record<string, DriverDTO>;
|
||||
const protestingDriver = driversById[protest.protestingDriverId];
|
||||
const accusedDriver = driversById[protest.accusedDriverId];
|
||||
|
||||
return {
|
||||
protest: new ProtestViewModel(protest),
|
||||
@@ -74,7 +81,14 @@ export class ProtestService {
|
||||
* Review protest
|
||||
*/
|
||||
async reviewProtest(input: { protestId: string; stewardId: string; decision: string; decisionNotes: string }): Promise<void> {
|
||||
await this.apiClient.reviewProtest(input);
|
||||
const command: ReviewProtestCommandDTO = {
|
||||
protestId: input.protestId,
|
||||
stewardId: input.stewardId,
|
||||
enum: input.decision === 'uphold' ? 'uphold' : 'dismiss',
|
||||
decision: input.decision,
|
||||
decisionNotes: input.decisionNotes
|
||||
};
|
||||
await this.apiClient.reviewProtest(command);
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@@ -27,10 +27,44 @@ export class RaceStewardingService {
|
||||
this.penaltiesApiClient.getRacePenalties(raceId),
|
||||
]);
|
||||
|
||||
// Convert API responses to match RaceStewardingViewModel expectations
|
||||
const convertedProtests = {
|
||||
protests: protests.protests.map(p => ({
|
||||
id: p.id,
|
||||
protestingDriverId: p.protestingDriverId,
|
||||
accusedDriverId: p.accusedDriverId,
|
||||
incident: {
|
||||
lap: p.lap,
|
||||
description: p.description
|
||||
},
|
||||
filedAt: p.filedAt,
|
||||
status: p.status
|
||||
})),
|
||||
driverMap: Object.entries(protests.driverMap).reduce((acc, [id, name]) => {
|
||||
acc[id] = { id, name: name as string };
|
||||
return acc;
|
||||
}, {} as Record<string, { id: string; name: string }>)
|
||||
};
|
||||
|
||||
const convertedPenalties = {
|
||||
penalties: penalties.penalties.map(p => ({
|
||||
id: p.id,
|
||||
driverId: p.driverId,
|
||||
type: p.type,
|
||||
value: p.value,
|
||||
reason: p.reason,
|
||||
notes: p.notes
|
||||
})),
|
||||
driverMap: Object.entries(penalties.driverMap).reduce((acc, [id, name]) => {
|
||||
acc[id] = { id, name: name as string };
|
||||
return acc;
|
||||
}, {} as Record<string, { id: string; name: string }>)
|
||||
};
|
||||
|
||||
return new RaceStewardingViewModel({
|
||||
raceDetail,
|
||||
protests,
|
||||
penalties,
|
||||
protests: convertedProtests,
|
||||
penalties: convertedPenalties,
|
||||
});
|
||||
}
|
||||
}
|
||||
@@ -1,8 +1,9 @@
|
||||
import type { SponsorsApiClient, CreateSponsorOutputDto, GetEntitySponsorshipPricingResultDto, SponsorDTO } from '../../api/sponsors/SponsorsApiClient';
|
||||
import type { SponsorsApiClient } from '../../api/sponsors/SponsorsApiClient';
|
||||
import { SponsorViewModel } from '../../view-models/SponsorViewModel';
|
||||
import { SponsorDashboardViewModel } from '../../view-models/SponsorDashboardViewModel';
|
||||
import { SponsorSponsorshipsViewModel } from '../../view-models/SponsorSponsorshipsViewModel';
|
||||
import type { CreateSponsorInputDTO } from '../../types/generated/CreateSponsorInputDTO';
|
||||
import type { SponsorDTO } from '../../types/generated/SponsorDTO';
|
||||
|
||||
/**
|
||||
* Sponsor Service
|
||||
@@ -48,14 +49,14 @@ export class SponsorService {
|
||||
/**
|
||||
* Create a new sponsor
|
||||
*/
|
||||
async createSponsor(input: CreateSponsorInputDTO): Promise<CreateSponsorOutputDto> {
|
||||
async createSponsor(input: CreateSponsorInputDTO): Promise<any> {
|
||||
return await this.apiClient.create(input);
|
||||
}
|
||||
|
||||
/**
|
||||
* Get sponsorship pricing
|
||||
*/
|
||||
async getSponsorshipPricing(): Promise<GetEntitySponsorshipPricingResultDto> {
|
||||
async getSponsorshipPricing(): Promise<any> {
|
||||
return await this.apiClient.getPricing();
|
||||
}
|
||||
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
import { TeamJoinRequestViewModel, type TeamJoinRequestDTO } from '@/lib/view-models/TeamJoinRequestViewModel';
|
||||
import { TeamJoinRequestViewModel } from '@/lib/view-models/TeamJoinRequestViewModel';
|
||||
import type { TeamsApiClient } from '../../api/teams/TeamsApiClient';
|
||||
import type { TeamJoinRequestDTO } from '../../types/generated/TeamJoinRequestDTO';
|
||||
|
||||
// Wrapper for the team join requests collection returned by the teams API in this build
|
||||
// Mirrors the current API response shape until a generated DTO is available.
|
||||
|
||||
10
apps/website/lib/types/generated/AvatarDTO.ts
Normal file
10
apps/website/lib/types/generated/AvatarDTO.ts
Normal file
@@ -0,0 +1,10 @@
|
||||
/**
|
||||
* Auto-generated DTO from OpenAPI spec
|
||||
* This file is generated by scripts/generate-api-types.ts
|
||||
* Do not edit manually - regenerate using: npm run api:sync-types
|
||||
*/
|
||||
|
||||
export interface AvatarDTO {
|
||||
driverId: string;
|
||||
avatarUrl?: string;
|
||||
}
|
||||
18
apps/website/lib/types/generated/DriverSummaryDTO.ts
Normal file
18
apps/website/lib/types/generated/DriverSummaryDTO.ts
Normal file
@@ -0,0 +1,18 @@
|
||||
/**
|
||||
* Auto-generated DTO from OpenAPI spec
|
||||
* This file is generated by scripts/generate-api-types.ts
|
||||
* Do not edit manually - regenerate using: npm run api:sync-types
|
||||
*/
|
||||
|
||||
export interface DriverSummaryDTO {
|
||||
id: string;
|
||||
name: string;
|
||||
country?: string;
|
||||
avatarUrl?: string;
|
||||
rating?: number;
|
||||
globalRank?: number;
|
||||
totalRaces?: number;
|
||||
wins?: number;
|
||||
podiums?: number;
|
||||
consistency?: number;
|
||||
}
|
||||
20
apps/website/lib/types/generated/FullTransactionDTO.ts
Normal file
20
apps/website/lib/types/generated/FullTransactionDTO.ts
Normal file
@@ -0,0 +1,20 @@
|
||||
/**
|
||||
* Auto-generated DTO from OpenAPI spec
|
||||
* This file is generated by scripts/generate-api-types.ts
|
||||
* Do not edit manually - regenerate using: npm run api:sync-types
|
||||
*/
|
||||
|
||||
export interface FullTransactionDTO {
|
||||
id: string;
|
||||
walletId: string;
|
||||
type: string;
|
||||
amount: number;
|
||||
description: string;
|
||||
referenceId?: string;
|
||||
referenceType?: string;
|
||||
/** Format: date-time */
|
||||
createdAt: string;
|
||||
leagueId?: string;
|
||||
driverId?: string;
|
||||
sponsorId?: string;
|
||||
}
|
||||
@@ -10,6 +10,6 @@ import type { DriverDTO } from './DriverDTO';
|
||||
|
||||
export interface LeagueAdminProtestsDTO {
|
||||
protests: ProtestDTO[];
|
||||
racesById: RaceDTO;
|
||||
driversById: DriverDTO;
|
||||
racesById: Record<string, RaceDTO>;
|
||||
driversById: Record<string, DriverDTO>;
|
||||
}
|
||||
|
||||
9
apps/website/lib/types/generated/ValidateFaceInputDTO.ts
Normal file
9
apps/website/lib/types/generated/ValidateFaceInputDTO.ts
Normal file
@@ -0,0 +1,9 @@
|
||||
/**
|
||||
* Auto-generated DTO from OpenAPI spec
|
||||
* This file is generated by scripts/generate-api-types.ts
|
||||
* Do not edit manually - regenerate using: npm run api:sync-types
|
||||
*/
|
||||
|
||||
export interface ValidateFaceInputDTO {
|
||||
imageData: string;
|
||||
}
|
||||
10
apps/website/lib/types/generated/ValidateFaceOutputDTO.ts
Normal file
10
apps/website/lib/types/generated/ValidateFaceOutputDTO.ts
Normal file
@@ -0,0 +1,10 @@
|
||||
/**
|
||||
* Auto-generated DTO from OpenAPI spec
|
||||
* This file is generated by scripts/generate-api-types.ts
|
||||
* Do not edit manually - regenerate using: npm run api:sync-types
|
||||
*/
|
||||
|
||||
export interface ValidateFaceOutputDTO {
|
||||
isValid: boolean;
|
||||
errorMessage?: string;
|
||||
}
|
||||
18
apps/website/lib/view-models/AvatarGenerationViewModel.ts
Normal file
18
apps/website/lib/view-models/AvatarGenerationViewModel.ts
Normal file
@@ -0,0 +1,18 @@
|
||||
import { RequestAvatarGenerationOutputDTO } from '@/lib/types/generated/RequestAvatarGenerationOutputDTO';
|
||||
|
||||
/**
|
||||
* AvatarGenerationViewModel
|
||||
*
|
||||
* View model for avatar generation process
|
||||
*/
|
||||
export class AvatarGenerationViewModel {
|
||||
readonly success: boolean;
|
||||
readonly avatarUrls: string[];
|
||||
readonly errorMessage?: string;
|
||||
|
||||
constructor(dto: RequestAvatarGenerationOutputDTO) {
|
||||
this.success = dto.success;
|
||||
this.avatarUrls = dto.avatarUrls || [];
|
||||
this.errorMessage = dto.errorMessage;
|
||||
}
|
||||
}
|
||||
@@ -7,13 +7,21 @@ import { CompleteOnboardingOutputDTO } from '../types/generated/CompleteOnboardi
|
||||
export class CompleteOnboardingViewModel {
|
||||
success: boolean;
|
||||
driverId?: string;
|
||||
errorMessage?: string;
|
||||
|
||||
constructor(dto: CompleteOnboardingOutputDTO) {
|
||||
this.success = dto.success;
|
||||
if (dto.driverId !== undefined) this.driverId = dto.driverId;
|
||||
if (dto.errorMessage !== undefined) this.errorMessage = dto.errorMessage;
|
||||
}
|
||||
|
||||
/** UI-specific: Whether onboarding was successful */
|
||||
get isSuccessful(): boolean {
|
||||
return this.success;
|
||||
}
|
||||
|
||||
/** UI-specific: Whether there was an error */
|
||||
get hasError(): boolean {
|
||||
return !!this.errorMessage;
|
||||
}
|
||||
}
|
||||
@@ -1,9 +1,9 @@
|
||||
import { DriverRegistrationStatusDTO } from '../types/generated/DriverRegistrationStatusDTO';
|
||||
|
||||
export class DriverRegistrationStatusViewModel {
|
||||
isRegistered: boolean;
|
||||
raceId: string;
|
||||
driverId: string;
|
||||
isRegistered!: boolean;
|
||||
raceId!: string;
|
||||
driverId!: string;
|
||||
|
||||
constructor(dto: DriverRegistrationStatusDTO) {
|
||||
Object.assign(this, dto);
|
||||
|
||||
@@ -10,6 +10,9 @@ export class DriverViewModel {
|
||||
avatarUrl?: string;
|
||||
iracingId?: string;
|
||||
rating?: number;
|
||||
country?: string;
|
||||
bio?: string;
|
||||
joinedAt?: string;
|
||||
|
||||
constructor(dto: {
|
||||
id: string;
|
||||
@@ -17,12 +20,18 @@ export class DriverViewModel {
|
||||
avatarUrl?: string;
|
||||
iracingId?: string;
|
||||
rating?: number;
|
||||
country?: string;
|
||||
bio?: string;
|
||||
joinedAt?: string;
|
||||
}) {
|
||||
this.id = dto.id;
|
||||
this.name = dto.name;
|
||||
if (dto.avatarUrl !== undefined) this.avatarUrl = dto.avatarUrl;
|
||||
if (dto.iracingId !== undefined) this.iracingId = dto.iracingId;
|
||||
if (dto.rating !== undefined) this.rating = dto.rating;
|
||||
if (dto.country !== undefined) this.country = dto.country;
|
||||
if (dto.bio !== undefined) this.bio = dto.bio;
|
||||
if (dto.joinedAt !== undefined) this.joinedAt = dto.joinedAt;
|
||||
}
|
||||
|
||||
/** UI-specific: Whether driver has an iRacing ID */
|
||||
|
||||
16
apps/website/lib/view-models/EmailSignupViewModel.ts
Normal file
16
apps/website/lib/view-models/EmailSignupViewModel.ts
Normal file
@@ -0,0 +1,16 @@
|
||||
/**
|
||||
* EmailSignupViewModel
|
||||
*
|
||||
* View model for email signup responses
|
||||
*/
|
||||
export class EmailSignupViewModel {
|
||||
readonly email: string;
|
||||
readonly message: string;
|
||||
readonly status: 'success' | 'error' | 'info';
|
||||
|
||||
constructor(email: string, message: string, status: 'success' | 'error' | 'info') {
|
||||
this.email = email;
|
||||
this.message = message;
|
||||
this.status = status;
|
||||
}
|
||||
}
|
||||
@@ -106,18 +106,22 @@ export class LeagueDetailPageViewModel {
|
||||
this.name = league.name;
|
||||
this.description = league.description ?? '';
|
||||
this.ownerId = league.ownerId;
|
||||
this.createdAt = ''; // Not provided by API
|
||||
this.createdAt = league.createdAt;
|
||||
this.settings = {
|
||||
maxDrivers: league.maxMembers,
|
||||
maxDrivers: league.settings?.maxDrivers,
|
||||
};
|
||||
this.socialLinks = {
|
||||
discordUrl: league.discordUrl,
|
||||
youtubeUrl: league.youtubeUrl,
|
||||
websiteUrl: league.websiteUrl,
|
||||
};
|
||||
this.socialLinks = undefined;
|
||||
|
||||
this.owner = owner;
|
||||
this.scoringConfig = scoringConfig;
|
||||
this.drivers = drivers;
|
||||
this.memberships = memberships.memberships.map(m => ({
|
||||
this.memberships = memberships.members.map(m => ({
|
||||
driverId: m.driverId,
|
||||
role: m.role,
|
||||
role: m.role as 'owner' | 'admin' | 'steward' | 'member',
|
||||
status: 'active',
|
||||
joinedAt: m.joinedAt,
|
||||
}));
|
||||
@@ -125,8 +129,9 @@ export class LeagueDetailPageViewModel {
|
||||
this.allRaces = allRaces;
|
||||
this.runningRaces = allRaces.filter(r => r.status === 'running');
|
||||
|
||||
this.averageSOF = leagueStats.averageSOF ?? null;
|
||||
this.completedRacesCount = leagueStats.completedRaces ?? 0;
|
||||
// Calculate SOF from available data
|
||||
this.averageSOF = leagueStats.averageRating ?? null;
|
||||
this.completedRacesCount = leagueStats.totalRaces ?? 0;
|
||||
|
||||
this.sponsors = sponsors;
|
||||
|
||||
|
||||
@@ -0,0 +1,26 @@
|
||||
import { LeagueScoringChampionshipDTO } from '@/lib/types/generated/LeagueScoringChampionshipDTO';
|
||||
|
||||
/**
|
||||
* LeagueScoringChampionshipViewModel
|
||||
*
|
||||
* View model for league scoring championship
|
||||
*/
|
||||
export class LeagueScoringChampionshipViewModel {
|
||||
readonly id: string;
|
||||
readonly name: string;
|
||||
readonly type: string;
|
||||
readonly sessionTypes: string[];
|
||||
readonly pointsPreview: Array<{ sessionType: string; position: number; points: number }>;
|
||||
readonly bonusSummary: string[];
|
||||
readonly dropPolicyDescription?: string;
|
||||
|
||||
constructor(dto: LeagueScoringChampionshipDTO) {
|
||||
this.id = dto.id;
|
||||
this.name = dto.name;
|
||||
this.type = dto.type;
|
||||
this.sessionTypes = dto.sessionTypes;
|
||||
this.pointsPreview = (dto.pointsPreview as any) || [];
|
||||
this.bonusSummary = (dto as any).bonusSummary || [];
|
||||
this.dropPolicyDescription = (dto as any).dropPolicyDescription;
|
||||
}
|
||||
}
|
||||
29
apps/website/lib/view-models/LeagueScoringConfigViewModel.ts
Normal file
29
apps/website/lib/view-models/LeagueScoringConfigViewModel.ts
Normal file
@@ -0,0 +1,29 @@
|
||||
import { LeagueScoringConfigDTO } from '@/lib/types/generated/LeagueScoringConfigDTO';
|
||||
|
||||
/**
|
||||
* LeagueScoringConfigViewModel
|
||||
*
|
||||
* View model for league scoring configuration
|
||||
*/
|
||||
export class LeagueScoringConfigViewModel {
|
||||
readonly gameName: string;
|
||||
readonly scoringPresetName?: string;
|
||||
readonly dropPolicySummary?: string;
|
||||
readonly championships?: Array<{
|
||||
id: string;
|
||||
name: string;
|
||||
type: 'driver' | 'team' | 'nations' | 'trophy' | string;
|
||||
sessionTypes: string[];
|
||||
pointsPreview: Array<{ sessionType: string; position: number; points: number }>;
|
||||
bonusSummary: string[];
|
||||
dropPolicyDescription?: string;
|
||||
}>;
|
||||
|
||||
constructor(dto: LeagueScoringConfigDTO) {
|
||||
this.gameName = dto.gameName;
|
||||
// These would be mapped from extended properties if available
|
||||
this.scoringPresetName = (dto as any).scoringPresetName;
|
||||
this.dropPolicySummary = (dto as any).dropPolicySummary;
|
||||
this.championships = (dto as any).championships;
|
||||
}
|
||||
}
|
||||
20
apps/website/lib/view-models/LeagueScoringPresetViewModel.ts
Normal file
20
apps/website/lib/view-models/LeagueScoringPresetViewModel.ts
Normal file
@@ -0,0 +1,20 @@
|
||||
import { LeagueScoringPresetDTO } from '@/lib/types/generated/LeagueScoringPresetDTO';
|
||||
|
||||
/**
|
||||
* LeagueScoringPresetViewModel
|
||||
*
|
||||
* View model for league scoring preset configuration
|
||||
*/
|
||||
export class LeagueScoringPresetViewModel {
|
||||
readonly id: string;
|
||||
readonly name: string;
|
||||
readonly sessionSummary: string;
|
||||
readonly bonusSummary?: string;
|
||||
|
||||
constructor(dto: LeagueScoringPresetDTO) {
|
||||
this.id = dto.id;
|
||||
this.name = dto.name;
|
||||
this.sessionSummary = dto.sessionSummary;
|
||||
this.bonusSummary = dto.bonusSummary;
|
||||
}
|
||||
}
|
||||
@@ -1,4 +1,4 @@
|
||||
import type { GetMediaOutputDTO } from '../types/generated';
|
||||
import type { GetMediaOutputDTO } from '../types/generated/GetMediaOutputDTO';
|
||||
|
||||
/**
|
||||
* Media View Model
|
||||
@@ -30,4 +30,4 @@ export class MediaViewModel {
|
||||
const mb = kb / 1024;
|
||||
return `${mb.toFixed(2)} MB`;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,14 +1,14 @@
|
||||
import type { MembershipFeeDTO } from '../types/generated/MembershipFeeDTO';
|
||||
|
||||
export class MembershipFeeViewModel {
|
||||
id: string;
|
||||
leagueId: string;
|
||||
id!: string;
|
||||
leagueId!: string;
|
||||
seasonId?: string;
|
||||
type: string;
|
||||
amount: number;
|
||||
enabled: boolean;
|
||||
createdAt: Date;
|
||||
updatedAt: Date;
|
||||
type!: string;
|
||||
amount!: number;
|
||||
enabled!: boolean;
|
||||
createdAt!: Date;
|
||||
updatedAt!: Date;
|
||||
|
||||
constructor(dto: MembershipFeeDTO) {
|
||||
Object.assign(this, dto);
|
||||
|
||||
@@ -1,17 +1,17 @@
|
||||
import type { PaymentDTO } from '../types/generated/PaymentDTO';
|
||||
|
||||
export class PaymentViewModel {
|
||||
id: string;
|
||||
type: string;
|
||||
amount: number;
|
||||
platformFee: number;
|
||||
netAmount: number;
|
||||
payerId: string;
|
||||
payerType: string;
|
||||
leagueId: string;
|
||||
id!: string;
|
||||
type!: string;
|
||||
amount!: number;
|
||||
platformFee!: number;
|
||||
netAmount!: number;
|
||||
payerId!: string;
|
||||
payerType!: string;
|
||||
leagueId!: string;
|
||||
seasonId?: string;
|
||||
status: string;
|
||||
createdAt: Date;
|
||||
status!: string;
|
||||
createdAt!: Date;
|
||||
completedAt?: Date;
|
||||
|
||||
constructor(dto: PaymentDTO) {
|
||||
|
||||
@@ -1,21 +1,32 @@
|
||||
import type { PrizeDto } from '../types/generated';
|
||||
import type { PrizeDTO } from '../types/generated/PrizeDTO';
|
||||
|
||||
export class PrizeViewModel {
|
||||
id: string;
|
||||
leagueId: string;
|
||||
seasonId: string;
|
||||
position: number;
|
||||
name: string;
|
||||
amount: number;
|
||||
type: string;
|
||||
id!: string;
|
||||
leagueId!: string;
|
||||
seasonId!: string;
|
||||
position!: number;
|
||||
name!: string;
|
||||
amount!: number;
|
||||
type!: string;
|
||||
description?: string;
|
||||
awarded: boolean;
|
||||
awarded!: boolean;
|
||||
awardedTo?: string;
|
||||
awardedAt?: Date;
|
||||
createdAt: Date;
|
||||
createdAt!: Date;
|
||||
|
||||
constructor(dto: PrizeDto) {
|
||||
Object.assign(this, dto);
|
||||
constructor(dto: PrizeDTO) {
|
||||
this.id = dto.id;
|
||||
this.leagueId = dto.leagueId;
|
||||
this.seasonId = dto.seasonId;
|
||||
this.position = dto.position;
|
||||
this.name = dto.name;
|
||||
this.amount = dto.amount;
|
||||
this.type = dto.type;
|
||||
this.description = dto.description;
|
||||
this.awarded = dto.awarded;
|
||||
this.awardedTo = dto.awardedTo;
|
||||
this.awardedAt = dto.awardedAt ? new Date(dto.awardedAt) : undefined;
|
||||
this.createdAt = new Date(dto.createdAt);
|
||||
}
|
||||
|
||||
/** UI-specific: Formatted amount */
|
||||
@@ -67,4 +78,4 @@ export class PrizeViewModel {
|
||||
get formattedCreatedAt(): string {
|
||||
return this.createdAt.toLocaleString();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
import { DriverSummaryDTO } from '../types/generated/LeagueAdminProtestsDTO';
|
||||
import { DriverSummaryDTO } from '../types/generated/DriverSummaryDTO';
|
||||
|
||||
export class ProtestDriverViewModel {
|
||||
constructor(private readonly dto: DriverSummaryDTO) {}
|
||||
|
||||
@@ -1,4 +1,5 @@
|
||||
import { ProtestDTO } from '../types/generated/ProtestDTO';
|
||||
import { RaceProtestDTO } from '../types/generated/RaceProtestDTO';
|
||||
|
||||
/**
|
||||
* Protest view model
|
||||
@@ -11,22 +12,49 @@ export class ProtestViewModel {
|
||||
accusedDriverId: string;
|
||||
description: string;
|
||||
submittedAt: string;
|
||||
filedAt?: string;
|
||||
status: string;
|
||||
reviewedAt?: string;
|
||||
decisionNotes?: string;
|
||||
incident?: { lap?: number } | null;
|
||||
incident?: { lap?: number; description?: string } | null;
|
||||
proofVideoUrl?: string | null;
|
||||
comment?: string | null;
|
||||
|
||||
constructor(dto: ProtestDTO) {
|
||||
constructor(dto: ProtestDTO | RaceProtestDTO) {
|
||||
this.id = dto.id;
|
||||
this.raceId = dto.raceId;
|
||||
this.raceId = (dto as any).raceId || '';
|
||||
this.protestingDriverId = dto.protestingDriverId;
|
||||
this.accusedDriverId = dto.accusedDriverId;
|
||||
this.description = dto.description;
|
||||
this.submittedAt = dto.submittedAt;
|
||||
this.description = (dto as any).description || dto.description;
|
||||
this.submittedAt = (dto as any).submittedAt || (dto as any).filedAt || '';
|
||||
this.filedAt = (dto as any).filedAt || (dto as any).submittedAt;
|
||||
|
||||
// Handle different DTO structures
|
||||
if ('status' in dto) {
|
||||
this.status = dto.status;
|
||||
} else {
|
||||
this.status = 'pending';
|
||||
}
|
||||
|
||||
// Handle incident data
|
||||
if ('incident' in dto && dto.incident) {
|
||||
this.incident = {
|
||||
lap: (dto.incident as any).lap,
|
||||
description: (dto.incident as any).description
|
||||
};
|
||||
} else if ('lap' in dto || 'description' in dto) {
|
||||
this.incident = {
|
||||
lap: (dto as any).lap,
|
||||
description: (dto as any).description
|
||||
};
|
||||
} else {
|
||||
this.incident = null;
|
||||
}
|
||||
|
||||
// Status and decision metadata are not part of the protest DTO in this build; they default to a pending, unreviewed protest
|
||||
this.status = 'pending';
|
||||
if (!('status' in dto)) {
|
||||
this.status = 'pending';
|
||||
}
|
||||
this.reviewedAt = undefined;
|
||||
this.decisionNotes = undefined;
|
||||
}
|
||||
|
||||
@@ -1,14 +1,14 @@
|
||||
import { RaceDetailUserResultDTO } from '../types/generated/RaceDetailUserResultDTO';
|
||||
|
||||
export class RaceDetailUserResultViewModel {
|
||||
position: number;
|
||||
startPosition: number;
|
||||
incidents: number;
|
||||
fastestLap: number;
|
||||
positionChange: number;
|
||||
ratingChange: number;
|
||||
isPodium: boolean;
|
||||
isClean: boolean;
|
||||
position!: number;
|
||||
startPosition!: number;
|
||||
incidents!: number;
|
||||
fastestLap!: number;
|
||||
positionChange!: number;
|
||||
isPodium!: boolean;
|
||||
isClean!: boolean;
|
||||
ratingChange!: number;
|
||||
|
||||
constructor(dto: RaceDetailUserResultDTO) {
|
||||
this.position = dto.position;
|
||||
@@ -16,8 +16,49 @@ export class RaceDetailUserResultViewModel {
|
||||
this.incidents = dto.incidents;
|
||||
this.fastestLap = dto.fastestLap;
|
||||
this.positionChange = dto.positionChange;
|
||||
this.ratingChange = dto.ratingChange;
|
||||
this.isPodium = dto.isPodium;
|
||||
this.isClean = dto.isClean;
|
||||
this.ratingChange = dto.ratingChange ?? 0;
|
||||
}
|
||||
|
||||
/** UI-specific: Display for position change */
|
||||
get positionChangeDisplay(): string {
|
||||
if (this.positionChange > 0) return `+${this.positionChange}`;
|
||||
if (this.positionChange < 0) return `${this.positionChange}`;
|
||||
return '0';
|
||||
}
|
||||
|
||||
/** UI-specific: Color for position change */
|
||||
get positionChangeColor(): string {
|
||||
if (this.positionChange > 0) return 'green';
|
||||
if (this.positionChange < 0) return 'red';
|
||||
return 'gray';
|
||||
}
|
||||
|
||||
/** UI-specific: Whether this is the winner */
|
||||
get isWinner(): boolean {
|
||||
return this.position === 1;
|
||||
}
|
||||
|
||||
/** UI-specific: Rating change display */
|
||||
get ratingChangeDisplay(): string {
|
||||
if (this.ratingChange > 0) return `+${this.ratingChange}`;
|
||||
return `${this.ratingChange}`;
|
||||
}
|
||||
|
||||
/** UI-specific: Rating change color */
|
||||
get ratingChangeColor(): string {
|
||||
if (this.ratingChange > 0) return 'green';
|
||||
if (this.ratingChange < 0) return 'red';
|
||||
return 'gray';
|
||||
}
|
||||
|
||||
/** UI-specific: Formatted lap time */
|
||||
get lapTimeFormatted(): string {
|
||||
if (this.fastestLap <= 0) return '--:--.---';
|
||||
const minutes = Math.floor(this.fastestLap / 60);
|
||||
const seconds = Math.floor(this.fastestLap % 60);
|
||||
const milliseconds = Math.floor((this.fastestLap % 1) * 1000);
|
||||
return `${minutes}:${seconds.toString().padStart(2, '0')}.${milliseconds.toString().padStart(3, '0')}`;
|
||||
}
|
||||
}
|
||||
@@ -1,16 +1,16 @@
|
||||
import { RaceResultDTO } from '../types/generated/RaceResultDTO';
|
||||
|
||||
export class RaceResultViewModel {
|
||||
driverId: string;
|
||||
driverName: string;
|
||||
avatarUrl: string;
|
||||
position: number;
|
||||
startPosition: number;
|
||||
incidents: number;
|
||||
fastestLap: number;
|
||||
positionChange: number;
|
||||
isPodium: boolean;
|
||||
isClean: boolean;
|
||||
driverId!: string;
|
||||
driverName!: string;
|
||||
avatarUrl!: string;
|
||||
position!: number;
|
||||
startPosition!: number;
|
||||
incidents!: number;
|
||||
fastestLap!: number;
|
||||
positionChange!: number;
|
||||
isPodium!: boolean;
|
||||
isClean!: boolean;
|
||||
|
||||
constructor(dto: RaceResultDTO) {
|
||||
Object.assign(this, dto);
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
import { describe, it, expect } from 'vitest';
|
||||
import { RaceStatsViewModel } from './RaceStatsViewModel';
|
||||
import type { RaceStatsDTO } from '../types/generated';
|
||||
import type { RaceStatsDTO } from '../types/generated/RaceStatsDTO';
|
||||
|
||||
const createDto = (overrides: Partial<RaceStatsDTO> = {}): RaceStatsDTO => ({
|
||||
totalRaces: 1234,
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
import { RaceStatsDTO } from '../types/generated';
|
||||
import type { RaceStatsDTO } from '../types/generated/RaceStatsDTO';
|
||||
|
||||
/**
|
||||
* Race stats view model
|
||||
@@ -15,4 +15,4 @@ export class RaceStatsViewModel {
|
||||
get formattedTotalRaces(): string {
|
||||
return this.totalRaces.toLocaleString();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,22 +1,45 @@
|
||||
import { RaceDTO } from '../types/generated/RaceDTO';
|
||||
import { RacesPageDataRaceDTO } from '../types/generated/RacesPageDataRaceDTO';
|
||||
|
||||
export class RaceViewModel {
|
||||
constructor(private readonly dto: RaceDTO, private readonly _status?: string, private readonly _registeredCount?: number, private readonly _strengthOfField?: number) {}
|
||||
constructor(
|
||||
private readonly dto: RaceDTO | RacesPageDataRaceDTO,
|
||||
private readonly _status?: string,
|
||||
private readonly _registeredCount?: number,
|
||||
private readonly _strengthOfField?: number
|
||||
) {}
|
||||
|
||||
get id(): string {
|
||||
return this.dto.id;
|
||||
}
|
||||
|
||||
get name(): string {
|
||||
return this.dto.name;
|
||||
if ('name' in this.dto) {
|
||||
return this.dto.name;
|
||||
}
|
||||
return '';
|
||||
}
|
||||
|
||||
get date(): string {
|
||||
return this.dto.date;
|
||||
if ('date' in this.dto) {
|
||||
return this.dto.date;
|
||||
}
|
||||
if ('scheduledAt' in this.dto) {
|
||||
return this.dto.scheduledAt;
|
||||
}
|
||||
return '';
|
||||
}
|
||||
|
||||
get track(): string {
|
||||
return (this.dto as any).track || '';
|
||||
}
|
||||
|
||||
get car(): string {
|
||||
return (this.dto as any).car || '';
|
||||
}
|
||||
|
||||
get status(): string | undefined {
|
||||
return this._status;
|
||||
return this._status || (this.dto as any).status;
|
||||
}
|
||||
|
||||
get registeredCount(): number | undefined {
|
||||
@@ -24,7 +47,7 @@ export class RaceViewModel {
|
||||
}
|
||||
|
||||
get strengthOfField(): number | undefined {
|
||||
return this._strengthOfField;
|
||||
return this._strengthOfField || (this.dto as any).strengthOfField;
|
||||
}
|
||||
|
||||
/** UI-specific: Formatted date */
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
import { RecordEngagementOutputDTO } from '../types/generated';
|
||||
import type { RecordEngagementOutputDTO } from '../types/generated/RecordEngagementOutputDTO';
|
||||
|
||||
/**
|
||||
* Record engagement output view model
|
||||
@@ -27,4 +27,4 @@ export class RecordEngagementOutputViewModel {
|
||||
get isHighEngagement(): boolean {
|
||||
return this.engagementWeight > 1.0;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
import { RecordPageViewOutputDTO } from '../types/generated';
|
||||
import type { RecordPageViewOutputDTO } from '../types/generated/RecordPageViewOutputDTO';
|
||||
|
||||
/**
|
||||
* Record page view output view model
|
||||
@@ -15,4 +15,4 @@ export class RecordPageViewOutputViewModel {
|
||||
get displayPageViewId(): string {
|
||||
return `Page View: ${this.pageViewId}`;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,9 +1,4 @@
|
||||
// Note: No generated DTO available for RequestAvatarGeneration yet
|
||||
interface RequestAvatarGenerationDTO {
|
||||
success: boolean;
|
||||
avatarUrl?: string;
|
||||
error?: string;
|
||||
}
|
||||
import { RequestAvatarGenerationOutputDTO } from '../types/generated/RequestAvatarGenerationOutputDTO';
|
||||
|
||||
/**
|
||||
* Request Avatar Generation View Model
|
||||
@@ -12,13 +7,15 @@ interface RequestAvatarGenerationDTO {
|
||||
*/
|
||||
export class RequestAvatarGenerationViewModel {
|
||||
success: boolean;
|
||||
avatarUrl?: string;
|
||||
error?: string;
|
||||
requestId?: string;
|
||||
avatarUrls?: string[];
|
||||
errorMessage?: string;
|
||||
|
||||
constructor(dto: RequestAvatarGenerationDTO) {
|
||||
constructor(dto: RequestAvatarGenerationOutputDTO) {
|
||||
this.success = dto.success;
|
||||
if (dto.avatarUrl !== undefined) this.avatarUrl = dto.avatarUrl;
|
||||
if (dto.error !== undefined) this.error = dto.error;
|
||||
if (dto.requestId !== undefined) this.requestId = dto.requestId;
|
||||
if (dto.avatarUrls !== undefined) this.avatarUrls = dto.avatarUrls;
|
||||
if (dto.errorMessage !== undefined) this.errorMessage = dto.errorMessage;
|
||||
}
|
||||
|
||||
/** UI-specific: Whether generation was successful */
|
||||
@@ -28,6 +25,11 @@ export class RequestAvatarGenerationViewModel {
|
||||
|
||||
/** UI-specific: Whether there was an error */
|
||||
get hasError(): boolean {
|
||||
return !!this.error;
|
||||
return !!this.errorMessage;
|
||||
}
|
||||
|
||||
/** UI-specific: Get first avatar URL */
|
||||
get firstAvatarUrl(): string | undefined {
|
||||
return this.avatarUrls?.[0];
|
||||
}
|
||||
}
|
||||
@@ -26,15 +26,18 @@ export class SponsorDashboardViewModel {
|
||||
this.sponsorId = dto.sponsorId;
|
||||
this.sponsorName = dto.sponsorName;
|
||||
this.metrics = dto.metrics;
|
||||
|
||||
// Cast sponsorships to proper type
|
||||
const sponsorships = dto.sponsorships as any;
|
||||
this.sponsorships = {
|
||||
leagues: (dto.sponsorships?.leagues || []).map(s => new SponsorshipViewModel(s)),
|
||||
teams: (dto.sponsorships?.teams || []).map(s => new SponsorshipViewModel(s)),
|
||||
drivers: (dto.sponsorships?.drivers || []).map(s => new SponsorshipViewModel(s)),
|
||||
races: (dto.sponsorships?.races || []).map(s => new SponsorshipViewModel(s)),
|
||||
platform: (dto.sponsorships?.platform || []).map(s => new SponsorshipViewModel(s)),
|
||||
leagues: (sponsorships?.leagues || []).map((s: any) => new SponsorshipViewModel(s)),
|
||||
teams: (sponsorships?.teams || []).map((s: any) => new SponsorshipViewModel(s)),
|
||||
drivers: (sponsorships?.drivers || []).map((s: any) => new SponsorshipViewModel(s)),
|
||||
races: (sponsorships?.races || []).map((s: any) => new SponsorshipViewModel(s)),
|
||||
platform: (sponsorships?.platform || []).map((s: any) => new SponsorshipViewModel(s)),
|
||||
};
|
||||
this.recentActivity = (dto.recentActivity || []).map(a => new ActivityItemViewModel(a));
|
||||
this.upcomingRenewals = (dto.upcomingRenewals || []).map(r => new RenewalAlertViewModel(r));
|
||||
this.recentActivity = (dto.recentActivity || []).map((a: any) => new ActivityItemViewModel(a));
|
||||
this.upcomingRenewals = (dto.upcomingRenewals || []).map((r: any) => new RenewalAlertViewModel(r));
|
||||
}
|
||||
|
||||
get totalSponsorships(): number {
|
||||
|
||||
@@ -1,12 +1,12 @@
|
||||
import type { GetTeamDetailsOutputDTO } from '@/lib/types/generated/GetTeamDetailsOutputDTO';
|
||||
|
||||
export class TeamDetailsViewModel {
|
||||
id: string;
|
||||
name: string;
|
||||
tag: string;
|
||||
id!: string;
|
||||
name!: string;
|
||||
tag!: string;
|
||||
description?: string;
|
||||
ownerId: string;
|
||||
leagues: string[];
|
||||
ownerId!: string;
|
||||
leagues!: string[];
|
||||
createdAt?: string;
|
||||
specialization?: string;
|
||||
region?: string;
|
||||
@@ -23,10 +23,15 @@ export class TeamDetailsViewModel {
|
||||
this.ownerId = dto.team.ownerId;
|
||||
this.leagues = dto.team.leagues;
|
||||
this.createdAt = dto.team.createdAt;
|
||||
this.specialization = dto.team.specialization;
|
||||
this.region = dto.team.region;
|
||||
this.languages = dto.team.languages;
|
||||
this.membership = dto.membership;
|
||||
// These properties don't exist in the current TeamDTO but may be added later
|
||||
this.specialization = undefined;
|
||||
this.region = undefined;
|
||||
this.languages = undefined;
|
||||
this.membership = dto.membership ? {
|
||||
role: dto.membership.role,
|
||||
joinedAt: dto.membership.joinedAt,
|
||||
isActive: dto.membership.isActive
|
||||
} : null;
|
||||
this._canManage = dto.canManage;
|
||||
this.currentUserId = currentUserId;
|
||||
}
|
||||
|
||||
@@ -1,3 +1,16 @@
|
||||
// Export the DTO type that WalletTransactionViewModel expects
|
||||
export type FullTransactionDto = {
|
||||
id: string;
|
||||
type: 'sponsorship' | 'membership' | 'withdrawal' | 'prize';
|
||||
description: string;
|
||||
amount: number;
|
||||
fee: number;
|
||||
netAmount: number;
|
||||
date: Date;
|
||||
status: 'completed' | 'pending' | 'failed';
|
||||
reference?: string;
|
||||
};
|
||||
|
||||
export class WalletTransactionViewModel {
|
||||
id: string;
|
||||
type: 'sponsorship' | 'membership' | 'withdrawal' | 'prize';
|
||||
@@ -9,17 +22,7 @@ export class WalletTransactionViewModel {
|
||||
status: 'completed' | 'pending' | 'failed';
|
||||
reference?: string;
|
||||
|
||||
constructor(dto: {
|
||||
id: string;
|
||||
type: 'sponsorship' | 'membership' | 'withdrawal' | 'prize';
|
||||
description: string;
|
||||
amount: number;
|
||||
fee: number;
|
||||
netAmount: number;
|
||||
date: Date;
|
||||
status: 'completed' | 'pending' | 'failed';
|
||||
reference?: string;
|
||||
}) {
|
||||
constructor(dto: FullTransactionDto) {
|
||||
this.id = dto.id;
|
||||
this.type = dto.type;
|
||||
this.description = dto.description;
|
||||
|
||||
Reference in New Issue
Block a user