wip
This commit is contained in:
@@ -1,15 +1,16 @@
|
||||
import type {
|
||||
ILeagueMembershipRepository,
|
||||
} from '@gridpilot/racing/domain/repositories/ILeagueMembershipRepository';
|
||||
import type {
|
||||
import type { AsyncUseCase } from '@gridpilot/shared/application';
|
||||
import {
|
||||
LeagueMembership,
|
||||
MembershipRole,
|
||||
MembershipStatus,
|
||||
type MembershipRole,
|
||||
type MembershipStatus,
|
||||
} from '@gridpilot/racing/domain/entities/LeagueMembership';
|
||||
import type { JoinLeagueCommandDTO } from '../dto/JoinLeagueCommandDTO';
|
||||
import { BusinessRuleViolationError } from '../errors/RacingApplicationError';
|
||||
|
||||
export class JoinLeagueUseCase {
|
||||
|
||||
export class JoinLeagueUseCase implements AsyncUseCase<JoinLeagueCommandDTO, LeagueMembership> {
|
||||
constructor(private readonly membershipRepository: ILeagueMembershipRepository) {}
|
||||
|
||||
/**
|
||||
@@ -27,13 +28,12 @@ export class JoinLeagueUseCase {
|
||||
throw new BusinessRuleViolationError('Already a member or have a pending request');
|
||||
}
|
||||
|
||||
const membership: LeagueMembership = {
|
||||
const membership = LeagueMembership.create({
|
||||
leagueId,
|
||||
driverId,
|
||||
role: 'member' as MembershipRole,
|
||||
status: 'active' as MembershipStatus,
|
||||
joinedAt: new Date(),
|
||||
};
|
||||
});
|
||||
|
||||
return this.membershipRepository.saveMembership(membership);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user