Commit 83b3bcdd by G

authenticationData state

parent 4a40ec39
import { createContext, useContext, useState } from "react";
import type { IauthenticationData } from "./Types";
export interface UserAuthenticationContextProps {
isAuthenticated: boolean;
setIsAuthenticated: React.Dispatch<React.SetStateAction<boolean>>;
setAuthenticationData: React.Dispatch<React.SetStateAction<IauthenticationData>>;
}
export const UserAuthenticationContext = createContext<UserAuthenticationContextProps>({
isAuthenticated: false,
setIsAuthenticated: () => {},
setAuthenticationData: () => {},
});
export const UserAuthenticationContextProvider = ({ children }: { children: React.ReactNode }) => {
const [isAuthenticated, setIsAuthenticated] = useState(false);
const [authenticationData, setAuthenticationData] = useState<IauthenticationData>({
access: "",
refresh: "",
});
return (
<UserAuthenticationContext.Provider
value={{ isAuthenticated: isAuthenticated, setIsAuthenticated }}
value={{ isAuthenticated: isAuthenticated, setIsAuthenticated, setAuthenticationData }}
>
{children}
</UserAuthenticationContext.Provider>
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment