view models
This commit is contained in:
@@ -1,19 +1,24 @@
|
||||
import { SessionDataDto } from '../dtos';
|
||||
import { AuthenticatedUserDTO } from '../types/generated/AuthenticatedUserDTO';
|
||||
|
||||
export class SessionViewModel implements SessionDataDto {
|
||||
export class SessionViewModel implements AuthenticatedUserDTO {
|
||||
userId: string;
|
||||
email: string;
|
||||
displayName?: string;
|
||||
driverId?: string;
|
||||
isAuthenticated: boolean;
|
||||
displayName: string;
|
||||
|
||||
constructor(dto: SessionDataDto) {
|
||||
Object.assign(this, dto);
|
||||
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 || this.email}!`;
|
||||
return `Hello, ${this.displayName}!`;
|
||||
}
|
||||
|
||||
/** UI-specific: Avatar initials */
|
||||
|
||||
Reference in New Issue
Block a user