diff --git a/app-main/public/css/style.css b/app-main/public/css/style.css index 106025b..defb0b9 100644 --- a/app-main/public/css/style.css +++ b/app-main/public/css/style.css @@ -583,6 +583,13 @@ form { overflow: hidden; overflow-y: scroll; } +.error{ + visibility: hidden; + color: red; + margin: 0; + text-align: center; + +} /* footer styles */ diff --git a/app-main/public/index.html b/app-main/public/index.html index eda2685..7152b54 100644 --- a/app-main/public/index.html +++ b/app-main/public/index.html @@ -177,7 +177,8 @@

Lessons

-
+

Notes section is empty!

+
add icon

New Lesson

diff --git a/app-main/public/js/lessons/index.js b/app-main/public/js/lessons/index.js index d1d266b..9c59427 100644 --- a/app-main/public/js/lessons/index.js +++ b/app-main/public/js/lessons/index.js @@ -9,7 +9,8 @@ const createLessonContainer = document.querySelector( ); const lessonInput = document.querySelector(".create-lesson-input"); const tagSelectors = document.querySelector(".tag-selectors"); - +const error = document.querySelector('.error'); + // handle if no lessons in local storage function handleNoLessons() { if (JSON.parse(localStorage.getItem("user")).lessons.length) { @@ -188,8 +189,8 @@ export function addLesson() { // Regex to match any number of whitespaces in the content form. var regex = /<(.|\n)*?>/g; if (content.replace(regex, "").trim().length === 0) { - alert("Tried to add empty lesson note."); - return; + error.style.visibility = 'visible'; + return; } if (isEditView) { const id = createLessonContainer.getAttribute("view").split(":")[1]; @@ -228,7 +229,8 @@ export function addLesson() { if (submitLessonElement.innerText === "UPDATE LESSON") { submitLessonElement.innerText = "ADD LESSON"; } - } catch { + error.style.visibility = 'hidden'; + } catch { alert("Failed to add lesson. Try again later!"); } }