/** * Verify Email Page * * Verify email address with token from email */ 'use client'; import { useState, useEffect } from 'react'; import { useSearchParams, useRouter } from 'next/navigation'; import { authApi } from '@/lib/api'; import Link from 'next/link'; export default function VerifyEmailPage() { const searchParams = useSearchParams(); const router = useRouter(); const [loading, setLoading] = useState(true); const [success, setSuccess] = useState(false); const [error, setError] = useState(''); useEffect(() => { const verifyEmail = async () => { const token = searchParams.get('token'); if (!token) { setError('Invalid verification link'); setLoading(false); return; } try { await authApi.verifyEmail(token); setSuccess(true); setTimeout(() => { router.push('/dashboard'); }, 3000); } catch (err: any) { setError( err.response?.data?.message || 'Email verification failed. The link may have expired.' ); } finally { setLoading(false); } }; verifyEmail(); }, [searchParams, router]); if (loading) { return (

Xpeditis

Verifying your email...

); } if (success) { return (

Xpeditis

Email verified successfully!

Your email has been verified successfully. You will be redirected to the dashboard in a few seconds...

Go to dashboard now
); } return (

Xpeditis

Verification failed

{error}

The verification link may have expired. Please request a new one.

Back to sign in
); }