|
|
@ -24,7 +24,6 @@ const Login = memo(() => { |
|
|
|
const { mutate: upLoginFun } = useAtomValue(upLoginAtom); |
|
|
|
const [emailCodeData, setEmailCodeData] = useState({}); |
|
|
|
const { mutate: emailLoginMutate } = useAtomValue(emailLoginAtom); |
|
|
|
const { mutate: telegramCodeMutate } = useAtomValue(telegramCodeAtom); |
|
|
|
const { mutate: telegramLoginMutate } = useAtomValue(telegramLoginAtom); |
|
|
|
|
|
|
|
const uphandleSubmit = (values: any) => { |
|
|
@ -32,21 +31,19 @@ const Login = memo(() => { |
|
|
|
upLoginFun(values); |
|
|
|
}; |
|
|
|
|
|
|
|
const getEmailCode = () => { |
|
|
|
const getEmailCode = async () => { |
|
|
|
const email = emailform.getFieldValue("email"); |
|
|
|
setCountdown(10); |
|
|
|
setIsButtonDisabled(true); |
|
|
|
setEmailCodeData(systemServ.emailCode({ is_register: false, email })); |
|
|
|
const result = await systemServ.emailCode({ is_register: false, email }); |
|
|
|
setEmailCodeData(result); |
|
|
|
}; |
|
|
|
const emailhandleSubmit = (values: any) => { |
|
|
|
emailLoginMutate(values); |
|
|
|
}; |
|
|
|
|
|
|
|
const getTelegramCode = () => { |
|
|
|
const getTelegramCode = async () => { |
|
|
|
const telegram = telegramform.getFieldValue("telegram"); |
|
|
|
setCountdown(10); |
|
|
|
setIsButtonDisabled(true); |
|
|
|
telegramCodeMutate({ telegram }); |
|
|
|
const result = await systemServ.telegramCode({ telegram }); |
|
|
|
setEmailCodeData(result); |
|
|
|
}; |
|
|
|
const telegramhandleSubmit = (values: any) => { |
|
|
|
telegramLoginMutate(values); |
|
|
@ -63,20 +60,24 @@ const Login = memo(() => { |
|
|
|
}); |
|
|
|
|
|
|
|
useEffect(() => { |
|
|
|
localStorage.setItem("countdown", String(countdown)); |
|
|
|
}, [countdown]); |
|
|
|
|
|
|
|
useEffect(() => { |
|
|
|
localStorage.setItem("isButtonDisabled", JSON.stringify(isButtonDisabled)); |
|
|
|
}, [isButtonDisabled]); |
|
|
|
|
|
|
|
useEffect(() => { |
|
|
|
if ((emailCodeData as any)?.code === 0) { |
|
|
|
setCountdown(10); |
|
|
|
setIsButtonDisabled(true); |
|
|
|
} |
|
|
|
}, [emailCodeData]); |
|
|
|
|
|
|
|
useEffect(() => { |
|
|
|
let timer: number; |
|
|
|
if (countdown > 0) { |
|
|
|
timer = setTimeout(() => setCountdown(countdown - 1), 1000); |
|
|
|
} else { |
|
|
|
setIsButtonDisabled(false); |
|
|
|
} |
|
|
|
localStorage.setItem("countdown", String(countdown)); |
|
|
|
return () => clearTimeout(timer); |
|
|
|
}, [countdown]); |
|
|
|
|
|
|
|