feat: optimize loading state in login and register forms

This commit is contained in:
javayhu 2025-08-16 10:48:58 +08:00
parent 9f71c9942a
commit 9f2fd58eb0
2 changed files with 10 additions and 2 deletions

View File

@ -95,6 +95,10 @@ export const LoginForm = ({
const onSubmit = async (values: z.infer<typeof LoginSchema>) => {
// 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,
});

View File

@ -94,6 +94,10 @@ export const RegisterForm = ({
const onSubmit = async (values: z.infer<typeof RegisterSchema>) => {
// 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) => {