2023-11-16 16:41:25 +00:00
|
|
|
|
import { QuizQuestionRating } from "@model/questionTypes/rating";
|
2023-12-31 02:53:25 +00:00
|
|
|
|
import {
|
|
|
|
|
Box,
|
|
|
|
|
ButtonBase,
|
|
|
|
|
Slider,
|
|
|
|
|
Typography,
|
|
|
|
|
useMediaQuery,
|
|
|
|
|
useTheme,
|
|
|
|
|
} from "@mui/material";
|
2024-02-26 15:56:07 +00:00
|
|
|
|
import { updateQuestion } from "@root/questions/actions";
|
2023-03-31 15:48:49 +00:00
|
|
|
|
import CustomCheckbox from "@ui_kit/CustomCheckbox";
|
2023-05-03 19:21:00 +00:00
|
|
|
|
import FlagIcon from "../../../assets/icons/questionsPage/FlagIcon";
|
2023-11-16 16:41:25 +00:00
|
|
|
|
import StarIconMini from "../../../assets/icons/questionsPage/StarIconMini";
|
|
|
|
|
import HashtagIcon from "../../../assets/icons/questionsPage/hashtagIcon";
|
2023-05-03 19:21:00 +00:00
|
|
|
|
import HeartIcon from "../../../assets/icons/questionsPage/heartIcon";
|
|
|
|
|
import LightbulbIcon from "../../../assets/icons/questionsPage/lightbulbIcon";
|
2023-11-16 16:41:25 +00:00
|
|
|
|
import LikeIcon from "../../../assets/icons/questionsPage/likeIcon";
|
|
|
|
|
import TropfyIcon from "../../../assets/icons/questionsPage/tropfyIcon";
|
2023-09-18 07:45:14 +00:00
|
|
|
|
import type { ButtonRatingFrom } from "./RatingOptions";
|
2023-11-16 16:41:25 +00:00
|
|
|
|
|
2023-09-06 06:47:23 +00:00
|
|
|
|
type SettingSliderProps = {
|
2023-12-31 02:53:25 +00:00
|
|
|
|
question: QuizQuestionRating;
|
2023-09-06 06:47:23 +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 isFigmaTablte = useMediaQuery(theme.breakpoints.down(990));
|
|
|
|
|
const isMobile = useMediaQuery(theme.breakpoints.down(790));
|
|
|
|
|
const isWrappColumn = useMediaQuery(theme.breakpoints.down(980));
|
2023-09-06 06:47:23 +00:00
|
|
|
|
|
2023-12-31 02:53:25 +00:00
|
|
|
|
const buttonRatingForm: ButtonRatingFrom[] = [
|
|
|
|
|
{ name: "star", icon: <StarIconMini color={theme.palette.grey3.main} /> },
|
|
|
|
|
{ name: "trophie", icon: <TropfyIcon color={theme.palette.grey3.main} /> },
|
|
|
|
|
{ name: "flag", icon: <FlagIcon color={theme.palette.grey3.main} /> },
|
|
|
|
|
{ name: "heart", icon: <HeartIcon color={theme.palette.grey3.main} /> },
|
|
|
|
|
{ name: "like", icon: <LikeIcon color={theme.palette.grey3.main} /> },
|
|
|
|
|
{
|
|
|
|
|
name: "bubble",
|
|
|
|
|
icon: <LightbulbIcon color={theme.palette.grey3.main} />,
|
|
|
|
|
},
|
|
|
|
|
{ name: "hashtag", icon: <HashtagIcon color={theme.palette.grey3.main} /> },
|
|
|
|
|
];
|
2023-09-26 21:11:27 +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 ? "25px" : "20px",
|
|
|
|
|
pl: "20px",
|
|
|
|
|
display: "flex",
|
|
|
|
|
flexDirection: "column",
|
|
|
|
|
gap: "14px",
|
|
|
|
|
maxWidth: "340px",
|
|
|
|
|
width: "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>
|
|
|
|
|
<Typography
|
|
|
|
|
sx={{
|
|
|
|
|
color: theme.palette.grey2.main,
|
|
|
|
|
fontSize: "16px",
|
|
|
|
|
fontWeight: 400,
|
|
|
|
|
}}
|
|
|
|
|
>
|
|
|
|
|
Форма
|
|
|
|
|
</Typography>
|
|
|
|
|
<Box sx={{ display: "flex", marginBottom: "15px" }}>
|
|
|
|
|
{buttonRatingForm.map(({ name, icon }, index) => (
|
|
|
|
|
<ButtonBase
|
|
|
|
|
key={index}
|
|
|
|
|
onClick={() => {
|
|
|
|
|
updateQuestion(question.id, (question) => {
|
|
|
|
|
if (question.type !== "rating") return;
|
2023-11-16 16:41:25 +00:00
|
|
|
|
|
2023-12-31 02:53:25 +00:00
|
|
|
|
question.content.form = name;
|
|
|
|
|
});
|
|
|
|
|
}}
|
|
|
|
|
sx={{
|
|
|
|
|
backgroundColor:
|
|
|
|
|
question.content.form === name
|
|
|
|
|
? theme.palette.brightPurple.main
|
|
|
|
|
: "transparent",
|
|
|
|
|
color:
|
|
|
|
|
question.content.form === name
|
|
|
|
|
? "#ffffff"
|
|
|
|
|
: theme.palette.grey3.main,
|
|
|
|
|
width: "40px",
|
|
|
|
|
height: "40px",
|
|
|
|
|
borderRadius: "4px",
|
|
|
|
|
}}
|
|
|
|
|
>
|
|
|
|
|
{icon}
|
|
|
|
|
</ButtonBase>
|
|
|
|
|
))}
|
|
|
|
|
</Box>
|
2023-11-16 16:41:25 +00:00
|
|
|
|
|
2023-12-31 02:53:25 +00:00
|
|
|
|
<Typography
|
|
|
|
|
sx={{
|
|
|
|
|
color: theme.palette.grey2.main,
|
|
|
|
|
fontSize: "16px",
|
|
|
|
|
fontWeight: 400,
|
|
|
|
|
}}
|
|
|
|
|
>
|
|
|
|
|
Количество
|
|
|
|
|
</Typography>
|
|
|
|
|
<Slider
|
|
|
|
|
value={question.content.steps}
|
|
|
|
|
min={2}
|
|
|
|
|
max={10}
|
|
|
|
|
aria-label="Default"
|
|
|
|
|
valueLabelDisplay="auto"
|
2024-02-14 02:24:25 +00:00
|
|
|
|
sx={{
|
|
|
|
|
color: theme.palette.brightPurple.main,
|
|
|
|
|
padding: "0",
|
|
|
|
|
width: isMobile ? "290px" : "100%",
|
|
|
|
|
}}
|
2023-12-31 02:53:25 +00:00
|
|
|
|
onChange={(_, value) => {
|
|
|
|
|
updateQuestion(question.id, (question) => {
|
|
|
|
|
if (question.type !== "rating") return;
|
2023-11-16 16:41:25 +00:00
|
|
|
|
|
2023-12-31 02:53:25 +00:00
|
|
|
|
question.content.steps = Number(value) || 1;
|
|
|
|
|
});
|
|
|
|
|
}}
|
|
|
|
|
/>
|
|
|
|
|
</Box>
|
|
|
|
|
<Box
|
|
|
|
|
sx={{
|
|
|
|
|
boxSizing: "border-box",
|
|
|
|
|
pt: isMobile ? "30px" : "20px",
|
|
|
|
|
pb: "20px",
|
|
|
|
|
pl: isFigmaTablte ? (isMobile ? "20px" : "34px") : "40px",
|
|
|
|
|
pr: isFigmaTablte ? "19px" : "20px",
|
|
|
|
|
display: "flex",
|
|
|
|
|
flexDirection: "column",
|
|
|
|
|
gap: isMobile ? "13px" : "14px",
|
|
|
|
|
width: "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={{ display: "block", mr: isMobile ? "0px" : "16px" }}
|
|
|
|
|
label={"Необязательный вопрос"}
|
|
|
|
|
checked={!question.content.required}
|
|
|
|
|
handleChange={(e) => {
|
|
|
|
|
updateQuestion<QuizQuestionRating>(question.id, (question) => {
|
|
|
|
|
if (question.type !== "rating") 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-04-23 08:39:34 +00:00
|
|
|
|
}
|