Files
gridpilot.gg/apps/website/lib/view-models/LeagueJoinRequestViewModel.ts
2026-01-12 01:01:49 +01:00

37 lines
989 B
TypeScript

import type { LeagueJoinRequestDTO } from '@/lib/types/generated/LeagueJoinRequestDTO';
/**
* League join request view model
* Transform from DTO to ViewModel with UI fields
*/
export class LeagueJoinRequestViewModel {
id: string;
leagueId: string;
driverId: string;
requestedAt: 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.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;
}
}