feat: add auth context typings

This commit is contained in:
Vinicius Souza 2024-10-30 09:45:44 -03:00
parent e6d880ef8a
commit 6cae1cc7f3
3 changed files with 19 additions and 5 deletions

10
App.tsx
View file

@ -19,10 +19,12 @@ export default function App() {
<GluestackUIProvider config={config}>
<AuthContext.Provider
value={{
id: '1',
name: 'John Doe',
email: 'john.doe@email.com',
avatar: 'https://i.pravatar.cc/200',
user: {
id: '1',
name: 'John Doe',
email: 'john.doe@email.com',
avatar: 'https://i.pravatar.cc/200',
},
}}>
{fontsLoaded ? <Routes /> : <Loading />}
</AuthContext.Provider>

View file

@ -1,3 +1,9 @@
import { createContext } from 'react';
export const AuthContext = createContext({});
import { UserDTO } from '@dtos/UserDTO';
type AuthContextData = {
user: UserDTO;
};
export const AuthContext = createContext<AuthContextData>({} as AuthContextData);

6
src/dtos/UserDTO.ts Normal file
View file

@ -0,0 +1,6 @@
export type UserDTO = {
id: string;
name: string;
email: string;
avatar: string;
};