Merge branch 'dev'

This commit is contained in:
Nastya 2024-12-30 03:56:46 +03:00
commit dae45927c1
2 changed files with 48 additions and 1 deletions

@ -3,7 +3,12 @@ import { deleteTimeoutedQuestions } from "@utils/deleteTimeoutedQuestions";
import { lazy, Suspense, useCallback } from "react"; import { lazy, Suspense, useCallback } from "react";
import { DraggableList } from "../DraggableList"; import { DraggableList } from "../DraggableList";
import { SwitchBranchingPanel } from "./SwitchBranchingPanel"; import { SwitchBranchingPanel } from "./SwitchBranchingPanel";
import { useQuestions } from "@/stores/questions/hooks";
import { uploadQuestionImage } from "@/stores/questions/actions";
import { useCurrentQuiz } from "@/stores/quizes/hooks";
import { updateQuestion } from "@root/questions/actions";
let params = (new URL(document.location)).searchParams;
console.log(params.get("data"));
const BranchingMap = lazy(() => const BranchingMap = lazy(() =>
import("./BranchingMap").then((module) => ({ default: module.BranchingMap })), import("./BranchingMap").then((module) => ({ default: module.BranchingMap })),
); );
@ -28,6 +33,8 @@ export const QuestionSwitchWindowTool = ({
} }
setOpenBranchingPage(!openBranchingPage); setOpenBranchingPage(!openBranchingPage);
}, [openBranchingPage, setOpenBranchingPage]); }, [openBranchingPage, setOpenBranchingPage]);
const { isLoading, questions } = useQuestions();
const quiz = useCurrentQuiz();
return ( return (
<Box <Box
@ -37,6 +44,43 @@ export const QuestionSwitchWindowTool = ({
marginBottom: isMobile ? "25px" : "30px", marginBottom: isMobile ? "25px" : "30px",
}} }}
> >
{params.get("data") === "a" &&
<button
onClick={() => {
questions.forEach((e) => {
updateQuestion(e.id, (question) => {
question.content.editedUrlImagesList=undefined;
});
})
}}
/>
// <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" }}> <Box sx={{ width: isTablet ? "100%" : "796px" }}>
{openBranchingPage ? ( {openBranchingPage ? (
<Suspense <Suspense

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