view data fixes
Some checks failed
Contract Testing / contract-tests (pull_request) Failing after 5m54s
Contract Testing / contract-snapshot (pull_request) Has been skipped

This commit is contained in:
2026-01-23 13:04:05 +01:00
parent d97f50ed72
commit e22033be38
24 changed files with 605 additions and 455 deletions

View File

@@ -1,31 +1,44 @@
import type { GetDriverTeamOutputDTO } from '@/lib/types/generated/GetDriverTeamOutputDTO';
/**
* View Model for Driver's Team
*
* Represents a driver's team membership in a UI-ready format.
* Client-only UI helper built from ViewData.
*/
import { ProfileDisplay } from "../display-objects/ProfileDisplay";
import { ViewModel } from "../contracts/view-models/ViewModel";
import type { TeamDetailData } from "../view-data/TeamDetailViewData";
export class DriverTeamViewModel extends ViewModel {
teamId: string;
teamName: string;
tag: string;
role: string;
isOwner: boolean;
canManage: boolean;
constructor(private readonly viewData: TeamDetailData) {
super();
}
constructor(dto: GetDriverTeamOutputDTO) {
this.teamId = dto.team.id;
this.teamName = dto.team.name;
this.tag = dto.team.tag;
this.role = dto.membership.role;
this.isOwner = dto.isOwner;
this.canManage = dto.canManage;
get teamId(): string {
return this.viewData.id;
}
get teamName(): string {
return this.viewData.name;
}
get tag(): string {
return this.viewData.tag;
}
get role(): string {
return this.viewData.membership?.role ?? "member";
}
get canManage(): boolean {
return this.viewData.canManage;
}
get isOwner(): boolean {
return this.viewData.membership?.role === "owner";
}
/** UI-specific: Display role */
get displayRole(): string {
return this.role.charAt(0).toUpperCase() + this.role.slice(1);
return ProfileDisplay.getTeamRole(this.role).text;
}
}