import VerifyLetterIcon from '../../icons/verify-letter.svg'; import { useEffect, useState } from 'preact/hooks'; import { httpPost } from '../../lib/http'; 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 = () => { httpPost(`${import.meta.env.PUBLIC_API_URL}/v1-send-verification-email`, { email, }) .then(({ response, error }) => { if (error) { setIsEmailResent(false); setError(error?.message || 'Something went wrong.'); setIsLoading(false); return; } 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!
)}