added child endpoint, ability to add and edit child as well as auto redirect to add-child page when user without child accesses home page
Build and Push Docker Image / build-and-push (pull_request) Successful in 1m5s
Python Code Quality / python-code-quality (pull_request) Successful in 10s
Python Test / python-test (pull_request) Successful in 17s

This commit is contained in:
Brian Bjarke Jensen
2025-11-09 11:54:28 +01:00
parent 1950b600cf
commit 16e7153f5f
10 changed files with 656 additions and 2 deletions
+22 -2
View File
@@ -129,6 +129,7 @@
<div class="menu-backdrop" id="menuBackdrop"></div>
<div class="menu-overlay" id="menuOverlay">
<div class="menu-item" id="menuAddChild">👶 Add Child</div>
<div class="menu-item logout" id="menuLogout">🚪 Logout</div>
</div>
@@ -160,6 +161,10 @@
burgerMenu.addEventListener("click", toggleMenu);
menuBackdrop.addEventListener("click", closeMenu);
document.getElementById("menuAddChild").addEventListener("click", () => {
window.location.href = "/add-child.html";
});
document.getElementById("menuLogout").addEventListener("click", () => {
closeMenu();
logout();
@@ -187,14 +192,29 @@
}
})
.then((user) => {
// Show authenticated content
document.getElementById("content").innerHTML = `
// Check if user has any children
return fetch("/api/children", {
headers: {
Authorization: `Bearer ${token}`,
},
})
.then((response) => response.json())
.then((children) => {
// If no children, redirect to add-child page
if (children.length === 0) {
window.location.href = "/add-child.html";
return;
}
// Show authenticated content
document.getElementById("content").innerHTML = `
<h1>Welcome to Baby Monitor!</h1>
<div class="user-info">
<p><strong>Logged in as:</strong> ${username}</p>
</div>
<p>Your session is active.</p>
`;
});
})
.catch((error) => {
console.error("Error:", error);