import React, { useEffect, useState } from 'react'; import { BookOpen, Puzzle, Mic } from 'lucide-react'; import { useNavigate } from 'react-router-dom'; import { supabase } from '../../lib/supabase'; interface ExerciseSuggestionsProps { storyId: string; storyText: string; readingMetrics: { difficultWords: string[]; errorCount: number; pauseCount: number; fluencyScore: number; }; } interface ExerciseWord { word: string; exercise_type: string; phonemes: string[] | null; syllable_pattern: string | null; } export function ExerciseSuggestions({ storyId, storyText, readingMetrics }: ExerciseSuggestionsProps) { const navigate = useNavigate(); const [exerciseWords, setExerciseWords] = useState([]); useEffect(() => { const loadExerciseWords = async () => { const { data, error } = await supabase .from('story_exercise_words') .select('*') .eq('story_id', storyId) .order('created_at', { ascending: true }); if (!error && data) { setExerciseWords(data); } }; loadExerciseWords(); }, [storyId]); const handleExerciseSelect = (exerciseType: string) => { if (!storyId) { console.error('ID da história não fornecido'); return; } navigate(`/aluno/historias/${storyId}/exercicios/${exerciseType}`); }; const generateExercises = () => { const exercises = [ { type: 'word-formation', title: 'Formação de Palavras', description: 'Monte novas palavras usando sílabas da história', icon: , words: exerciseWords .filter(w => w.exercise_type === 'formation') .map(w => w.word), }, { type: 'sentence-completion', title: 'Complete a História', description: 'Complete as frases com as palavras corretas', icon: , words: exerciseWords .filter(w => w.exercise_type === 'completion') .map(w => w.word), }, { type: 'pronunciation-practice', title: 'Treino de Pronúncia', description: 'Pratique a pronúncia das palavras difíceis', icon: , words: exerciseWords .filter(w => w.exercise_type === 'pronunciation') .map(w => w.word), } ]; return exercises; }; return (

Exercícios Sugeridos

{generateExercises().map((exercise) => ( ))}
); }