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
21 changes: 14 additions & 7 deletions apps/web/ui/auth/register/verify-email-form.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -51,12 +51,19 @@ export const VerifyEmailForm = () => {
return;
}

const handleVerify = (completedCode?: string) => {
if (isPending || isRedirecting) return;
const finalCode = (completedCode ?? code).trim();
if (!finalCode || finalCode.length < 6) return;
executeAsync({ email, password, code: finalCode });
};

return (
<div className="flex flex-col gap-3">
<form
onSubmit={(e) => {
e.preventDefault();
executeAsync({ email, password, code });
handleVerify();
}}
>
<div>
Expand All @@ -65,7 +72,7 @@ export const VerifyEmailForm = () => {
value={code}
onChange={(code) => {
setIsInvalidCode(false);
setCode(code);
setCode(code.trim());
}}
autoFocus={!isMobile}
render={({ slots }) => (
Expand All @@ -85,14 +92,14 @@ export const VerifyEmailForm = () => {
{hasFakeCaret && (
<div className="animate-caret-blink pointer-events-none absolute inset-0 flex items-center justify-center">
<div className="h-5 w-px bg-black" />
</div>
</div>
)}
</div>
))}
</div>
)}
onComplete={() => {
executeAsync({ email, password, code });
onComplete={(completedCode) => {
handleVerify(completedCode);
}}
/>
<AnimatedSizeContainer height>
Expand All @@ -108,12 +115,12 @@ export const VerifyEmailForm = () => {
text={isPending ? "Verifying..." : "Continue"}
type="submit"
loading={isPending || isRedirecting}
disabled={!code || code.length < 6}
disabled={isPending || isRedirecting || code.length < 6}
/>
</div>
</form>

<ResendOtp email={email} />
</div>
);
};
};