2024-01-30 16:49:33 +00:00
|
|
|
|
import AddressIcon from "@icons/ContactFormIcon/AddressIcon";
|
2023-12-17 13:22:21 +00:00
|
|
|
|
import EmailIcon from "@icons/ContactFormIcon/EmailIcon";
|
2024-02-02 14:35:02 +00:00
|
|
|
|
import NameIcon from "@icons/ContactFormIcon/NameIcon";
|
2023-12-17 13:22:21 +00:00
|
|
|
|
import PhoneIcon from "@icons/ContactFormIcon/PhoneIcon";
|
|
|
|
|
import TextIcon from "@icons/ContactFormIcon/TextIcon";
|
2024-03-14 17:17:19 +00:00
|
|
|
|
import {
|
|
|
|
|
Box,
|
|
|
|
|
Button,
|
|
|
|
|
InputAdornment,
|
|
|
|
|
Link,
|
|
|
|
|
TextField as MuiTextField,
|
|
|
|
|
TextFieldProps,
|
|
|
|
|
Typography,
|
|
|
|
|
useTheme
|
|
|
|
|
} from "@mui/material";
|
2024-01-30 16:49:33 +00:00
|
|
|
|
|
2023-12-17 13:22:21 +00:00
|
|
|
|
import CustomCheckbox from "@ui_kit/CustomCheckbox";
|
2024-04-09 19:52:45 +00:00
|
|
|
|
import { FC, useRef, useState } from "react";
|
|
|
|
|
|
2024-04-03 12:42:12 +00:00
|
|
|
|
import { DESIGN_LIST } from "@/utils/designList";
|
2024-04-09 19:52:45 +00:00
|
|
|
|
import { sendFC } from "@api/quizRelase";
|
|
|
|
|
import { useQuizData } from "@contexts/QuizDataContext";
|
|
|
|
|
import { NameplateLogo } from "@icons/NameplateLogo";
|
|
|
|
|
import { QuizQuestionResult } from "@model/questionTypes/result";
|
|
|
|
|
import { AnyTypedQuizQuestion } from "@model/questionTypes/shared";
|
|
|
|
|
import { quizThemes } from "@utils/themes/Publication/themePublication";
|
|
|
|
|
import { enqueueSnackbar } from "notistack";
|
|
|
|
|
import { useRootContainerSize } from "../../contexts/RootContainerWidthContext";
|
2024-01-30 16:49:33 +00:00
|
|
|
|
|
2023-12-16 14:55:56 +00:00
|
|
|
|
|
2024-01-30 16:49:33 +00:00
|
|
|
|
const TextField = MuiTextField as unknown as FC<TextFieldProps>; // temporary fix ts(2590)
|
|
|
|
|
const EMAIL_REGEXP = /^(([^<>()[\].,:\s@"]+(\.[^<>()[\].,:\s@"]+)*)|(".+"))@(([^<>()[\].,:\s@"]+\.)+[^<>()[\].,:\s@"]{2,})$/iu;
|
2024-01-05 17:00:30 +00:00
|
|
|
|
|
2024-02-08 13:42:31 +00:00
|
|
|
|
type Props = {
|
|
|
|
|
currentQuestion: AnyTypedQuizQuestion;
|
|
|
|
|
onShowResult: () => void;
|
2023-12-16 14:55:56 +00:00
|
|
|
|
};
|
|
|
|
|
|
2024-04-09 19:52:45 +00:00
|
|
|
|
export const ContactForm = ({ currentQuestion, onShowResult }: Props) => {
|
2024-01-30 16:49:33 +00:00
|
|
|
|
const theme = useTheme();
|
2024-04-09 19:52:45 +00:00
|
|
|
|
const { settings, questions, quizId, show_badge, preview } = useQuizData();
|
2024-01-30 16:49:33 +00:00
|
|
|
|
|
2024-01-31 12:57:07 +00:00
|
|
|
|
const [ready, setReady] = useState(false);
|
|
|
|
|
const [name, setName] = useState("");
|
|
|
|
|
const [email, setEmail] = useState("");
|
|
|
|
|
const [phone, setPhone] = useState("");
|
|
|
|
|
const [text, setText] = useState("");
|
|
|
|
|
const [adress, setAdress] = useState("");
|
2024-01-30 16:49:33 +00:00
|
|
|
|
|
2024-01-31 12:57:07 +00:00
|
|
|
|
const fireOnce = useRef(true);
|
|
|
|
|
const [fire, setFire] = useState(false);
|
2024-02-05 10:10:02 +00:00
|
|
|
|
const isMobile = useRootContainerSize() < 850;
|
2024-03-26 00:06:54 +00:00
|
|
|
|
const isTablet = useRootContainerSize() < 1000;
|
2024-01-30 16:49:33 +00:00
|
|
|
|
|
2024-02-08 13:42:31 +00:00
|
|
|
|
const resultQuestion = currentQuestion.type === "result"
|
|
|
|
|
? currentQuestion
|
|
|
|
|
: questions.find((question): question is QuizQuestionResult => {
|
|
|
|
|
if (settings?.cfg.haveRoot) {
|
|
|
|
|
return (
|
|
|
|
|
question.type === "result" &&
|
|
|
|
|
question.content.rule.parentId === currentQuestion.content.id
|
|
|
|
|
);
|
|
|
|
|
} else {
|
|
|
|
|
return (
|
|
|
|
|
question.type === "result" && question.content.rule.parentId === "line"
|
|
|
|
|
);
|
|
|
|
|
}
|
|
|
|
|
});
|
2023-12-23 18:03:34 +00:00
|
|
|
|
|
2024-02-08 13:42:31 +00:00
|
|
|
|
if (!resultQuestion) throw new Error("Result question not found");
|
2024-04-09 19:52:45 +00:00
|
|
|
|
|
2024-01-30 16:49:33 +00:00
|
|
|
|
const inputHC = async () => {
|
2024-02-08 13:42:31 +00:00
|
|
|
|
const FC = settings.cfg.formContact.fields || settings.cfg.formContact;
|
|
|
|
|
const body = {} as any;
|
2024-01-30 16:49:33 +00:00
|
|
|
|
if (name.length > 0) body.name = name;
|
|
|
|
|
if (email.length > 0) body.email = email;
|
|
|
|
|
if (phone.length > 0) body.phone = phone;
|
2024-01-31 12:57:07 +00:00
|
|
|
|
if (adress.length > 0) body.address = adress;
|
2024-04-09 19:52:45 +00:00
|
|
|
|
if (text.length > 0) body.customs = { [FC.text.text || "Фамилия"]: text };
|
2024-01-30 16:49:33 +00:00
|
|
|
|
|
|
|
|
|
if (Object.keys(body).length > 0) {
|
|
|
|
|
try {
|
|
|
|
|
await sendFC({
|
2024-02-08 13:42:31 +00:00
|
|
|
|
questionId: currentQuestion.id,
|
2024-01-30 16:49:33 +00:00
|
|
|
|
body: body,
|
2024-02-14 11:03:35 +00:00
|
|
|
|
qid: quizId,
|
2024-04-01 06:08:20 +00:00
|
|
|
|
preview
|
2024-01-31 12:57:07 +00:00
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
const sessions = JSON.parse(localStorage.getItem("sessions") || "{}");
|
|
|
|
|
localStorage.setItem(
|
|
|
|
|
"sessions",
|
2024-04-09 19:52:45 +00:00
|
|
|
|
JSON.stringify({ ...sessions, [quizId]: new Date().getTime() })
|
2024-01-31 12:57:07 +00:00
|
|
|
|
);
|
2024-01-30 16:49:33 +00:00
|
|
|
|
} catch (e) {
|
2024-01-31 12:57:07 +00:00
|
|
|
|
enqueueSnackbar("ответ не был засчитан");
|
2024-01-30 16:49:33 +00:00
|
|
|
|
}
|
|
|
|
|
}
|
2024-01-31 12:57:07 +00:00
|
|
|
|
};
|
2024-01-30 16:49:33 +00:00
|
|
|
|
|
2024-02-08 13:42:31 +00:00
|
|
|
|
const FCcopy: any = settings.cfg.formContact.fields || settings.cfg.formContact;
|
|
|
|
|
|
|
|
|
|
const filteredFC: any = {};
|
|
|
|
|
for (const i in FCcopy) {
|
|
|
|
|
const field = FCcopy[i];
|
2024-01-30 16:49:33 +00:00
|
|
|
|
if (field.used) {
|
|
|
|
|
filteredFC[i] = field;
|
|
|
|
|
}
|
|
|
|
|
}
|
2024-04-10 17:49:47 +00:00
|
|
|
|
|
2024-02-08 13:42:31 +00:00
|
|
|
|
|
|
|
|
|
async function handleShowResultsClick() {
|
2024-04-09 19:52:45 +00:00
|
|
|
|
const FC: any = settings.cfg.formContact.fields;
|
2024-02-08 13:42:31 +00:00
|
|
|
|
if (FC["email"].used !== EMAIL_REGEXP.test(email)) {
|
|
|
|
|
return enqueueSnackbar("введена некорректная почта");
|
|
|
|
|
}
|
2023-12-24 11:52:09 +00:00
|
|
|
|
|
2024-02-08 13:42:31 +00:00
|
|
|
|
|
|
|
|
|
if (fireOnce.current) {
|
|
|
|
|
if (
|
|
|
|
|
name.length === 0
|
|
|
|
|
&& email.length === 0
|
|
|
|
|
&& phone.length === 0
|
|
|
|
|
&& text.length === 0
|
|
|
|
|
&& adress.length === 0
|
|
|
|
|
) return enqueueSnackbar("Пожалуйста, заполните поля");
|
|
|
|
|
|
2024-02-14 11:03:35 +00:00
|
|
|
|
//почта валидна, хоть одно поле заполнено
|
|
|
|
|
setFire(true);
|
2024-02-08 13:42:31 +00:00
|
|
|
|
try {
|
|
|
|
|
await inputHC();
|
|
|
|
|
fireOnce.current = false;
|
|
|
|
|
const sessions: any = JSON.parse(
|
|
|
|
|
localStorage.getItem("sessions") || "{}"
|
|
|
|
|
);
|
2024-02-14 11:03:35 +00:00
|
|
|
|
sessions[quizId] = Date.now();
|
2024-02-08 13:42:31 +00:00
|
|
|
|
localStorage.setItem(
|
|
|
|
|
"sessions",
|
|
|
|
|
JSON.stringify(sessions)
|
|
|
|
|
);
|
|
|
|
|
enqueueSnackbar("Данные успешно отправлены");
|
|
|
|
|
} catch (e) {
|
|
|
|
|
enqueueSnackbar("повторите попытку позже");
|
|
|
|
|
}
|
2024-04-09 19:52:45 +00:00
|
|
|
|
if (settings.cfg.resultInfo.showResultForm === "after") {
|
2024-03-29 13:36:38 +00:00
|
|
|
|
onShowResult();
|
|
|
|
|
}
|
2024-02-08 13:42:31 +00:00
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
setFire(false);
|
|
|
|
|
}
|
2023-12-24 11:52:09 +00:00
|
|
|
|
|
2024-01-30 16:49:33 +00:00
|
|
|
|
return (
|
2024-01-06 23:56:13 +00:00
|
|
|
|
<Box
|
|
|
|
|
sx={{
|
2024-01-30 16:49:33 +00:00
|
|
|
|
display: "flex",
|
|
|
|
|
alignItems: "center",
|
|
|
|
|
justifyContent: "center",
|
|
|
|
|
backgroundColor: theme.palette.background.default,
|
2024-02-08 13:42:31 +00:00
|
|
|
|
height: "100%",
|
2024-01-30 16:49:33 +00:00
|
|
|
|
overflow: "auto",
|
2024-01-31 12:57:07 +00:00
|
|
|
|
"&::-webkit-scrollbar": {
|
|
|
|
|
width: "0",
|
|
|
|
|
display: "none",
|
|
|
|
|
msOverflowStyle: "none",
|
|
|
|
|
},
|
2024-01-30 16:49:33 +00:00
|
|
|
|
scrollbarWidth: "none",
|
2024-01-31 12:57:07 +00:00
|
|
|
|
msOverflowStyle: "none",
|
2024-03-07 20:52:54 +00:00
|
|
|
|
backgroundPosition: "center",
|
|
|
|
|
backgroundSize: "cover",
|
2024-03-14 17:17:19 +00:00
|
|
|
|
backgroundImage: settings.cfg.design && !isMobile
|
2024-04-09 19:52:45 +00:00
|
|
|
|
? quizThemes[settings.cfg.theme].isLight
|
|
|
|
|
? `url(${DESIGN_LIST[settings.cfg.theme]})`
|
|
|
|
|
: `linear-gradient(90deg, #272626, transparent), url(${DESIGN_LIST[settings.cfg.theme]})`
|
2024-03-07 20:52:54 +00:00
|
|
|
|
: null,
|
2024-01-06 23:56:13 +00:00
|
|
|
|
}}
|
|
|
|
|
>
|
2024-01-30 16:49:33 +00:00
|
|
|
|
<Box
|
|
|
|
|
sx={{
|
2024-04-10 17:49:47 +00:00
|
|
|
|
width: !isMobile ? "100%" : isMobile ? undefined : "530px",
|
2024-01-30 16:49:33 +00:00
|
|
|
|
borderRadius: "4px",
|
2024-02-19 14:20:21 +00:00
|
|
|
|
height: "100%",
|
2024-04-02 17:21:31 +00:00
|
|
|
|
minHeight: "100%",
|
2024-04-10 17:49:47 +00:00
|
|
|
|
display: isMobile ? undefined : "flex",
|
2024-04-09 19:52:45 +00:00
|
|
|
|
background: settings.cfg.design && !isMobile ? undefined : theme.palette.background.default,
|
2024-01-30 16:49:33 +00:00
|
|
|
|
}}
|
2023-12-17 21:28:57 +00:00
|
|
|
|
>
|
2024-01-30 16:49:33 +00:00
|
|
|
|
<Box
|
|
|
|
|
sx={{
|
2024-04-10 17:49:47 +00:00
|
|
|
|
width: isMobile ? undefined : "100%",
|
2024-01-30 16:49:33 +00:00
|
|
|
|
display: "flex",
|
|
|
|
|
flexDirection: "column",
|
|
|
|
|
alignItems: "center",
|
|
|
|
|
justifyContent: "center",
|
2024-04-10 17:49:47 +00:00
|
|
|
|
borderRight: isMobile ? undefined : "1px solid #9A9AAF80",
|
2024-03-26 00:06:54 +00:00
|
|
|
|
margin: isMobile ? 0 : "40px 0"
|
2024-01-30 16:49:33 +00:00
|
|
|
|
}}
|
|
|
|
|
>
|
2024-03-14 16:09:40 +00:00
|
|
|
|
<Box
|
2024-01-30 16:49:33 +00:00
|
|
|
|
sx={{
|
2024-03-14 16:09:40 +00:00
|
|
|
|
maxWidth: "630px",
|
|
|
|
|
width: "100%",
|
|
|
|
|
display: "flex",
|
|
|
|
|
flexDirection: "column",
|
|
|
|
|
alignItems: "flex-start",
|
|
|
|
|
justifyContent: "center",
|
|
|
|
|
padding: isMobile ? "20px 20px 0 20px" : "0 0 0 40px"
|
2024-01-30 16:49:33 +00:00
|
|
|
|
}}
|
|
|
|
|
>
|
|
|
|
|
<Typography
|
|
|
|
|
sx={{
|
2024-03-26 00:06:54 +00:00
|
|
|
|
textAlign: isTablet ? undefined : "center",
|
2024-01-30 16:49:33 +00:00
|
|
|
|
m: "20px 0",
|
2024-03-26 00:06:54 +00:00
|
|
|
|
fontSize: isTablet ? "24px" : "28px",
|
|
|
|
|
lineHeight: "normal",
|
|
|
|
|
fontWeight: 501,
|
2024-03-14 16:09:40 +00:00
|
|
|
|
color: theme.palette.text.primary,
|
2024-02-15 01:20:35 +00:00
|
|
|
|
wordBreak: "break-word"
|
2024-01-30 16:49:33 +00:00
|
|
|
|
}}
|
|
|
|
|
>
|
2024-03-14 16:09:40 +00:00
|
|
|
|
{settings.cfg.formContact.title ||
|
2024-04-09 19:52:45 +00:00
|
|
|
|
"Заполните форму, чтобы получить результаты теста"}
|
2024-01-30 16:49:33 +00:00
|
|
|
|
</Typography>
|
2024-03-14 16:09:40 +00:00
|
|
|
|
{settings.cfg.formContact.desc && (
|
|
|
|
|
<Typography
|
|
|
|
|
sx={{
|
|
|
|
|
color: theme.palette.text.primary,
|
|
|
|
|
m: "20px 0",
|
|
|
|
|
fontSize: "18px",
|
|
|
|
|
wordBreak: "break-word"
|
|
|
|
|
}}
|
|
|
|
|
>
|
|
|
|
|
{settings.cfg.formContact.desc}
|
|
|
|
|
</Typography>
|
|
|
|
|
)}
|
|
|
|
|
</Box>
|
|
|
|
|
|
2024-01-30 16:49:33 +00:00
|
|
|
|
</Box>
|
|
|
|
|
|
|
|
|
|
<Box
|
|
|
|
|
sx={{
|
|
|
|
|
display: "flex",
|
|
|
|
|
alignItems: "center",
|
|
|
|
|
justifyContent: "center",
|
|
|
|
|
flexDirection: "column",
|
|
|
|
|
backgroundColor: theme.palette.background.default,
|
2024-03-26 00:06:54 +00:00
|
|
|
|
p: isMobile ? "40px" : "125px 60px 30px 60px",
|
2024-01-31 12:57:07 +00:00
|
|
|
|
}}
|
|
|
|
|
>
|
2024-01-30 16:49:33 +00:00
|
|
|
|
<Box
|
|
|
|
|
sx={{
|
|
|
|
|
display: "flex",
|
|
|
|
|
flexDirection: "column",
|
2024-01-31 12:57:07 +00:00
|
|
|
|
my: "20px",
|
2024-01-30 16:49:33 +00:00
|
|
|
|
}}
|
|
|
|
|
>
|
|
|
|
|
<Inputs
|
2024-01-31 12:57:07 +00:00
|
|
|
|
name={name}
|
|
|
|
|
setName={setName}
|
|
|
|
|
email={email}
|
|
|
|
|
setEmail={setEmail}
|
|
|
|
|
phone={phone}
|
|
|
|
|
setPhone={setPhone}
|
|
|
|
|
text={text}
|
|
|
|
|
setText={setText}
|
|
|
|
|
adress={adress}
|
|
|
|
|
setAdress={setAdress}
|
2024-01-30 16:49:33 +00:00
|
|
|
|
/>
|
|
|
|
|
</Box>
|
|
|
|
|
|
|
|
|
|
{
|
|
|
|
|
// resultQuestion &&
|
2024-02-08 13:42:31 +00:00
|
|
|
|
// settings.cfg.resultInfo.when === "after" &&
|
2024-01-31 12:57:07 +00:00
|
|
|
|
<Button
|
|
|
|
|
disabled={!(ready && !fire)}
|
|
|
|
|
variant="contained"
|
2024-02-08 13:42:31 +00:00
|
|
|
|
onClick={handleShowResultsClick}
|
2024-03-07 20:52:54 +00:00
|
|
|
|
sx={{
|
|
|
|
|
border: `1px solid ${theme.palette.primary.main}`,
|
|
|
|
|
"&:disabled": {
|
|
|
|
|
border: "1px solid #9A9AAF",
|
|
|
|
|
color: "#9A9AAF"
|
|
|
|
|
}
|
|
|
|
|
}}
|
2024-01-31 12:57:07 +00:00
|
|
|
|
>
|
2024-02-08 13:42:31 +00:00
|
|
|
|
{settings.cfg.formContact?.button || "Получить результаты"}
|
2024-01-31 12:57:07 +00:00
|
|
|
|
</Button>
|
|
|
|
|
}
|
2024-02-14 11:03:35 +00:00
|
|
|
|
|
2024-01-30 16:49:33 +00:00
|
|
|
|
<Box
|
|
|
|
|
sx={{
|
|
|
|
|
display: "flex",
|
|
|
|
|
mt: "20px",
|
2024-03-26 00:06:54 +00:00
|
|
|
|
width: isMobile ? "300px" : "390px",
|
2024-01-30 16:49:33 +00:00
|
|
|
|
}}
|
|
|
|
|
>
|
2024-01-31 12:57:07 +00:00
|
|
|
|
<CustomCheckbox
|
|
|
|
|
label=""
|
2024-04-09 19:52:45 +00:00
|
|
|
|
handleChange={({ target }) => {
|
2024-01-31 12:57:07 +00:00
|
|
|
|
setReady(target.checked);
|
|
|
|
|
}}
|
|
|
|
|
checked={ready}
|
|
|
|
|
colorIcon={theme.palette.primary.main}
|
|
|
|
|
/>
|
2024-04-09 19:52:45 +00:00
|
|
|
|
<Typography sx={{ color: theme.palette.text.primary }}>
|
2024-01-30 16:49:33 +00:00
|
|
|
|
С 
|
|
|
|
|
<Link href={"https://shub.pena.digital/ppdd"} target="_blank">
|
2024-01-31 12:57:07 +00:00
|
|
|
|
Положением об обработке персональных данных{" "}
|
|
|
|
|
</Link>
|
2024-01-30 16:49:33 +00:00
|
|
|
|
 и 
|
2024-01-31 12:57:07 +00:00
|
|
|
|
<Link
|
|
|
|
|
href={"https://shub.pena.digital/docs/privacy"}
|
|
|
|
|
target="_blank"
|
|
|
|
|
>
|
|
|
|
|
{" "}
|
|
|
|
|
Политикой конфиденциальности{" "}
|
|
|
|
|
</Link>
|
2024-01-30 16:49:33 +00:00
|
|
|
|
 ознакомлен
|
|
|
|
|
</Typography>
|
|
|
|
|
</Box>
|
2024-03-05 16:29:44 +00:00
|
|
|
|
{show_badge &&
|
2024-04-09 19:52:45 +00:00
|
|
|
|
<Box
|
|
|
|
|
component={Link}
|
|
|
|
|
target={"_blank"}
|
|
|
|
|
href={
|
|
|
|
|
`https://${window.location.hostname.includes("s") ? "s" : ""}quiz.pena.digital/squiz/quiz/logo?q=${quizId}`
|
2024-03-30 09:52:02 +00:00
|
|
|
|
}
|
2024-01-31 12:57:07 +00:00
|
|
|
|
sx={{
|
2024-04-09 19:52:45 +00:00
|
|
|
|
display: "flex",
|
|
|
|
|
alignItems: "center",
|
|
|
|
|
mt: "55px",
|
|
|
|
|
mb: "50px",
|
|
|
|
|
gap: "15px",
|
|
|
|
|
textDecoration: "none",
|
2024-01-31 12:57:07 +00:00
|
|
|
|
}}
|
|
|
|
|
>
|
2024-04-09 19:52:45 +00:00
|
|
|
|
<NameplateLogo
|
|
|
|
|
style={{
|
|
|
|
|
fontSize: "23px",
|
|
|
|
|
color: quizThemes[settings.cfg.theme].isLight ? "#151515" : "#FFFFFF",
|
|
|
|
|
}}
|
|
|
|
|
/>
|
|
|
|
|
<Typography
|
|
|
|
|
sx={{
|
|
|
|
|
fontSize: "14px",
|
|
|
|
|
color: quizThemes[settings.cfg.theme].isLight ? "#4D4D4D" : "#F5F7FF",
|
|
|
|
|
whiteSpace: "nowrap",
|
|
|
|
|
}}
|
|
|
|
|
>
|
|
|
|
|
Сделано на PenaQuiz
|
|
|
|
|
</Typography>
|
|
|
|
|
</Box>
|
2024-03-02 15:33:28 +00:00
|
|
|
|
}
|
|
|
|
|
|
2024-01-30 16:49:33 +00:00
|
|
|
|
</Box>
|
2024-01-31 12:57:07 +00:00
|
|
|
|
</Box>
|
2023-12-29 21:31:21 +00:00
|
|
|
|
</Box>
|
2024-01-30 16:49:33 +00:00
|
|
|
|
);
|
|
|
|
|
};
|
2023-12-17 13:22:21 +00:00
|
|
|
|
|
2024-01-30 16:49:33 +00:00
|
|
|
|
const Inputs = ({
|
2024-04-09 19:52:45 +00:00
|
|
|
|
name,
|
|
|
|
|
setName,
|
|
|
|
|
email,
|
|
|
|
|
setEmail,
|
|
|
|
|
phone,
|
|
|
|
|
setPhone,
|
|
|
|
|
text,
|
|
|
|
|
setText,
|
|
|
|
|
adress,
|
|
|
|
|
setAdress,
|
|
|
|
|
}: any) => {
|
|
|
|
|
const { settings } = useQuizData();
|
2023-12-17 13:22:21 +00:00
|
|
|
|
|
2024-02-21 10:23:25 +00:00
|
|
|
|
const FC = settings.cfg.formContact.fields;
|
2023-12-29 13:35:25 +00:00
|
|
|
|
|
2024-01-31 12:57:07 +00:00
|
|
|
|
if (!FC) return null;
|
2024-04-09 19:52:45 +00:00
|
|
|
|
console.log(email);
|
2024-01-31 12:57:07 +00:00
|
|
|
|
const Name = (
|
|
|
|
|
<CustomInput
|
2024-04-09 19:52:45 +00:00
|
|
|
|
onChange={({ target }) => setName(target.value)}
|
2024-01-31 12:57:07 +00:00
|
|
|
|
id={name}
|
|
|
|
|
title={FC["name"].innerText || "Введите имя"}
|
2024-03-14 16:09:40 +00:00
|
|
|
|
desc={FC["name"].text || "Имя"}
|
2024-01-31 12:57:07 +00:00
|
|
|
|
Icon={NameIcon}
|
|
|
|
|
/>
|
2024-01-25 07:36:45 +00:00
|
|
|
|
);
|
2024-01-31 12:57:07 +00:00
|
|
|
|
const Email = (
|
|
|
|
|
<CustomInput
|
2024-04-09 19:52:45 +00:00
|
|
|
|
onChange={({ target }) => setEmail(target.value.replaceAll(/\s/g, ''))}
|
2024-01-31 12:57:07 +00:00
|
|
|
|
id={email}
|
|
|
|
|
title={FC["email"].innerText || "Введите Email"}
|
|
|
|
|
desc={FC["email"].text || "Email"}
|
|
|
|
|
Icon={EmailIcon}
|
|
|
|
|
/>
|
|
|
|
|
);
|
|
|
|
|
const Phone = (
|
|
|
|
|
<CustomInput
|
2024-04-09 19:52:45 +00:00
|
|
|
|
onChange={({ target }) => setPhone(target.value)}
|
2024-01-31 12:57:07 +00:00
|
|
|
|
id={phone}
|
|
|
|
|
title={FC["phone"].innerText || "Введите номер телефона"}
|
2024-03-14 16:09:40 +00:00
|
|
|
|
desc={FC["phone"].text || "Номер телефона"}
|
2024-01-31 12:57:07 +00:00
|
|
|
|
Icon={PhoneIcon}
|
|
|
|
|
/>
|
2024-01-25 07:36:45 +00:00
|
|
|
|
);
|
2024-01-31 12:57:07 +00:00
|
|
|
|
const Text = (
|
|
|
|
|
<CustomInput
|
2024-04-09 19:52:45 +00:00
|
|
|
|
onChange={({ target }) => setText(target.value)}
|
2024-01-31 12:57:07 +00:00
|
|
|
|
id={text}
|
|
|
|
|
title={FC["text"].text || "Введите фамилию"}
|
2024-03-14 16:09:40 +00:00
|
|
|
|
desc={FC["text"].innerText || "Фамилия"}
|
2024-01-31 12:57:07 +00:00
|
|
|
|
Icon={TextIcon}
|
|
|
|
|
/>
|
|
|
|
|
);
|
|
|
|
|
const Adress = (
|
|
|
|
|
<CustomInput
|
2024-04-09 19:52:45 +00:00
|
|
|
|
onChange={({ target }) => setAdress(target.value)}
|
2024-01-31 12:57:07 +00:00
|
|
|
|
id={adress}
|
|
|
|
|
title={FC["address"].innerText || "Введите адрес"}
|
2024-03-14 16:09:40 +00:00
|
|
|
|
desc={FC["address"].text || "Адрес"}
|
2024-01-31 12:57:07 +00:00
|
|
|
|
Icon={AddressIcon}
|
|
|
|
|
/>
|
|
|
|
|
);
|
2023-12-17 13:22:21 +00:00
|
|
|
|
|
2024-01-30 16:49:33 +00:00
|
|
|
|
if (Object.values(FC).some((data) => data.used)) {
|
2024-01-31 12:57:07 +00:00
|
|
|
|
return (
|
|
|
|
|
<>
|
|
|
|
|
{FC["name"].used ? Name : <></>}
|
|
|
|
|
{FC["email"].used ? Email : <></>}
|
|
|
|
|
{FC["phone"].used ? Phone : <></>}
|
|
|
|
|
{FC["text"].used ? Text : <></>}
|
|
|
|
|
{FC["address"].used ? Adress : <></>}
|
|
|
|
|
</>
|
|
|
|
|
);
|
2024-01-30 16:49:33 +00:00
|
|
|
|
} else {
|
2024-01-31 12:57:07 +00:00
|
|
|
|
return (
|
|
|
|
|
<>
|
|
|
|
|
{Name}
|
|
|
|
|
{Email}
|
|
|
|
|
{Phone}
|
|
|
|
|
</>
|
|
|
|
|
);
|
2024-01-30 16:49:33 +00:00
|
|
|
|
}
|
2024-01-25 07:36:45 +00:00
|
|
|
|
};
|
2023-12-17 13:22:21 +00:00
|
|
|
|
|
2024-04-09 19:52:45 +00:00
|
|
|
|
const CustomInput = ({ title, desc, Icon, onChange, id }: {
|
2024-02-21 10:23:25 +00:00
|
|
|
|
id: string;
|
|
|
|
|
title: string;
|
|
|
|
|
desc: string;
|
2024-04-09 19:52:45 +00:00
|
|
|
|
Icon: FC<{ color: string; backgroundColor: string; }>;
|
2024-02-21 10:23:25 +00:00
|
|
|
|
onChange: TextFieldProps["onChange"];
|
|
|
|
|
}) => {
|
2024-01-30 16:49:33 +00:00
|
|
|
|
const theme = useTheme();
|
2024-02-05 10:10:02 +00:00
|
|
|
|
const isMobile = useRootContainerSize() < 600;
|
2024-04-09 19:52:45 +00:00
|
|
|
|
const { settings } = useQuizData();
|
2024-01-30 16:49:33 +00:00
|
|
|
|
return (
|
2024-03-26 00:06:54 +00:00
|
|
|
|
<Box m="10px 0">
|
2024-01-31 12:57:07 +00:00
|
|
|
|
<Typography mb="7px" color={theme.palette.text.primary}>
|
|
|
|
|
{title}
|
|
|
|
|
</Typography>
|
2024-01-30 16:49:33 +00:00
|
|
|
|
|
|
|
|
|
<TextField
|
|
|
|
|
onChange={onChange}
|
|
|
|
|
sx={{
|
2024-03-26 00:06:54 +00:00
|
|
|
|
width: isMobile ? "300px" : "390px",
|
2024-03-14 16:09:40 +00:00
|
|
|
|
backgroundColor: theme.palette.background.default,
|
2024-03-07 20:52:54 +00:00
|
|
|
|
"& .MuiOutlinedInput-notchedOutline": {
|
2024-03-14 16:09:40 +00:00
|
|
|
|
borderColor: "#9A9AAF80",
|
|
|
|
|
borderRadius: "12px"
|
|
|
|
|
},
|
|
|
|
|
"& .MuiInputBase-root": {
|
|
|
|
|
paddingLeft: 0
|
2024-03-26 00:06:54 +00:00
|
|
|
|
},
|
|
|
|
|
'& .MuiOutlinedInput-root': {
|
|
|
|
|
'&:hover fieldset': {
|
|
|
|
|
borderColor: theme.palette.primary.main,
|
|
|
|
|
},
|
2024-03-07 20:52:54 +00:00
|
|
|
|
}
|
2024-03-14 16:09:40 +00:00
|
|
|
|
|
2024-01-30 16:49:33 +00:00
|
|
|
|
}}
|
|
|
|
|
placeholder={desc}
|
|
|
|
|
InputProps={{
|
2024-01-31 12:57:07 +00:00
|
|
|
|
startAdornment: (
|
|
|
|
|
<InputAdornment position="start">
|
2024-03-14 17:17:19 +00:00
|
|
|
|
<Icon color="gray"
|
2024-04-09 19:52:45 +00:00
|
|
|
|
backgroundColor={quizThemes[settings.cfg.theme].isLight ? "#F2F3F7" : "#F2F3F71A"} />
|
2024-01-31 12:57:07 +00:00
|
|
|
|
</InputAdornment>
|
|
|
|
|
),
|
2024-01-30 16:49:33 +00:00
|
|
|
|
}}
|
|
|
|
|
/>
|
|
|
|
|
</Box>
|
2024-01-31 12:57:07 +00:00
|
|
|
|
);
|
2024-01-25 07:36:45 +00:00
|
|
|
|
};
|