mirror of
https://github.com/lucasrcsantana/story-generator.git
synced 2025-12-17 05:47:52 +00:00
fix: adiciona optional chaining para prevenir erros de undefined
- Corrige acesso a propriedades undefined em story.content.pages - Adiciona verificações de segurança com optional chaining (?.) - Implementa fallback para texto quando conteúdo não está disponível - Previne erros de runtime em: - StudentDashboardPage - StudentStoriesPage - StoryPage Resolves: #BUG-789
This commit is contained in:
parent
4f3b80246f
commit
3701e692f1
@ -334,7 +334,7 @@ export function StoryPage() {
|
||||
|
||||
<div className="bg-white rounded-xl shadow-sm border border-gray-200 overflow-hidden">
|
||||
{/* Imagem da página atual */}
|
||||
{story.content.pages[currentPage].image && (
|
||||
{story.content?.pages?.[currentPage]?.image && (
|
||||
<div className="relative aspect-video">
|
||||
<img
|
||||
src={story.content.pages[currentPage].image}
|
||||
@ -349,7 +349,7 @@ export function StoryPage() {
|
||||
|
||||
{/* Texto da página atual */}
|
||||
<p className="text-lg text-gray-700 mb-8">
|
||||
{story.content.pages[currentPage].text}
|
||||
{story.content?.pages?.[currentPage]?.text || 'Carregando...'}
|
||||
</p>
|
||||
|
||||
{/* Gravador de áudio */}
|
||||
|
||||
@ -231,7 +231,7 @@ export function StudentDashboardPage() {
|
||||
className="bg-white rounded-xl shadow-sm border border-gray-200 overflow-hidden cursor-pointer hover:shadow-md transition"
|
||||
onClick={() => navigate(`/aluno/historias/${story.id}`)}
|
||||
>
|
||||
{story.content.pages[0].image && (
|
||||
{story.content?.pages?.[0]?.image && (
|
||||
<img
|
||||
src={story.content.pages[0].image}
|
||||
alt={story.title}
|
||||
|
||||
@ -197,7 +197,7 @@ export function StudentStoriesPage() {
|
||||
className="bg-white rounded-xl shadow-sm border border-gray-200 overflow-hidden cursor-pointer hover:shadow-md transition"
|
||||
onClick={() => navigate(`/aluno/historias/${story.id}`)}
|
||||
>
|
||||
{story.content.pages[0].image && (
|
||||
{story.content?.pages?.[0]?.image && (
|
||||
<img
|
||||
src={story.content.pages[0].image}
|
||||
alt={story.title}
|
||||
|
||||
Loading…
Reference in New Issue
Block a user