45 lines
1.6 KiB
TypeScript
45 lines
1.6 KiB
TypeScript
import type { CompleteOnboardingViewData } from '@/lib/builders/view-data/CompleteOnboardingViewData';
|
|
import { OnboardingStatusDisplay } from '../display-objects/OnboardingStatusDisplay';
|
|
|
|
import { ViewModel } from "../contracts/view-models/ViewModel";
|
|
|
|
/**
|
|
* Complete onboarding view model
|
|
* UI representation of onboarding completion result
|
|
*
|
|
* Composes Display Objects and transforms ViewData for UI consumption.
|
|
*/
|
|
export class CompleteOnboardingViewModel extends ViewModel {
|
|
success: boolean;
|
|
driverId?: string;
|
|
errorMessage?: string;
|
|
|
|
// UI-specific derived fields (primitive outputs only)
|
|
readonly statusLabel: string;
|
|
readonly statusVariant: string;
|
|
readonly statusIcon: string;
|
|
readonly statusMessage: string;
|
|
|
|
constructor(viewData: CompleteOnboardingViewData) {
|
|
super();
|
|
this.success = viewData.success;
|
|
if (viewData.driverId !== undefined) this.driverId = viewData.driverId;
|
|
if (viewData.errorMessage !== undefined) this.errorMessage = viewData.errorMessage;
|
|
|
|
// Derive UI-specific fields using Display Object
|
|
this.statusLabel = OnboardingStatusDisplay.statusLabel(this.success);
|
|
this.statusVariant = OnboardingStatusDisplay.statusVariant(this.success);
|
|
this.statusIcon = OnboardingStatusDisplay.statusIcon(this.success);
|
|
this.statusMessage = OnboardingStatusDisplay.statusMessage(this.success, this.errorMessage);
|
|
}
|
|
|
|
/** UI-specific: Whether onboarding was successful */
|
|
get isSuccessful(): boolean {
|
|
return this.success;
|
|
}
|
|
|
|
/** UI-specific: Whether there was an error */
|
|
get hasError(): boolean {
|
|
return !!this.errorMessage;
|
|
}
|
|
} |