mirror of
https://gitlab.com/megazordpobeda/DataRush.git
synced 2026-05-23 05:07:10 +00:00
fix test
This commit is contained in:
@@ -9,8 +9,6 @@ import FileSolution from './components/FileSolution';
|
|||||||
import CodeSolution from './components/CodeSolution';
|
import CodeSolution from './components/CodeSolution';
|
||||||
import ActionButtons from './components/ActionButtons';
|
import ActionButtons from './components/ActionButtons';
|
||||||
import SolutionHistorySheet from './components/SolutionHistorySheet';
|
import SolutionHistorySheet from './components/SolutionHistorySheet';
|
||||||
import { AlertTriangle, ArrowRight } from 'lucide-react';
|
|
||||||
import { Button } from '@/components/ui/button';
|
|
||||||
|
|
||||||
interface TaskSolutionProps {
|
interface TaskSolutionProps {
|
||||||
task: Task;
|
task: Task;
|
||||||
@@ -19,7 +17,6 @@ interface TaskSolutionProps {
|
|||||||
selectedFile: File | null;
|
selectedFile: File | null;
|
||||||
setSelectedFile: (file: File | null) => void;
|
setSelectedFile: (file: File | null) => void;
|
||||||
onSubmit: () => void;
|
onSubmit: () => void;
|
||||||
isSubmitting?: boolean;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
const TaskSolution: React.FC<TaskSolutionProps> = ({
|
const TaskSolution: React.FC<TaskSolutionProps> = ({
|
||||||
@@ -29,7 +26,6 @@ const TaskSolution: React.FC<TaskSolutionProps> = ({
|
|||||||
selectedFile,
|
selectedFile,
|
||||||
setSelectedFile,
|
setSelectedFile,
|
||||||
onSubmit,
|
onSubmit,
|
||||||
isSubmitting = false
|
|
||||||
}) => {
|
}) => {
|
||||||
const fileInputRef = useRef<HTMLInputElement>(null);
|
const fileInputRef = useRef<HTMLInputElement>(null);
|
||||||
const [isHistoryOpen, setIsHistoryOpen] = useState(false);
|
const [isHistoryOpen, setIsHistoryOpen] = useState(false);
|
||||||
@@ -46,16 +42,6 @@ const TaskSolution: React.FC<TaskSolutionProps> = ({
|
|||||||
|
|
||||||
const solutionHistory = solutionsQuery.data || [];
|
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
|
// Set initial solution to the last one (most recent) when solutions are loaded
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
if (solutionHistory.length > 0 && !displayedSolution) {
|
if (solutionHistory.length > 0 && !displayedSolution) {
|
||||||
@@ -125,20 +111,13 @@ const TaskSolution: React.FC<TaskSolutionProps> = ({
|
|||||||
|
|
||||||
const handleSolutionSelect = (solution: Solution) => {
|
const handleSolutionSelect = (solution: Solution) => {
|
||||||
setDisplayedSolution(solution);
|
setDisplayedSolution(solution);
|
||||||
|
console.log(displayedSolution)
|
||||||
};
|
};
|
||||||
|
|
||||||
const handleClearExistingFile = () => {
|
const handleClearExistingFile = () => {
|
||||||
setSelectedSolutionUrl(null);
|
setSelectedSolutionUrl(null);
|
||||||
};
|
};
|
||||||
|
|
||||||
// Function to switch to the latest solution
|
|
||||||
const goToLatestSolution = () => {
|
|
||||||
const latestSolution = getLatestSolution();
|
|
||||||
if (latestSolution) {
|
|
||||||
setDisplayedSolution(latestSolution);
|
|
||||||
}
|
|
||||||
};
|
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<div className="md:w-[500px] flex flex-col gap-4">
|
<div className="md:w-[500px] flex flex-col gap-4">
|
||||||
{displayedSolution ? (
|
{displayedSolution ? (
|
||||||
@@ -149,25 +128,6 @@ const TaskSolution: React.FC<TaskSolutionProps> = ({
|
|||||||
</div>
|
</div>
|
||||||
)}
|
)}
|
||||||
|
|
||||||
{/* Outdated solution warning */}
|
|
||||||
{isOutdatedSolution() && (
|
|
||||||
<div className="bg-amber-50 border border-amber-200 rounded-lg p-3 flex justify-between items-center">
|
|
||||||
<div className="flex items-center text-amber-800">
|
|
||||||
<AlertTriangle size={18} className="mr-2 text-amber-500" />
|
|
||||||
<span className="font-hse-sans text-sm">Устаревшая посылка</span>
|
|
||||||
</div>
|
|
||||||
<Button
|
|
||||||
variant="ghost"
|
|
||||||
size="sm"
|
|
||||||
className="text-blue-600 hover:text-blue-700 hover:bg-blue-50 flex items-center"
|
|
||||||
onClick={goToLatestSolution}
|
|
||||||
>
|
|
||||||
<span className="mr-1">К последней</span>
|
|
||||||
<ArrowRight size={16} />
|
|
||||||
</Button>
|
|
||||||
</div>
|
|
||||||
)}
|
|
||||||
|
|
||||||
{task.type === TaskType.INPUT && (
|
{task.type === TaskType.INPUT && (
|
||||||
<InputSolution
|
<InputSolution
|
||||||
answer={answer}
|
answer={answer}
|
||||||
@@ -182,7 +142,6 @@ const TaskSolution: React.FC<TaskSolutionProps> = ({
|
|||||||
fileInputRef={fileInputRef}
|
fileInputRef={fileInputRef}
|
||||||
existingFileUrl={selectedSolutionUrl}
|
existingFileUrl={selectedSolutionUrl}
|
||||||
onClearExistingFile={handleClearExistingFile}
|
onClearExistingFile={handleClearExistingFile}
|
||||||
isLoading={isSubmitting}
|
|
||||||
/>
|
/>
|
||||||
)}
|
)}
|
||||||
|
|
||||||
@@ -204,7 +163,6 @@ const TaskSolution: React.FC<TaskSolutionProps> = ({
|
|||||||
solutions={solutionHistory}
|
solutions={solutionHistory}
|
||||||
maxPoints={task.points}
|
maxPoints={task.points}
|
||||||
onSolutionSelect={handleSolutionSelect}
|
onSolutionSelect={handleSolutionSelect}
|
||||||
currentSolutionId={displayedSolution?.id}
|
|
||||||
/>
|
/>
|
||||||
</div>
|
</div>
|
||||||
);
|
);
|
||||||
|
|||||||
Reference in New Issue
Block a user