Compare commits
2 commits
1c8aee2fa0
...
9afd06fe0f
| Author | SHA1 | Date | |
|---|---|---|---|
| 9afd06fe0f | |||
| 8f3f487080 |
2 changed files with 34 additions and 18 deletions
|
|
@ -10,6 +10,7 @@ import { HistoryByDayDTO } from '@dtos/HistoryByDayDTO';
|
|||
import { HistoryCard } from '@components/HistoryCard';
|
||||
import { ScreenHeader } from '@components/ScreenHeader';
|
||||
import { ToastMessage } from '@components/ToastMessage';
|
||||
import { Loading } from '@components/Loading';
|
||||
|
||||
export function History() {
|
||||
const [isLoading, setIsLoading] = useState(true);
|
||||
|
|
@ -47,24 +48,28 @@ export function History() {
|
|||
<VStack flex={1}>
|
||||
<ScreenHeader title="Histórico" />
|
||||
|
||||
<SectionList
|
||||
sections={exercises}
|
||||
keyExtractor={(item) => item.id}
|
||||
renderItem={({ item }) => <HistoryCard data={item} />}
|
||||
renderSectionHeader={({ section }) => (
|
||||
<Heading color="$gray200" fontSize="$md" mt="$10" mb="$3">
|
||||
{section.title}
|
||||
</Heading>
|
||||
)}
|
||||
style={{ paddingHorizontal: 32 }}
|
||||
contentContainerStyle={exercises.length === 0 && { flex: 1, justifyContent: 'center' }}
|
||||
ListEmptyComponent={() => (
|
||||
<Text color="$gray100" textAlign="center">
|
||||
Não há exercícios registrados ainda.{'\n'}Vamos fazer exercícios hoje?
|
||||
</Text>
|
||||
)}
|
||||
showsVerticalScrollIndicator={false}
|
||||
/>
|
||||
{isLoading ? (
|
||||
<Loading />
|
||||
) : (
|
||||
<SectionList
|
||||
sections={exercises}
|
||||
keyExtractor={(item) => item.id}
|
||||
renderItem={({ item }) => <HistoryCard data={item} />}
|
||||
renderSectionHeader={({ section }) => (
|
||||
<Heading color="$gray200" fontSize="$md" mt="$10" mb="$3">
|
||||
{section.title}
|
||||
</Heading>
|
||||
)}
|
||||
style={{ paddingHorizontal: 32 }}
|
||||
contentContainerStyle={exercises.length === 0 && { flex: 1, justifyContent: 'center' }}
|
||||
ListEmptyComponent={() => (
|
||||
<Text color="$gray100" textAlign="center">
|
||||
Não há exercícios registrados ainda.{'\n'}Vamos fazer exercícios hoje?
|
||||
</Text>
|
||||
)}
|
||||
showsVerticalScrollIndicator={false}
|
||||
/>
|
||||
)}
|
||||
</VStack>
|
||||
);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -69,6 +69,17 @@ api.registerInterceptTokenManager = (signOut: SignOut) => {
|
|||
try {
|
||||
const { data } = api.post('/sessions/refresh_token', { refresh_token });
|
||||
await storageAuthTokenSave({ token: data.token, refresh_token: data.refresh_token });
|
||||
|
||||
if (originalRequestConfig.data) {
|
||||
originalRequestConfig.data = JSON.parse(JSON.stringify(originalRequestConfig.data));
|
||||
}
|
||||
|
||||
originalRequestConfig.headers.Authorization = `Bearer ${data.token}`;
|
||||
api.defaults.headers.common.Authorization = `Bearer ${data.token}`;
|
||||
|
||||
failedQueue.forEach((request) => request.onSuccess(data.token));
|
||||
|
||||
resolve(api(originalRequestConfig));
|
||||
} catch (error: any) {
|
||||
failedQueue.forEach((request) => request.onFailure(error));
|
||||
signOut();
|
||||
|
|
|
|||
Loading…
Reference in a new issue