2023-12-16 12:33:06 +00:00
|
|
|
|
import { Box, Typography, Button, Paper, TextField, Link, FormControl } from "@mui/material";
|
|
|
|
|
import NameIcon from "@icons/ContactFormIcon/NameIcon";
|
|
|
|
|
import EmailIcon from "@icons/ContactFormIcon/EmailIcon";
|
|
|
|
|
import PhoneIcon from "@icons/ContactFormIcon/PhoneIcon";
|
|
|
|
|
import TextIcon from "@icons/ContactFormIcon/TextIcon";
|
|
|
|
|
import AddressIcon from "@icons/ContactFormIcon/AddressIcon";
|
2023-12-15 12:12:36 +00:00
|
|
|
|
|
|
|
|
|
import { useCurrentQuiz } from "@root/quizes/hooks";
|
2023-12-16 12:33:06 +00:00
|
|
|
|
import CustomCheckbox from "@ui_kit/CustomCheckbox";
|
|
|
|
|
import { useState } from "react";
|
2023-12-16 09:36:35 +00:00
|
|
|
|
import { useQuestionsStore } from "@root/questions/store";
|
|
|
|
|
|
|
|
|
|
import type { AnyTypedQuizQuestion } from "../../model/questionTypes/shared";
|
2023-12-15 12:12:36 +00:00
|
|
|
|
|
|
|
|
|
type ContactFormProps = {
|
2023-12-16 09:36:35 +00:00
|
|
|
|
currentQuestion: AnyTypedQuizQuestion;
|
2023-12-15 12:12:36 +00:00
|
|
|
|
showResultForm: boolean;
|
|
|
|
|
setShowContactForm: (show: boolean) => void;
|
|
|
|
|
setShowResultForm: (show: boolean) => void;
|
|
|
|
|
};
|
|
|
|
|
|
2023-12-16 12:33:06 +00:00
|
|
|
|
const icons = [
|
|
|
|
|
{ type: "name", icon: NameIcon, defaultText: "Введите имя", defaultTitle: "имя" },
|
|
|
|
|
{ type: "email", icon: EmailIcon, defaultText: "Введите Email", defaultTitle: "Email" },
|
|
|
|
|
{ type: "phone", icon: PhoneIcon, defaultText: "Введите номер телефона", defaultTitle: "номер телефона" },
|
|
|
|
|
{ type: "text", icon: TextIcon, defaultText: "Введите фамилию", defaultTitle: "фамилию" },
|
|
|
|
|
{ type: "address", icon: AddressIcon, defaultText: "Введите адрес", defaultTitle: "адрес" },
|
|
|
|
|
]
|
|
|
|
|
|
2023-12-15 12:12:36 +00:00
|
|
|
|
export const ContactForm = ({
|
2023-12-16 09:36:35 +00:00
|
|
|
|
currentQuestion,
|
2023-12-15 12:12:36 +00:00
|
|
|
|
showResultForm,
|
|
|
|
|
setShowContactForm,
|
|
|
|
|
setShowResultForm,
|
|
|
|
|
}: ContactFormProps) => {
|
|
|
|
|
const quiz = useCurrentQuiz();
|
2023-12-16 09:36:35 +00:00
|
|
|
|
const { questions } = useQuestionsStore();
|
2023-12-15 12:12:36 +00:00
|
|
|
|
|
2023-12-16 12:33:06 +00:00
|
|
|
|
const [ready, setReady] = useState(false)
|
2023-12-15 12:12:36 +00:00
|
|
|
|
const followNextForm = () => {
|
|
|
|
|
setShowContactForm(false);
|
|
|
|
|
setShowResultForm(true);
|
|
|
|
|
};
|
|
|
|
|
|
2023-12-16 09:36:35 +00:00
|
|
|
|
const resultQuestion = questions.find(
|
|
|
|
|
(question) =>
|
|
|
|
|
question.type === "result" &&
|
|
|
|
|
question.content.rule.parentId === currentQuestion.content.id
|
|
|
|
|
);
|
2023-12-15 12:12:36 +00:00
|
|
|
|
return (
|
2023-12-16 12:33:06 +00:00
|
|
|
|
<Box
|
|
|
|
|
sx={{
|
|
|
|
|
display: "flex",
|
|
|
|
|
alignItems: "center",
|
|
|
|
|
justifyContent: "center",
|
|
|
|
|
height: "100vh"
|
|
|
|
|
}}
|
|
|
|
|
>
|
|
|
|
|
<Box
|
|
|
|
|
sx={{
|
|
|
|
|
width: "800px"
|
|
|
|
|
}}
|
|
|
|
|
>
|
|
|
|
|
|
|
|
|
|
<Box>
|
|
|
|
|
<Typography
|
|
|
|
|
sx={{
|
|
|
|
|
textAlign: "center",
|
|
|
|
|
m: "20px 0",
|
|
|
|
|
fontSize: "28px"
|
|
|
|
|
}}
|
|
|
|
|
>
|
|
|
|
|
Заполните форму, чтобы получить результаты теста
|
|
|
|
|
</Typography>
|
|
|
|
|
</Box>
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
<Paper
|
|
|
|
|
sx={{
|
|
|
|
|
display: "flex",
|
|
|
|
|
alignItems: "center",
|
|
|
|
|
justifyContent: "center",
|
|
|
|
|
flexDirection: "column",
|
|
|
|
|
p: "30px"
|
|
|
|
|
}}>
|
|
|
|
|
|
|
|
|
|
<Box
|
|
|
|
|
sx={{
|
|
|
|
|
display: "flex",
|
|
|
|
|
flexDirection: "column",
|
|
|
|
|
my: "20px"
|
|
|
|
|
}}
|
|
|
|
|
>
|
|
|
|
|
{
|
|
|
|
|
icons.map((data) => {
|
|
|
|
|
const FC = quiz?.config.formContact[data.type]
|
|
|
|
|
return FC.used ? <CustomInput title={FC.innerText || data.defaultText} desc={FC.text || data.defaultTitle} Icon={data.icon} />
|
|
|
|
|
:
|
|
|
|
|
<></>
|
|
|
|
|
})
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
</Box>
|
|
|
|
|
|
2023-12-16 15:59:36 +00:00
|
|
|
|
{
|
|
|
|
|
// resultQuestion &&
|
|
|
|
|
// quiz?.config.resultInfo.when === "after" &&
|
|
|
|
|
(
|
|
|
|
|
<Button
|
|
|
|
|
disabled={!ready}
|
|
|
|
|
variant="contained" onClick={followNextForm}>
|
|
|
|
|
Получить результаты
|
|
|
|
|
</Button>
|
|
|
|
|
)}
|
2023-12-16 12:33:06 +00:00
|
|
|
|
|
|
|
|
|
<Box
|
|
|
|
|
sx={{
|
|
|
|
|
display: "flex",
|
|
|
|
|
mt: "20px",
|
|
|
|
|
width: "450px",
|
|
|
|
|
}}
|
|
|
|
|
>
|
2023-12-16 15:59:36 +00:00
|
|
|
|
<CustomCheckbox label="" handleChange={({ target }) => { setReady(target.checked) }} checked={ready} />
|
2023-12-16 12:33:06 +00:00
|
|
|
|
<Typography>
|
|
|
|
|
С
|
|
|
|
|
<Link> Положением об обработке персональных данных </Link>
|
|
|
|
|
и
|
|
|
|
|
<Link> Политикой конфиденциальности </Link>
|
|
|
|
|
ознакомлен
|
|
|
|
|
</Typography>
|
|
|
|
|
|
|
|
|
|
</Box>
|
|
|
|
|
</Paper>
|
2023-12-16 15:59:36 +00:00
|
|
|
|
</Box >
|
|
|
|
|
</Box >
|
2023-12-15 12:12:36 +00:00
|
|
|
|
);
|
|
|
|
|
};
|
2023-12-16 12:33:06 +00:00
|
|
|
|
|
|
|
|
|
const CustomInput = ({ title, desc, Icon }: any) => {
|
|
|
|
|
return <Box m="15px 0">
|
|
|
|
|
<Typography mb="7px">{title}</Typography>
|
|
|
|
|
<TextField
|
|
|
|
|
sx={{
|
|
|
|
|
width: "350px",
|
|
|
|
|
}}
|
|
|
|
|
placeholder={desc}
|
|
|
|
|
InputProps={{
|
|
|
|
|
startAdornment: <Icon color="gray" />,
|
|
|
|
|
}}
|
|
|
|
|
/>
|
|
|
|
|
</Box>
|
2023-12-16 15:59:36 +00:00
|
|
|
|
}
|