From 9a69d11d5886520a3e99b89d255c1a5315656f0b Mon Sep 17 00:00:00 2001 From: Sidney Gomes Date: Tue, 21 Jul 2026 17:59:06 -0300 Subject: [PATCH] fix: padronizacao dos botoes salvar do admin, encapsulamento em e adicao de ErrorBoundary contra tela branca --- src/Root.tsx | 9 ++-- src/components/AdminContentManager.tsx | 22 ++++++---- src/components/AdminDashboard.tsx | 2 +- src/components/ErrorBoundary.tsx | 60 ++++++++++++++++++++++++++ 4 files changed, 80 insertions(+), 13 deletions(-) create mode 100644 src/components/ErrorBoundary.tsx diff --git a/src/Root.tsx b/src/Root.tsx index 7bffd1c..a725cdc 100644 --- a/src/Root.tsx +++ b/src/Root.tsx @@ -1,6 +1,7 @@ import React, { useState } from 'react'; import App from './App.tsx'; import AdminApp from './AdminApp.tsx'; +import { ErrorBoundary } from './components/ErrorBoundary.tsx'; export default function Root() { const [simulatedDomain] = useState<'student' | 'admin'>(() => { @@ -33,8 +34,10 @@ export default function Root() { }, [isAdmin]); return ( -
- {isAdmin ? : } -
+ +
+ {isAdmin ? : } +
+
); } diff --git a/src/components/AdminContentManager.tsx b/src/components/AdminContentManager.tsx index ef07b79..5642c29 100644 --- a/src/components/AdminContentManager.tsx +++ b/src/components/AdminContentManager.tsx @@ -1,7 +1,7 @@ import React, { useState, useEffect } from 'react'; import { GraduationCap, Plus, Edit, Trash2, FolderPlus, FilePlus, ChevronRight, - ArrowLeft, Film, Youtube, RefreshCw, Layers, CheckCircle + ArrowLeft, Film, Youtube, RefreshCw, Layers, CheckCircle, CheckCircle2 } from 'lucide-react'; interface Lesson { @@ -510,9 +510,10 @@ export default function AdminContentManager({ token }: AdminContentManagerProps)
@@ -579,8 +580,9 @@ export default function AdminContentManager({ token }: AdminContentManagerProps) />
-
-
@@ -922,8 +925,9 @@ export default function AdminContentManager({ token }: AdminContentManagerProps) - diff --git a/src/components/AdminDashboard.tsx b/src/components/AdminDashboard.tsx index 571cbd8..1bbe0b0 100644 --- a/src/components/AdminDashboard.tsx +++ b/src/components/AdminDashboard.tsx @@ -924,7 +924,7 @@ export default function AdminDashboard({ token }: AdminDashboardProps) { ) : ( )} - {isSavingSettings ? 'Salvando...' : 'Salvar Configurações'} + {isSavingSettings ? 'Salvando...' : 'Salvar Configurações'} diff --git a/src/components/ErrorBoundary.tsx b/src/components/ErrorBoundary.tsx new file mode 100644 index 0000000..e34b874 --- /dev/null +++ b/src/components/ErrorBoundary.tsx @@ -0,0 +1,60 @@ +import React, { Component, ErrorInfo, ReactNode } from 'react'; +import { RefreshCw, AlertTriangle } from 'lucide-react'; + +interface Props { + children: ReactNode; +} + +interface State { + hasError: boolean; + error: Error | null; +} + +export class ErrorBoundary extends Component { + public state: State = { + hasError: false, + error: null + }; + + public static getDerivedStateFromError(error: Error): State { + return { hasError: true, error }; + } + + public componentDidCatch(error: Error, errorInfo: ErrorInfo) { + console.error('Uncaught error caught by ErrorBoundary:', error, errorInfo); + } + + private handleReload = () => { + this.setState({ hasError: false, error: null }); + window.location.reload(); + }; + + public render() { + if (this.state.hasError) { + return ( +
+
+
+ +
+
+

Recarregando Interface

+

+ Uma alteração de estrutura foi detectada pelo navegador. Clique no botão abaixo para restaurar a página. +

+
+ +
+
+ ); + } + + return this.props.children; + } +}