mirror of
https://gitlab.com/megazordpobeda/DataRush.git
synced 2026-05-23 03:57:09 +00:00
fix file submissions
This commit is contained in:
@@ -44,15 +44,18 @@ const TaskSolution: React.FC<TaskSolutionProps> = ({
|
||||
setIsHistoryOpen(true);
|
||||
};
|
||||
|
||||
const latestSolution = solutionHistory && solutionHistory.length > 0 ? solutionHistory[solutionHistory.length - 1] : null;
|
||||
const latestSolution = solutionHistory && solutionHistory.length > 0 ? solutionHistory[0] : null;
|
||||
|
||||
const handleSolutionSelect = async (solution: Solution) => {
|
||||
if (!solution.content) return;
|
||||
|
||||
setSelectedSolutionUrl(solution.content);
|
||||
|
||||
try {
|
||||
if (task.type !== TaskType.FILE) {
|
||||
if (task.type === TaskType.FILE) {
|
||||
// For file tasks, just store the URL
|
||||
setSelectedFile(null); // Clear any selected file first
|
||||
setSelectedSolutionUrl(solution.content);
|
||||
} else {
|
||||
// For INPUT and CODE tasks, fetch the content and set as answer
|
||||
const response = await fetch(solution.content);
|
||||
if (!response.ok) {
|
||||
throw new Error(`Failed to fetch solution content: ${response.status}`);
|
||||
@@ -65,6 +68,11 @@ const TaskSolution: React.FC<TaskSolutionProps> = ({
|
||||
}
|
||||
};
|
||||
|
||||
// Function to clear the existing file URL
|
||||
const handleClearExistingFile = () => {
|
||||
setSelectedSolutionUrl(null);
|
||||
};
|
||||
|
||||
return (
|
||||
<div className="md:w-[500px] flex flex-col gap-4">
|
||||
{latestSolution ? (
|
||||
@@ -85,6 +93,7 @@ const TaskSolution: React.FC<TaskSolutionProps> = ({
|
||||
setSelectedFile={setSelectedFile}
|
||||
fileInputRef={fileInputRef}
|
||||
existingFileUrl={selectedSolutionUrl}
|
||||
onClearExistingFile={handleClearExistingFile}
|
||||
/>
|
||||
)}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user