31 lines
997 B
TypeScript
31 lines
997 B
TypeScript
import { ViewModel } from "../contracts/view-models/ViewModel";
|
|
import type { LeagueJoinRequestViewData } from "../view-data/LeagueJoinRequestViewData";
|
|
|
|
export class LeagueJoinRequestViewModel extends ViewModel {
|
|
private readonly data: LeagueJoinRequestViewData;
|
|
|
|
constructor(data: LeagueJoinRequestViewData) {
|
|
super();
|
|
this.data = data;
|
|
}
|
|
|
|
get id(): string { return this.data.id; }
|
|
get leagueId(): string { return this.data.leagueId; }
|
|
get driverId(): string { return this.data.driverId; }
|
|
get requestedAt(): string { return this.data.requestedAt; }
|
|
|
|
/** 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.data.isAdmin;
|
|
}
|
|
|
|
/** UI-specific: Whether the request can be rejected by current user */
|
|
get canReject(): boolean {
|
|
return this.data.isAdmin;
|
|
}
|
|
} |