feat: drag and drop for files, code redactor in task + competition session decomposed

This commit is contained in:
rngsurrounded
2025-03-01 22:52:51 +09:00
parent c79b3df909
commit 758d0de9ed
17 changed files with 784 additions and 132 deletions
@@ -0,0 +1,52 @@
import React, { useState, useRef } from 'react';
import { Task } from "@/shared/types";
import SolutionStatus from './components/SolutionStatus';
import InputSolution from './components/InputSolution';
import FileSolution from './components/FileSolution';
import CodeSolution from './components/CodeSolution';
import ActionButtons from './components/ActionButtons';
interface TaskSolutionProps {
task: Task;
answer: string;
setAnswer: (value: string) => void;
onSubmit: () => void;
onHistoryClick: () => void;
}
const TaskSolution: React.FC<TaskSolutionProps> = ({
task,
answer,
setAnswer,
onSubmit,
onHistoryClick,
}) => {
const [selectedFile, setSelectedFile] = useState<File | null>(null);
const fileInputRef = useRef<HTMLInputElement>(null);
return (
<div className="md:w-[500px] flex flex-col gap-4">
<SolutionStatus task={task} />
{task.solutionType === 'input' && (
<InputSolution answer={answer} setAnswer={setAnswer} />
)}
{task.solutionType === 'file' && (
<FileSolution
selectedFile={selectedFile}
setSelectedFile={setSelectedFile}
fileInputRef={fileInputRef}
/>
)}
{task.solutionType === 'code' && (
<CodeSolution answer={answer} setAnswer={setAnswer} />
)}
<ActionButtons onHistoryClick={onHistoryClick} onSubmit={onSubmit} />
</div>
);
};
export default TaskSolution;