feat: optimize loading state in login and register forms
This commit is contained in:
parent
9f71c9942a
commit
9f2fd58eb0
@ -95,6 +95,10 @@ export const LoginForm = ({
|
|||||||
const onSubmit = async (values: z.infer<typeof LoginSchema>) => {
|
const onSubmit = async (values: z.infer<typeof LoginSchema>) => {
|
||||||
// Validate captcha token if turnstile is enabled and site key is available
|
// Validate captcha token if turnstile is enabled and site key is available
|
||||||
if (captchaConfigured && values.captchaToken) {
|
if (captchaConfigured && values.captchaToken) {
|
||||||
|
setIsPending(true);
|
||||||
|
setError('');
|
||||||
|
setSuccess('');
|
||||||
|
|
||||||
const captchaResult = await validateCaptchaAction({
|
const captchaResult = await validateCaptchaAction({
|
||||||
captchaToken: values.captchaToken,
|
captchaToken: values.captchaToken,
|
||||||
});
|
});
|
||||||
|
@ -94,6 +94,10 @@ export const RegisterForm = ({
|
|||||||
const onSubmit = async (values: z.infer<typeof RegisterSchema>) => {
|
const onSubmit = async (values: z.infer<typeof RegisterSchema>) => {
|
||||||
// Validate captcha token if turnstile is enabled and site key is available
|
// Validate captcha token if turnstile is enabled and site key is available
|
||||||
if (captchaConfigured && values.captchaToken) {
|
if (captchaConfigured && values.captchaToken) {
|
||||||
|
setIsPending(true);
|
||||||
|
setError('');
|
||||||
|
setSuccess('');
|
||||||
|
|
||||||
const captchaResult = await validateCaptchaAction({
|
const captchaResult = await validateCaptchaAction({
|
||||||
captchaToken: values.captchaToken,
|
captchaToken: values.captchaToken,
|
||||||
});
|
});
|
||||||
@ -119,13 +123,13 @@ export const RegisterForm = ({
|
|||||||
},
|
},
|
||||||
{
|
{
|
||||||
onRequest: (ctx) => {
|
onRequest: (ctx) => {
|
||||||
console.log('register, request:', ctx.url);
|
// console.log('register, request:', ctx.url);
|
||||||
setIsPending(true);
|
setIsPending(true);
|
||||||
setError('');
|
setError('');
|
||||||
setSuccess('');
|
setSuccess('');
|
||||||
},
|
},
|
||||||
onResponse: (ctx) => {
|
onResponse: (ctx) => {
|
||||||
console.log('register, response:', ctx.response);
|
// console.log('register, response:', ctx.response);
|
||||||
setIsPending(false);
|
setIsPending(false);
|
||||||
},
|
},
|
||||||
onSuccess: (ctx) => {
|
onSuccess: (ctx) => {
|
||||||
|
Loading…
Reference in New Issue
Block a user