Files
gridpilot.gg/apps/website/lib/view-models/SessionViewModel.ts
2025-12-18 13:56:05 +01:00

41 lines
1.1 KiB
TypeScript

import { AuthenticatedUserDTO } from '../types/generated/AuthenticatedUserDTO';
export class SessionViewModel {
userId: string;
email: string;
displayName: string;
constructor(dto: AuthenticatedUserDTO) {
this.userId = dto.userId;
this.email = dto.email;
this.displayName = dto.displayName;
}
// Note: The generated DTO doesn't have these fields
// These will need to be added when the OpenAPI spec is updated
driverId?: string;
isAuthenticated: boolean = true;
/** UI-specific: User greeting */
get greeting(): string {
return `Hello, ${this.displayName}!`;
}
/** UI-specific: Avatar initials */
get avatarInitials(): string {
if (this.displayName) {
return this.displayName.split(' ').map(n => n[0]).join('').toUpperCase();
}
return this.email[0].toUpperCase();
}
/** UI-specific: Whether has driver profile */
get hasDriverProfile(): boolean {
return !!this.driverId;
}
/** UI-specific: Authentication status display */
get authStatusDisplay(): string {
return this.isAuthenticated ? 'Logged In' : 'Logged Out';
}
}