From 184b33c9d91a041267ab1724e86d72c1c7342df8 Mon Sep 17 00:00:00 2001 From: Timur Ercan Date: Sat, 14 Jan 2023 18:55:17 +0100 Subject: [PATCH] toast fix --- apps/web/components/signup.tsx | 60 +++++++++++++++++----------------- 1 file changed, 30 insertions(+), 30 deletions(-) diff --git a/apps/web/components/signup.tsx b/apps/web/components/signup.tsx index e8e9f82d4..44cb72d4b 100644 --- a/apps/web/components/signup.tsx +++ b/apps/web/components/signup.tsx @@ -29,39 +29,39 @@ export default function Signup() { }; const signUp: SubmitHandler = async (data) => { - const res = await toast.promise( - fetch("/api/auth/signup", { - body: JSON.stringify({ - ...data, - }), - headers: { - "Content-Type": "application/json", - }, - method: "POST", - }) - .then(handleErrors) - .then(async () => { - await signIn<"credentials">("credentials", { + const res = await toast + .promise( + fetch("/api/auth/signup", { + body: JSON.stringify({ ...data, - callbackUrl: "https://app.documenso.com/dashboard", - }); + }), + headers: { + "Content-Type": "application/json", + }, + method: "POST", }) - .catch((err) => { - methods.setError("apiError", { message: err.message }); - // Throw again for toast - throw new Error(err.message); - }), - { - loading: "Creating your account...", - success: "Done!", - error: (err) => err.message, - }, - { - style: { - minWidth: "200px", + .then(handleErrors) + .then(async () => { + await signIn<"credentials">("credentials", { + ...data, + callbackUrl: "https://app.documenso.com/dashboard", + }); + }), + { + loading: "Creating your account...", + success: "Done!", + error: (err) => err.message, }, - } - ); + { + style: { + minWidth: "200px", + }, + } + ) + .catch((err) => { + toast.dismiss(); + methods.setError("apiError", { message: err.message }); + }); }; function renderApiError() {