fix types
This commit is contained in:
parent
d0bf50fc15
commit
bc284032bf
@ -98,8 +98,7 @@ export const ContactForm = ({ currentQuestion, onShowResult }: Props) => {
|
||||
const isWide = Object.keys(filteredFC).length > 2;
|
||||
|
||||
async function handleShowResultsClick() {
|
||||
//@ts-ignore
|
||||
const FC: any = settings.cfg.formContact.fields || settings.cfg.formContact;
|
||||
const FC: any = settings.cfg.formContact.fields
|
||||
if (FC["email"].used !== EMAIL_REGEXP.test(email)) {
|
||||
return enqueueSnackbar("введена некорректная почта");
|
||||
}
|
||||
@ -323,15 +322,12 @@ const Inputs = ({
|
||||
}: any) => {
|
||||
const { settings } = useQuizData();
|
||||
|
||||
// @ts-ignore
|
||||
const FC = settings.cfg.formContact.fields || settings.cfg.formContact;
|
||||
const FC = settings.cfg.formContact.fields;
|
||||
|
||||
if (!FC) return null;
|
||||
|
||||
//@ts-ignore
|
||||
const Name = (
|
||||
<CustomInput
|
||||
//@ts-ignore
|
||||
onChange={({ target }) => setName(target.value)}
|
||||
id={name}
|
||||
title={FC["name"].innerText || "Введите имя"}
|
||||
@ -339,12 +335,8 @@ const Inputs = ({
|
||||
Icon={NameIcon}
|
||||
/>
|
||||
);
|
||||
//@ts-ignore
|
||||
const Email = (
|
||||
<CustomInput
|
||||
error={!EMAIL_REGEXP.test(email)}
|
||||
label={!EMAIL_REGEXP.test(email) ? "" : "Некорректная почта"}
|
||||
//@ts-ignore
|
||||
onChange={({ target }) => setEmail(target.value)}
|
||||
id={email}
|
||||
title={FC["email"].innerText || "Введите Email"}
|
||||
@ -354,7 +346,6 @@ const Inputs = ({
|
||||
);
|
||||
const Phone = (
|
||||
<CustomInput
|
||||
//@ts-ignore
|
||||
onChange={({ target }) => setPhone(target.value)}
|
||||
id={phone}
|
||||
title={FC["phone"].innerText || "Введите номер телефона"}
|
||||
@ -362,10 +353,8 @@ const Inputs = ({
|
||||
Icon={PhoneIcon}
|
||||
/>
|
||||
);
|
||||
//@ts-ignore
|
||||
const Text = (
|
||||
<CustomInput
|
||||
//@ts-ignore
|
||||
onChange={({ target }) => setText(target.value)}
|
||||
id={text}
|
||||
title={FC["text"].text || "Введите фамилию"}
|
||||
@ -373,10 +362,8 @@ const Inputs = ({
|
||||
Icon={TextIcon}
|
||||
/>
|
||||
);
|
||||
//@ts-ignore
|
||||
const Adress = (
|
||||
<CustomInput
|
||||
//@ts-ignore
|
||||
onChange={({ target }) => setAdress(target.value)}
|
||||
id={adress}
|
||||
title={FC["address"].innerText || "Введите адрес"}
|
||||
@ -385,7 +372,6 @@ const Inputs = ({
|
||||
/>
|
||||
);
|
||||
|
||||
//@ts-ignore
|
||||
if (Object.values(FC).some((data) => data.used)) {
|
||||
return (
|
||||
<>
|
||||
@ -407,10 +393,16 @@ const Inputs = ({
|
||||
}
|
||||
};
|
||||
|
||||
const CustomInput = ({ title, desc, Icon, onChange }: any) => {
|
||||
const CustomInput = ({ title, desc, Icon, onChange, id }: {
|
||||
id: string;
|
||||
title: string;
|
||||
desc: string;
|
||||
Icon: FC<{ color: string; }>;
|
||||
onChange: TextFieldProps["onChange"];
|
||||
}) => {
|
||||
const theme = useTheme();
|
||||
const isMobile = useRootContainerSize() < 600;
|
||||
//@ts-ignore
|
||||
|
||||
return (
|
||||
<Box m="15px 0">
|
||||
<Typography mb="7px" color={theme.palette.text.primary}>
|
||||
|
@ -1,4 +1,4 @@
|
||||
import {Box, TextField, Typography, useTheme} from "@mui/material";
|
||||
import {Box, TextField as MuiTextField, TextFieldProps, Typography, useTheme} from "@mui/material";
|
||||
|
||||
import CustomTextField from "@ui_kit/CustomTextField";
|
||||
|
||||
@ -8,10 +8,12 @@ import { sendAnswer } from "@api/quizRelase";
|
||||
import { useQuizData } from "@contexts/QuizDataContext";
|
||||
import { useRootContainerSize } from "@contexts/RootContainerWidthContext";
|
||||
import { enqueueSnackbar } from "notistack";
|
||||
import {ChangeEvent, useEffect, useState} from "react";
|
||||
import {ChangeEvent, FC, useEffect, useState} from "react";
|
||||
import { useDebouncedCallback } from "use-debounce";
|
||||
import type { QuizQuestionText } from "../../../model/questionTypes/text";
|
||||
|
||||
const TextField = MuiTextField as unknown as FC<TextFieldProps>; // temporary fix ts(2590)
|
||||
|
||||
type TextProps = {
|
||||
currentQuestion: QuizQuestionText;
|
||||
stepNumber: number | null;
|
||||
@ -108,7 +110,6 @@ const TextNormal = ({currentQuestion, answer, inputHC}: Props) => {
|
||||
>
|
||||
<CustomTextField
|
||||
placeholder={currentQuestion.content.placeholder}
|
||||
// @ts-ignore
|
||||
value={answer || ""}
|
||||
onChange={async ({ target }) => {
|
||||
updateAnswer(currentQuestion.id, target.value, 0);
|
||||
@ -163,13 +164,11 @@ const TextNormal = ({currentQuestion, answer, inputHC}: Props) => {
|
||||
</Box>
|
||||
)}
|
||||
{
|
||||
//@ts-ignore
|
||||
(<TextField
|
||||
autoFocus={true}
|
||||
multiline
|
||||
maxRows={4}
|
||||
placeholder={currentQuestion.content.placeholder}
|
||||
//@ts-ignore
|
||||
value={answer || ""}
|
||||
onChange={async ({ target }:ChangeEvent<HTMLInputElement>) => {
|
||||
updateAnswer(currentQuestion.id, target.value, 0);
|
||||
@ -199,4 +198,4 @@ const TextNormal = ({currentQuestion, answer, inputHC}: Props) => {
|
||||
)}
|
||||
</Box>
|
||||
)
|
||||
}
|
||||
}
|
||||
|
@ -31,6 +31,7 @@ import { quizThemes } from "@utils/themes/Publication/themePublication";
|
||||
import { enqueueSnackbar } from "notistack";
|
||||
import type { QuestionVariant } from "../../../model/questionTypes/shared";
|
||||
import type { QuizQuestionVariant } from "../../../model/questionTypes/variant";
|
||||
import moment from "moment";
|
||||
|
||||
const TextField = MuiTextField as unknown as FC<TextFieldProps>;
|
||||
|
||||
@ -60,6 +61,8 @@ export const Variant = ({ currentQuestion }: VariantProps) => {
|
||||
}
|
||||
}, []);
|
||||
|
||||
if (moment.isMoment(answer)) throw new Error("Answer is Moment in Variant question");
|
||||
|
||||
return (
|
||||
<Box>
|
||||
<Typography variant="h5" color={theme.palette.text.primary} sx={{ wordBreak: "break-word" }}>{currentQuestion.title}</Typography>
|
||||
@ -96,7 +99,6 @@ export const Variant = ({ currentQuestion }: VariantProps) => {
|
||||
key={variant.id}
|
||||
currentQuestion={currentQuestion}
|
||||
variant={variant}
|
||||
// @ts-ignore
|
||||
answer={answer}
|
||||
index={index}
|
||||
isSending={isSending}
|
||||
@ -108,7 +110,6 @@ export const Variant = ({ currentQuestion }: VariantProps) => {
|
||||
own
|
||||
currentQuestion={currentQuestion}
|
||||
variant={ownVariant.variant}
|
||||
// @ts-ignore
|
||||
answer={answer}
|
||||
index={currentQuestion.content.variants.length + 2}
|
||||
isSending={isSending}
|
||||
|
Loading…
Reference in New Issue
Block a user