import React from 'react'; import { Dialog, DialogContent, DialogHeader, DialogTitle, DialogDescription, } from "@/components/ui/dialog"; import { Loader2 } from 'lucide-react'; export interface CompetitionResult { task_name: string; result: number; max_points: number; position: number; } interface CompetitionResultsModalProps { competitionTitle: string; results: CompetitionResult[] | undefined; isLoading: boolean; error: unknown; isOpen: boolean; onOpenChange: (open: boolean) => void; } export const CompetitionResultsModal: React.FC = ({ competitionTitle, results, isLoading, error, isOpen, onOpenChange, }) => { const renderResultValue = (result: number, maxPoints: number) => { if (result === -1) { return ( На проверке ); } else if (result === -2) { return ( Нет ответа ); } else if (result === 0) { return ( Неверно (0/{maxPoints}) ); } else if (result < maxPoints) { return ( Частично верно ({result}/{maxPoints}) ); } else { return ( Верно ({result}/{maxPoints}) ); } }; return ( Результаты Ваши результаты по соревнованию "{competitionTitle}"
{isLoading ? (
) : error ? (
Произошла ошибка при загрузке результатов
) : results && results.length > 0 ? ( [...results] .sort((a, b) => a.position - b.position) .map((result, index) => (
{result.task_name}
{renderResultValue(result.result, result.max_points)}
)) ) : (
Нет доступных результатов
)}
); };