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
Build and Deploy (Gitea) / build-and-deploy (push) Successful in 37s
Details
This commit is contained in:
parent
ef54421000
commit
433417118b
|
|
@ -126,9 +126,13 @@ export default function AdminContentManager({ token }: AdminContentManagerProps)
|
||||||
setShowCourseForm(false);
|
setShowCourseForm(false);
|
||||||
setEditingCourse(null);
|
setEditingCourse(null);
|
||||||
setCourseForm({ title: '', description: '', thumbnail: '', category: '', isLocked: false, price: 0 });
|
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) {
|
} catch (err) {
|
||||||
console.error('Error saving course:', 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
|
price: course.price || 0
|
||||||
});
|
});
|
||||||
setShowCourseForm(true);
|
setShowCourseForm(true);
|
||||||
|
setTimeout(() => {
|
||||||
|
window.scrollTo({ top: 0, behavior: 'smooth' });
|
||||||
|
}, 50);
|
||||||
};
|
};
|
||||||
|
|
||||||
const handleDeleteCourse = async (courseId: string) => {
|
const handleDeleteCourse = async (courseId: string) => {
|
||||||
|
|
@ -200,6 +207,9 @@ export default function AdminContentManager({ token }: AdminContentManagerProps)
|
||||||
setEditingModule(mod);
|
setEditingModule(mod);
|
||||||
setModuleForm({ title: mod.title, order: mod.order });
|
setModuleForm({ title: mod.title, order: mod.order });
|
||||||
setShowModuleForm(true);
|
setShowModuleForm(true);
|
||||||
|
setTimeout(() => {
|
||||||
|
window.scrollTo({ top: 0, behavior: 'smooth' });
|
||||||
|
}, 50);
|
||||||
};
|
};
|
||||||
|
|
||||||
const handleDeleteModule = async (modId: string) => {
|
const handleDeleteModule = async (modId: string) => {
|
||||||
|
|
@ -262,6 +272,9 @@ export default function AdminContentManager({ token }: AdminContentManagerProps)
|
||||||
content: ''
|
content: ''
|
||||||
});
|
});
|
||||||
setShowLessonForm(true);
|
setShowLessonForm(true);
|
||||||
|
setTimeout(() => {
|
||||||
|
window.scrollTo({ top: 0, behavior: 'smooth' });
|
||||||
|
}, 50);
|
||||||
};
|
};
|
||||||
|
|
||||||
const handleEditLesson = (lesson: Lesson) => {
|
const handleEditLesson = (lesson: Lesson) => {
|
||||||
|
|
@ -274,6 +287,9 @@ export default function AdminContentManager({ token }: AdminContentManagerProps)
|
||||||
content: lesson.content
|
content: lesson.content
|
||||||
});
|
});
|
||||||
setShowLessonForm(true);
|
setShowLessonForm(true);
|
||||||
|
setTimeout(() => {
|
||||||
|
window.scrollTo({ top: 0, behavior: 'smooth' });
|
||||||
|
}, 50);
|
||||||
};
|
};
|
||||||
|
|
||||||
const handleDeleteLesson = async (lessonId: string) => {
|
const handleDeleteLesson = async (lessonId: string) => {
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue