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

36 lines
909 B
TypeScript

import { SessionDataDto } from '../dtos';
export class SessionViewModel implements SessionDataDto {
userId: string;
email: string;
displayName?: string;
driverId?: string;
isAuthenticated: boolean;
constructor(dto: SessionDataDto) {
Object.assign(this, dto);
}
/** UI-specific: User greeting */
get greeting(): string {
return `Hello, ${this.displayName || this.email}!`;
}
/** 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';
}
}