diff --git a/src/hooks/useAuthentication.js b/src/hooks/useAuthentication.js index 9096d15..21b76ca 100644 --- a/src/hooks/useAuthentication.js +++ b/src/hooks/useAuthentication.js @@ -27,6 +27,9 @@ const useAuthentication = () => { } else { navigate("/admin"); } + toast('successful login, have fun!', { + icon: '👏', + }); } catch (error) { if (error.response) { if (error.response.status === 401) { diff --git a/src/hooks/useSignupLogic.js b/src/hooks/useSignupLogic.js index f435058..5106eb2 100644 --- a/src/hooks/useSignupLogic.js +++ b/src/hooks/useSignupLogic.js @@ -2,6 +2,7 @@ import { useState } from "react"; import { useNavigate, useLocation } from "react-router-dom"; import useAuth from "./useAuth"; import axios from "axios"; +import { toast } from "react-hot-toast"; const useSignupLogic = () => { const [data, setData] = useState({ @@ -9,7 +10,7 @@ const useSignupLogic = () => { email: "", password: "", }); - const [error, setError] = useState(""); + const [error] = useState(""); const { setAuth } = useAuth(); @@ -31,16 +32,27 @@ const useSignupLogic = () => { const token = res?.token; setAuth({ roles, token }); navigate(from, { replace: true }); + toast('Account creation successful, now log in!', { + icon: '👏', + }); } catch (error) { if ( error.response && error.response.status >= 400 && error.response.status <= 500 ) { - setError(error.response.data.message); + const errorMessage = error.response.data.message; + toast.error(`Error: ${errorMessage}`, { + icon: '❌', + }); + } else { + toast.error('An error occurred. Please try again later.', { + icon: '❌', + }); } } }; + return { data,