This commit is contained in:
2025-12-21 17:05:36 +01:00
parent 08b0d59e45
commit f2d8a23583
66 changed files with 1131 additions and 1342 deletions

View File

@@ -27,14 +27,14 @@ export class GetAllLeaguesWithCapacityUseCase {
constructor(
private readonly leagueRepository: ILeagueRepository,
private readonly leagueMembershipRepository: ILeagueMembershipRepository,
private readonly output: UseCaseOutputPort<GetAllLeaguesWithCapacityResult>,
private readonly outputPort: UseCaseOutputPort<GetAllLeaguesWithCapacityResult, GetAllLeaguesWithCapacityErrorCode>,
) {}
async execute(
_input: GetAllLeaguesWithCapacityInput = {},
): Promise<
Result<
void,
GetAllLeaguesWithCapacityResult,
ApplicationErrorCode<GetAllLeaguesWithCapacityErrorCode, { message: string }>
>
> {
@@ -44,15 +44,15 @@ export class GetAllLeaguesWithCapacityUseCase {
const summaries: LeagueCapacitySummary[] = [];
for (const league of leagues) {
const members = await this.leagueMembershipRepository.getLeagueMembers(league.id);
const members = await this.leagueMembershipRepository.getLeagueMembers(league.id.toString());
const currentDrivers = members.filter(
(m) =>
m.status === 'active' &&
(m.role === 'owner' ||
m.role === 'admin' ||
m.role === 'steward' ||
m.role === 'member'),
m.status.toString() === 'active' &&
(m.role.toString() === 'owner' ||
m.role.toString() === 'admin' ||
m.role.toString() === 'steward' ||
m.role.toString() === 'member'),
).length;
const maxDrivers = league.settings.maxDrivers ?? 0;
@@ -60,9 +60,7 @@ export class GetAllLeaguesWithCapacityUseCase {
summaries.push({ league, currentDrivers, maxDrivers });
}
this.output.present({ leagues: summaries });
return Result.ok(undefined);
return Result.ok({ leagues: summaries });
} catch (error: unknown) {
const message =
error instanceof Error && error.message