diff --git a/packages/frontpage/app/(auth)/login/_lib/form.tsx b/packages/frontpage/app/(auth)/login/_lib/form.tsx index cab15406..5a468cb9 100644 --- a/packages/frontpage/app/(auth)/login/_lib/form.tsx +++ b/packages/frontpage/app/(auth)/login/_lib/form.tsx @@ -1,6 +1,6 @@ "use client"; -import { startTransition, useActionState } from "react"; +import { startTransition, Suspense, useActionState } from "react"; import { loginAction } from "./action"; import { Label } from "@/lib/components/ui/label"; import { Input } from "@/lib/components/ui/input"; @@ -11,8 +11,6 @@ import { CrossCircledIcon } from "@radix-ui/react-icons"; export function LoginForm() { const [state, action, isPending] = useActionState(loginAction, null); - const searchParams = useSearchParams(); - const error = state?.error ?? searchParams.get("error"); return ( <> @@ -36,13 +34,22 @@ export function LoginForm() { - {error ? ( - - - Login error - {error} - - ) : null} + + + ); } + +function LoginError({ errorState }: { errorState?: string }) { + const searchParams = useSearchParams(); + const error = errorState ?? searchParams.get("error"); + if (!error) return null; + return ( + + + Login error + {error} + + ); +}