fix presenter issues
This commit is contained in:
@@ -1,21 +1,12 @@
|
||||
import { DriversLeaderboardDTO } from '../dtos/DriversLeaderboardDTO';
|
||||
import { Result } from '@core/shared/application/Result';
|
||||
import type { ApplicationErrorCode } from '@core/shared/errors/ApplicationErrorCode';
|
||||
import type {
|
||||
GetDriversLeaderboardResult,
|
||||
GetDriversLeaderboardErrorCode,
|
||||
} from '@core/racing/application/use-cases/GetDriversLeaderboardUseCase';
|
||||
|
||||
export class DriversLeaderboardPresenter {
|
||||
private responseModel: DriversLeaderboardDTO | null = null;
|
||||
|
||||
present(result: Result<GetDriversLeaderboardResult, ApplicationErrorCode<GetDriversLeaderboardErrorCode, { message: string }>>): void {
|
||||
if (result.isErr()) {
|
||||
const error = result.unwrapErr();
|
||||
throw new Error(error.details?.message ?? 'Failed to get drivers leaderboard');
|
||||
}
|
||||
|
||||
const data = result.unwrap();
|
||||
present(data: GetDriversLeaderboardResult): void {
|
||||
this.responseModel = {
|
||||
drivers: data.items.map(item => ({
|
||||
id: item.driver.id,
|
||||
|
||||
Reference in New Issue
Block a user