added skip add-child for new users to allow for adding a shared child

This commit is contained in:
Brian Bjarke Jensen
2025-11-11 14:39:59 +01:00
parent dea3b5d3b5
commit c745ab1b7a
2 changed files with 45 additions and 2 deletions
+19
View File
@@ -192,6 +192,15 @@
Cancel
</button>
</form>
<div id="skipOption" style="text-align: center; margin-top: 20px; display: none;">
<p style="color: #666; font-size: 14px; margin-bottom: 10px;">
Want to accept a child share invitation first?
</p>
<button type="button" class="button secondary" onclick="skipToHome()" style="margin: 0;">
Skip for now
</button>
</div>
</div>
<script>
@@ -205,11 +214,17 @@
const urlParams = new URLSearchParams(window.location.search);
const childId = urlParams.get("id");
const isEditMode = !!childId;
const fromHome = urlParams.get("from") === "home"; // Check if redirected from home
const form = document.getElementById("addChildForm");
const messageDiv = document.getElementById("message");
const submitBtn = document.getElementById("submitBtn");
// Show skip option if user was redirected from home (has no children)
if (fromHome && !isEditMode) {
document.getElementById("skipOption").style.display = "block";
}
// Update page title and button text if editing
if (isEditMode) {
document.querySelector("h1").textContent = "✏️ Edit Child";
@@ -317,6 +332,10 @@
function goBack() {
window.location.href = "/";
}
function skipToHome() {
window.location.href = "/";
}
</script>
</body>
</html>
+26 -2
View File
@@ -275,9 +275,9 @@
})
.then((response) => response.json())
.then((children) => {
// If no children, redirect to add-child page
// If no children, show welcome message with option to add
if (children.length === 0) {
window.location.href = "/add-child.html";
showNoChildrenMessage();
return;
}
@@ -290,6 +290,30 @@
});
}
function showNoChildrenMessage() {
const content = document.getElementById("content");
content.className = "";
content.innerHTML = `
<h1>👶 Welcome to Baby Monitor</h1>
<div style="text-align: center; padding: 40px 20px;">
<div style="font-size: 64px; margin-bottom: 20px;">🍼</div>
<h2 style="color: #333; margin-bottom: 15px;">No Children Added Yet</h2>
<p style="color: #666; margin-bottom: 30px; line-height: 1.6;">
You can add a child to start tracking or redeem a child share code<br>
from another user to access their child's information.
</p>
<div style="display: flex; gap: 15px; justify-content: center; flex-wrap: wrap;">
<a href="/add-child.html" class="button" style="text-decoration: none; display: inline-block;">
Add Your Child
</a>
<a href="/settings.html" class="button secondary" style="text-decoration: none; display: inline-block;">
🔗 Redeem Share Code
</a>
</div>
</div>
`;
}
let activeFeeding = null;
let userChildren = [];
let lastFeeding = null;