results rework

This commit is contained in:
rngsurrounded
2025-03-04 02:39:14 +09:00
parent 67cc475f59
commit 2e0ea88db5
2 changed files with 52 additions and 8 deletions
@@ -1,3 +1,4 @@
// src/components/competition/CompetitionResultsModal.tsx
import React from 'react';
import {
Dialog,
@@ -33,13 +34,58 @@ export const CompetitionResultsModal: React.FC<CompetitionResultsModalProps> = (
}) => {
const renderResultValue = (result: number, maxPoints: number) => {
if (result === -1) {
return <span className="text-yellow-600">На проверке</span>;
return (
<span className="font-semibold" style={{
color: 'var(--color-task-text-checking)',
backgroundColor: 'var(--color-task-checking)',
padding: '4px 8px',
borderRadius: '4px'
}}>
На проверке
</span>
);
} else if (result === -2) {
return <span className="text-gray-500">Нет ответа</span>;
return (
<span className="font-semibold" style={{
color: 'var(--color-task-text-uncleared)',
backgroundColor: 'var(--color-task-uncleared)',
padding: '4px 8px',
borderRadius: '4px'
}}>
Нет ответа
</span>
);
} else if (result === 0) {
return (
<span className="font-semibold" style={{
color: 'var(--color-task-text-wrong)',
backgroundColor: 'var(--color-task-wrong)',
padding: '4px 8px',
borderRadius: '4px'
}}>
Неверно (0/{maxPoints})
</span>
);
} else if (result < maxPoints) {
return (
<span className="font-semibold" style={{
color: 'var(--color-task-text-partial)',
backgroundColor: 'var(--color-task-partial)',
padding: '4px 8px',
borderRadius: '4px'
}}>
Частично верно ({result}/{maxPoints})
</span>
);
} else {
return (
<span className="text-green-600">
Зачтено {result}/{maxPoints} баллов
<span className="font-semibold" style={{
color: 'var(--color-task-text-correct)',
backgroundColor: 'var(--color-task-correct)',
padding: '4px 8px',
borderRadius: '4px'
}}>
Верно ({result}/{maxPoints})
</span>
);
}
@@ -71,7 +117,7 @@ export const CompetitionResultsModal: React.FC<CompetitionResultsModalProps> = (
className="flex flex-col md:flex-row justify-between items-start md:items-center p-4 bg-gray-50 rounded-lg border"
>
<div className="font-medium mb-2 md:mb-0">{result.task_name}</div>
<div className="text-right font-semibold">
<div className="text-right">
{renderResultValue(result.result, result.max_points)}
</div>
</div>
@@ -93,7 +93,6 @@ const CompetitionPage = () => {
return now < startDate;
};
// Check if competition has ended
const isCompetitionEnded = () => {
if (!competition?.end_date) return false;
@@ -212,7 +211,6 @@ const CompetitionPage = () => {
<Button
size={"lg"}
onClick={() => setIsResultsModalOpen(true)}
className="bg-indigo-600 hover:bg-indigo-700"
>
<BarChart2 size={18} className="mr-2" />
Посмотреть результаты
@@ -221,7 +219,7 @@ const CompetitionPage = () => {
{competitionEnded && !hasResults && competition.type === CompetitionType.COMPETITIVE && !resultsQuery.isLoading && (
<div className="text-center p-4 border rounded-md bg-gray-50">
<p className="text-gray-600">Соревнование завершено. Результаты пока не доступны.</p>
<p className="text-gray-600">Соревнование завершено. Увы</p>
</div>
)}
</div>