Fix admin card edit buttons: add scroll to top and API error handling
Build and Deploy (Gitea) / build-and-deploy (push) Successful in 37s Details

This commit is contained in:
Sidney Gomes 2026-07-20 19:20:19 -03:00
parent ef54421000
commit 433417118b
1 changed files with 16 additions and 0 deletions

View File

@ -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) => {