import { signIn } from "next-auth/react"; import Link from "next/link"; import { FormProvider, SubmitHandler, useForm } from "react-hook-form"; import Logo from "./logo"; type FormValues = { username: string; email: string; password: string; passwordcheck: string; apiError: string; }; export default function Signup() { const methods = useForm({}); const { register, formState: { errors, isSubmitting }, } = methods; const handleErrors = async (resp: Response) => { if (!resp.ok) { const err = await resp.json(); throw new Error(err.message); } }; const signUp: SubmitHandler = async (data) => { await fetch("/api/auth/signup", { body: JSON.stringify({ ...data, }), headers: { "Content-Type": "application/json", }, method: "POST", }) .then(handleErrors) .then(async () => { await signIn<"credentials">("credentials", { ...data, callbackUrl: "http://localhost:3000/dashboard", }); }) .catch((err) => { methods.setError("apiError", { message: err.message }); }); }; return ( <>

Create a shiny, new

Documenso Account{" "}

Create your account and start using

state-of-the-art document signing for free.

Already have an account?{" "} Sign In

); }