refactor use cases
This commit is contained in:
@@ -4,7 +4,6 @@ import type { ITeamRepository } from '../../domain/repositories/ITeamRepository'
|
||||
import type { TeamJoinRequest } from '../../domain/types/TeamMembership';
|
||||
import type { Driver } from '../../domain/entities/Driver';
|
||||
import type { Team } from '../../domain/entities/Team';
|
||||
import type { UseCaseOutputPort } from '@core/shared/application';
|
||||
import { Result } from '@core/shared/application/Result';
|
||||
import type { ApplicationErrorCode } from '@core/shared/errors/ApplicationErrorCode';
|
||||
|
||||
@@ -24,16 +23,13 @@ export type GetTeamJoinRequestsResult = {
|
||||
};
|
||||
|
||||
export class GetTeamJoinRequestsUseCase {
|
||||
constructor(
|
||||
private readonly membershipRepository: ITeamMembershipRepository,
|
||||
constructor(private readonly membershipRepository: ITeamMembershipRepository,
|
||||
private readonly driverRepository: IDriverRepository,
|
||||
private readonly teamRepository: ITeamRepository,
|
||||
private readonly output: UseCaseOutputPort<GetTeamJoinRequestsResult>,
|
||||
) {}
|
||||
private readonly teamRepository: ITeamRepository) {}
|
||||
|
||||
async execute(
|
||||
input: GetTeamJoinRequestsInput,
|
||||
): Promise<Result<void, ApplicationErrorCode<GetTeamJoinRequestsErrorCode, { message: string }>>> {
|
||||
): Promise<Result<GetTeamJoinRequestsResult, ApplicationErrorCode<GetTeamJoinRequestsErrorCode, { message: string }>>> {
|
||||
try {
|
||||
const team = await this.teamRepository.findById(input.teamId);
|
||||
|
||||
@@ -64,9 +60,7 @@ export class GetTeamJoinRequestsUseCase {
|
||||
joinRequests: enrichedJoinRequests,
|
||||
};
|
||||
|
||||
this.output.present(result);
|
||||
|
||||
return Result.ok(undefined);
|
||||
return Result.ok(result);
|
||||
} catch (error: unknown) {
|
||||
const message =
|
||||
error instanceof Error && error.message
|
||||
|
||||
Reference in New Issue
Block a user