import type { ITeamMembershipRepository } from '../../domain/repositories/ITeamMembershipRepository';
import type { RejectTeamJoinRequestCommandDTO } from '../dtos/RejectTeamJoinRequestCommandDTO';
import { Result } from '@core/shared/application/Result';
import type { ApplicationErrorCode } from '@core/shared/errors/ApplicationErrorCode';

export class RejectTeamJoinRequestUseCase {
  constructor(
    private readonly membershipRepository: ITeamMembershipRepository,
  ) {}

  async execute(command: RejectTeamJoinRequestCommandDTO): Promise<Result<void, ApplicationErrorCode<'NO_ERROR'>>> {
    const { requestId } = command;
    await this.membershipRepository.removeJoinRequest(requestId);
    return Result.ok(undefined);
  }
}