diff --git a/apps/web/src/components/AuthForm.tsx b/apps/web/src/components/AuthForm.tsx index f80fd0360..6f9726a32 100644 --- a/apps/web/src/components/AuthForm.tsx +++ b/apps/web/src/components/AuthForm.tsx @@ -2,10 +2,7 @@ import Link from 'next/link' import { Auth } from '@supabase/auth-ui-react' -import { - ThemeSupa, - ViewType, -} from '@supabase/auth-ui-shared' +import { ThemeSupa, ViewType } from '@supabase/auth-ui-shared' import { createClientComponentClient } from '@supabase/auth-helpers-nextjs' import { useSearchParams, useRouter } from 'next/navigation' import { useEffect } from 'react' @@ -20,19 +17,22 @@ export interface Props { function AuthForm({ view }: Props) { const searchParams = useSearchParams() - const redirectTo = searchParams?.get('redirect_to') || undefined + const redirectTo = searchParams?.get('redirect_to') || '/dashboard' const router = useRouter() const user = useUser() - useEffect(function redirect() { - if (user.user && redirectTo) { - router.push(redirectTo) - } + useEffect( + function redirect() { + if (user.user && redirectTo) { + router.push(redirectTo) + } - if (user.wasUpdated && !redirectTo) { - router.push('/dashboard') - } - }, [user.user, router, redirectTo, view, user.wasUpdated]) + if (user.wasUpdated && !redirectTo) { + router.push('/dashboard') + } + }, + [user.user, router, redirectTo, view, user.wasUpdated] + ) return (