From 6eed718d0a48750ff396da56e7a6f0c5b7e5de82 Mon Sep 17 00:00:00 2001 From: subhanshu jha Date: Tue, 29 Oct 2024 21:51:23 +0530 Subject: [PATCH] added apt. toast message --- src/components/auth/signin.tsx | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) diff --git a/src/components/auth/signin.tsx b/src/components/auth/signin.tsx index a164f3dc..a5bc47e0 100644 --- a/src/components/auth/signin.tsx +++ b/src/components/auth/signin.tsx @@ -39,8 +39,13 @@ export const Signin = () => { try { const response = await signIn('signin', { ...data, redirect: false }); if (!response?.ok) { + const errorMessage = + response?.error?.includes('User') && response?.error?.includes('does not exist') + ? 'User does not exist' + : response?.error || 'Internal server error'; + return toast({ - title: response?.error || 'Internal server error', + title: errorMessage, variant: 'destructive', }); } @@ -48,7 +53,7 @@ export const Signin = () => { title: 'Login successful! Welcome back!', variant: 'success', }); - // const redirect = searchParams.get('next') || APP_PATHS.HOME; + const searchParams = new URLSearchParams(window.location.search); const redirect = searchParams.get('next') || APP_PATHS.HOME; router.push(redirect); @@ -60,7 +65,7 @@ export const Signin = () => { }); } } - + return (