diff --git a/src/components/Login/OtpPage.tsx b/src/components/Login/OtpPage.tsx index 318f56f4..33e2d214 100644 --- a/src/components/Login/OtpPage.tsx +++ b/src/components/Login/OtpPage.tsx @@ -24,6 +24,7 @@ const TIME_LEFT = 60; // seconds before next otp request interface OtpProps { email?: string; + busy?: boolean; onRequestLogin: (idToken: string) => void | Promise; } @@ -33,7 +34,7 @@ const validationSchema = yup }) .required(); -export const OtpPage = ({ email, onRequestLogin }: OtpProps) => { +export const OtpPage = ({ email, onRequestLogin, busy = false }: OtpProps) => { const location = useLocation(); const navigate = useNavigate(); const [timeLeft, setTimeLeft] = useState(TIME_LEFT); @@ -161,7 +162,7 @@ export const OtpPage = ({ email, onRequestLogin }: OtpProps) => { )} - + {errors.root ? 'Retry' : 'Verify'} {timeLeft ? ( diff --git a/src/routes/Authorize/AuthorizeLink.tsx b/src/routes/Authorize/AuthorizeLink.tsx index 51d49c47..6e161dc6 100644 --- a/src/routes/Authorize/AuthorizeLink.tsx +++ b/src/routes/Authorize/AuthorizeLink.tsx @@ -20,7 +20,7 @@ const AuthorizeLink = () => { const [query] = useSearchParams(); const encodedState = query.get('state'); const state = useMemo(() => parseState(encodedState), [encodedState]); - const [email, linkCode, otp, appName] = state || []; + const [email, otp, linkCode, appName] = state || []; const error = !state || validationError; useEffect(() => { @@ -48,12 +48,14 @@ const AuthorizeLink = () => { : 'The login link is invalid or expired. Please try again.'; return ( - + {title} - {message} + + {message} + ); }; diff --git a/src/routes/Authorize/AuthorizeOtp.tsx b/src/routes/Authorize/AuthorizeOtp.tsx index e422bc9b..ef47dc86 100644 --- a/src/routes/Authorize/AuthorizeOtp.tsx +++ b/src/routes/Authorize/AuthorizeOtp.tsx @@ -1,5 +1,5 @@ import { observer } from 'mobx-react-lite'; -import { useCallback, useEffect } from 'react'; +import { useCallback, useEffect, useState } from 'react'; import { Stack, useIsMobile, useTheme, ArrowBackIosIcon } from '@cere-wallet/ui'; import { useLocation, useNavigate, useOutletContext } from 'react-router-dom'; @@ -16,6 +16,7 @@ const AuthorizeOtp = ({ sendOtp }: AuthorizeOtpProps) => { const isMobile = useIsMobile(); const location = useLocation(); const navigate = useNavigate(); + const [isBusy, setBusy] = useState(false); const store = useOutletContext(); const { whiteLabel } = useAppContextStore(); const { isGame } = useTheme(); @@ -27,6 +28,7 @@ const AuthorizeOtp = ({ sendOtp }: AuthorizeOtpProps) => { const handleLoginRequest = useCallback( async (idToken: string) => { + setBusy(true); const { isNewUser } = await store.login(idToken); if ( @@ -42,6 +44,7 @@ const AuthorizeOtp = ({ sendOtp }: AuthorizeOtpProps) => { } await store.acceptSession(); + setBusy(false); }, [location, navigate, store, whiteLabel], ); @@ -67,7 +70,7 @@ const AuthorizeOtp = ({ sendOtp }: AuthorizeOtpProps) => { {hasBackButton && navigate(-1)} />} - + ); @@ -85,7 +88,7 @@ const AuthorizeOtp = ({ sendOtp }: AuthorizeOtpProps) => { - +