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';
|
import { UserDTO } from '@dtos/UserDTO';
|
||||||
|
|
||||||
|
|
@ -13,17 +13,12 @@ type AuthContextProviderProps = {
|
||||||
export const AuthContext = createContext<AuthContextData>({} as AuthContextData);
|
export const AuthContext = createContext<AuthContextData>({} as AuthContextData);
|
||||||
|
|
||||||
export function AuthContextProvider({ children }: AuthContextProviderProps) {
|
export function AuthContextProvider({ children }: AuthContextProviderProps) {
|
||||||
return (
|
const [user, setUser] = useState<UserDTO>({
|
||||||
<AuthContext.Provider
|
|
||||||
value={{
|
|
||||||
user: {
|
|
||||||
id: '1',
|
id: '1',
|
||||||
name: 'John Doe',
|
name: 'John Doe',
|
||||||
email: 'john.doe@email.com',
|
email: 'john.doe@email.com',
|
||||||
avatar: 'https://i.pravatar.cc/200',
|
avatar: 'https://i.pravatar.cc/200',
|
||||||
},
|
});
|
||||||
}}>
|
|
||||||
{children}
|
return <AuthContext.Provider value={{ user }}>{children}</AuthContext.Provider>;
|
||||||
</AuthContext.Provider>
|
|
||||||
);
|
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue