diff --git a/services/frontend/src/pages/CompetitionSession/modules/TaskSolution/index.tsx b/services/frontend/src/pages/CompetitionSession/modules/TaskSolution/index.tsx index 2d0df9e..87cd253 100644 --- a/services/frontend/src/pages/CompetitionSession/modules/TaskSolution/index.tsx +++ b/services/frontend/src/pages/CompetitionSession/modules/TaskSolution/index.tsx @@ -9,6 +9,8 @@ import FileSolution from './components/FileSolution'; import CodeSolution from './components/CodeSolution'; import ActionButtons from './components/ActionButtons'; import SolutionHistorySheet from './components/SolutionHistorySheet'; +import { AlertTriangle, ArrowRight } from 'lucide-react'; +import { Button } from '@/components/ui/button'; interface TaskSolutionProps { task: Task; @@ -17,6 +19,7 @@ interface TaskSolutionProps { selectedFile: File | null; setSelectedFile: (file: File | null) => void; onSubmit: () => void; + isSubmitting?: boolean; } const TaskSolution: React.FC = ({ @@ -26,6 +29,7 @@ const TaskSolution: React.FC = ({ selectedFile, setSelectedFile, onSubmit, + isSubmitting = false }) => { const fileInputRef = useRef(null); const [isHistoryOpen, setIsHistoryOpen] = useState(false); @@ -41,6 +45,16 @@ const TaskSolution: React.FC = ({ }); const solutionHistory = solutionsQuery.data || []; + + const getLatestSolution = () => { + return solutionHistory.length > 0 ? solutionHistory[solutionHistory.length - 1] : null; + }; + + const isOutdatedSolution = () => { + if (!displayedSolution || solutionHistory.length === 0) return false; + const latestSolution = getLatestSolution(); + return latestSolution?.id !== displayedSolution.id; + }; // Set initial solution to the last one (most recent) when solutions are loaded useEffect(() => { @@ -111,12 +125,19 @@ const TaskSolution: React.FC = ({ const handleSolutionSelect = (solution: Solution) => { setDisplayedSolution(solution); - console.log(displayedSolution) }; const handleClearExistingFile = () => { setSelectedSolutionUrl(null); }; + + // Function to switch to the latest solution + const goToLatestSolution = () => { + const latestSolution = getLatestSolution(); + if (latestSolution) { + setDisplayedSolution(latestSolution); + } + }; return (
@@ -128,6 +149,25 @@ const TaskSolution: React.FC = ({
)} + {/* Outdated solution warning */} + {isOutdatedSolution() && ( +
+
+ + Устаревшая посылка +
+ +
+ )} + {task.type === TaskType.INPUT && ( = ({ fileInputRef={fileInputRef} existingFileUrl={selectedSolutionUrl} onClearExistingFile={handleClearExistingFile} + isLoading={isSubmitting} /> )} @@ -163,6 +204,7 @@ const TaskSolution: React.FC = ({ solutions={solutionHistory} maxPoints={task.points} onSolutionSelect={handleSolutionSelect} + currentSolutionId={displayedSolution?.id} /> );