view models
This commit is contained in:
@@ -1,16 +1,32 @@
|
||||
import type { LeagueAdminDto } from '../dtos';
|
||||
import type { LeagueMemberViewModel, LeagueJoinRequestViewModel } from './';
|
||||
import type { LeagueMemberViewModel } from './LeagueMemberViewModel';
|
||||
import type { LeagueJoinRequestViewModel } from './LeagueJoinRequestViewModel';
|
||||
|
||||
/**
|
||||
* League admin view model
|
||||
* Transform from DTO to ViewModel with UI fields
|
||||
*/
|
||||
export interface LeagueAdminViewModel {
|
||||
config: LeagueAdminDto['config'];
|
||||
export class LeagueAdminViewModel {
|
||||
config: any;
|
||||
members: LeagueMemberViewModel[];
|
||||
joinRequests: LeagueJoinRequestViewModel[];
|
||||
// Total pending requests count
|
||||
pendingRequestsCount: number;
|
||||
// Whether there are any pending requests
|
||||
hasPendingRequests: boolean;
|
||||
|
||||
constructor(dto: {
|
||||
config: any;
|
||||
members: LeagueMemberViewModel[];
|
||||
joinRequests: LeagueJoinRequestViewModel[];
|
||||
}) {
|
||||
this.config = dto.config;
|
||||
this.members = dto.members;
|
||||
this.joinRequests = dto.joinRequests;
|
||||
}
|
||||
|
||||
/** UI-specific: Total pending requests count */
|
||||
get pendingRequestsCount(): number {
|
||||
return this.joinRequests.length;
|
||||
}
|
||||
|
||||
/** UI-specific: Whether there are any pending requests */
|
||||
get hasPendingRequests(): boolean {
|
||||
return this.joinRequests.length > 0;
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user