refactor use cases
This commit is contained in:
@@ -1,4 +1,3 @@
|
||||
import type { UseCaseOutputPort } from '@core/shared/application';
|
||||
import { Result } from '@core/shared/application/Result';
|
||||
import type { ApplicationErrorCode } from '@core/shared/errors/ApplicationErrorCode';
|
||||
import type { Driver } from '../../domain/entities/Driver';
|
||||
@@ -30,12 +29,11 @@ export class GetLeagueRosterJoinRequestsUseCase {
|
||||
private readonly leagueMembershipRepository: ILeagueMembershipRepository,
|
||||
private readonly driverRepository: IDriverRepository,
|
||||
private readonly leagueRepository: ILeagueRepository,
|
||||
private readonly output: UseCaseOutputPort<GetLeagueRosterJoinRequestsResult>,
|
||||
) {}
|
||||
|
||||
async execute(
|
||||
input: GetLeagueRosterJoinRequestsInput,
|
||||
): Promise<Result<void, ApplicationErrorCode<GetLeagueRosterJoinRequestsErrorCode, { message: string }>>> {
|
||||
): Promise<Result<GetLeagueRosterJoinRequestsResult, ApplicationErrorCode<GetLeagueRosterJoinRequestsErrorCode, { message: string }>>> {
|
||||
try {
|
||||
const leagueExists = await this.leagueRepository.exists(input.leagueId);
|
||||
|
||||
@@ -65,9 +63,7 @@ export class GetLeagueRosterJoinRequestsUseCase {
|
||||
driver: driverMap.get(request.driverId.toString())!,
|
||||
}));
|
||||
|
||||
this.output.present({ joinRequests: enrichedJoinRequests });
|
||||
|
||||
return Result.ok(undefined);
|
||||
return Result.ok({ joinRequests: enrichedJoinRequests });
|
||||
} catch (error: unknown) {
|
||||
const message = error instanceof Error ? error.message : 'Failed to load league roster join requests';
|
||||
|
||||
|
||||
Reference in New Issue
Block a user