Files
gridpilot.gg/apps/website/lib/view-models/LeagueMemberViewModel.ts
Marc Mintel d97f50ed72
Some checks failed
Contract Testing / contract-tests (pull_request) Failing after 6m4s
Contract Testing / contract-snapshot (pull_request) Has been skipped
view data fixes
2026-01-23 11:59:49 +01:00

45 lines
1.3 KiB
TypeScript

import { LeagueMemberDTO } from '@/lib/types/generated/LeagueMemberDTO';
import { DriverViewModel } from './DriverViewModel';
import { ViewModel } from "../contracts/view-models/ViewModel";
export class LeagueMemberViewModel extends ViewModel {
driverId: string;
currentUserId: string;
constructor(dto: LeagueMemberDTO, currentUserId: string) {
this.driverId = dto.driverId;
this.currentUserId = currentUserId;
}
// Note: The generated DTO is incomplete
// These fields will need to be added when the OpenAPI spec is updated
driver?: DriverViewModel;
role: string = 'member';
joinedAt: string = new Date().toISOString();
/** UI-specific: Formatted join date */
get formattedJoinedAt(): string {
return new Date(this.joinedAt).toLocaleDateString();
}
/** UI-specific: Badge variant for role */
get roleBadgeVariant(): string {
switch (this.role) {
case 'owner': return 'primary';
case 'admin': return 'secondary';
default: return 'default';
}
}
/** UI-specific: Whether this member is the owner */
get isOwner(): boolean {
return this.role === 'owner';
}
/** UI-specific: Whether this is the current user */
get isCurrentUser(): boolean {
return this.driverId === this.currentUserId;
}
}