wip
This commit is contained in:
@@ -0,0 +1,26 @@
|
||||
import type { IRaceRegistrationRepository } from '@gridpilot/racing/domain/repositories/IRaceRegistrationRepository';
|
||||
|
||||
export interface WithdrawFromRaceCommand {
|
||||
raceId: string;
|
||||
driverId: string;
|
||||
}
|
||||
|
||||
/**
|
||||
* Mirrors legacy withdrawFromRace behavior:
|
||||
* - throws when driver is not registered
|
||||
* - removes registration and cleans up empty race sets
|
||||
*
|
||||
* The repository encapsulates the in-memory or persistent details.
|
||||
*/
|
||||
export class WithdrawFromRaceUseCase {
|
||||
constructor(
|
||||
private readonly registrationRepository: IRaceRegistrationRepository,
|
||||
) {}
|
||||
|
||||
async execute(command: WithdrawFromRaceCommand): Promise<void> {
|
||||
const { raceId, driverId } = command;
|
||||
|
||||
// Let repository enforce "not registered" error behavior to match legacy logic.
|
||||
await this.registrationRepository.withdraw(raceId, driverId);
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user