46 lines
1.6 KiB
TypeScript
46 lines
1.6 KiB
TypeScript
import { ViewModel } from "../contracts/view-models/ViewModel";
|
|
import type { TeamDetailsViewData } from "../view-data/TeamDetailsViewData";
|
|
|
|
export class TeamDetailsViewModel extends ViewModel {
|
|
private readonly data: TeamDetailsViewData;
|
|
|
|
constructor(data: TeamDetailsViewData) {
|
|
super();
|
|
this.data = data;
|
|
}
|
|
|
|
get id(): string { return this.data.team.id; }
|
|
get name(): string { return this.data.team.name; }
|
|
get tag(): string { return this.data.team.tag; }
|
|
get description(): string | undefined { return this.data.team.description; }
|
|
get ownerId(): string { return this.data.team.ownerId; }
|
|
get leagues(): string[] { return this.data.team.leagues; }
|
|
get createdAt(): string | undefined { return this.data.team.createdAt; }
|
|
get specialization(): string | undefined { return this.data.team.specialization; }
|
|
get region(): string | undefined { return this.data.team.region; }
|
|
get languages(): string[] | undefined { return this.data.team.languages; }
|
|
get category(): string | undefined { return this.data.team.category; }
|
|
get membership() { return this.data.membership; }
|
|
get currentUserId(): string { return this.data.currentUserId; }
|
|
|
|
/** UI-specific: Whether current user is owner */
|
|
get isOwner(): boolean {
|
|
return this.membership?.role === 'owner';
|
|
}
|
|
|
|
/** UI-specific: Whether can manage team */
|
|
get canManage(): boolean {
|
|
return this.data.canManage;
|
|
}
|
|
|
|
/** UI-specific: Whether current user is member */
|
|
get isMember(): boolean {
|
|
return this.membership !== null;
|
|
}
|
|
|
|
/** UI-specific: Current user's role */
|
|
get userRole(): string {
|
|
return this.membership?.role || 'none';
|
|
}
|
|
}
|