Fixed a bug from the previous commit, ENCOA-274

This commit is contained in:
Carlos-Mesquita
2024-12-11 16:09:59 +00:00
parent cf85b5a822
commit fa0c257040
2 changed files with 5 additions and 7 deletions

View File

@@ -93,14 +93,12 @@ const WritingSettings: React.FC = () => {
return;
}
try {
let firebase_url = undefined;
let firebase_url: string | undefined = undefined;
if (type === "academic" && academic_url) {
const formData = new FormData();
const sectionMap = new Map<number, string>();
const fetchedBlob = await fetch(academic_url);
const blob = await fetchedBlob.blob();
formData.append('file', blob);
sectionMap.set(1, academic_url);
const response = await axios.post('/api/storage', formData, {
params: {
@@ -110,13 +108,13 @@ const WritingSettings: React.FC = () => {
'Content-Type': 'multipart/form-data'
}
});
firebase_url = response.data.urls[1];
firebase_url = response.data.urls[0];
}
const exam: WritingExam = {
exercises: sections.map((s) => {
exercises: sections.map((s, index) => {
const exercise = s.state as WritingExercise;
if (exercise.sectionId == 1 && firebase_url) {
if (index == 0 && firebase_url) {
exercise["attachment"] = {
url: firebase_url,
description: "Visual Information"