view data fixes
Some checks failed
Contract Testing / contract-tests (pull_request) Failing after 5m54s
Contract Testing / contract-snapshot (pull_request) Has been skipped

This commit is contained in:
2026-01-23 13:04:05 +01:00
parent d97f50ed72
commit e22033be38
24 changed files with 605 additions and 455 deletions

View File

@@ -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);
}
}