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

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

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

@ -58,7 +58,6 @@ export const UploadFile = ({ currentQuestion, setModalWarningType, isSending, se
}, },
qid: quizId, qid: quizId,
}); });
console.log(data);
await sendAnswer({ await sendAnswer({
questionId: currentQuestion.id, questionId: currentQuestion.id,
body: `${data!.data.fileIDMap[currentQuestion.id]}`, body: `${data!.data.fileIDMap[currentQuestion.id]}`,
@ -87,9 +86,15 @@ export const UploadFile = ({ currentQuestion, setModalWarningType, isSending, se
return ( return (
<Box sx={{ display: "flex", alignItems: "center" }}> <Box sx={{ display: "flex", alignItems: "center" }}>
{isSending ? ( {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 <input
onChange={({ target }) => uploadFile(target.files?.[0])} onChange={({ target }) => uploadFile(target.files?.[0])}
hidden hidden

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