41 lines
1.1 KiB
TypeScript
41 lines
1.1 KiB
TypeScript
import { AuthenticatedUserDTO } from '../types/generated/AuthenticatedUserDTO';
|
|
|
|
export class SessionViewModel implements AuthenticatedUserDTO {
|
|
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';
|
|
}
|
|
} |