view data fixes
This commit is contained in:
@@ -1,27 +1,19 @@
|
||||
import type { LeagueJoinRequestDTO } from '@/lib/types/generated/LeagueJoinRequestDTO';
|
||||
|
||||
/**
|
||||
* League join request view model
|
||||
* Transform from DTO to ViewModel with UI fields
|
||||
*/
|
||||
import { ViewModel } from "../contracts/view-models/ViewModel";
|
||||
import type { LeagueJoinRequestViewData } from "../view-data/LeagueJoinRequestViewData";
|
||||
|
||||
export class LeagueJoinRequestViewModel extends ViewModel {
|
||||
id: string;
|
||||
leagueId: string;
|
||||
driverId: string;
|
||||
requestedAt: string;
|
||||
private readonly data: LeagueJoinRequestViewData;
|
||||
|
||||
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;
|
||||
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();
|
||||
@@ -29,11 +21,11 @@ export class LeagueJoinRequestViewModel extends ViewModel {
|
||||
|
||||
/** UI-specific: Whether the request can be approved by current user */
|
||||
get canApprove(): boolean {
|
||||
return this.isAdmin;
|
||||
return this.data.isAdmin;
|
||||
}
|
||||
|
||||
/** UI-specific: Whether the request can be rejected by current user */
|
||||
get canReject(): boolean {
|
||||
return this.isAdmin;
|
||||
return this.data.isAdmin;
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user