mirror of
https://gitlab.com/megazordpobeda/DataRush.git
synced 2026-05-23 21:27:10 +00:00
fix check
This commit is contained in:
+11
-6
@@ -2,13 +2,14 @@ import React from 'react';
|
|||||||
import { Link } from 'react-router-dom';
|
import { Link } from 'react-router-dom';
|
||||||
import { Task } from '@/shared/types/task';
|
import { Task } from '@/shared/types/task';
|
||||||
import { ArrowLeft } from 'lucide-react';
|
import { ArrowLeft } from 'lucide-react';
|
||||||
|
import { useNavigate } from 'react-router-dom';
|
||||||
|
|
||||||
interface CompetitionHeaderProps {
|
interface CompetitionHeaderProps {
|
||||||
title: string;
|
title: string;
|
||||||
tasks: Task[];
|
tasks: Task[];
|
||||||
competitionId: string;
|
competitionId: string;
|
||||||
setAnswer: (value: string) => void;
|
setAnswer: (value: string) => void;
|
||||||
setSelectedFile: (file: File | null) => void; // заглушка
|
setSelectedFile: (file: File | null) => void;
|
||||||
}
|
}
|
||||||
|
|
||||||
const CompetitionHeader: React.FC<CompetitionHeaderProps> = ({
|
const CompetitionHeader: React.FC<CompetitionHeaderProps> = ({
|
||||||
@@ -18,11 +19,15 @@ const CompetitionHeader: React.FC<CompetitionHeaderProps> = ({
|
|||||||
setAnswer,
|
setAnswer,
|
||||||
setSelectedFile
|
setSelectedFile
|
||||||
}) => {
|
}) => {
|
||||||
|
const navigate = useNavigate();
|
||||||
|
|
||||||
const handleTaskSelect = () => {
|
const handleTaskSelect = (event: React.MouseEvent, taskId: string) => {
|
||||||
setAnswer("")
|
event.preventDefault();
|
||||||
setSelectedFile(null)
|
setAnswer("");
|
||||||
console.log("STOP IT")
|
setSelectedFile(null);
|
||||||
|
console.log("link check");
|
||||||
|
|
||||||
|
navigate(`/competition/${competitionId}/tasks/${taskId}`);
|
||||||
}
|
}
|
||||||
|
|
||||||
return (
|
return (
|
||||||
@@ -32,7 +37,6 @@ const CompetitionHeader: React.FC<CompetitionHeaderProps> = ({
|
|||||||
<Link
|
<Link
|
||||||
to={`/competition/${competitionId}`}
|
to={`/competition/${competitionId}`}
|
||||||
className="flex items-center text-gray-600 hover:text-gray-900 transition-colors font-hse-sans text-sm"
|
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" />
|
<ArrowLeft className="h-4 w-4 mr-1" />
|
||||||
</Link>
|
</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
|
rounded-lg px-3 py-1.5 font-medium text-sm font-hse-sans cursor-pointer
|
||||||
transition-all hover:brightness-95 flex-shrink-0
|
transition-all hover:brightness-95 flex-shrink-0
|
||||||
`}
|
`}
|
||||||
|
onClick={(e) => handleTaskSelect(e, task.id)}
|
||||||
>
|
>
|
||||||
{task.in_competition_position}
|
{task.in_competition_position}
|
||||||
</Link>
|
</Link>
|
||||||
|
|||||||
@@ -54,7 +54,6 @@ const TaskSolution: React.FC<TaskSolutionProps> = ({
|
|||||||
setDisplayedSolution(null);
|
setDisplayedSolution(null);
|
||||||
setSelectedSolutionUrl(null);
|
setSelectedSolutionUrl(null);
|
||||||
|
|
||||||
// If solutions are already loaded for the new task, set the latest one
|
|
||||||
if (solutionHistory.length > 0) {
|
if (solutionHistory.length > 0) {
|
||||||
const latestSolution = solutionHistory[solutionHistory.length - 1];
|
const latestSolution = solutionHistory[solutionHistory.length - 1];
|
||||||
setDisplayedSolution(latestSolution);
|
setDisplayedSolution(latestSolution);
|
||||||
@@ -64,13 +63,10 @@ const TaskSolution: React.FC<TaskSolutionProps> = ({
|
|||||||
}
|
}
|
||||||
}, [task.id, solutionHistory]);
|
}, [task.id, solutionHistory]);
|
||||||
|
|
||||||
// Check if a new solution was submitted (latest solution ID changed)
|
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
if (solutionHistory.length > 0 && displayedSolution) {
|
if (solutionHistory.length > 0 && displayedSolution) {
|
||||||
const latestSolution = solutionHistory[solutionHistory.length - 1];
|
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) {
|
if (latestSolution.id !== displayedSolution.id) {
|
||||||
setDisplayedSolution(latestSolution);
|
setDisplayedSolution(latestSolution);
|
||||||
}
|
}
|
||||||
@@ -108,7 +104,6 @@ const TaskSolution: React.FC<TaskSolutionProps> = ({
|
|||||||
|
|
||||||
const handleSolutionSelect = (solution: Solution) => {
|
const handleSolutionSelect = (solution: Solution) => {
|
||||||
setDisplayedSolution(solution);
|
setDisplayedSolution(solution);
|
||||||
console.log(displayedSolution)
|
|
||||||
};
|
};
|
||||||
|
|
||||||
const handleClearExistingFile = () => {
|
const handleClearExistingFile = () => {
|
||||||
|
|||||||
Reference in New Issue
Block a user