Complete main UI #37
@@ -1,4 +1,4 @@
|
|||||||
import React from 'react'
|
import React, { useCallback } from 'react'
|
||||||
import Icon from '@ant-design/icons'
|
import Icon from '@ant-design/icons'
|
||||||
import { Turnstile, TurnstileInstance } from '@marsidev/react-turnstile'
|
import { Turnstile, TurnstileInstance } from '@marsidev/react-turnstile'
|
||||||
import {
|
import {
|
||||||
@@ -18,7 +18,27 @@ const Forget: React.FC = () => {
|
|||||||
const navigate = useNavigate()
|
const navigate = useNavigate()
|
||||||
const [searchParams] = useSearchParams()
|
const [searchParams] = useSearchParams()
|
||||||
const turnstileRef = useRef<TurnstileInstance>()
|
const turnstileRef = useRef<TurnstileInstance>()
|
||||||
|
const turnstileRefCallback = useCallback(
|
||||||
|
(node: TurnstileInstance) => {
|
||||||
|
turnstileRef.current = node
|
||||||
|
|
||||||
|
if (location.pathname === '/forget' && !searchParams.get('code')) {
|
||||||
|
turnstileRef.current?.execute()
|
||||||
|
}
|
||||||
|
},
|
||||||
|
[location.pathname, searchParams]
|
||||||
|
)
|
||||||
const retrieveTurnstileRef = useRef<TurnstileInstance>()
|
const retrieveTurnstileRef = useRef<TurnstileInstance>()
|
||||||
|
const retrieveTurnstileRefCallback = useCallback(
|
||||||
|
(node: TurnstileInstance) => {
|
||||||
|
retrieveTurnstileRef.current = node
|
||||||
|
|
||||||
|
if (location.pathname === '/forget' && searchParams.get('code')) {
|
||||||
|
retrieveTurnstileRef.current?.execute()
|
||||||
|
}
|
||||||
|
},
|
||||||
|
[location.pathname, searchParams]
|
||||||
|
)
|
||||||
const [isSending, setIsSending] = useState(false)
|
const [isSending, setIsSending] = useState(false)
|
||||||
const [isSent, setIsSent] = useState(false)
|
const [isSent, setIsSent] = useState(false)
|
||||||
const [isChanging, setIsChanging] = useState(false)
|
const [isChanging, setIsChanging] = useState(false)
|
||||||
@@ -42,20 +62,6 @@ const Forget: React.FC = () => {
|
|||||||
}
|
}
|
||||||
}, [isChanging])
|
}, [isChanging])
|
||||||
|
|
||||||
useUpdatedEffect(() => {
|
|
||||||
if (location.pathname !== '/forget') {
|
|
||||||
return
|
|
||||||
}
|
|
||||||
|
|
||||||
setTimeout(() => {
|
|
||||||
if (!searchParams.get('code')) {
|
|
||||||
turnstileRef.current?.execute()
|
|
||||||
} else {
|
|
||||||
retrieveTurnstileRef.current?.execute()
|
|
||||||
}
|
|
||||||
}, 500)
|
|
||||||
}, [location.pathname])
|
|
||||||
|
|
||||||
const handleOnSend = (forgetParam: ForgetParam) => {
|
const handleOnSend = (forgetParam: ForgetParam) => {
|
||||||
if (isSending) {
|
if (isSending) {
|
||||||
return
|
return
|
||||||
@@ -93,10 +99,6 @@ const Forget: React.FC = () => {
|
|||||||
|
|
||||||
const handleOnRetry = () => {
|
const handleOnRetry = () => {
|
||||||
setIsSent(false)
|
setIsSent(false)
|
||||||
|
|
||||||
setTimeout(() => {
|
|
||||||
turnstileRef.current?.execute()
|
|
||||||
}, 500)
|
|
||||||
}
|
}
|
||||||
|
|
||||||
const handleOnChange = (retrieveParam: RetrieveParam) => {
|
const handleOnChange = (retrieveParam: RetrieveParam) => {
|
||||||
@@ -162,7 +164,7 @@ const Forget: React.FC = () => {
|
|||||||
<AntdForm.Item>
|
<AntdForm.Item>
|
||||||
<Turnstile
|
<Turnstile
|
||||||
id={'forget-turnstile'}
|
id={'forget-turnstile'}
|
||||||
ref={turnstileRef}
|
ref={turnstileRefCallback}
|
||||||
siteKey={H_CAPTCHA_SITE_KEY}
|
siteKey={H_CAPTCHA_SITE_KEY}
|
||||||
options={{ theme: 'light', execution: 'execute' }}
|
options={{ theme: 'light', execution: 'execute' }}
|
||||||
onSuccess={setCaptchaCode}
|
onSuccess={setCaptchaCode}
|
||||||
@@ -234,7 +236,7 @@ const Forget: React.FC = () => {
|
|||||||
<AntdForm.Item>
|
<AntdForm.Item>
|
||||||
<Turnstile
|
<Turnstile
|
||||||
id={'retrieve-turnstile'}
|
id={'retrieve-turnstile'}
|
||||||
ref={retrieveTurnstileRef}
|
ref={retrieveTurnstileRefCallback}
|
||||||
siteKey={H_CAPTCHA_SITE_KEY}
|
siteKey={H_CAPTCHA_SITE_KEY}
|
||||||
options={{ theme: 'light', execution: 'execute' }}
|
options={{ theme: 'light', execution: 'execute' }}
|
||||||
onSuccess={setRetrieveCaptchaCode}
|
onSuccess={setRetrieveCaptchaCode}
|
||||||
|
|||||||
@@ -1,4 +1,4 @@
|
|||||||
import React from 'react'
|
import React, { useCallback } from 'react'
|
||||||
import Icon from '@ant-design/icons'
|
import Icon from '@ant-design/icons'
|
||||||
import { Turnstile, TurnstileInstance } from '@marsidev/react-turnstile'
|
import { Turnstile, TurnstileInstance } from '@marsidev/react-turnstile'
|
||||||
import {
|
import {
|
||||||
@@ -22,6 +22,15 @@ const SignIn: React.FC = () => {
|
|||||||
const navigate = useNavigate()
|
const navigate = useNavigate()
|
||||||
const [searchParams] = useSearchParams()
|
const [searchParams] = useSearchParams()
|
||||||
const turnstileRef = useRef<TurnstileInstance>()
|
const turnstileRef = useRef<TurnstileInstance>()
|
||||||
|
const turnstileRefCallback = useCallback(
|
||||||
|
(node: TurnstileInstance) => {
|
||||||
|
turnstileRef.current = node
|
||||||
|
if (location.pathname === '/login') {
|
||||||
|
turnstileRef.current?.execute()
|
||||||
|
}
|
||||||
|
},
|
||||||
|
[location.pathname]
|
||||||
|
)
|
||||||
const [isSigningIn, setIsSigningIn] = useState(false)
|
const [isSigningIn, setIsSigningIn] = useState(false)
|
||||||
const [captchaCode, setCaptchaCode] = useState('')
|
const [captchaCode, setCaptchaCode] = useState('')
|
||||||
|
|
||||||
@@ -33,15 +42,6 @@ const SignIn: React.FC = () => {
|
|||||||
}
|
}
|
||||||
}, [isSigningIn])
|
}, [isSigningIn])
|
||||||
|
|
||||||
useUpdatedEffect(() => {
|
|
||||||
if (location.pathname !== '/login') {
|
|
||||||
return
|
|
||||||
}
|
|
||||||
setTimeout(() => {
|
|
||||||
turnstileRef.current?.execute()
|
|
||||||
}, 500)
|
|
||||||
}, [turnstileRef])
|
|
||||||
|
|
||||||
const handleOnFinish = (loginParam: LoginParam) => {
|
const handleOnFinish = (loginParam: LoginParam) => {
|
||||||
if (isSigningIn) {
|
if (isSigningIn) {
|
||||||
return
|
return
|
||||||
@@ -165,7 +165,7 @@ const SignIn: React.FC = () => {
|
|||||||
<AntdForm.Item>
|
<AntdForm.Item>
|
||||||
<Turnstile
|
<Turnstile
|
||||||
id={'sign-in-turnstile'}
|
id={'sign-in-turnstile'}
|
||||||
ref={turnstileRef}
|
ref={turnstileRefCallback}
|
||||||
siteKey={H_CAPTCHA_SITE_KEY}
|
siteKey={H_CAPTCHA_SITE_KEY}
|
||||||
options={{ theme: 'light', execution: 'execute' }}
|
options={{ theme: 'light', execution: 'execute' }}
|
||||||
onSuccess={setCaptchaCode}
|
onSuccess={setCaptchaCode}
|
||||||
|
|||||||
@@ -1,4 +1,4 @@
|
|||||||
import React from 'react'
|
import React, { useCallback } from 'react'
|
||||||
import Icon from '@ant-design/icons'
|
import Icon from '@ant-design/icons'
|
||||||
import { Turnstile, TurnstileInstance } from '@marsidev/react-turnstile'
|
import { Turnstile, TurnstileInstance } from '@marsidev/react-turnstile'
|
||||||
import {
|
import {
|
||||||
@@ -17,6 +17,16 @@ const SignUp: React.FC = () => {
|
|||||||
const location = useLocation()
|
const location = useLocation()
|
||||||
const navigate = useNavigate()
|
const navigate = useNavigate()
|
||||||
const turnstileRef = useRef<TurnstileInstance>()
|
const turnstileRef = useRef<TurnstileInstance>()
|
||||||
|
const turnstileRefCallback = useCallback(
|
||||||
|
(node: TurnstileInstance) => {
|
||||||
|
turnstileRef.current = node
|
||||||
|
|
||||||
|
if (location.pathname === '/register') {
|
||||||
|
turnstileRef.current?.execute()
|
||||||
|
}
|
||||||
|
},
|
||||||
|
[location.pathname]
|
||||||
|
)
|
||||||
const [isSigningUp, setIsSigningUp] = useState(false)
|
const [isSigningUp, setIsSigningUp] = useState(false)
|
||||||
const [isFinish, setIsFinish] = useState(false)
|
const [isFinish, setIsFinish] = useState(false)
|
||||||
const [isSending, setIsSending] = useState(false)
|
const [isSending, setIsSending] = useState(false)
|
||||||
@@ -39,9 +49,6 @@ const SignUp: React.FC = () => {
|
|||||||
replace: true
|
replace: true
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
setTimeout(() => {
|
|
||||||
turnstileRef.current?.execute()
|
|
||||||
}, 500)
|
|
||||||
}, [location.pathname])
|
}, [location.pathname])
|
||||||
|
|
||||||
const handleOnFinish = (registerParam: RegisterParam) => {
|
const handleOnFinish = (registerParam: RegisterParam) => {
|
||||||
@@ -192,7 +199,7 @@ const SignUp: React.FC = () => {
|
|||||||
<AntdForm.Item>
|
<AntdForm.Item>
|
||||||
<Turnstile
|
<Turnstile
|
||||||
id={'sign-up-turnstile'}
|
id={'sign-up-turnstile'}
|
||||||
ref={turnstileRef}
|
ref={turnstileRefCallback}
|
||||||
siteKey={H_CAPTCHA_SITE_KEY}
|
siteKey={H_CAPTCHA_SITE_KEY}
|
||||||
options={{ theme: 'light', execution: 'execute' }}
|
options={{ theme: 'light', execution: 'execute' }}
|
||||||
onSuccess={setCaptchaCode}
|
onSuccess={setCaptchaCode}
|
||||||
|
|||||||
Reference in New Issue
Block a user