fix issues
This commit is contained in:
@@ -49,12 +49,15 @@ export class ProtestService {
|
||||
if (!protest) return null;
|
||||
|
||||
const race = Object.values(dto.racesById)[0];
|
||||
|
||||
if (!race) return null;
|
||||
|
||||
// Cast to the correct type for indexing
|
||||
const driversById = dto.driversById as unknown as Record<string, DriverDTO>;
|
||||
const protestingDriver = driversById[protest.protestingDriverId];
|
||||
const accusedDriver = driversById[protest.accusedDriverId];
|
||||
|
||||
if (!protestingDriver || !accusedDriver) return null;
|
||||
|
||||
return {
|
||||
protest: new ProtestViewModel(protest),
|
||||
race: new RaceViewModel(race),
|
||||
@@ -81,13 +84,18 @@ export class ProtestService {
|
||||
* Review protest
|
||||
*/
|
||||
async reviewProtest(input: { protestId: string; stewardId: string; decision: string; decisionNotes: string }): Promise<void> {
|
||||
const normalizedDecision = input.decision.toLowerCase();
|
||||
const enumValue: ReviewProtestCommandDTO['enum'] =
|
||||
normalizedDecision === 'uphold' || normalizedDecision === 'upheld' ? 'uphold' : 'dismiss';
|
||||
|
||||
const command: ReviewProtestCommandDTO = {
|
||||
protestId: input.protestId,
|
||||
stewardId: input.stewardId,
|
||||
enum: input.decision === 'uphold' ? 'uphold' : 'dismiss',
|
||||
enum: enumValue,
|
||||
decision: input.decision,
|
||||
decisionNotes: input.decisionNotes
|
||||
decisionNotes: input.decisionNotes,
|
||||
};
|
||||
|
||||
await this.apiClient.reviewProtest(command);
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user