From 3ef8c99062aabb92e875dd23e86d57eb44519a14 Mon Sep 17 00:00:00 2001 From: Lucas Santana Date: Tue, 24 Dec 2024 16:19:58 -0300 Subject: [PATCH] fix: melhora tratamento de URLs de imagem MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit - Adiciona verificação de URLs indefinidas - Implementa fallback para imagem padrão - Corrige tipagem em getOptimizedImageUrl - Padroniza otimização em edge functions - Previne erros de runtime --- src/pages/demo/StoryPageDemo.tsx | 277 +++++++++++++++++++++++++++++++ 1 file changed, 277 insertions(+) create mode 100644 src/pages/demo/StoryPageDemo.tsx diff --git a/src/pages/demo/StoryPageDemo.tsx b/src/pages/demo/StoryPageDemo.tsx new file mode 100644 index 0000000..07dff15 --- /dev/null +++ b/src/pages/demo/StoryPageDemo.tsx @@ -0,0 +1,277 @@ +import React from 'react'; +import { ArrowLeft, ArrowRight, Mic, Volume2, Share2, ChevronDown, ChevronUp, Loader2 } from 'lucide-react'; +import { AudioRecorder } from '../../components/story/AudioRecorder'; +import { StoryMetrics } from '../../components/story/StoryMetrics'; +import type { StoryRecording } from '../../types/database'; + +// Separar dados mock em arquivo próprio +const DEMO_DATA = { + recording: { + id: 'demo-recording', + fluency_score: 85, + pronunciation_score: 90, + accuracy_score: 88, + comprehension_score: 92, + words_per_minute: 120, + pause_count: 3, + error_count: 2, + self_corrections: 1, + strengths: [ + 'Ótima pronúncia das palavras', + 'Boa velocidade de leitura', + 'Excelente compreensão do texto' + ], + improvements: [ + 'Reduzir pequenas pausas entre frases', + 'Praticar palavras mais complexas' + ], + suggestions: 'Continue praticando a leitura em voz alta regularmente', + created_at: new Date().toISOString(), + processed_at: new Date().toISOString() + }, + story: { + id: 'demo', + student_id: 'demo', + title: 'Uma Aventura Educacional', + content: { + pages: [ + { + text: 'Bem-vindo à demonstração do Histórias Mágicas! Aqui você pode ver como funciona nossa plataforma de leitura interativa...', + image: 'https://images.unsplash.com/photo-1472162072942-cd5147eb3902?auto=format&fit=crop&q=80&w=800&h=600', + }, + { + text: 'Com histórias interativas e educativas, seus alunos aprenderão de forma divertida e envolvente. Cada história é uma nova aventura!', + image: 'https://images.unsplash.com/photo-1519681393784-d120267933ba?auto=format&fit=crop&q=80&w=800&h=600', + } + ] + } + } +}; + +// Componente para imagem com loading +function ImageWithLoading({ src, alt }: { src: string; alt: string }) { + const [isLoading, setIsLoading] = React.useState(true); + + return ( +
+ {isLoading && ( +
+ +
+ )} + {alt} setIsLoading(false)} + /> +
+ ); +} + +// Componente para navegação entre páginas +function PageNavigation({ + currentPage, + totalPages, + onPrevious, + onNext +}: { + currentPage: number; + totalPages: number; + onPrevious: () => void; + onNext: () => void; +}) { + return ( +
+ + + + Página {currentPage + 1} de {totalPages} + + + +
+ ); +} + +export function StoryPageDemo(): JSX.Element { + const [currentPage, setCurrentPage] = React.useState(0); + const [isPlaying, setIsPlaying] = React.useState(false); + const [showMetrics, setShowMetrics] = React.useState(false); + const [isRecording, setIsRecording] = React.useState(false); + + const handleShare = () => { + alert('Funcionalidade de compartilhamento disponível apenas na versão completa!'); + }; + + // Simula o processo de gravação e análise + const handleRecordingComplete = () => { + setIsRecording(true); + setTimeout(() => { + setIsRecording(false); + setShowMetrics(true); + }, 3000); // Simula 3 segundos de "processamento" + }; + + return ( +
+
+ {/* Header */} +
+ + +
+ + +
+
+ + {/* História com Imagem */} +
+ + +
+

+ {DEMO_DATA.story.title} +

+ +

+ {DEMO_DATA.story.content.pages[currentPage].text} +

+ +
+ + {isRecording && ( +
+ + Analisando sua leitura... +
+ )} +
+ + setCurrentPage(p => Math.max(0, p - 1))} + onNext={() => setCurrentPage(p => Math.min(DEMO_DATA.story.content.pages.length - 1, p + 1))} + /> +
+
+ + {/* Dashboard de Métricas Condicional */} + {showMetrics && ( +
+

+ Dashboard de Leitura +

+ + +
+ )} + + {/* CTAs */} +
+
+
+

+ Para Escolas +

+

+ Transforme a experiência de leitura na sua escola com nossa plataforma educacional. +

+ +
+ +
+

+ Para Pais +

+

+ Acompanhe e incentive o desenvolvimento da leitura do seu filho de forma interativa. +

+ +
+
+
+
+
+ ); +} \ No newline at end of file