diff --git a/src/components/Login/EmailSignupForm.tsx b/src/components/Login/EmailSignupForm.tsx index 1cacffc02..7dbb51b4c 100644 --- a/src/components/Login/EmailSignupForm.tsx +++ b/src/components/Login/EmailSignupForm.tsx @@ -19,7 +19,7 @@ const EmailSignupForm: FunctionComponent = () => { return; } - window.location.href = `/verify?email=${email}`; + window.location.href = `/verification-pending?email=${encodeURIComponent(email)}`; }; const onSubmit = (e: Event) => { diff --git a/src/components/RegistrationFlow/VerificationEmailMessage.tsx b/src/components/RegistrationFlow/VerificationEmailMessage.tsx new file mode 100644 index 000000000..9a7c43d07 --- /dev/null +++ b/src/components/RegistrationFlow/VerificationEmailMessage.tsx @@ -0,0 +1,84 @@ +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 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 &&Email sent!
} +- Check your inbox at john@example.com and click the verification link inside to complete your registration. - This link will expire shortly, so verify soon! -
- -