mirror of
https://gitlab.com/megazordpobeda/DataRush.git
synced 2026-05-23 23:47:10 +00:00
fixed different input types
This commit is contained in:
@@ -43,7 +43,7 @@ const TaskSolution: React.FC<TaskSolutionProps> = ({
|
|||||||
setIsHistoryOpen(true);
|
setIsHistoryOpen(true);
|
||||||
};
|
};
|
||||||
|
|
||||||
const latestSolution = solutionHistory && solutionHistory.length > 0 ? solutionHistory[0] : null;
|
const latestSolution = solutionHistory && solutionHistory.length > 0 ? solutionHistory[solutionHistory.length - 1] : null;
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<div className="md:w-[500px] flex flex-col gap-4">
|
<div className="md:w-[500px] flex flex-col gap-4">
|
||||||
|
|||||||
@@ -20,18 +20,18 @@ export const submitTaskSolution = async (
|
|||||||
solution: string | File
|
solution: string | File
|
||||||
) => {
|
) => {
|
||||||
const endpoint = `/competitions/${competitionId}/tasks/${taskId}/submit`;
|
const endpoint = `/competitions/${competitionId}/tasks/${taskId}/submit`;
|
||||||
if (typeof solution === 'string') {
|
|
||||||
return await userFetch(endpoint, {
|
|
||||||
method: 'POST',
|
|
||||||
body: { content: solution }
|
|
||||||
});
|
|
||||||
} else {
|
|
||||||
const formData = new FormData();
|
const formData = new FormData();
|
||||||
|
|
||||||
|
// туповатый костыль но для мвп сойдет
|
||||||
|
if (typeof solution === 'string') {
|
||||||
|
const textFile = new File([solution], 'solution.txt', { type: 'text/plain' });
|
||||||
|
formData.append('content', textFile);
|
||||||
|
} else {
|
||||||
formData.append('content', solution);
|
formData.append('content', solution);
|
||||||
|
}
|
||||||
|
|
||||||
return await userFetch(endpoint, {
|
return await userFetch(endpoint, {
|
||||||
method: 'POST',
|
method: 'POST',
|
||||||
body: formData
|
body: formData
|
||||||
});
|
});
|
||||||
}
|
|
||||||
};
|
};
|
||||||
Reference in New Issue
Block a user