From 433417118b45273d09558e69d04df2d8d0abf4b4 Mon Sep 17 00:00:00 2001 From: Sidney Gomes Date: Mon, 20 Jul 2026 19:20:19 -0300 Subject: [PATCH] Fix admin card edit buttons: add scroll to top and API error handling --- src/components/AdminContentManager.tsx | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) diff --git a/src/components/AdminContentManager.tsx b/src/components/AdminContentManager.tsx index 4c26d06..245ab52 100644 --- a/src/components/AdminContentManager.tsx +++ b/src/components/AdminContentManager.tsx @@ -126,9 +126,13 @@ export default function AdminContentManager({ token }: AdminContentManagerProps) setShowCourseForm(false); setEditingCourse(null); setCourseForm({ title: '', description: '', thumbnail: '', category: '', isLocked: false, price: 0 }); + } else { + const errData = await res.json(); + alert(`Erro ao salvar curso: ${errData.error || 'Falha na resposta do servidor'}`); } } catch (err) { console.error('Error saving course:', err); + alert('Erro de rede ao salvar curso.'); } }; @@ -143,6 +147,9 @@ export default function AdminContentManager({ token }: AdminContentManagerProps) price: course.price || 0 }); setShowCourseForm(true); + setTimeout(() => { + window.scrollTo({ top: 0, behavior: 'smooth' }); + }, 50); }; const handleDeleteCourse = async (courseId: string) => { @@ -200,6 +207,9 @@ export default function AdminContentManager({ token }: AdminContentManagerProps) setEditingModule(mod); setModuleForm({ title: mod.title, order: mod.order }); setShowModuleForm(true); + setTimeout(() => { + window.scrollTo({ top: 0, behavior: 'smooth' }); + }, 50); }; const handleDeleteModule = async (modId: string) => { @@ -262,6 +272,9 @@ export default function AdminContentManager({ token }: AdminContentManagerProps) content: '' }); setShowLessonForm(true); + setTimeout(() => { + window.scrollTo({ top: 0, behavior: 'smooth' }); + }, 50); }; const handleEditLesson = (lesson: Lesson) => { @@ -274,6 +287,9 @@ export default function AdminContentManager({ token }: AdminContentManagerProps) content: lesson.content }); setShowLessonForm(true); + setTimeout(() => { + window.scrollTo({ top: 0, behavior: 'smooth' }); + }, 50); }; const handleDeleteLesson = async (lessonId: string) => {