fix presenter issues
This commit is contained in:
@@ -1,17 +1,10 @@
|
||||
import { Result } from '@core/shared/application/Result';
|
||||
import type { CompleteOnboardingOutputDTO } from '../dtos/CompleteOnboardingOutputDTO';
|
||||
import type { CompleteDriverOnboardingResult } from '@core/racing/application/use-cases/CompleteDriverOnboardingUseCase';
|
||||
|
||||
export class CompleteOnboardingPresenter {
|
||||
private responseModel: CompleteOnboardingOutputDTO | null = null;
|
||||
|
||||
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
||||
present(result: Result<any, any>): void {
|
||||
if (result.isErr()) {
|
||||
const error = result.unwrapErr();
|
||||
throw new Error(error.details?.message ?? 'Failed to complete onboarding');
|
||||
}
|
||||
|
||||
const data = result.unwrap();
|
||||
present(data: CompleteDriverOnboardingResult): void {
|
||||
this.responseModel = {
|
||||
success: true,
|
||||
driverId: data.driver.id,
|
||||
|
||||
@@ -1,5 +1,4 @@
|
||||
import { GetDriversLeaderboardResult } from '@core/racing/application/use-cases/GetDriversLeaderboardUseCase';
|
||||
import { Result } from '@core/shared/application/Result';
|
||||
import { beforeEach, describe, expect, it } from 'vitest';
|
||||
import { DriversLeaderboardPresenter } from './DriversLeaderboardPresenter';
|
||||
import type { Driver } from '@core/racing/domain/entities/Driver';
|
||||
@@ -54,9 +53,7 @@ describe('DriversLeaderboardPresenter', () => {
|
||||
activeCount: 2,
|
||||
};
|
||||
|
||||
const result = Result.ok<GetDriversLeaderboardResult, never>(coreResult);
|
||||
|
||||
presenter.present(result);
|
||||
presenter.present(coreResult);
|
||||
|
||||
const output = presenter.getResponseModel();
|
||||
|
||||
|
||||
@@ -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