From ec8ea14ed2b13c9dd9688b7e8573b3288eec6625 Mon Sep 17 00:00:00 2001 From: rgrgogu Date: Thu, 16 Jul 2026 02:49:23 +0800 Subject: [PATCH] added more new --- src/modules/auth/components/RegisterForm.jsx | 65 ++++++++++++++++---- 1 file changed, 54 insertions(+), 11 deletions(-) diff --git a/src/modules/auth/components/RegisterForm.jsx b/src/modules/auth/components/RegisterForm.jsx index 8f2a397..07e88b9 100644 --- a/src/modules/auth/components/RegisterForm.jsx +++ b/src/modules/auth/components/RegisterForm.jsx @@ -159,6 +159,11 @@ export function RegisterForm({ className, ...props }) { const [isResuming, setIsResuming] = useState(false) const [pendingCreds, setPendingCreds] = useState(null) + // ── Confirm-before-create (asked before the register request ever fires) ── + const [confirmCreateOpen, setConfirmCreateOpen] = useState(false) + const [isCreating, setIsCreating] = useState(false) + const [pendingCredsData, setPendingCredsData] = useState(null) + // ── Warn before the tab is closed/reloaded mid-registration ──────────────── // Once the user reaches Credentials, submitting can already create a // server-side account + send an OTP — losing the tab here (slow internet, @@ -262,7 +267,24 @@ export function RegisterForm({ className, ...props }) { setStep(2) } - const onCredentialsSubmit = (data) => submitRegistration(data) + // Validated credentials don't submit yet — stage them and ask for explicit + // confirmation first, since this is the step that actually creates the + // server-side account and sends an OTP. + const onCredentialsSubmit = (data) => { + setPendingCredsData(data) + setConfirmCreateOpen(true) + } + + const handleConfirmCreate = async () => { + if (!pendingCredsData) return + setIsCreating(true) + try { + await submitRegistration(pendingCredsData) + } finally { + setIsCreating(false) + setConfirmCreateOpen(false) + } + } const handleConfirmResume = async () => { if (!pendingCreds) return @@ -440,7 +462,7 @@ export function RegisterForm({ className, ...props }) {

@@ -581,15 +603,8 @@ export function RegisterForm({ className, ...props }) { > ← Back - @@ -624,6 +639,34 @@ export function RegisterForm({ className, ...props }) { + !isCreating && setConfirmCreateOpen(open)}> + + + Create this account? + + We'll create your account with{' '} + {pendingCredsData?.email}{' '} + and email a 6-digit verification code to that address. + + + + + + {isCreating ? ( + + + Creating... + + ) : ( + 'Proceed' + )} + + + + + !isResuming && setResumeDialogOpen(open)}>