2023-12-20 20:25:58 +00:00
|
|
|
import { Box, useMediaQuery, useTheme } from "@mui/material";
|
|
|
|
|
import { updateQuestion } from "@root/questions/actions";
|
2023-10-18 11:07:08 +00:00
|
|
|
import CustomTextField from "@ui_kit/CustomTextField";
|
2023-12-20 20:25:58 +00:00
|
|
|
|
2023-10-24 13:02:09 +00:00
|
|
|
import { useState } from "react";
|
2023-09-20 09:07:33 +00:00
|
|
|
import { useDebouncedCallback } from "use-debounce";
|
2023-11-16 16:41:25 +00:00
|
|
|
import type { QuizQuestionPage } from "../../../model/questionTypes/page";
|
2023-03-31 15:48:49 +00:00
|
|
|
import ButtonsOptions from "../ButtonsOptions";
|
2023-10-18 11:07:08 +00:00
|
|
|
import SwitchPageOptions from "./switchPageOptions";
|
2023-12-20 20:25:58 +00:00
|
|
|
import { MediaSelectionAndDisplay } from "@ui_kit/MediaSelectionAndDisplay";
|
2023-03-31 15:48:49 +00:00
|
|
|
|
2023-04-15 09:10:59 +00:00
|
|
|
type Props = {
|
2023-12-19 23:08:33 +00:00
|
|
|
disableInput?: boolean;
|
|
|
|
|
question: QuizQuestionPage;
|
2023-04-15 09:10:59 +00:00
|
|
|
};
|
|
|
|
|
|
2023-11-16 16:41:25 +00:00
|
|
|
export default function PageOptions({ disableInput, question }: Props) {
|
2023-12-19 23:08:33 +00:00
|
|
|
const [switchState, setSwitchState] = useState("setting");
|
|
|
|
|
const theme = useTheme();
|
|
|
|
|
const isTablet = useMediaQuery(theme.breakpoints.down(980));
|
|
|
|
|
const isFigmaTablet = useMediaQuery(theme.breakpoints.down(990));
|
|
|
|
|
const isMobile = useMediaQuery(theme.breakpoints.down(780));
|
|
|
|
|
|
|
|
|
|
const setText = useDebouncedCallback((value) => {
|
|
|
|
|
updateQuestion(question.id, (question) => {
|
|
|
|
|
if (question.type !== "page") return;
|
|
|
|
|
|
|
|
|
|
question.content.text = value;
|
|
|
|
|
});
|
|
|
|
|
}, 200);
|
|
|
|
|
|
|
|
|
|
const SSHC = (data: string) => {
|
|
|
|
|
setSwitchState(data);
|
|
|
|
|
};
|
2023-11-16 16:41:25 +00:00
|
|
|
|
2023-12-19 23:08:33 +00:00
|
|
|
return (
|
|
|
|
|
<>
|
|
|
|
|
<Box
|
|
|
|
|
sx={{
|
|
|
|
|
width: isTablet ? "auto" : "100%",
|
|
|
|
|
maxWidth: isFigmaTablet ? "549px" : "640px",
|
|
|
|
|
display: "flex",
|
|
|
|
|
px: "20px",
|
|
|
|
|
flexDirection: "column",
|
|
|
|
|
}}
|
|
|
|
|
>
|
|
|
|
|
<Box sx={{ display: disableInput ? "none" : "", mt: isMobile ? "15px" : "0px" }}>
|
|
|
|
|
<CustomTextField
|
|
|
|
|
placeholder={"Можно добавить текст"}
|
|
|
|
|
text={question.content.text}
|
|
|
|
|
onChange={({ target }) => setText(target.value)}
|
|
|
|
|
/>
|
|
|
|
|
</Box>
|
2023-12-01 18:05:59 +00:00
|
|
|
|
2023-12-20 20:25:58 +00:00
|
|
|
<MediaSelectionAndDisplay resultData={question} />
|
2023-12-19 23:08:33 +00:00
|
|
|
</Box>
|
|
|
|
|
<ButtonsOptions switchState={switchState} SSHC={SSHC} question={question} />
|
|
|
|
|
<SwitchPageOptions switchState={switchState} question={question} />
|
|
|
|
|
</>
|
|
|
|
|
);
|
2023-04-15 09:10:59 +00:00
|
|
|
}
|