diff --git a/src/components/VerifyEmail/VerifyEmail.tsx b/src/components/VerifyEmail/VerifyEmail.tsx index bd3cb5ff..5522f452 100644 --- a/src/components/VerifyEmail/VerifyEmail.tsx +++ b/src/components/VerifyEmail/VerifyEmail.tsx @@ -1,13 +1,21 @@ +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 = () => { 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}), }) @@ -15,5 +23,23 @@ export const VerifyEmail: FC = () => { typeof verificationKey === 'string' && verifyEmail(verificationKey) }, [verificationKey, verifyEmail]) - return <>isEmailVerified = {String(isEmailVerified)} + 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ás + { + router.push('/') + }} + /> + + ) + return }