Files
gridpilot.gg/apps/website/lib/view-models/RequestAvatarGenerationViewModel.ts
2025-12-26 00:20:53 +01:00

43 lines
1.1 KiB
TypeScript

import { RequestAvatarGenerationOutputDTO } from '../types/generated/RequestAvatarGenerationOutputDTO';
/**
* Request Avatar Generation View Model
*
* Represents the result of an avatar generation request
*/
export class RequestAvatarGenerationViewModel {
success: boolean;
requestId?: string;
avatarUrls?: string[];
errorMessage?: string;
constructor(dto: RequestAvatarGenerationOutputDTO) {
this.success = dto.success;
if (dto.requestId !== undefined) this.requestId = dto.requestId;
if (dto.avatarUrls !== undefined) this.avatarUrls = dto.avatarUrls;
if (dto.errorMessage !== undefined) this.errorMessage = dto.errorMessage;
}
/** UI-specific: Whether generation was successful */
get isSuccessful(): boolean {
return this.success;
}
/** UI-specific: Whether there was an error */
get hasError(): boolean {
return !!this.errorMessage;
}
/** UI-specific: Get first avatar URL */
get firstAvatarUrl(): string | undefined {
return this.avatarUrls?.[0];
}
get avatarUrl(): string | undefined {
return this.firstAvatarUrl;
}
get error(): string | undefined {
return this.errorMessage;
}
}