refactor use cases
This commit is contained in:
@@ -1,4 +1,4 @@
|
||||
import type { Logger, UseCaseOutputPort } from '@core/shared/application';
|
||||
import type { Logger } from '@core/shared/application';
|
||||
import { Result } from '@core/shared/application/Result';
|
||||
import type { ApplicationErrorCode } from '@core/shared/errors/ApplicationErrorCode';
|
||||
import type { Team } from '../../domain/entities/Team';
|
||||
@@ -27,13 +27,12 @@ export class LeaveTeamUseCase {
|
||||
private readonly teamRepository: ITeamRepository,
|
||||
private readonly membershipRepository: ITeamMembershipRepository,
|
||||
private readonly logger: Logger,
|
||||
private readonly output: UseCaseOutputPort<LeaveTeamResult>,
|
||||
) {}
|
||||
|
||||
async execute(
|
||||
input: LeaveTeamInput,
|
||||
): Promise<
|
||||
Result<void, ApplicationErrorCode<LeaveTeamErrorCode, { message: string }>>
|
||||
Result<LeaveTeamResult, ApplicationErrorCode<LeaveTeamErrorCode, { message: string }>>
|
||||
> {
|
||||
this.logger.debug('Attempting to leave team', { input });
|
||||
const { teamId, driverId } = input;
|
||||
@@ -82,9 +81,7 @@ export class LeaveTeamUseCase {
|
||||
team,
|
||||
previousMembership: membership,
|
||||
};
|
||||
this.output.present(result);
|
||||
|
||||
return Result.ok(undefined);
|
||||
return Result.ok(result);
|
||||
} catch (error) {
|
||||
this.logger.error(
|
||||
'Failed to leave team due to an unexpected error',
|
||||
|
||||
Reference in New Issue
Block a user