-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
176 email verification landing page (#254)
* feat(verification): Added login form to verification page * feat(verification): added loading state to verification * feat(verification): fixed eslint complaints * feat(verification): changes after review * feat(verification): changed verification err message
- Loading branch information
Showing
1 changed file
with
28 additions
and
2 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,19 +1,45 @@ | ||
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}), | ||
}) | ||
|
||
useEffect(() => { | ||
typeof verificationKey === 'string' && verifyEmail(verificationKey) | ||
}, [verificationKey, verifyEmail]) | ||
|
||
return <>isEmailVerified = {String(isEmailVerified)}</> | ||
if (isError) | ||
return ( | ||
<Typography variant="body1"> | ||
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. | ||
</Typography> | ||
) | ||
if (isVerified) | ||
return ( | ||
<> | ||
<Typography variant="body1">Pre dokončenie overenia emailu sa prihlás</Typography> | ||
<LoginForm | ||
closeOverlay={() => { | ||
router.push('/') | ||
}} | ||
/> | ||
</> | ||
) | ||
return <Loading /> | ||
} |