From ea7341f26e07736ba6dac85ecf007175a03ad591 Mon Sep 17 00:00:00 2001 From: Vinicius Souza Date: Tue, 5 Nov 2024 19:03:06 +0000 Subject: [PATCH] feat: list exercise history by day --- src/dtos/HistoryByDayDTO.ts | 6 ++++++ src/dtos/HistoryDTO.ts | 7 +++++++ src/screens/History.tsx | 8 ++++---- 3 files changed, 17 insertions(+), 4 deletions(-) create mode 100644 src/dtos/HistoryByDayDTO.ts create mode 100644 src/dtos/HistoryDTO.ts diff --git a/src/dtos/HistoryByDayDTO.ts b/src/dtos/HistoryByDayDTO.ts new file mode 100644 index 0000000..78ca90c --- /dev/null +++ b/src/dtos/HistoryByDayDTO.ts @@ -0,0 +1,6 @@ +import { HistoryDTO } from './HistoryDTO'; + +export type HistoryByDayDTO = { + title: string; + data: HistoryDTO[]; +}; diff --git a/src/dtos/HistoryDTO.ts b/src/dtos/HistoryDTO.ts new file mode 100644 index 0000000..7280d54 --- /dev/null +++ b/src/dtos/HistoryDTO.ts @@ -0,0 +1,7 @@ +export type HistoryDTO = { + id: string; + name: string; + group: string; + hour: number; + created_at: string; +}; diff --git a/src/screens/History.tsx b/src/screens/History.tsx index e18085e..5c71f8e 100644 --- a/src/screens/History.tsx +++ b/src/screens/History.tsx @@ -5,7 +5,7 @@ import { Heading, Text, useToast, VStack } from '@gluestack-ui/themed'; import { api } from '@services/api'; import { AppError } from '@utils/AppError'; -import { ExerciseDTO } from '@dtos/ExerciseDTO'; +import { HistoryByDayDTO } from '@dtos/HistoryByDayDTO'; import { HistoryCard } from '@components/HistoryCard'; import { ScreenHeader } from '@components/ScreenHeader'; @@ -13,7 +13,7 @@ import { ToastMessage } from '@components/ToastMessage'; export function History() { const [isLoading, setIsLoading] = useState(true); - const [exercises, setExercises] = useState([]); + const [exercises, setExercises] = useState([]); const toast = useToast(); @@ -22,7 +22,7 @@ export function History() { setIsLoading(true); const response = await api.get('/history'); - console.debug(response.data); + setExercises(response.data); } catch (error) { const isAppError = error instanceof AppError; const title = isAppError ? error.message : 'Não foi possível carregar o histórico.'; @@ -49,7 +49,7 @@ export function History() { item} + keyExtractor={(item) => item.id} renderItem={({ item }) => } renderSectionHeader={({ section }) => (