Skip to content

Commit

Permalink
176 email verification landing page (#254)
Browse files Browse the repository at this point in the history
* 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
vgeffer authored Dec 8, 2023
1 parent e580299 commit e1731f1
Showing 1 changed file with 28 additions and 2 deletions.
30 changes: 28 additions & 2 deletions src/components/VerifyEmail/VerifyEmail.tsx
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 />
}

0 comments on commit e1731f1

Please sign in to comment.