2023-09-06 06:47:23 +00:00
|
|
|
|
import { useState } from "react";
|
2023-08-24 11:09:47 +00:00
|
|
|
|
import { Box, Typography, useTheme } from "@mui/material";
|
2023-03-31 15:48:49 +00:00
|
|
|
|
import ButtonsOptions from "../ButtonsOptions";
|
2023-08-24 11:09:47 +00:00
|
|
|
|
import Rating from "@mui/material/Rating";
|
2023-05-03 19:21:00 +00:00
|
|
|
|
import RatingStar from "../../../assets/icons/questionsPage/ratingStar";
|
2023-03-31 15:48:49 +00:00
|
|
|
|
import SwitchRating from "./switchRating";
|
2023-09-06 06:47:23 +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-03-31 15:48:49 +00:00
|
|
|
|
|
2023-08-24 11:09:47 +00:00
|
|
|
|
export default function RatingOptions({ totalIndex }: Props) {
|
2023-09-06 06:47:23 +00:00
|
|
|
|
const [switchState, setSwitchState] = useState("setting");
|
|
|
|
|
const { listQuestions } = questionStore();
|
2023-08-24 11:09:47 +00:00
|
|
|
|
const theme = useTheme();
|
2023-09-06 06:47:23 +00:00
|
|
|
|
|
2023-08-24 11:09:47 +00:00
|
|
|
|
const SSHC = (data: string) => {
|
|
|
|
|
setSwitchState(data);
|
|
|
|
|
};
|
2023-09-06 06:47:23 +00:00
|
|
|
|
|
2023-08-24 11:09:47 +00:00
|
|
|
|
return (
|
|
|
|
|
<>
|
|
|
|
|
<Box
|
|
|
|
|
sx={{
|
|
|
|
|
width: "100%",
|
|
|
|
|
maxWidth: "310px",
|
|
|
|
|
display: "flex",
|
|
|
|
|
padding: "20px",
|
|
|
|
|
flexDirection: "column",
|
|
|
|
|
gap: "20px",
|
|
|
|
|
}}
|
|
|
|
|
>
|
|
|
|
|
<Rating
|
|
|
|
|
name="customized-color"
|
2023-09-06 06:47:23 +00:00
|
|
|
|
defaultValue={listQuestions[totalIndex].content.starts}
|
2023-08-24 11:09:47 +00:00
|
|
|
|
getLabelText={(value: number) =>
|
|
|
|
|
`${value} Heart${value !== 1 ? "s" : ""}`
|
|
|
|
|
}
|
|
|
|
|
precision={1}
|
|
|
|
|
icon={<RatingStar color={theme.palette.brightPurple.main} />}
|
|
|
|
|
emptyIcon={<RatingStar color={"#9A9AAF"} />}
|
|
|
|
|
sx={{ display: "flex", gap: "15px" }}
|
2023-09-06 06:47:23 +00:00
|
|
|
|
onChange={(_, value) => {
|
|
|
|
|
const clonContent = listQuestions[totalIndex].content;
|
|
|
|
|
clonContent.starts = value || 0;
|
|
|
|
|
updateQuestionsList(totalIndex, { content: clonContent });
|
|
|
|
|
}}
|
2023-08-24 11:09:47 +00:00
|
|
|
|
/>
|
|
|
|
|
<Box
|
|
|
|
|
sx={{
|
|
|
|
|
display: "flex",
|
|
|
|
|
alignItems: "center",
|
|
|
|
|
justifyContent: "space-between",
|
|
|
|
|
}}
|
|
|
|
|
>
|
|
|
|
|
<Typography
|
|
|
|
|
sx={{
|
|
|
|
|
color: theme.palette.grey2.main,
|
|
|
|
|
fontSize: "16px",
|
|
|
|
|
fontWeight: 400,
|
|
|
|
|
}}
|
|
|
|
|
>
|
|
|
|
|
Негативно
|
|
|
|
|
</Typography>
|
|
|
|
|
<Typography
|
|
|
|
|
sx={{
|
|
|
|
|
color: theme.palette.grey2.main,
|
|
|
|
|
fontSize: "16px",
|
|
|
|
|
fontWeight: 400,
|
|
|
|
|
}}
|
|
|
|
|
>
|
|
|
|
|
Позитивно
|
|
|
|
|
</Typography>
|
|
|
|
|
</Box>
|
|
|
|
|
</Box>
|
|
|
|
|
<ButtonsOptions
|
|
|
|
|
switchState={switchState}
|
|
|
|
|
SSHC={SSHC}
|
|
|
|
|
totalIndex={totalIndex}
|
|
|
|
|
/>
|
|
|
|
|
<SwitchRating switchState={switchState} totalIndex={totalIndex} />
|
|
|
|
|
</>
|
|
|
|
|
);
|
|
|
|
|
}
|