From 9f2fd58eb0d732ec9af33c4f46cb0f7330c496ae Mon Sep 17 00:00:00 2001 From: javayhu Date: Sat, 16 Aug 2025 10:48:58 +0800 Subject: [PATCH] feat: optimize loading state in login and register forms --- src/components/auth/login-form.tsx | 4 ++++ src/components/auth/register-form.tsx | 8 ++++++-- 2 files changed, 10 insertions(+), 2 deletions(-) diff --git a/src/components/auth/login-form.tsx b/src/components/auth/login-form.tsx index 60145a0..66af4e9 100644 --- a/src/components/auth/login-form.tsx +++ b/src/components/auth/login-form.tsx @@ -95,6 +95,10 @@ export const LoginForm = ({ const onSubmit = async (values: z.infer) => { // Validate captcha token if turnstile is enabled and site key is available if (captchaConfigured && values.captchaToken) { + setIsPending(true); + setError(''); + setSuccess(''); + const captchaResult = await validateCaptchaAction({ captchaToken: values.captchaToken, }); diff --git a/src/components/auth/register-form.tsx b/src/components/auth/register-form.tsx index ea0dbba..b5e7d09 100644 --- a/src/components/auth/register-form.tsx +++ b/src/components/auth/register-form.tsx @@ -94,6 +94,10 @@ export const RegisterForm = ({ const onSubmit = async (values: z.infer) => { // Validate captcha token if turnstile is enabled and site key is available if (captchaConfigured && values.captchaToken) { + setIsPending(true); + setError(''); + setSuccess(''); + const captchaResult = await validateCaptchaAction({ captchaToken: values.captchaToken, }); @@ -119,13 +123,13 @@ export const RegisterForm = ({ }, { onRequest: (ctx) => { - console.log('register, request:', ctx.url); + // console.log('register, request:', ctx.url); setIsPending(true); setError(''); setSuccess(''); }, onResponse: (ctx) => { - console.log('register, response:', ctx.response); + // console.log('register, response:', ctx.response); setIsPending(false); }, onSuccess: (ctx) => {