improvement: keep user data on login fails

This commit is contained in:
canove
2021-01-12 20:30:31 -03:00
parent 96e92e6079
commit 2bec877e4f
3 changed files with 25 additions and 14 deletions

View File

@@ -63,9 +63,8 @@ const useAuth = () => {
setLoading(false);
}, []);
const handleLogin = async (e, user) => {
const handleLogin = async user => {
setLoading(true);
e.preventDefault();
try {
const { data } = await api.post("/auth/login", user);
@@ -78,11 +77,11 @@ const useAuth = () => {
setIsAuth(true);
toast.success(i18n.t("auth.toasts.success"));
history.push("/tickets");
setLoading(false);
} catch (err) {
toastError(err);
setLoading(false);
}
setLoading(false);
};
const handleLogout = e => {