From 8ea7e785a18fb7f2d8987e1c2e915844837299ca Mon Sep 17 00:00:00 2001 From: vgeffer Date: Fri, 8 Dec 2023 23:18:53 +0100 Subject: [PATCH 1/5] feat(verification): Added login form to verification page --- src/components/VerifyEmail/VerifyEmail.tsx | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) diff --git a/src/components/VerifyEmail/VerifyEmail.tsx b/src/components/VerifyEmail/VerifyEmail.tsx index bd3cb5ff..3fe1a021 100644 --- a/src/components/VerifyEmail/VerifyEmail.tsx +++ b/src/components/VerifyEmail/VerifyEmail.tsx @@ -2,6 +2,7 @@ import {useMutation} from '@tanstack/react-query' import axios from 'axios' import {useRouter} from 'next/router' import {FC, useEffect} from 'react' +import {LoginForm} from '../PageLayout/LoginForm/LoginForm' export const VerifyEmail: FC = () => { const router = useRouter() @@ -15,5 +16,14 @@ export const VerifyEmail: FC = () => { typeof verificationKey === 'string' && verifyEmail(verificationKey) }, [verificationKey, verifyEmail]) - return <>isEmailVerified = {String(isEmailVerified)} + + if (!isEmailVerified) + 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("/") }}/> + + ) } From 871befd1b87046f62f1af41b8254316c7a6ae4a9 Mon Sep 17 00:00:00 2001 From: vgeffer Date: Fri, 8 Dec 2023 23:28:54 +0100 Subject: [PATCH 2/5] 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... } From 34f5e521e3fb5ef73c1993138480187248fbd878 Mon Sep 17 00:00:00 2001 From: vgeffer Date: Fri, 8 Dec 2023 23:45:23 +0100 Subject: [PATCH 3/5] feat(verification): fixed eslint complaints --- src/components/VerifyEmail/VerifyEmail.tsx | 24 ++++++++++++---------- 1 file changed, 13 insertions(+), 11 deletions(-) diff --git a/src/components/VerifyEmail/VerifyEmail.tsx b/src/components/VerifyEmail/VerifyEmail.tsx index 3487a8c8..78ab10cb 100644 --- a/src/components/VerifyEmail/VerifyEmail.tsx +++ b/src/components/VerifyEmail/VerifyEmail.tsx @@ -2,13 +2,18 @@ import {useMutation} from '@tanstack/react-query' import axios from 'axios' import {useRouter} from 'next/router' import {FC, useEffect} from 'react' + import {LoginForm} from '../PageLayout/LoginForm/LoginForm' export const VerifyEmail: FC = () => { const router = useRouter() const {verificationKey} = router.query - const {mutate: verifyEmail, isError: isError, isSuccess: isVerified} = useMutation({ + const { + mutate: verifyEmail, + isError: isError, + isSuccess: isVerified, + } = useMutation({ mutationFn: (verificationKey: string) => axios.post('/api/user/registration/verify-email', {key: verificationKey}), }) @@ -16,20 +21,17 @@ export const VerifyEmail: FC = () => { typeof verificationKey === 'string' && verifyEmail(verificationKey) }, [verificationKey, verifyEmail]) - - - - if (isError) - return <>I am a temporary email verification error. Please put me out of my misery. - + if (isError) return <>I am a temporary email verification error. Please put me out of my misery. else if (isVerified) return ( <>

Pre dokončenie overenia emailu sa prihláste

- { router.push("/") }}/> + { + router.push('/') + }} + /> ) - - else - return <>Loading... + else return <>Loading... } From d1bfc51a8c2943a41e07cbcf8da056f198698003 Mon Sep 17 00:00:00 2001 From: vgeffer Date: Fri, 8 Dec 2023 23:58:44 +0100 Subject: [PATCH 4/5] feat(verification): changes after review --- src/components/VerifyEmail/VerifyEmail.tsx | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/src/components/VerifyEmail/VerifyEmail.tsx b/src/components/VerifyEmail/VerifyEmail.tsx index 78ab10cb..babe712f 100644 --- a/src/components/VerifyEmail/VerifyEmail.tsx +++ b/src/components/VerifyEmail/VerifyEmail.tsx @@ -1,8 +1,10 @@ +import {Typography} from '@mui/material' import {useMutation} from '@tanstack/react-query' import axios from 'axios' import {useRouter} from 'next/router' import {FC, useEffect} from 'react' +import {Loading} from '../Loading/Loading' import {LoginForm} from '../PageLayout/LoginForm/LoginForm' export const VerifyEmail: FC = () => { @@ -21,11 +23,11 @@ export const VerifyEmail: FC = () => { typeof verificationKey === 'string' && verifyEmail(verificationKey) }, [verificationKey, verifyEmail]) - if (isError) return <>I am a temporary email verification error. Please put me out of my misery. - else if (isVerified) + if (isError) return Email už bol verifikovaný, skús sa prihlásiť. + if (isVerified) return ( <> -

Pre dokončenie overenia emailu sa prihláste

+ Pre dokončenie overenia emailu sa prihláste { router.push('/') @@ -33,5 +35,5 @@ export const VerifyEmail: FC = () => { /> ) - else return <>Loading... + return } From ea82ea17a5826ccf210db3d0244986fe227dd1b7 Mon Sep 17 00:00:00 2001 From: vgeffer Date: Sat, 9 Dec 2023 00:07:14 +0100 Subject: [PATCH 5/5] feat(verification): changed verification err message --- src/components/VerifyEmail/VerifyEmail.tsx | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/src/components/VerifyEmail/VerifyEmail.tsx b/src/components/VerifyEmail/VerifyEmail.tsx index babe712f..5522f452 100644 --- a/src/components/VerifyEmail/VerifyEmail.tsx +++ b/src/components/VerifyEmail/VerifyEmail.tsx @@ -23,11 +23,17 @@ export const VerifyEmail: FC = () => { typeof verificationKey === 'string' && verifyEmail(verificationKey) }, [verificationKey, verifyEmail]) - if (isError) return Email už bol verifikovaný, skús sa prihlásiť. + if (isError) + return ( + + Email už bol verifikovaný, alebo nastal iný problém. Skús sa prihlásiť a v prípade problémov skús overiť email + znovu alebo nás kontaktuj. + + ) if (isVerified) return ( <> - Pre dokončenie overenia emailu sa prihláste + Pre dokončenie overenia emailu sa prihlás { router.push('/')