view models

This commit is contained in:
2025-12-18 00:08:47 +01:00
parent f7a56a92ce
commit 7c449af311
56 changed files with 2594 additions and 206 deletions

View File

@@ -1,14 +1,39 @@
import type { LeagueJoinRequestDto } from '../dtos';
import type { LeagueJoinRequestDTO } from '../types/generated/LeagueJoinRequestDTO';
/**
* League join request view model
* Transform from DTO to ViewModel with UI fields
*/
export interface LeagueJoinRequestViewModel extends LeagueJoinRequestDto {
// Formatted request date
formattedRequestedAt: string;
// Whether the request can be approved by current user
canApprove: boolean;
// Whether the request can be rejected by current user
canReject: boolean;
export class LeagueJoinRequestViewModel implements LeagueJoinRequestDTO {
id: string;
leagueId: string;
driverId: string;
requestedAt: string;
private currentUserId: string;
private isAdmin: boolean;
constructor(dto: LeagueJoinRequestDTO, currentUserId: string, isAdmin: boolean) {
this.id = dto.id;
this.leagueId = dto.leagueId;
this.driverId = dto.driverId;
this.requestedAt = dto.requestedAt;
this.currentUserId = currentUserId;
this.isAdmin = isAdmin;
}
/** UI-specific: Formatted request date */
get formattedRequestedAt(): string {
return new Date(this.requestedAt).toLocaleString();
}
/** UI-specific: Whether the request can be approved by current user */
get canApprove(): boolean {
return this.isAdmin;
}
/** UI-specific: Whether the request can be rejected by current user */
get canReject(): boolean {
return this.isAdmin;
}
}