diff --git a/client/src/App.tsx b/client/src/App.tsx
index dba1ee4..4fa7fd3 100644
--- a/client/src/App.tsx
+++ b/client/src/App.tsx
@@ -4,6 +4,7 @@ import Login from './routes/login';
import Home from './routes/home';
import { CookiesProvider, useCookies } from 'react-cookie';
import Signup from './routes/signup';
+import { ToastContainer } from 'react-toastify';
// Create a client
const queryClient = new QueryClient();
@@ -38,6 +39,7 @@ export default () => {
} />
} />
+
diff --git a/client/src/routes/home.tsx b/client/src/routes/home.tsx
index de25e61..940e4c5 100644
--- a/client/src/routes/home.tsx
+++ b/client/src/routes/home.tsx
@@ -1,7 +1,6 @@
import AppHeader from '@components/AppHeader';
import MessageWrapper from '@components/MessageWrapper';
import NewMessage from '@components/NewMessage';
-import { ToastContainer } from 'react-toastify';
import 'react-toastify/dist/ReactToastify.css';
const Home = () => {
@@ -10,7 +9,6 @@ const Home = () => {
-
);
};
diff --git a/client/src/routes/login.tsx b/client/src/routes/login.tsx
index 67dd2ad..dc96623 100644
--- a/client/src/routes/login.tsx
+++ b/client/src/routes/login.tsx
@@ -4,6 +4,7 @@ import { useQuery } from '@tanstack/react-query';
import { useState } from 'react';
import { useCookies } from 'react-cookie';
import type { Token } from '../types';
+import { toastError } from '@controllers/Toasts';
const Login = () => {
const [email, setEmail] = useState('');
@@ -21,6 +22,10 @@ const Login = () => {
'Content-Type': 'application/json',
},
});
+ const data = await response.json();
+ if (data.error) {
+ throw data.error;
+ }
return response.json();
},
{
@@ -28,7 +33,7 @@ const Login = () => {
setCookie('token', data.token, { path: '/', expires: new Date(data.expiresAt) });
},
onError: (error) => {
- console.error(error);
+ toastError(error as string);
},
enabled: false,
refetchOnWindowFocus: false,