diff --git a/src/components/auth/signin.tsx b/src/components/auth/signin.tsx index a5bc47e0..8a68d90d 100644 --- a/src/components/auth/signin.tsx +++ b/src/components/auth/signin.tsx @@ -22,6 +22,7 @@ import { import { useToast } from '../ui/use-toast'; import { DemarcationLine, GoogleOauthButton } from './social-auth'; import { PasswordInput } from '../password-input'; +import { LoadingSpinner } from '../loading-spinner'; export const Signin = () => { const { toast } = useToast(); @@ -40,10 +41,11 @@ export const Signin = () => { const response = await signIn('signin', { ...data, redirect: false }); if (!response?.ok) { const errorMessage = - response?.error?.includes('User') && response?.error?.includes('does not exist') + response?.error?.includes('User') && + response?.error?.includes('does not exist') ? 'User does not exist' : response?.error || 'Internal server error'; - + return toast({ title: errorMessage, variant: 'destructive', @@ -53,7 +55,7 @@ export const Signin = () => { title: 'Login successful! Welcome back!', variant: 'success', }); - + const searchParams = new URLSearchParams(window.location.search); const redirect = searchParams.get('next') || APP_PATHS.HOME; router.push(redirect); @@ -65,7 +67,7 @@ export const Signin = () => { }); } } - + return (
@@ -114,7 +116,13 @@ export const Signin = () => { className="w-full h-10" aria-label="submit" > - {form.formState.isSubmitting ? 'Please wait...' : 'Sign In'} + {form.formState.isSubmitting ? ( + <> + Please wait... + + ) : ( + 'Sign In' + )} diff --git a/src/components/auth/signup.tsx b/src/components/auth/signup.tsx index 5319d393..216209ca 100644 --- a/src/components/auth/signup.tsx +++ b/src/components/auth/signup.tsx @@ -23,6 +23,7 @@ import { useToast } from '../ui/use-toast'; import { signUp } from '@/actions/auth.actions'; import { DemarcationLine, GoogleOauthButton } from './social-auth'; import { PasswordInput } from '../password-input'; +import { LoadingSpinner } from '../loading-spinner'; export const Signup = () => { const { toast } = useToast(); @@ -121,7 +122,13 @@ export const Signup = () => { className="w-full h-10" aria-label="submit" > - {form.formState.isSubmitting ? 'Please wait...' : 'Create Account'} + {form.formState.isSubmitting ? ( + <> + Please wait... + + ) : ( + 'Create Account' + )} diff --git a/src/components/loading-spinner.tsx b/src/components/loading-spinner.tsx index 393f8060..8fe82bc7 100644 --- a/src/components/loading-spinner.tsx +++ b/src/components/loading-spinner.tsx @@ -1,9 +1,15 @@ 'use client'; +import { cn } from '@/lib/utils'; -export const LoadingSpinner = () => { +export const LoadingSpinner = (props: { className?: string }) => { return (
-
+
); };