33 lines
765 B
TypeScript
33 lines
765 B
TypeScript
/**
|
|
* Upload Media View Model
|
|
*
|
|
* Represents the result of a media upload operation
|
|
*/
|
|
import { ViewModel } from "../contracts/view-models/ViewModel";
|
|
import type { UploadMediaViewData } from "../view-data/UploadMediaViewData";
|
|
|
|
export class UploadMediaViewModel extends ViewModel {
|
|
success: boolean;
|
|
mediaId?: string;
|
|
url?: string;
|
|
error?: string;
|
|
|
|
constructor(data: UploadMediaViewData) {
|
|
super();
|
|
this.success = data.success;
|
|
this.mediaId = data.mediaId;
|
|
this.url = data.url;
|
|
this.error = data.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;
|
|
}
|
|
}
|