api client refactor
This commit is contained in:
@@ -1,29 +1,6 @@
|
||||
import type {
|
||||
IDriverRegistrationStatusPresenter,
|
||||
DriverRegistrationStatusViewModel,
|
||||
} from '@core/racing/application/presenters/IDriverRegistrationStatusPresenter';
|
||||
import { DriverRegistrationStatusDto } from '../dtos';
|
||||
import { DriverRegistrationStatusViewModel } from '../view-models';
|
||||
|
||||
export class DriverRegistrationStatusPresenter implements IDriverRegistrationStatusPresenter {
|
||||
private viewModel: DriverRegistrationStatusViewModel | null = null;
|
||||
|
||||
present(
|
||||
isRegistered: boolean,
|
||||
raceId: string,
|
||||
driverId: string
|
||||
): DriverRegistrationStatusViewModel {
|
||||
this.viewModel = {
|
||||
isRegistered,
|
||||
raceId,
|
||||
driverId,
|
||||
};
|
||||
|
||||
return this.viewModel;
|
||||
}
|
||||
|
||||
getViewModel(): DriverRegistrationStatusViewModel {
|
||||
if (!this.viewModel) {
|
||||
throw new Error('Presenter has not been called yet');
|
||||
}
|
||||
return this.viewModel;
|
||||
}
|
||||
}
|
||||
export const presentDriverRegistrationStatus = (dto: DriverRegistrationStatusDto): DriverRegistrationStatusViewModel => {
|
||||
return new DriverRegistrationStatusViewModel(dto);
|
||||
};
|
||||
Reference in New Issue
Block a user