mirror of
https://github.com/cheveguerra/whaticket-community.git
synced 2026-04-19 20:29:17 +00:00
chore: removed unused export
This commit is contained in:
@@ -5,18 +5,11 @@ import useAuth from "./useAuth";
|
|||||||
const AuthContext = createContext();
|
const AuthContext = createContext();
|
||||||
|
|
||||||
const AuthProvider = ({ children }) => {
|
const AuthProvider = ({ children }) => {
|
||||||
const {
|
const { loading, user, isAuth, handleLogin, handleLogout } = useAuth();
|
||||||
loading,
|
|
||||||
user,
|
|
||||||
setUser,
|
|
||||||
isAuth,
|
|
||||||
handleLogin,
|
|
||||||
handleLogout,
|
|
||||||
} = useAuth();
|
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<AuthContext.Provider
|
<AuthContext.Provider
|
||||||
value={{ loading, user, setUser, isAuth, handleLogin, handleLogout }}
|
value={{ loading, user, isAuth, handleLogin, handleLogout }}
|
||||||
>
|
>
|
||||||
{children}
|
{children}
|
||||||
</AuthContext.Provider>
|
</AuthContext.Provider>
|
||||||
|
|||||||
@@ -1,5 +1,6 @@
|
|||||||
import { useState, useEffect } from "react";
|
import { useState, useEffect } from "react";
|
||||||
import { useHistory } from "react-router-dom";
|
import { useHistory } from "react-router-dom";
|
||||||
|
import openSocket from "socket.io-client";
|
||||||
|
|
||||||
import { toast } from "react-toastify";
|
import { toast } from "react-toastify";
|
||||||
|
|
||||||
@@ -69,6 +70,20 @@ const useAuth = () => {
|
|||||||
})();
|
})();
|
||||||
}, []);
|
}, []);
|
||||||
|
|
||||||
|
useEffect(() => {
|
||||||
|
const socket = openSocket(process.env.REACT_APP_BACKEND_URL);
|
||||||
|
|
||||||
|
socket.on("user", data => {
|
||||||
|
if (data.action === "update" && data.user.id === user.id) {
|
||||||
|
setUser(data.user);
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
|
return () => {
|
||||||
|
socket.disconnect();
|
||||||
|
};
|
||||||
|
}, [user]);
|
||||||
|
|
||||||
const handleLogin = async user => {
|
const handleLogin = async user => {
|
||||||
setLoading(true);
|
setLoading(true);
|
||||||
|
|
||||||
@@ -97,7 +112,7 @@ const useAuth = () => {
|
|||||||
history.push("/login");
|
history.push("/login");
|
||||||
};
|
};
|
||||||
|
|
||||||
return { isAuth, user, setUser, loading, handleLogin, handleLogout };
|
return { isAuth, user, loading, handleLogin, handleLogout };
|
||||||
};
|
};
|
||||||
|
|
||||||
export default useAuth;
|
export default useAuth;
|
||||||
|
|||||||
Reference in New Issue
Block a user