import VerifyLetterIcon from '../../icons/verify-letter.svg'; import { useEffect, useState } from 'preact/hooks'; export function VerificationEmailMessage() { const [email, setEmail] = useState('..'); const [error, setError] = useState(''); const [isLoading, setIsLoading] = useState(false); const [isEmailResent, setIsEmailResent] = useState(false); useEffect(() => { const urlParams = new URLSearchParams(window.location.search); setEmail(urlParams.get('email')!); }, []); const resendVerificationEmail = () => { fetch(`${import.meta.env.PUBLIC_API_URL}/v1-send-verification-email`, { method: 'POST', headers: { 'Content-Type': 'application/json', }, body: JSON.stringify({ email, }), }) .then((res) => { if (!res.ok) { throw new Error('Something went wrong. Please try again later.'); } setIsEmailResent(true); }) .catch(() => { setIsEmailResent(false); setIsLoading(false); setError('Something went wrong. Please try again later.'); }); }; return (
We have sent you an email at {email}. Please click the link to verify your account. This link will expire shortly, so please verify soon!
Sending the email ..
} {!isLoading && !error && (Please make sure to check your spam folder. If you still don't have the email click to{' '}
)} {error &&{error}
} > )} {isEmailResent &&Verification email has been sent!
}