view data fixes

This commit is contained in:
2026-01-23 15:30:23 +01:00
parent e22033be38
commit f8099f04bc
213 changed files with 3466 additions and 3003 deletions

View File

@@ -1,52 +1,28 @@
import type { GetTeamDetailsOutputDTO } from '@/lib/types/generated/GetTeamDetailsOutputDTO';
import { ViewModel } from "../contracts/view-models/ViewModel";
import type { TeamDetailsViewData } from "../view-data/TeamDetailsViewData";
export class TeamDetailsViewModel extends ViewModel {
id!: string;
name!: string;
tag!: string;
description?: string;
ownerId!: string;
leagues!: string[];
createdAt: string | undefined;
specialization: string | undefined;
region: string | undefined;
languages: string[] | undefined;
category: string | undefined;
membership: { role: string; joinedAt: string; isActive: boolean } | null;
private _canManage: boolean;
private currentUserId: string;
private readonly data: TeamDetailsViewData;
constructor(dto: GetTeamDetailsOutputDTO, currentUserId: string) {
this.id = dto.team.id;
this.name = dto.team.name;
this.tag = dto.team.tag;
this.description = dto.team.description;
this.ownerId = dto.team.ownerId;
this.leagues = dto.team.leagues;
this.createdAt = dto.team.createdAt;
const teamExtras = dto.team as typeof dto.team & {
specialization?: string;
region?: string;
languages?: string[];
category?: string;
};
this.specialization = teamExtras.specialization ?? undefined;
this.region = teamExtras.region ?? undefined;
this.languages = teamExtras.languages ?? undefined;
this.category = teamExtras.category ?? undefined;
this.membership = dto.membership ? {
role: dto.membership.role,
joinedAt: dto.membership.joinedAt,
isActive: dto.membership.isActive
} : null;
this._canManage = dto.canManage;
this.currentUserId = currentUserId;
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';
@@ -54,7 +30,7 @@ export class TeamDetailsViewModel extends ViewModel {
/** UI-specific: Whether can manage team */
get canManage(): boolean {
return this._canManage;
return this.data.canManage;
}
/** UI-specific: Whether current user is member */
@@ -66,4 +42,4 @@ export class TeamDetailsViewModel extends ViewModel {
get userRole(): string {
return this.membership?.role || 'none';
}
}
}