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

102 lines
3.5 KiB
TypeScript
Raw Normal View History

2023-08-24 11:09:47 +00:00
import { Box, Typography, useTheme } from "@mui/material";
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-08-24 11:09:47 +00:00
interface Props {
totalIndex: number;
}
2023-08-24 11:09:47 +00:00
export default function SliderOptions({ totalIndex }: Props) {
const [switchState, setSwitchState] = React.useState("setting");
2023-09-06 08:01:44 +00:00
const { listQuestions } = questionStore();
const theme = useTheme();
2023-08-24 11:09:47 +00:00
const SSHC = (data: string) => {
setSwitchState(data);
};
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"}
text={listQuestions[totalIndex].content.range.split("—")[0]}
onChange={({ target }) => {
const clonContent = listQuestions[totalIndex].content;
clonContent.range = `${target.value}${
listQuestions[totalIndex].content.range.split("—")[1]
}`;
updateQuestionsList(totalIndex, { content: clonContent });
}}
/>
2023-08-24 11:09:47 +00:00
<Typography></Typography>
2023-09-06 08:01:44 +00:00
<CustomTextField
placeholder={"100"}
text={listQuestions[totalIndex].content.range.split("—")[1]}
onChange={({ target }) => {
const clonContent = listQuestions[totalIndex].content;
clonContent.range = `${
listQuestions[totalIndex].content.range.split("—")[0]
}${target.value}`;
updateQuestionsList(totalIndex, { content: clonContent });
}}
/>
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"}
text={String(listQuestions[totalIndex].content.start)}
onChange={({ target }) => {
const clonContent = listQuestions[totalIndex].content;
clonContent.start = Number(target.value);
updateQuestionsList(totalIndex, { content: clonContent });
}}
/>
2023-08-24 11:09:47 +00:00
</Box>
<Box>
<Typography>Шаг</Typography>
2023-09-06 08:01:44 +00:00
<CustomTextField
placeholder={"1"}
text={String(listQuestions[totalIndex].content.step)}
onChange={({ target }) => {
const clonContent = listQuestions[totalIndex].content;
clonContent.step = Number(target.value);
updateQuestionsList(totalIndex, { content: clonContent });
}}
/>
2023-08-24 11:09:47 +00:00
</Box>
</Box>
</Box>
<ButtonsOptions
switchState={switchState}
SSHC={SSHC}
totalIndex={totalIndex}
/>
<SwitchSlider switchState={switchState} totalIndex={totalIndex} />
</>
);
}