♻️ signup

This commit is contained in:
Timur Ercan
2023-03-01 15:18:45 +01:00
parent 5e70b4620c
commit 74f5f830fe
3 changed files with 16 additions and 12 deletions

View File

@ -1,3 +1,4 @@
import { signup } from "@documenso/lib/api";
import { NEXT_PUBLIC_WEBAPP_URL } from "@documenso/lib/constants";
import { Button } from "@documenso/ui";
import { XCircleIcon } from "@heroicons/react/24/outline";
@ -30,19 +31,9 @@ export default function Signup(props: { source: string }) {
};
const signUp: SubmitHandler<FormValues> = async (data) => {
// todo encapsulate
const res = await toast
await toast
.promise(
fetch("/api/auth/signup", {
body: JSON.stringify({
source: props.source,
...data,
}),
headers: {
"Content-Type": "application/json",
},
method: "POST",
})
signup(props.source, data)
.then(handleErrors)
.then(async () => {
await signIn<"credentials">("credentials", {

View File

@ -2,3 +2,4 @@ export { createOrUpdateField } from "./createOrUpdateField";
export { deleteField } from "./deleteField";
export { signDocument } from "./signDocument";
export { getUser } from "./getUser";
export { signup } from "./signup";

View File

@ -0,0 +1,12 @@
export const signup = (source: any, data: any) => {
return fetch("/api/auth/signup", {
body: JSON.stringify({
source: source,
...data,
}),
headers: {
"Content-Type": "application/json",
},
method: "POST",
});
};