'use client' import { useEffect, useState } from 'react' import { useRouter, useParams } from 'next/navigation' import Link from 'next/link' import { toast } from 'sonner' import { Button } from '@/components/ui/button' import { Card, CardHeader, CardTitle, CardDescription, CardContent } from '@/components/ui/card' import { authAPI } from '@/lib/api' export default function VerifyEmailPage() { const router = useRouter() const params = useParams() const token = params.token as string const [status, setStatus] = useState<'verifying' | 'success' | 'error'>('verifying') const [message, setMessage] = useState('') useEffect(() => { const verifyEmail = async () => { try { const response = await authAPI.verifyEmail(token) setStatus('success') setMessage(response.message || 'Email verified successfully!') toast.success('Email verified successfully!') // Redirect to dashboard after 3 seconds setTimeout(() => { router.push('/dashboard') }, 3000) } catch (error: any) { setStatus('error') const errorMessage = error.response?.data?.message || 'Failed to verify email. The link may have expired.' setMessage(errorMessage) toast.error(errorMessage) } } if (token) { verifyEmail() } }, [token, router]) return (
{/* Logo */}
Website Monitor
Email Verification {status === 'verifying' && 'Verifying your email address...'} {status === 'success' && 'Your email has been verified'} {status === 'error' && 'Verification failed'} {status === 'verifying' && (

Please wait...

)} {status === 'success' && (

Email Verified!

{message}

Redirecting to dashboard...

)} {status === 'error' && (

Verification Failed

{message}

Possible reasons:

  • The verification link has expired (24 hours)
  • The link was already used
  • The link is invalid
Back to Login
)}
) }