fix issues in core
This commit is contained in:
@@ -139,6 +139,7 @@ export const DashboardProviders: Provider[] = [
|
||||
feedRepo: IFeedRepository,
|
||||
socialRepo: ISocialGraphRepository,
|
||||
imageService: ImageServicePort,
|
||||
output: DashboardOverviewPresenter,
|
||||
) =>
|
||||
new DashboardOverviewUseCase(
|
||||
driverRepo,
|
||||
@@ -152,6 +153,7 @@ export const DashboardProviders: Provider[] = [
|
||||
socialRepo,
|
||||
async (driverId: string) => imageService.getDriverAvatar(driverId),
|
||||
() => null,
|
||||
output,
|
||||
),
|
||||
inject: [
|
||||
DRIVER_REPOSITORY_TOKEN,
|
||||
@@ -164,6 +166,7 @@ export const DashboardProviders: Provider[] = [
|
||||
FEED_REPOSITORY_TOKEN,
|
||||
SOCIAL_GRAPH_REPOSITORY_TOKEN,
|
||||
IMAGE_SERVICE_TOKEN,
|
||||
DASHBOARD_OVERVIEW_OUTPUT_PORT_TOKEN,
|
||||
],
|
||||
},
|
||||
];
|
||||
@@ -20,7 +20,13 @@ export class DashboardService {
|
||||
async getDashboardOverview(driverId: string): Promise<DashboardOverviewDTO> {
|
||||
this.logger.debug('[DashboardService] Getting dashboard overview:', { driverId });
|
||||
|
||||
await this.dashboardOverviewUseCase.execute({ driverId });
|
||||
const result = await this.dashboardOverviewUseCase.execute({ driverId });
|
||||
|
||||
if (result.isErr()) {
|
||||
const error = result.error;
|
||||
const message = error?.details?.message || 'Unknown error';
|
||||
throw new Error(`Failed to get dashboard overview: ${message}`);
|
||||
}
|
||||
|
||||
return this.presenter.getResponseModel();
|
||||
}
|
||||
|
||||
@@ -144,7 +144,7 @@ describe('DashboardOverviewPresenter', () => {
|
||||
it('maps DashboardOverviewResult to DashboardOverviewDTO correctly', () => {
|
||||
const output = createOutput();
|
||||
|
||||
presenter.present(Result.ok(output));
|
||||
presenter.present(output);
|
||||
const dto = presenter.getResponseModel();
|
||||
|
||||
expect(dto.activeLeaguesCount).toBe(2);
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
import { Result } from '@core/shared/application/Result';
|
||||
import type { UseCaseOutputPort } from '@core/shared/application/UseCaseOutputPort';
|
||||
import type {
|
||||
DashboardOverviewResult,
|
||||
} from '@core/racing/application/use-cases/DashboardOverviewUseCase';
|
||||
@@ -13,12 +13,10 @@ import {
|
||||
DashboardFriendSummaryDTO,
|
||||
} from '../dtos/DashboardOverviewDTO';
|
||||
|
||||
export class DashboardOverviewPresenter {
|
||||
export class DashboardOverviewPresenter implements UseCaseOutputPort<DashboardOverviewResult> {
|
||||
private responseModel: DashboardOverviewDTO | null = null;
|
||||
|
||||
present(result: Result<DashboardOverviewResult, unknown>): void {
|
||||
const data = result.unwrap();
|
||||
|
||||
present(data: DashboardOverviewResult): void {
|
||||
const currentDriver: DashboardDriverSummaryDTO | null = data.currentDriver
|
||||
? {
|
||||
id: data.currentDriver.driver.id,
|
||||
|
||||
Reference in New Issue
Block a user