website cleanup
This commit is contained in:
@@ -3,7 +3,9 @@
|
||||
import { useState } from 'react';
|
||||
import Modal from '@/components/ui/Modal';
|
||||
import Button from '@/components/ui/Button';
|
||||
import type { ProtestIncident } from '@core/racing/domain/entities/Protest';
|
||||
import type { FileProtestCommandDTO } from '@/lib/types/generated/FileProtestCommandDTO';
|
||||
import type { ProtestIncidentDTO } from '@/lib/types/generated/ProtestIncidentDTO';
|
||||
import { useServices } from '@/lib/services/ServiceProvider';
|
||||
import {
|
||||
AlertTriangle,
|
||||
Video,
|
||||
@@ -37,6 +39,7 @@ export default function FileProtestModal({
|
||||
protestingDriverId,
|
||||
participants,
|
||||
}: FileProtestModalProps) {
|
||||
const { raceService } = useServices();
|
||||
const [step, setStep] = useState<'form' | 'submitting' | 'success' | 'error'>('form');
|
||||
const [errorMessage, setErrorMessage] = useState<string | null>(null);
|
||||
|
||||
@@ -69,14 +72,10 @@ export default function FileProtestModal({
|
||||
setErrorMessage(null);
|
||||
|
||||
try {
|
||||
const useCase = getFileProtestUseCase();
|
||||
|
||||
const incident: ProtestIncident = {
|
||||
const incident: ProtestIncidentDTO = {
|
||||
lap: parseInt(lap, 10),
|
||||
description: description.trim(),
|
||||
...(timeInRace
|
||||
? { timeInRace: parseInt(timeInRace, 10) }
|
||||
: {}),
|
||||
...(timeInRace ? { timeInRace: parseInt(timeInRace, 10) } : {}),
|
||||
};
|
||||
|
||||
const command = {
|
||||
@@ -84,15 +83,11 @@ export default function FileProtestModal({
|
||||
protestingDriverId,
|
||||
accusedDriverId,
|
||||
incident,
|
||||
...(comment.trim()
|
||||
? { comment: comment.trim() }
|
||||
: {}),
|
||||
...(proofVideoUrl.trim()
|
||||
? { proofVideoUrl: proofVideoUrl.trim() }
|
||||
: {}),
|
||||
};
|
||||
...(comment.trim() ? { comment: comment.trim() } : {}),
|
||||
...(proofVideoUrl.trim() ? { proofVideoUrl: proofVideoUrl.trim() } : {}),
|
||||
} satisfies FileProtestCommandDTO;
|
||||
|
||||
await useCase.execute(command);
|
||||
await raceService.fileProtest(command);
|
||||
|
||||
setStep('success');
|
||||
} catch (err) {
|
||||
@@ -290,4 +285,4 @@ export default function FileProtestModal({
|
||||
</div>
|
||||
</Modal>
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user