-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Incluindo contexto e resolvendo bugs de sessao, autenticacao e dashboard
- Loading branch information
Showing
29 changed files
with
465 additions
and
244 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
// src/context/DateContext.tsx | ||
import React, { createContext, useState, ReactNode } from 'react'; | ||
import moment from 'moment'; | ||
|
||
interface DateContextData { | ||
date: string; | ||
setDate: React.Dispatch<React.SetStateAction<string>>; | ||
} | ||
|
||
export const DateContext = createContext<DateContextData | undefined>(undefined); | ||
|
||
interface DateProviderProps { | ||
children: ReactNode; | ||
} | ||
|
||
export const DateProvider = ({ children }: DateProviderProps) => { | ||
const [date, setDate] = useState(moment.utc().format("YYYY-MM-DD")); | ||
|
||
return ( | ||
<DateContext.Provider value={{ date, setDate }}> | ||
{children} | ||
</DateContext.Provider> | ||
); | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,36 @@ | ||
// src/context/UserContext.tsx | ||
import React, { createContext, useState, ReactNode, useEffect } from 'react'; | ||
import AsyncStorage from '@react-native-async-storage/async-storage'; | ||
import { IuserLogin } from '../types/user'; | ||
|
||
interface UserContextData { | ||
user: IuserLogin | null; | ||
setUser: React.Dispatch<React.SetStateAction<IuserLogin | null>>; | ||
} | ||
|
||
export const UserContext = createContext<UserContextData | undefined>(undefined); | ||
|
||
interface UserProviderProps { | ||
children: ReactNode; | ||
} | ||
|
||
export const UserProvider = ({ children }: UserProviderProps) => { | ||
const [user, setUser] = useState<IuserLogin | null>(null); | ||
|
||
useEffect(() => { | ||
// Verifica se há um usuário salvo no AsyncStorage ao iniciar a aplicação | ||
const loadUser = async () => { | ||
const storedUser = await AsyncStorage.getItem('user'); | ||
if (storedUser) { | ||
setUser(JSON.parse(storedUser)); | ||
} | ||
}; | ||
loadUser(); | ||
}, []); | ||
|
||
return ( | ||
<UserContext.Provider value={{ user, setUser }}> | ||
{children} | ||
</UserContext.Provider> | ||
); | ||
}; |
Oops, something went wrong.