frontPanel/src/pages/Questions/QuestionOptions/SliderOptions/settingSlider.tsx

104 lines
3.1 KiB
TypeScript
Raw Normal View History

import { Box, Typography, useMediaQuery, useTheme } from "@mui/material";
import { updateQuestion } from "@root/questions/actions";
import CustomCheckbox from "@ui_kit/CustomCheckbox";
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
};
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-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-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-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
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-12-31 02:53:25 +00:00
question.content.required = !e.target.checked;
});
}}
/>
</Box>
</Box>
);
2023-09-06 08:01:44 +00:00
}