Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions src/hooks/useAuthentication.js
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
Expand Down
16 changes: 14 additions & 2 deletions src/hooks/useSignupLogic.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,14 +2,15 @@ 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({
username: "",
email: "",
password: "",
});
const [error, setError] = useState("");
const [error] = useState("");

const { setAuth } = useAuth();

Expand All @@ -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,
Expand Down