From 871befd1b87046f62f1af41b8254316c7a6ae4a9 Mon Sep 17 00:00:00 2001 From: vgeffer Date: Fri, 8 Dec 2023 23:28:54 +0100 Subject: [PATCH] feat(verification): added loading state to verification --- src/components/VerifyEmail/VerifyEmail.tsx | 22 ++++++++++++++-------- 1 file changed, 14 insertions(+), 8 deletions(-) diff --git a/src/components/VerifyEmail/VerifyEmail.tsx b/src/components/VerifyEmail/VerifyEmail.tsx index 3fe1a021..3487a8c8 100644 --- a/src/components/VerifyEmail/VerifyEmail.tsx +++ b/src/components/VerifyEmail/VerifyEmail.tsx @@ -8,7 +8,7 @@ export const VerifyEmail: FC = () => { const router = useRouter() const {verificationKey} = router.query - const {mutate: verifyEmail, isSuccess: isEmailVerified} = useMutation({ + const {mutate: verifyEmail, isError: isError, isSuccess: isVerified} = useMutation({ mutationFn: (verificationKey: string) => axios.post('/api/user/registration/verify-email', {key: verificationKey}), }) @@ -17,13 +17,19 @@ export const VerifyEmail: FC = () => { }, [verificationKey, verifyEmail]) - if (!isEmailVerified) + + + if (isError) return <>I am a temporary email verification error. Please put me out of my misery. - return ( - <> -

Pre dokončenie overenia emailu sa prihláste

- { router.push("/") }}/> - - ) + else if (isVerified) + return ( + <> +

Pre dokončenie overenia emailu sa prihláste

+ { router.push("/") }}/> + + ) + + else + return <>Loading... }