2024-02-26 15:56:07 +00:00
|
|
|
|
import { Box, Typography, useMediaQuery, useTheme } from "@mui/material";
|
|
|
|
|
import { updateQuestion } from "@root/questions/actions";
|
2023-03-31 15:48:49 +00:00
|
|
|
|
import CustomCheckbox from "@ui_kit/CustomCheckbox";
|
2024-06-19 20:22:37 +00:00
|
|
|
|
import type { QuizQuestionNumber } from "@frontend/squzanswerer";
|
2023-10-03 14:03:57 +00:00
|
|
|
|
|
2023-09-06 08:01:44 +00:00
|
|
|
|
type SettingSliderProps = {
|
2023-12-31 02:53:25 +00:00
|
|
|
|
question: QuizQuestionNumber;
|
2023-09-06 08:01:44 +00:00
|
|
|
|
};
|
2023-03-31 15:48:49 +00:00
|
|
|
|
|
2023-11-16 16:41:25 +00:00
|
|
|
|
export default function SettingSlider({ question }: SettingSliderProps) {
|
2023-12-31 02:53:25 +00:00
|
|
|
|
const theme = useTheme();
|
|
|
|
|
const isWrappColumn = useMediaQuery(theme.breakpoints.down(980));
|
|
|
|
|
const isFigmaTablte = useMediaQuery(theme.breakpoints.down(990));
|
|
|
|
|
const isMobile = useMediaQuery(theme.breakpoints.down(790));
|
2023-11-16 16:41:25 +00:00
|
|
|
|
|
2023-12-31 02:53:25 +00:00
|
|
|
|
return (
|
|
|
|
|
<Box
|
|
|
|
|
sx={{
|
|
|
|
|
display: "flex",
|
|
|
|
|
justifyContent: "space-between",
|
|
|
|
|
flexDirection: isWrappColumn ? "column" : null,
|
|
|
|
|
}}
|
|
|
|
|
>
|
|
|
|
|
<Box
|
|
|
|
|
sx={{
|
|
|
|
|
pt: isMobile ? "25px" : "20px",
|
|
|
|
|
pb: isMobile ? "30px" : "20px",
|
|
|
|
|
pl: "20px",
|
|
|
|
|
display: "flex",
|
|
|
|
|
flexDirection: "column",
|
|
|
|
|
gap: "14px",
|
|
|
|
|
width: isMobile ? "auto" : "100%",
|
|
|
|
|
}}
|
|
|
|
|
>
|
|
|
|
|
<Typography
|
|
|
|
|
sx={{
|
|
|
|
|
height: isMobile ? "18px" : "auto",
|
|
|
|
|
fontWeight: "500",
|
|
|
|
|
fontSize: "18px",
|
|
|
|
|
color: " #4D4D4D",
|
|
|
|
|
}}
|
2023-11-16 16:41:25 +00:00
|
|
|
|
>
|
2023-12-31 02:53:25 +00:00
|
|
|
|
Настройки ползунка
|
|
|
|
|
</Typography>
|
|
|
|
|
<CustomCheckbox
|
|
|
|
|
sx={{
|
|
|
|
|
mr: isMobile ? "0px" : "16px",
|
|
|
|
|
height: isMobile ? "100%" : "auto",
|
|
|
|
|
alignItems: isMobile ? "flex-start" : "center",
|
|
|
|
|
}}
|
|
|
|
|
label={"Выбор диапазона (два ползунка)"}
|
|
|
|
|
checked={question.content.chooseRange}
|
|
|
|
|
handleChange={({ target }) => {
|
|
|
|
|
updateQuestion(question.id, (question) => {
|
|
|
|
|
if (question.type !== "number") return;
|
2023-11-16 16:41:25 +00:00
|
|
|
|
|
2023-12-31 02:53:25 +00:00
|
|
|
|
question.content.chooseRange = target.checked;
|
|
|
|
|
});
|
|
|
|
|
}}
|
|
|
|
|
/>
|
|
|
|
|
</Box>
|
|
|
|
|
<Box
|
|
|
|
|
sx={{
|
|
|
|
|
pt: isMobile ? "0px" : "20px",
|
|
|
|
|
pb: "20px",
|
|
|
|
|
pl: isFigmaTablte ? (isWrappColumn ? "20px" : "0px") : "0px",
|
|
|
|
|
pr: isFigmaTablte ? (isMobile ? "20px" : "12px") : "20px",
|
|
|
|
|
display: "flex",
|
|
|
|
|
flexDirection: "column",
|
|
|
|
|
gap: "14px",
|
|
|
|
|
width: isMobile ? "auto" : "100%",
|
|
|
|
|
}}
|
|
|
|
|
>
|
|
|
|
|
<Typography
|
|
|
|
|
sx={{
|
|
|
|
|
height: isMobile ? "18px" : "auto",
|
|
|
|
|
fontWeight: "500",
|
|
|
|
|
fontSize: "18px",
|
|
|
|
|
color: " #4D4D4D",
|
|
|
|
|
}}
|
|
|
|
|
>
|
|
|
|
|
Настройки вопросов
|
|
|
|
|
</Typography>
|
|
|
|
|
<CustomCheckbox
|
2024-01-10 10:43:04 +00:00
|
|
|
|
dataCy="checkbox-optional-question"
|
2023-12-31 02:53:25 +00:00
|
|
|
|
sx={{
|
|
|
|
|
mr: isMobile ? "0px" : "16px",
|
|
|
|
|
alignItems: isMobile ? "flex-end" : "center",
|
|
|
|
|
}}
|
|
|
|
|
label={"Необязательный вопрос"}
|
|
|
|
|
checked={!question.content.required}
|
|
|
|
|
handleChange={(e) => {
|
|
|
|
|
updateQuestion<QuizQuestionNumber>(question.id, (question) => {
|
|
|
|
|
if (question.type !== "number") return;
|
2023-11-16 16:41:25 +00:00
|
|
|
|
|
2023-12-31 02:53:25 +00:00
|
|
|
|
question.content.required = !e.target.checked;
|
|
|
|
|
});
|
|
|
|
|
}}
|
|
|
|
|
/>
|
|
|
|
|
</Box>
|
|
|
|
|
</Box>
|
|
|
|
|
);
|
2023-09-06 08:01:44 +00:00
|
|
|
|
}
|