diff --git a/apps/web/components/signup.tsx b/apps/web/components/signup.tsx index 2dacf1831..ff6c726b8 100644 --- a/apps/web/components/signup.tsx +++ b/apps/web/components/signup.tsx @@ -1,3 +1,4 @@ +import { XCircleIcon } from "@heroicons/react/24/outline"; import { signIn } from "next-auth/react"; import Link from "next/link"; import { FormProvider, SubmitHandler, useForm } from "react-hook-form"; @@ -8,7 +9,6 @@ type FormValues = { username: string; email: string; password: string; - passwordcheck: string; apiError: string; }; @@ -27,6 +27,7 @@ export default function Signup() { }; const signUp: SubmitHandler = async (data) => { + methods.clearErrors(); await fetch("/api/auth/signup", { body: JSON.stringify({ ...data, @@ -48,6 +49,24 @@ export default function Signup() { }); }; + function renderApiError() { + if (!errors.apiError) return; + return ( +
+
+
+
+
+

+ {errors.apiError &&
{errors.apiError?.message}
} +

+
+
+
+ ); + } + return ( <>
@@ -74,6 +93,7 @@ export default function Signup() { state-of-the-art document signing for free.

+ {renderApiError()}