fix: custom input arrow function

This commit is contained in:
Nastya 2024-07-16 01:06:38 +03:00
parent bfc46d1b46
commit 01e9c5c48f
5 changed files with 15 additions and 22 deletions

@ -114,7 +114,6 @@ export const ContactForm = ({ currentQuestion, onShowResult }: Props) => {
async function handleShowResultsClick() {
const FC = settings.cfg.formContact.fields;
console.log(phone);
if (FC["email"].used !== EMAIL_REGEXP.test(email)) {
return enqueueSnackbar("введена некорректная почта");
}
@ -316,8 +315,9 @@ export const ContactForm = ({ currentQuestion, onShowResult }: Props) => {
<Box
component={Link}
target={"_blank"}
href={`https://${window.location.hostname[0] === "s" ? "s" : ""
}quiz.pena.digital/squiz/quiz/logo?q=${quizId}`}
href={`https://${
window.location.hostname[0] === "s" ? "s" : ""
}quiz.pena.digital/squiz/quiz/logo?q=${quizId}`}
sx={{
display: "flex",
alignItems: "center",

@ -23,19 +23,14 @@ const TextField = MuiTextField as unknown as FC<TextFieldProps>;
let first = true;
function phoneChange(e: ChangeEvent<HTMLInputElement>, mask: string) {
console.log(e);
const masked = IMask.createMask({
mask: "+7 (000) 000-00-00",
// ...and other options
});
masked.value = e.target.value;
console.log(masked);
console.log(masked.typedValue);
console.log(masked.parse);
const a = IMask.pipe(e.target.value, {
mask,
});
console.log(a);
return a || "";
}
@ -44,7 +39,6 @@ export const CustomInput = ({ title, desc, Icon, onChange, onChangePhone, isPhon
const isMobile = useRootContainerSize() < 600;
const { settings } = useQuizSettings();
const [mask, setMask] = useState(phoneMasksByCountry["RU"][1]);
console.log(mask);
// const { ref } = useIMask({ mask });
return (
@ -60,7 +54,9 @@ export const CustomInput = ({ title, desc, Icon, onChange, onChangePhone, isPhon
<TextField
// inputRef={isPhone ? ref : null}
//@ts-ignore
onChange={isPhone ? (e: ChangeEvent<HTMLInputElement>) => onChangePhone(phoneChange(e, mask)) : onChange(e)}
onChange={(e: ChangeEvent<HTMLInputElement>) =>
isPhone ? onChangePhone?.(phoneChange(e, mask)) : onChange?.(e)
}
type={isPhone ? "tel" : type}
value={value}
sx={{

@ -49,8 +49,6 @@ export const Inputs = ({
const Email = (
<CustomInput
onChange={({ target }) => {
console.log("onChange of email");
console.log(target.value);
setEmail(target.value.replaceAll(/\s/g, ""));
}}
id={email}
@ -64,8 +62,6 @@ export const Inputs = ({
<CustomInput
onChange={({ target }) => setText(target.value)}
onChangePhone={(phone: string) => {
console.log("onChange of phone");
console.log(phone);
setPhone(phone);
}}
value={phone}

@ -58,7 +58,6 @@ export const UploadFile = ({ currentQuestion, setModalWarningType, isSending, se
},
qid: quizId,
});
console.log(data);
await sendAnswer({
questionId: currentQuestion.id,
body: `${data!.data.fileIDMap[currentQuestion.id]}`,
@ -87,9 +86,15 @@ export const UploadFile = ({ currentQuestion, setModalWarningType, isSending, se
return (
<Box sx={{ display: "flex", alignItems: "center" }}>
{isSending ? (
<Skeleton variant="rounded" sx={{ width: "100%", height: "120px", maxWidth: "560px" }} />
<Skeleton
variant="rounded"
sx={{ width: "100%", height: "120px", maxWidth: "560px" }}
/>
) : (
<ButtonBase component="label" sx={{ justifyContent: "flex-start", width: "100%" }}>
<ButtonBase
component="label"
sx={{ justifyContent: "flex-start", width: "100%" }}
>
<input
onChange={({ target }) => uploadFile(target.files?.[0])}
hidden

@ -6,11 +6,7 @@ let domain = "https://hbpn.link";
const currentDomain = location.hostname;
//туризм больше не в исключениях
if (
currentDomain === "s.hbpn.link" ||
currentDomain.includes("localhost") ||
currentDomain.includes("127.0.0.1")
)
if (currentDomain === "s.hbpn.link" || currentDomain.includes("localhost") || currentDomain.includes("127.0.0.1"))
domain = "https://s.hbpn.link";
export { domain };