view models
This commit is contained in:
@@ -1,11 +1,36 @@
|
||||
// Note: No generated DTO available for UploadMedia yet
|
||||
interface UploadMediaDTO {
|
||||
success: boolean;
|
||||
mediaId?: string;
|
||||
url?: string;
|
||||
error?: string;
|
||||
}
|
||||
|
||||
/**
|
||||
* Upload Media View Model
|
||||
*
|
||||
* Represents the result of a media upload operation
|
||||
*/
|
||||
export interface UploadMediaViewModel {
|
||||
export class UploadMediaViewModel {
|
||||
success: boolean;
|
||||
mediaId?: string;
|
||||
url?: string;
|
||||
error?: string;
|
||||
|
||||
constructor(dto: UploadMediaDTO) {
|
||||
this.success = dto.success;
|
||||
if (dto.mediaId !== undefined) this.mediaId = dto.mediaId;
|
||||
if (dto.url !== undefined) this.url = dto.url;
|
||||
if (dto.error !== undefined) this.error = dto.error;
|
||||
}
|
||||
|
||||
/** UI-specific: Whether upload was successful */
|
||||
get isSuccessful(): boolean {
|
||||
return this.success;
|
||||
}
|
||||
|
||||
/** UI-specific: Whether there was an error */
|
||||
get hasError(): boolean {
|
||||
return !!this.error;
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user