fix: corrige erros de tipagem no ExercisePage
Some checks failed
Docker Build and Push / build (push) Has been cancelled

- 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
This commit is contained in:
Lucas Santana 2025-01-01 10:10:57 -03:00
parent 9840fe76b0
commit 634fa6fb48
2 changed files with 19 additions and 2 deletions

View File

@ -80,3 +80,6 @@
- Adicionada validação para palavras repetidas - Adicionada validação para palavras repetidas
- Implementado sistema de feedback temporário - Implementado sistema de feedback temporário
- Otimizadas transições e animações - 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

View File

@ -13,6 +13,18 @@ interface ExerciseWord {
syllable_pattern: string | null; 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() { export function ExercisePage() {
const { id: storyId, type } = useParams(); const { id: storyId, type } = useParams();
const navigate = useNavigate(); const navigate = useNavigate();
@ -67,8 +79,10 @@ export function ExercisePage() {
} }
// Ordenar gravações por data e pegar a mais recente // Ordenar gravações por data e pegar a mais recente
const latestRecording = story.story_recordings const latestRecording = (story as Story).story_recordings
.sort((a, b) => new Date(b.created_at).getTime() - new Date(a.created_at).getTime())[0]; .sort((a: StoryRecording, b: StoryRecording) =>
new Date(b.created_at).getTime() - new Date(a.created_at).getTime()
)[0];
setExerciseData({ setExerciseData({
story, story,