From 634fa6fb480a29720217fab33c2ff5a71bfb7676 Mon Sep 17 00:00:00 2001 From: Lucas Santana Date: Wed, 1 Jan 2025 10:10:57 -0300 Subject: [PATCH] fix: corrige erros de tipagem no ExercisePage - Adiciona interfaces para Story e StoryRecording - Corrige tipagem no sort de recordings - Melhora type safety no acesso aos dados type: fix scope: typescript breaking: false --- CHANGELOG.md | 3 +++ src/pages/student-dashboard/ExercisePage.tsx | 18 ++++++++++++++++-- 2 files changed, 19 insertions(+), 2 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 6e08bd8..2cf8bb3 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -80,3 +80,6 @@ - Adicionada validação para palavras repetidas - Implementado sistema de feedback temporário - Otimizadas transições e animações +- Corrigidos erros de tipagem no ExercisePage + - Adicionadas interfaces para Story e StoryRecording + - Melhorada type safety no acesso aos dados diff --git a/src/pages/student-dashboard/ExercisePage.tsx b/src/pages/student-dashboard/ExercisePage.tsx index c45a514..1edde6c 100644 --- a/src/pages/student-dashboard/ExercisePage.tsx +++ b/src/pages/student-dashboard/ExercisePage.tsx @@ -13,6 +13,18 @@ interface ExerciseWord { syllable_pattern: string | null; } +interface StoryRecording { + id: string; + created_at: string; + improvements: string[]; +} + +interface Story { + id: string; + story_recordings: StoryRecording[]; + // ... outros campos necessários +} + export function ExercisePage() { const { id: storyId, type } = useParams(); const navigate = useNavigate(); @@ -67,8 +79,10 @@ export function ExercisePage() { } // Ordenar gravações por data e pegar a mais recente - const latestRecording = story.story_recordings - .sort((a, b) => new Date(b.created_at).getTime() - new Date(a.created_at).getTime())[0]; + const latestRecording = (story as Story).story_recordings + .sort((a: StoryRecording, b: StoryRecording) => + new Date(b.created_at).getTime() - new Date(a.created_at).getTime() + )[0]; setExerciseData({ story,