gmokercom/front_end/src/services/AuthContext.jsx
dorian melenotte 8f6d6d68a8
Some checks failed
/ deploy (push) Failing after 4s
ADD: good set up docker
2024-10-10 17:28:29 +02:00

26 lines
531 B
JavaScript

import { createContext, useContext, useState } from "react";
const AuthContext = createContext();
export function AuthProvider({ children }) {
const [isAuthenticated, setIsAuthenticated] = useState(false);
const login = () => {
setIsAuthenticated(true);
};
const logout = () => {
setIsAuthenticated(false);
};
return (
<AuthContext.Provider value={{ isAuthenticated, login, logout }}>
{children}
</AuthContext.Provider>
);
}
export function useAuth() {
return useContext(AuthContext);
}