fix check

This commit is contained in:
rngsurrounded
2025-03-03 20:29:34 +09:00
parent 404ca1cc59
commit 46a1f43c49
2 changed files with 158 additions and 158 deletions
@@ -2,13 +2,14 @@ import React from 'react';
import { Link } from 'react-router-dom';
import { Task } from '@/shared/types/task';
import { ArrowLeft } from 'lucide-react';
import { useNavigate } from 'react-router-dom';
interface CompetitionHeaderProps {
title: string;
tasks: Task[];
competitionId: string;
setAnswer: (value: string) => void;
setSelectedFile: (file: File | null) => void; // заглушка
setSelectedFile: (file: File | null) => void;
}
const CompetitionHeader: React.FC<CompetitionHeaderProps> = ({
@@ -18,11 +19,15 @@ const CompetitionHeader: React.FC<CompetitionHeaderProps> = ({
setAnswer,
setSelectedFile
}) => {
const navigate = useNavigate();
const handleTaskSelect = () => {
setAnswer("")
setSelectedFile(null)
console.log("STOP IT")
const handleTaskSelect = (event: React.MouseEvent, taskId: string) => {
event.preventDefault();
setAnswer("");
setSelectedFile(null);
console.log("link check");
navigate(`/competition/${competitionId}/tasks/${taskId}`);
}
return (
@@ -32,7 +37,6 @@ const CompetitionHeader: React.FC<CompetitionHeaderProps> = ({
<Link
to={`/competition/${competitionId}`}
className="flex items-center text-gray-600 hover:text-gray-900 transition-colors font-hse-sans text-sm"
onClick={handleTaskSelect}
>
<ArrowLeft className="h-4 w-4 mr-1" />
</Link>
@@ -53,6 +57,7 @@ const CompetitionHeader: React.FC<CompetitionHeaderProps> = ({
rounded-lg px-3 py-1.5 font-medium text-sm font-hse-sans cursor-pointer
transition-all hover:brightness-95 flex-shrink-0
`}
onClick={(e) => handleTaskSelect(e, task.id)}
>
{task.in_competition_position}
</Link>
@@ -54,7 +54,6 @@ const TaskSolution: React.FC<TaskSolutionProps> = ({
setDisplayedSolution(null);
setSelectedSolutionUrl(null);
// If solutions are already loaded for the new task, set the latest one
if (solutionHistory.length > 0) {
const latestSolution = solutionHistory[solutionHistory.length - 1];
setDisplayedSolution(latestSolution);
@@ -64,13 +63,10 @@ const TaskSolution: React.FC<TaskSolutionProps> = ({
}
}, [task.id, solutionHistory]);
// Check if a new solution was submitted (latest solution ID changed)
useEffect(() => {
if (solutionHistory.length > 0 && displayedSolution) {
const latestSolution = solutionHistory[solutionHistory.length - 1];
// If the latest solution ID is different from the displayed one,
// a new solution was submitted - update to show the latest
if (latestSolution.id !== displayedSolution.id) {
setDisplayedSolution(latestSolution);
}
@@ -108,7 +104,6 @@ const TaskSolution: React.FC<TaskSolutionProps> = ({
const handleSolutionSelect = (solution: Solution) => {
setDisplayedSolution(solution);
console.log(displayedSolution)
};
const handleClearExistingFile = () => {