Add auto-resend effect with localStorage guard
cgen-8ed044ff2dcf45f39af440d1435c9384
This commit is contained in:
parent
c90c63a0a9
commit
0f671b2eec
1 changed files with 26 additions and 0 deletions
|
|
@ -299,6 +299,32 @@ export default function Welcome({
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
const autoResendTriggeredRef = useRef(false);
|
||||||
|
useEffect(() => {
|
||||||
|
if (typeof window === "undefined") return;
|
||||||
|
if (!emailAddress) return;
|
||||||
|
if (isVerified) return;
|
||||||
|
if (autoResendTriggeredRef.current) return;
|
||||||
|
|
||||||
|
const key = `auto_resend_v1:${String(emailAddress).toLowerCase()}`;
|
||||||
|
try {
|
||||||
|
if (window.localStorage.getItem(key) === "1") return;
|
||||||
|
autoResendTriggeredRef.current = true;
|
||||||
|
window.localStorage.setItem(key, "1");
|
||||||
|
// Fire-and-forget; handler manages its own toasts/states
|
||||||
|
handleResendVerification().catch(() => {
|
||||||
|
/* ignore */
|
||||||
|
});
|
||||||
|
} catch {
|
||||||
|
if (!autoResendTriggeredRef.current) {
|
||||||
|
autoResendTriggeredRef.current = true;
|
||||||
|
handleResendVerification().catch(() => {
|
||||||
|
/* ignore */
|
||||||
|
});
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}, [emailAddress, isVerified]);
|
||||||
|
|
||||||
const VerificationIcon = isVerified ? MailCheck : MailWarning;
|
const VerificationIcon = isVerified ? MailCheck : MailWarning;
|
||||||
const verificationBorderClass = isVerified
|
const verificationBorderClass = isVerified
|
||||||
? "border-emerald-500/40"
|
? "border-emerald-500/40"
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue