feat(auth): save auth data into state
This commit is contained in:
parent
dcd9021be2
commit
fb21229cf6
1 changed files with 9 additions and 14 deletions
|
|
@ -1,4 +1,4 @@
|
|||
import { createContext } from 'react';
|
||||
import { createContext, useState } from 'react';
|
||||
|
||||
import { UserDTO } from '@dtos/UserDTO';
|
||||
|
||||
|
|
@ -13,17 +13,12 @@ type AuthContextProviderProps = {
|
|||
export const AuthContext = createContext<AuthContextData>({} as AuthContextData);
|
||||
|
||||
export function AuthContextProvider({ children }: AuthContextProviderProps) {
|
||||
return (
|
||||
<AuthContext.Provider
|
||||
value={{
|
||||
user: {
|
||||
id: '1',
|
||||
name: 'John Doe',
|
||||
email: 'john.doe@email.com',
|
||||
avatar: 'https://i.pravatar.cc/200',
|
||||
},
|
||||
}}>
|
||||
{children}
|
||||
</AuthContext.Provider>
|
||||
);
|
||||
const [user, setUser] = useState<UserDTO>({
|
||||
id: '1',
|
||||
name: 'John Doe',
|
||||
email: 'john.doe@email.com',
|
||||
avatar: 'https://i.pravatar.cc/200',
|
||||
});
|
||||
|
||||
return <AuthContext.Provider value={{ user }}>{children}</AuthContext.Provider>;
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in a new issue