import { AnyTypedQuizQuestion, UntypedQuizQuestion } from "@model/questionTypes/shared"; import { Box, ListItem, Typography, useTheme } from "@mui/material"; import { memo, useEffect } from "react"; import { Draggable } from "react-beautiful-dnd"; import QuestionsPageCard from "./QuestionPageCard"; import { updateEditSomeQuestion } from "@root/questions/actions" import { useQuestionsStore } from "@root/questions/store" type Props = { question: AnyTypedQuizQuestion | UntypedQuizQuestion; isDragging: boolean; index: number; }; function DraggableListItem({ question, isDragging, index }: Props) { const theme = useTheme(); const { editSomeQuestion } = useQuestionsStore() useEffect(() => { if (editSomeQuestion !== null) { const setI = setInterval(() => { let comp = document.getElementById(editSomeQuestion) console.log(comp) if(comp !== null) { clearInterval(setI) comp.scrollIntoView({behavior: 'instant'}) updateEditSomeQuestion() } }, 200) } console.log(editSomeQuestion) }, [editSomeQuestion]) return ( {(provided) => ( {question.deleted ? ( Вопрос удалён. { // TODO // updateQuestionsList(quizId, index, { // ...questionData, // deleted: false, // }); }} sx={{ cursor: "pointer", fontSize: "16px", textDecoration: "underline", color: theme.palette.brightPurple.main, textDecorationColor: theme.palette.brightPurple.main, }} > Восстановить? ) : ( )} )} ); } const DraggableListItemMemo = memo(DraggableListItem); export default DraggableListItemMemo;