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 4 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
24 changes: 22 additions & 2 deletions src/components/VerifyEmail/VerifyEmail.tsx
Original file line number Diff line number Diff line change
@@ -1,19 +1,39 @@
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ý, skús sa prihlásiť.</Typography>
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

hmm ale padnut by to mohlo asi aj kvoli networku alebo hocicomu inemu... asi by som radsej dal aj tu moznost, nejako takto:

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 (
<>
<Typography variant="body1">Pre dokončenie overenia emailu sa prihláste</Typography>
<LoginForm
closeOverlay={() => {
router.push('/')
}}
/>
</>
)
return <Loading />
}
Loading