2024-02-28 08:18:21 +00:00
|
|
|
|
import { Box, Link, Typography, useMediaQuery, useTheme } from "@mui/material";
|
2024-02-29 11:23:52 +00:00
|
|
|
|
import { useCallback, useState } from "react";
|
2023-09-25 13:43:15 +00:00
|
|
|
|
import { EnterIcon } from "../../../assets/icons/questionsPage/enterIcon";
|
2023-12-19 23:08:33 +00:00
|
|
|
|
import { useAddAnswer } from "../../../utils/hooks/useAddAnswer";
|
2024-02-28 08:18:21 +00:00
|
|
|
|
import { AnswerDraggableList } from "../AnswerDraggableList";
|
2024-09-02 20:48:06 +00:00
|
|
|
|
import ButtonsOptions from "../QuestionOptions/ButtonsOptions/ButtonsOptions";
|
2024-02-28 08:18:21 +00:00
|
|
|
|
import SwitchDropDown from "./switchDropDown";
|
2023-11-16 16:41:25 +00:00
|
|
|
|
|
2024-06-19 20:22:37 +00:00
|
|
|
|
import type { QuizQuestionSelect } from "@frontend/squzanswerer";
|
2024-02-28 08:18:21 +00:00
|
|
|
|
import AnswerItem from "../AnswerDraggableList/AnswerItem";
|
|
|
|
|
|
2023-06-30 14:39:07 +00:00
|
|
|
|
interface Props {
|
2023-11-16 16:41:25 +00:00
|
|
|
|
question: QuizQuestionSelect;
|
2024-01-05 07:07:06 +00:00
|
|
|
|
openBranchingPage: boolean;
|
|
|
|
|
setOpenBranchingPage: (a: boolean) => void;
|
2023-06-30 14:39:07 +00:00
|
|
|
|
}
|
2023-03-31 15:48:49 +00:00
|
|
|
|
|
2024-06-19 20:22:37 +00:00
|
|
|
|
export default function DropDown({ question, openBranchingPage, setOpenBranchingPage }: Props) {
|
2023-12-19 23:08:33 +00:00
|
|
|
|
const onClickAddAnAnswer = useAddAnswer();
|
2023-08-25 10:27:43 +00:00
|
|
|
|
const [switchState, setSwitchState] = useState("setting");
|
2023-08-24 11:09:47 +00:00
|
|
|
|
const theme = useTheme();
|
2023-09-15 12:37:12 +00:00
|
|
|
|
const isMobile = useMediaQuery(theme.breakpoints.down(790));
|
2023-06-30 14:39:07 +00:00
|
|
|
|
|
2023-08-24 11:09:47 +00:00
|
|
|
|
return (
|
|
|
|
|
<>
|
2023-09-21 10:07:30 +00:00
|
|
|
|
<Box
|
|
|
|
|
sx={{
|
|
|
|
|
padding: isMobile ? "15px 20px 20px 20px" : "20px 20px 20px 20px ",
|
|
|
|
|
}}
|
|
|
|
|
>
|
2023-10-03 14:03:57 +00:00
|
|
|
|
{question.content.variants.length === 0 ? (
|
2023-08-25 10:27:43 +00:00
|
|
|
|
<Typography
|
|
|
|
|
sx={{
|
|
|
|
|
padding: "0 0 33px 80px",
|
|
|
|
|
fontWeight: 400,
|
|
|
|
|
fontSize: "18px",
|
|
|
|
|
lineHeight: "21.33px",
|
|
|
|
|
color: theme.palette.grey2.main,
|
|
|
|
|
}}
|
|
|
|
|
>
|
|
|
|
|
Добавьте ответ
|
|
|
|
|
</Typography>
|
|
|
|
|
) : (
|
2024-02-28 08:18:21 +00:00
|
|
|
|
<AnswerDraggableList
|
|
|
|
|
questionId={question.id}
|
|
|
|
|
variants={question.content.variants.map((variant, index) => (
|
|
|
|
|
<AnswerItem
|
|
|
|
|
key={variant.id}
|
|
|
|
|
index={index}
|
|
|
|
|
disableKeyDown={question.content.variants.length >= 100}
|
|
|
|
|
questionId={question.id}
|
|
|
|
|
variant={variant}
|
|
|
|
|
/>
|
|
|
|
|
))}
|
|
|
|
|
/>
|
2023-08-25 10:27:43 +00:00
|
|
|
|
)}
|
2023-09-26 21:11:27 +00:00
|
|
|
|
<Box
|
|
|
|
|
sx={{
|
|
|
|
|
display: "flex",
|
|
|
|
|
alignItems: "center",
|
2023-10-03 14:41:12 +00:00
|
|
|
|
marginBottom: "20px",
|
2023-09-26 21:11:27 +00:00
|
|
|
|
}}
|
|
|
|
|
>
|
2023-08-24 11:09:47 +00:00
|
|
|
|
<Link
|
|
|
|
|
component="button"
|
|
|
|
|
variant="body2"
|
2023-09-26 21:11:27 +00:00
|
|
|
|
sx={{
|
|
|
|
|
color: theme.palette.brightPurple.main,
|
|
|
|
|
fontWeight: "400",
|
|
|
|
|
fontSize: "16px",
|
|
|
|
|
mr: "4px",
|
|
|
|
|
height: "19px",
|
|
|
|
|
}}
|
2023-12-19 23:08:33 +00:00
|
|
|
|
onClick={() => onClickAddAnAnswer(question)}
|
2023-08-24 11:09:47 +00:00
|
|
|
|
>
|
|
|
|
|
Добавьте ответ
|
|
|
|
|
</Link>
|
2023-09-15 12:37:12 +00:00
|
|
|
|
{isMobile ? null : (
|
|
|
|
|
<>
|
|
|
|
|
<Typography
|
|
|
|
|
sx={{
|
|
|
|
|
fontWeight: 400,
|
|
|
|
|
lineHeight: "21.33px",
|
|
|
|
|
color: theme.palette.grey2.main,
|
2023-09-26 21:11:27 +00:00
|
|
|
|
fontSize: "16px",
|
2023-09-15 12:37:12 +00:00
|
|
|
|
}}
|
|
|
|
|
>
|
|
|
|
|
или нажмите Enter
|
|
|
|
|
</Typography>
|
2023-10-17 10:53:19 +00:00
|
|
|
|
<EnterIcon
|
|
|
|
|
style={{
|
|
|
|
|
color: "#7E2AEA",
|
|
|
|
|
fontSize: "24px",
|
|
|
|
|
marginLeft: "6px",
|
|
|
|
|
}}
|
|
|
|
|
/>
|
2023-09-15 12:37:12 +00:00
|
|
|
|
</>
|
|
|
|
|
)}
|
2023-08-24 11:09:47 +00:00
|
|
|
|
</Box>
|
|
|
|
|
</Box>
|
2023-12-31 02:53:25 +00:00
|
|
|
|
<ButtonsOptions
|
|
|
|
|
switchState={switchState}
|
2024-02-29 11:23:52 +00:00
|
|
|
|
SSHC={setSwitchState}
|
|
|
|
|
questionId={question.id}
|
|
|
|
|
questionContentId={question.content.id}
|
|
|
|
|
questionType={question.type}
|
2024-06-19 20:22:37 +00:00
|
|
|
|
questionHasParent={question.content.rule.parentId?.length !== 0}
|
2024-01-05 07:07:06 +00:00
|
|
|
|
setOpenBranchingPage={setOpenBranchingPage}
|
2023-12-31 02:53:25 +00:00
|
|
|
|
/>
|
2024-06-19 20:22:37 +00:00
|
|
|
|
<SwitchDropDown
|
|
|
|
|
switchState={switchState}
|
|
|
|
|
question={question}
|
|
|
|
|
/>
|
2023-08-24 11:09:47 +00:00
|
|
|
|
</>
|
|
|
|
|
);
|
|
|
|
|
}
|