Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

176 email verification landing page #254

Merged
merged 5 commits into from
Dec 8, 2023
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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 />
}
Loading