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 }) => (