Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
28 changes: 21 additions & 7 deletions frontend/src/components/register/Register.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -181,6 +181,7 @@ function Register() {
const [alert_message, setalert_message] = useState("");
const [otp_alert_box, setotp_alert_box] = useState(false);
const [otp_alert_message, setotp_alert_message] = useState("");
const [verificationEmailSent, setVerificationEmailSent] = useState(false);
const [date_validation, setdate_validation] = useState(false);
const [password_validation, setpassword_validation] = useState(false);
const [user_values, setuser_values] = useState({
Expand Down Expand Up @@ -266,7 +267,9 @@ function Register() {
});
const data = await res.json();
if (data.status === 201) {
if (data.email_sent === false) {
const emailSent = data.email_sent !== false;
setVerificationEmailSent(emailSent);
if (!emailSent) {
setotp_alert_message(
"We couldn't send the verification email. Click Resend."
);
Expand Down Expand Up @@ -345,6 +348,7 @@ function Register() {
});
const data = await res.json();
if (data.status === 201) {
setVerificationEmailSent(data.email_sent !== false);
setotp_alert_message(
data.email_sent === false
? "Couldn't send email. Please try again."
Expand Down Expand Up @@ -602,6 +606,7 @@ function Register() {
setotp_value("");
setotp_alert_box(false);
setotp_alert_message("");
setVerificationEmailSent(false);
}
}}
>
Expand Down Expand Up @@ -636,10 +641,19 @@ function Register() {
className="text-center text-sm mt-1"
style={{ color: "rgba(255,255,255,0.45)" }}
>
We sent a verification code to{" "}
<span className="font-semibold" style={{ color: "rgba(255,255,255,0.7)" }}>
{user_values.email}
</span>
{verificationEmailSent ? (
<>
We sent a verification code to{" "}
<span className="font-semibold" style={{ color: "rgba(255,255,255,0.7)" }}>
{user_values.email}
</span>
</>
) : (
<>
We couldn't send the verification email yet. Click Resend to try
again.
</>
)}
</DialogDescription>
{otp_alert_box && (
<div className="mt-4">
Expand All @@ -657,7 +671,7 @@ function Register() {
onChange={handle_otp}
inputMode="numeric"
autoFocus
disabled={verifying}
disabled={verifying || !verificationEmailSent}
placeholder="Enter code"
style={{ textAlign: "center", letterSpacing: "0.3em", fontSize: "1.1rem" }}
/>
Expand Down Expand Up @@ -686,7 +700,7 @@ function Register() {

<PrimaryButton
type="submit"
disabled={otp_value.trim() === "" || verifying}
disabled={otp_value.trim() === "" || verifying || !verificationEmailSent}
style={{ flex: 1 }}
>
{verifying ? (
Expand Down