view data fixes
This commit is contained in:
@@ -1,38 +1,37 @@
|
||||
import { DriverRegistrationStatusDTO } from '@/lib/types/generated/DriverRegistrationStatusDTO';
|
||||
|
||||
import { ViewModel } from "../contracts/view-models/ViewModel";
|
||||
import type { DriverRegistrationStatusViewData } from "../view-data/DriverRegistrationStatusViewData";
|
||||
import { DriverRegistrationStatusDisplay } from "../display-objects/DriverRegistrationStatusDisplay";
|
||||
|
||||
export class DriverRegistrationStatusViewModel extends ViewModel {
|
||||
isRegistered!: boolean;
|
||||
raceId!: string;
|
||||
driverId!: string;
|
||||
|
||||
constructor(dto: DriverRegistrationStatusDTO) {
|
||||
Object.assign(this, dto);
|
||||
constructor(private readonly viewData: DriverRegistrationStatusViewData) {
|
||||
super();
|
||||
}
|
||||
|
||||
/** UI-specific: Status message */
|
||||
get statusMessage(): string {
|
||||
return this.isRegistered ? 'Registered for this race' : 'Not registered';
|
||||
get isRegistered(): boolean {
|
||||
return this.viewData.isRegistered;
|
||||
}
|
||||
|
||||
/** UI-specific: Status color */
|
||||
get statusColor(): string {
|
||||
return this.isRegistered ? 'green' : 'red';
|
||||
get raceId(): string {
|
||||
return this.viewData.raceId;
|
||||
}
|
||||
|
||||
/** UI-specific: Badge variant */
|
||||
get statusBadgeVariant(): string {
|
||||
return this.isRegistered ? 'success' : 'warning';
|
||||
get driverId(): string {
|
||||
return this.viewData.driverId;
|
||||
}
|
||||
|
||||
/** UI-specific: Registration button text */
|
||||
get registrationButtonText(): string {
|
||||
return this.isRegistered ? 'Withdraw' : 'Register';
|
||||
}
|
||||
|
||||
/** UI-specific: Whether can register (assuming always can if not registered) */
|
||||
get canRegister(): boolean {
|
||||
return !this.isRegistered;
|
||||
return this.viewData.canRegister;
|
||||
}
|
||||
|
||||
get statusMessage(): string {
|
||||
return DriverRegistrationStatusDisplay.statusMessage(this.isRegistered);
|
||||
}
|
||||
|
||||
get statusBadgeVariant(): string {
|
||||
return DriverRegistrationStatusDisplay.statusBadgeVariant(this.isRegistered);
|
||||
}
|
||||
|
||||
get registrationButtonText(): string {
|
||||
return DriverRegistrationStatusDisplay.registrationButtonText(this.isRegistered);
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user