2023-12-31 02:53:25 +00:00
|
|
|
|
import {
|
|
|
|
|
Box,
|
|
|
|
|
Tooltip,
|
|
|
|
|
Typography,
|
|
|
|
|
useMediaQuery,
|
|
|
|
|
useTheme,
|
|
|
|
|
} from "@mui/material";
|
2023-11-27 23:07:24 +00:00
|
|
|
|
import { updateQuestion } from "@root/questions/actions";
|
2023-11-16 16:41:25 +00:00
|
|
|
|
import CustomTextField from "@ui_kit/CustomTextField";
|
2024-02-26 15:56:07 +00:00
|
|
|
|
import TooltipClickInfo from "@ui_kit/Toolbars/TooltipClickInfo";
|
2024-02-29 11:23:52 +00:00
|
|
|
|
import { useEffect, useState } from "react";
|
2023-11-16 16:41:25 +00:00
|
|
|
|
import InfoIcon from "../../../assets/icons/InfoIcon";
|
|
|
|
|
import type { QuizQuestionText } from "../../../model/questionTypes/text";
|
2024-02-14 02:45:13 +00:00
|
|
|
|
import ButtonsOptionsAndPict from "../ButtonsOptionsAndPict";
|
2024-02-26 15:56:07 +00:00
|
|
|
|
import SwitchTextField from "./switchTextField";
|
2023-08-25 08:29:42 +00:00
|
|
|
|
|
2023-06-30 14:39:07 +00:00
|
|
|
|
interface Props {
|
2023-12-31 02:53:25 +00:00
|
|
|
|
question: QuizQuestionText;
|
2024-01-05 07:07:06 +00:00
|
|
|
|
openBranchingPage: boolean;
|
|
|
|
|
setOpenBranchingPage: (a: boolean) => void;
|
2023-08-24 11:09:47 +00:00
|
|
|
|
}
|
2023-08-25 08:29:42 +00:00
|
|
|
|
|
2024-01-05 07:07:06 +00:00
|
|
|
|
export default function OwnTextField({
|
|
|
|
|
question,
|
|
|
|
|
openBranchingPage,
|
|
|
|
|
setOpenBranchingPage,
|
|
|
|
|
}: Props) {
|
2023-12-31 02:53:25 +00:00
|
|
|
|
const [switchState, setSwitchState] = useState("setting");
|
|
|
|
|
const theme = useTheme();
|
|
|
|
|
const isMobile = useMediaQuery(theme.breakpoints.down(790));
|
|
|
|
|
const isFigmaTablte = useMediaQuery(theme.breakpoints.down(990));
|
2023-11-16 16:41:25 +00:00
|
|
|
|
|
2024-02-26 15:56:07 +00:00
|
|
|
|
const setPlaceholder = (value: string) => {
|
2023-12-31 02:53:25 +00:00
|
|
|
|
updateQuestion(question.id, (question) => {
|
|
|
|
|
if (question.type !== "text") return;
|
2023-11-16 16:41:25 +00:00
|
|
|
|
|
2023-12-31 02:53:25 +00:00
|
|
|
|
question.content.placeholder = value;
|
|
|
|
|
});
|
2024-02-26 15:56:07 +00:00
|
|
|
|
};
|
2023-11-16 16:41:25 +00:00
|
|
|
|
|
2024-02-29 11:23:52 +00:00
|
|
|
|
useEffect(() => {
|
|
|
|
|
if (question.deleteTimeoutId) {
|
|
|
|
|
clearTimeout(question.deleteTimeoutId);
|
|
|
|
|
}
|
|
|
|
|
}, [question]);
|
2023-08-25 08:29:42 +00:00
|
|
|
|
|
2023-12-31 02:53: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={"Пример ответа"}
|
2024-02-26 15:56:07 +00:00
|
|
|
|
value={question.content.placeholder}
|
2023-12-31 02:53:25 +00:00
|
|
|
|
onChange={({ target }) => setPlaceholder(target.value)}
|
|
|
|
|
sx={{
|
|
|
|
|
maxWidth: isFigmaTablte ? "549px" : "640px",
|
|
|
|
|
width: "100%",
|
|
|
|
|
mt: isMobile ? "15px" : "0px",
|
|
|
|
|
}}
|
2024-02-16 23:41:38 +00:00
|
|
|
|
maxLength={200}
|
2023-12-31 02:53:25 +00:00
|
|
|
|
/>
|
|
|
|
|
<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>
|
2024-01-04 18:36:26 +00:00
|
|
|
|
{isMobile ? (
|
|
|
|
|
<TooltipClickInfo
|
|
|
|
|
title={"Будет использоваться для ввода значения."}
|
|
|
|
|
/>
|
|
|
|
|
) : (
|
|
|
|
|
<Tooltip
|
|
|
|
|
title="Будет использоваться для ввода значения."
|
|
|
|
|
placement="top"
|
|
|
|
|
>
|
|
|
|
|
<Box>
|
|
|
|
|
<InfoIcon />
|
|
|
|
|
</Box>
|
|
|
|
|
</Tooltip>
|
|
|
|
|
)}
|
2023-12-31 02:53:25 +00:00
|
|
|
|
</Box>
|
|
|
|
|
</Box>
|
2024-02-14 02:45:13 +00:00
|
|
|
|
<ButtonsOptionsAndPict
|
2023-12-31 02:53:25 +00:00
|
|
|
|
switchState={switchState}
|
2024-02-29 11:23:52 +00:00
|
|
|
|
SSHC={setSwitchState}
|
|
|
|
|
questionId={question.id}
|
|
|
|
|
questionContentId={question.content.id}
|
|
|
|
|
questionHasParent={question.content.rule.parentId.length !== 0}
|
|
|
|
|
questionType={question.type}
|
2024-01-05 07:07:06 +00:00
|
|
|
|
openBranchingPage={openBranchingPage}
|
|
|
|
|
setOpenBranchingPage={setOpenBranchingPage}
|
2023-12-31 02:53:25 +00:00
|
|
|
|
/>
|
|
|
|
|
<SwitchTextField switchState={switchState} question={question} />
|
|
|
|
|
</>
|
|
|
|
|
);
|
2023-06-30 14:39:07 +00:00
|
|
|
|
}
|