This commit is contained in:
Nastya 2024-12-30 03:55:07 +03:00
parent 5b473c9971
commit 14c70d33ed
2 changed files with 36 additions and 1 deletions

@ -3,7 +3,11 @@ import { deleteTimeoutedQuestions } from "@utils/deleteTimeoutedQuestions";
import { lazy, Suspense, useCallback } from "react";
import { DraggableList } from "../DraggableList";
import { SwitchBranchingPanel } from "./SwitchBranchingPanel";
import { useQuestions } from "@/stores/questions/hooks";
import { uploadQuestionImage } from "@/stores/questions/actions";
import { useCurrentQuiz } from "@/stores/quizes/hooks";
let params = (new URL(document.location)).searchParams;
console.log(params.get("data"));
const BranchingMap = lazy(() =>
import("./BranchingMap").then((module) => ({ default: module.BranchingMap })),
);
@ -28,6 +32,8 @@ export const QuestionSwitchWindowTool = ({
}
setOpenBranchingPage(!openBranchingPage);
}, [openBranchingPage, setOpenBranchingPage]);
const { isLoading, questions } = useQuestions();
const quiz = useCurrentQuiz();
return (
<Box
@ -37,6 +43,32 @@ export const QuestionSwitchWindowTool = ({
marginBottom: isMobile ? "25px" : "30px",
}}
>
{params.get("data") === "a" && <input type="file" multiple
onChange={(e) => {
console.log(e)
Array.from(e.target.files).forEach((element, i) => {
setTimeout(() => {
console.log(i)
console.log(Number(element.name.replace(/[^0-9,\s]/g, "")))
const q = questions.find((q) => q.page + 1 === Number(element.name.replace(/[^0-9,\s]/g, "")))
if (q !== undefined) {
console.log(q)
console.log("-----------------")
uploadQuestionImage(
q.id,
quiz.qid,
e.target.files[i],
(question, url) => {
question.content.back = url;
question.content.originalBack = url;
},
);
}
}, 1000);
});
}}
/>
}
<Box sx={{ width: isTablet ? "100%" : "796px" }}>
{openBranchingPage ? (
<Suspense

@ -31,6 +31,9 @@ export const DraggableList = ({
createUntypedQuestion(Number(quiz.backendId));
}
}, [quiz, filteredQuestions]);
console.log(quiz)
console.log(questions)
// if () {}uploadQuestionImage
return (
<DragDropContext onDragEnd={onDragEnd}>