2023-09-06 13:20:12 +00:00
|
|
|
|
import { useParams } from "react-router-dom";
|
|
|
|
|
import { Box, Typography } from "@mui/material";
|
2023-03-31 15:48:49 +00:00
|
|
|
|
import ButtonsOptions from "../ButtonsOptions";
|
|
|
|
|
import React from "react";
|
|
|
|
|
import CustomTextField from "@ui_kit/CustomTextField";
|
|
|
|
|
import SwitchSlider from "./switchSlider";
|
2023-09-06 08:01:44 +00:00
|
|
|
|
import { questionStore, updateQuestionsList } from "@root/questions";
|
2023-03-31 15:48:49 +00:00
|
|
|
|
|
2023-08-24 11:09:47 +00:00
|
|
|
|
interface Props {
|
|
|
|
|
totalIndex: number;
|
2023-06-30 14:39:07 +00:00
|
|
|
|
}
|
|
|
|
|
|
2023-08-24 11:09:47 +00:00
|
|
|
|
export default function SliderOptions({ totalIndex }: Props) {
|
|
|
|
|
const [switchState, setSwitchState] = React.useState("setting");
|
2023-09-06 13:20:12 +00:00
|
|
|
|
const quizId = Number(useParams().quizId);
|
2023-09-06 08:01:44 +00:00
|
|
|
|
const { listQuestions } = questionStore();
|
2023-09-06 13:20:12 +00:00
|
|
|
|
|
2023-08-24 11:09:47 +00:00
|
|
|
|
const SSHC = (data: string) => {
|
|
|
|
|
setSwitchState(data);
|
|
|
|
|
};
|
2023-03-31 15:48:49 +00:00
|
|
|
|
|
2023-08-24 11:09:47 +00:00
|
|
|
|
return (
|
|
|
|
|
<>
|
|
|
|
|
<Box
|
|
|
|
|
sx={{
|
|
|
|
|
width: "100%",
|
|
|
|
|
maxWidth: "640px",
|
|
|
|
|
display: "flex",
|
|
|
|
|
padding: "20px",
|
|
|
|
|
flexDirection: "column",
|
|
|
|
|
gap: "20px",
|
|
|
|
|
}}
|
|
|
|
|
>
|
|
|
|
|
<Box sx={{ gap: "10px", display: "flex", flexDirection: "column" }}>
|
|
|
|
|
<Typography>Выбор значения из диапазона</Typography>
|
|
|
|
|
<Box sx={{ display: "flex", alignItems: "center", gap: "20px" }}>
|
2023-09-06 08:01:44 +00:00
|
|
|
|
<CustomTextField
|
|
|
|
|
placeholder={"0"}
|
2023-09-06 13:20:12 +00:00
|
|
|
|
text={
|
|
|
|
|
listQuestions[quizId][totalIndex].content.range.split("—")[0]
|
|
|
|
|
}
|
2023-09-06 08:01:44 +00:00
|
|
|
|
onChange={({ target }) => {
|
2023-09-06 13:20:12 +00:00
|
|
|
|
const clonContent = listQuestions[quizId][totalIndex].content;
|
2023-09-06 08:01:44 +00:00
|
|
|
|
clonContent.range = `${target.value}—${
|
2023-09-06 13:20:12 +00:00
|
|
|
|
listQuestions[quizId][totalIndex].content.range.split("—")[1]
|
2023-09-06 08:01:44 +00:00
|
|
|
|
}`;
|
2023-09-06 13:20:12 +00:00
|
|
|
|
updateQuestionsList(quizId, totalIndex, {
|
|
|
|
|
content: clonContent,
|
|
|
|
|
});
|
2023-09-06 08:01:44 +00:00
|
|
|
|
}}
|
|
|
|
|
/>
|
2023-08-24 11:09:47 +00:00
|
|
|
|
<Typography>—</Typography>
|
2023-09-06 08:01:44 +00:00
|
|
|
|
<CustomTextField
|
|
|
|
|
placeholder={"100"}
|
2023-09-06 13:20:12 +00:00
|
|
|
|
text={
|
|
|
|
|
listQuestions[quizId][totalIndex].content.range.split("—")[1]
|
|
|
|
|
}
|
2023-09-06 08:01:44 +00:00
|
|
|
|
onChange={({ target }) => {
|
2023-09-06 13:20:12 +00:00
|
|
|
|
const clonContent = listQuestions[quizId][totalIndex].content;
|
2023-09-06 08:01:44 +00:00
|
|
|
|
clonContent.range = `${
|
2023-09-06 13:20:12 +00:00
|
|
|
|
listQuestions[quizId][totalIndex].content.range.split("—")[0]
|
2023-09-06 08:01:44 +00:00
|
|
|
|
}—${target.value}`;
|
2023-09-06 13:20:12 +00:00
|
|
|
|
updateQuestionsList(quizId, totalIndex, {
|
|
|
|
|
content: clonContent,
|
|
|
|
|
});
|
2023-09-06 08:01:44 +00:00
|
|
|
|
}}
|
|
|
|
|
/>
|
2023-08-24 11:09:47 +00:00
|
|
|
|
</Box>
|
|
|
|
|
</Box>
|
|
|
|
|
<Box
|
|
|
|
|
sx={{
|
|
|
|
|
display: "flex",
|
|
|
|
|
alignItems: "center",
|
|
|
|
|
justifyContent: "space-between",
|
|
|
|
|
}}
|
|
|
|
|
>
|
|
|
|
|
<Box>
|
|
|
|
|
<Typography>Начальное значение</Typography>
|
2023-09-06 08:01:44 +00:00
|
|
|
|
<CustomTextField
|
|
|
|
|
placeholder={"50"}
|
2023-09-06 13:20:12 +00:00
|
|
|
|
text={String(listQuestions[quizId][totalIndex].content.start)}
|
2023-09-06 08:01:44 +00:00
|
|
|
|
onChange={({ target }) => {
|
2023-09-06 13:20:12 +00:00
|
|
|
|
const clonContent = listQuestions[quizId][totalIndex].content;
|
2023-09-06 08:01:44 +00:00
|
|
|
|
clonContent.start = Number(target.value);
|
2023-09-06 13:20:12 +00:00
|
|
|
|
updateQuestionsList(quizId, totalIndex, {
|
|
|
|
|
content: clonContent,
|
|
|
|
|
});
|
2023-09-06 08:01:44 +00:00
|
|
|
|
}}
|
|
|
|
|
/>
|
2023-08-24 11:09:47 +00:00
|
|
|
|
</Box>
|
|
|
|
|
<Box>
|
|
|
|
|
<Typography>Шаг</Typography>
|
2023-09-06 08:01:44 +00:00
|
|
|
|
<CustomTextField
|
|
|
|
|
placeholder={"1"}
|
2023-09-06 13:20:12 +00:00
|
|
|
|
text={String(listQuestions[quizId][totalIndex].content.step)}
|
2023-09-06 08:01:44 +00:00
|
|
|
|
onChange={({ target }) => {
|
2023-09-06 13:20:12 +00:00
|
|
|
|
const clonContent = listQuestions[quizId][totalIndex].content;
|
2023-09-06 08:01:44 +00:00
|
|
|
|
clonContent.step = Number(target.value);
|
2023-09-06 13:20:12 +00:00
|
|
|
|
updateQuestionsList(quizId, totalIndex, {
|
|
|
|
|
content: clonContent,
|
|
|
|
|
});
|
2023-09-06 08:01:44 +00:00
|
|
|
|
}}
|
|
|
|
|
/>
|
2023-08-24 11:09:47 +00:00
|
|
|
|
</Box>
|
|
|
|
|
</Box>
|
|
|
|
|
</Box>
|
|
|
|
|
<ButtonsOptions
|
|
|
|
|
switchState={switchState}
|
|
|
|
|
SSHC={SSHC}
|
|
|
|
|
totalIndex={totalIndex}
|
|
|
|
|
/>
|
|
|
|
|
<SwitchSlider switchState={switchState} totalIndex={totalIndex} />
|
|
|
|
|
</>
|
|
|
|
|
);
|
|
|
|
|
}
|