2023-11-16 16:41:25 +00:00
|
|
|
|
import { Box, Tooltip, Typography, useMediaQuery, useTheme } from "@mui/material";
|
|
|
|
|
import { updateQuestionWithFnOptimistic } from "@root/questions/actions";
|
|
|
|
|
import CustomTextField from "@ui_kit/CustomTextField";
|
2023-08-25 08:29:42 +00:00
|
|
|
|
import { useState } from "react";
|
2023-09-20 09:07:33 +00:00
|
|
|
|
import { useDebouncedCallback } from "use-debounce";
|
2023-11-16 16:41:25 +00:00
|
|
|
|
import InfoIcon from "../../../assets/icons/InfoIcon";
|
|
|
|
|
import type { QuizQuestionText } from "../../../model/questionTypes/text";
|
2023-03-31 15:48:49 +00:00
|
|
|
|
import ButtonsOptions from "../ButtonsOptions";
|
|
|
|
|
import SwitchTextField from "./switchTextField";
|
2023-08-25 08:29:42 +00:00
|
|
|
|
|
2023-10-03 14:03:57 +00:00
|
|
|
|
|
2023-06-30 14:39:07 +00:00
|
|
|
|
interface Props {
|
2023-11-16 16:41:25 +00:00
|
|
|
|
question: QuizQuestionText;
|
2023-08-24 11:09:47 +00:00
|
|
|
|
}
|
2023-08-25 08:29:42 +00:00
|
|
|
|
|
2023-11-16 16:41:25 +00:00
|
|
|
|
export default function OwnTextField({ question }: Props) {
|
|
|
|
|
const [switchState, setSwitchState] = useState("setting");
|
|
|
|
|
const theme = useTheme();
|
|
|
|
|
const isMobile = useMediaQuery(theme.breakpoints.down(790));
|
|
|
|
|
const isFigmaTablte = useMediaQuery(theme.breakpoints.down(990));
|
|
|
|
|
|
|
|
|
|
const setPlaceholder = useDebouncedCallback((value) => {
|
|
|
|
|
updateQuestionWithFnOptimistic(question.id, question => {
|
|
|
|
|
if (question.type !== "text") return;
|
|
|
|
|
|
|
|
|
|
question.content.placeholder = value;
|
|
|
|
|
});
|
|
|
|
|
}, 1000);
|
|
|
|
|
|
|
|
|
|
const SSHC = (data: string) => {
|
|
|
|
|
setSwitchState(data);
|
|
|
|
|
};
|
2023-08-25 08:29:42 +00:00
|
|
|
|
|
2023-11-16 16:41:25 +00:00
|
|
|
|
return (
|
|
|
|
|
<>
|
|
|
|
|
<Box
|
|
|
|
|
sx={{
|
|
|
|
|
width: "auto",
|
|
|
|
|
maxWidth: "745px",
|
|
|
|
|
display: "flex",
|
|
|
|
|
pb: "20px",
|
|
|
|
|
pl: "20px",
|
|
|
|
|
pr: "20px",
|
|
|
|
|
flexDirection: "column",
|
|
|
|
|
gap: isMobile ? "15px" : "20px",
|
|
|
|
|
}}
|
|
|
|
|
>
|
|
|
|
|
<CustomTextField
|
|
|
|
|
placeholder={"Пример ответа"}
|
|
|
|
|
text={question.content.placeholder}
|
|
|
|
|
onChange={({ target }) => setPlaceholder(target.value)}
|
|
|
|
|
sx={{ maxWidth: isFigmaTablte ? "549px" : "640px", width: "100%", mt: isMobile ? "15px" : "0px" }}
|
|
|
|
|
/>
|
|
|
|
|
<Box sx={{ display: "flex", alignItems: isMobile ? "flex-start" : "center", gap: "12px" }}>
|
|
|
|
|
<Typography
|
|
|
|
|
sx={{
|
|
|
|
|
fontWeight: 400,
|
|
|
|
|
fontSize: "16px",
|
|
|
|
|
lineHeight: "18.96px",
|
|
|
|
|
color: theme.palette.grey2.main,
|
|
|
|
|
}}
|
|
|
|
|
>
|
|
|
|
|
Пользователю будет дано поле для ввода значения
|
|
|
|
|
</Typography>
|
|
|
|
|
<Tooltip title="Будет использоваться для ввода значения." placement="top">
|
|
|
|
|
<Box>
|
|
|
|
|
<InfoIcon />
|
|
|
|
|
</Box>
|
|
|
|
|
</Tooltip>
|
|
|
|
|
</Box>
|
2023-09-18 12:34:41 +00:00
|
|
|
|
</Box>
|
2023-11-16 16:41:25 +00:00
|
|
|
|
<ButtonsOptions switchState={switchState} SSHC={SSHC} question={question} />
|
|
|
|
|
<SwitchTextField switchState={switchState} question={question} />
|
|
|
|
|
</>
|
|
|
|
|
);
|
2023-06-30 14:39:07 +00:00
|
|
|
|
}
|