fix issues in core
This commit is contained in:
@@ -10,6 +10,8 @@ import type { IResultRepository } from '../../domain/repositories/IResultReposit
|
||||
import type { ILeagueRepository } from '../../domain/repositories/ILeagueRepository';
|
||||
import type { ILeagueMembershipRepository } from '../../domain/repositories/ILeagueMembershipRepository';
|
||||
import { isLeagueStewardOrHigherRole } from '../../domain/types/LeagueRoles';
|
||||
import { Position } from '../../domain/entities/result/Position';
|
||||
import { IncidentCount } from '../../domain/entities/result/IncidentCount';
|
||||
|
||||
export type SendFinalResultsInput = {
|
||||
leagueId: string;
|
||||
@@ -61,8 +63,11 @@ export class SendFinalResultsUseCase {
|
||||
return Result.err({ code: 'RACE_NOT_FOUND', details: { message: 'Race event not found' } });
|
||||
}
|
||||
|
||||
const membership = await this.membershipRepository.getMembership(league.id.toString(), input.triggeredById);
|
||||
if (!membership || !isLeagueStewardOrHigherRole(membership.role)) {
|
||||
const membership = await this.membershipRepository.getMembership(
|
||||
league.id.toString(),
|
||||
input.triggeredById,
|
||||
);
|
||||
if (!membership || !isLeagueStewardOrHigherRole(membership.role.toString())) {
|
||||
return Result.err({
|
||||
code: 'INSUFFICIENT_PERMISSIONS',
|
||||
details: { message: 'Insufficient permissions to send final results' },
|
||||
@@ -133,10 +138,12 @@ export class SendFinalResultsUseCase {
|
||||
);
|
||||
|
||||
const title = `Final Results: ${raceEvent.name}`;
|
||||
const positionValue = position instanceof Position ? position.toNumber() : position;
|
||||
const incidentValue = incidents instanceof IncidentCount ? incidents.toNumber() : incidents;
|
||||
const body = this.buildFinalResultsBody(
|
||||
position,
|
||||
positionValue,
|
||||
positionChange,
|
||||
incidents,
|
||||
incidentValue,
|
||||
finalRatingChange,
|
||||
hadPenaltiesApplied,
|
||||
);
|
||||
@@ -152,9 +159,9 @@ export class SendFinalResultsUseCase {
|
||||
raceEventId: raceEvent.id,
|
||||
sessionId: raceEvent.getMainRaceSession()?.id ?? '',
|
||||
leagueId,
|
||||
position,
|
||||
position: positionValue,
|
||||
positionChange,
|
||||
incidents,
|
||||
incidents: incidentValue,
|
||||
finalRatingChange,
|
||||
hadPenaltiesApplied,
|
||||
},
|
||||
|
||||
Reference in New Issue
Block a user