diff --git a/src/baby_monitor/static/admin.html b/src/baby_monitor/static/admin.html index acf2843..9088f07 100644 --- a/src/baby_monitor/static/admin.html +++ b/src/baby_monitor/static/admin.html @@ -506,8 +506,8 @@ ID: ${user.id} โ€ข Created: ${new Date(user.created_at).toLocaleDateString()} - ` : ` - `; @@ -547,7 +547,7 @@ // Build diaper card const diaperCard = lastDiaperChange ? ` -
+
๐Ÿงท
Last Diaper
${formatTime(lastDiaperChange.change_time)}
@@ -556,19 +556,19 @@ ${lastDiaperChange.poop_amount && lastDiaperChange.pee_amount ? " โ€ข " : ""} ${lastDiaperChange.pee_amount ? `๐Ÿ’ง ${lastDiaperChange.pee_amount}` : ""}
- + ` : ` -
+
๐Ÿงท
No diaper changes yet
-
+ `; // Build feeding card const feedingCard = lastFeeding ? ` -
+
๐Ÿผ
Last Feeding
${formatTime(lastFeeding.start_time)}
@@ -576,32 +576,32 @@ ${formatFeedingType(lastFeeding.feeding_type)} ${lastFeeding.end_time ? ` โ€ข ${calculateDuration(lastFeeding.start_time, lastFeeding.end_time)}` : " (ongoing)"}
- + ` : ` -
+
๐Ÿผ
No feedings yet
-
+ `; // Build sleep card const sleepCard = lastSleep ? ` -
+
๐Ÿ˜ด
Last Sleep
${formatTime(lastSleep.start_time)}
${lastSleep.end_time ? calculateDuration(lastSleep.start_time, lastSleep.end_time) : "ongoing"}
-
+ ` : ` -
+
๐Ÿ˜ด
No sleep sessions yet
-
+ `; return ` @@ -802,42 +802,7 @@ } function showStartSleepModal() { - const modal = document.getElementById("startSleepModal"); - const childSelect = document.getElementById("modalSleepChildId"); - - // Clear and populate child select or show single child - if (userChildren.length === 1) { - // Single child: replace dropdown with text display - const child = userChildren[0]; - const formGroup = childSelect.parentElement; - formGroup.innerHTML = ` - - - - `; - } else { - // Multiple children: show dropdown - childSelect.innerHTML = ''; - userChildren.forEach((child) => { - const option = document.createElement("option"); - option.value = child.id; - option.textContent = child.name; - childSelect.appendChild(option); - }); - - // Set default based on last sleep - if (lastSleep) { - childSelect.value = lastSleep.child_id; - } - } - - modal.classList.add("show"); + window.location.href = "/log-sleep.html"; } function closeStartSleepModal() { diff --git a/src/baby_monitor/static/log-diaper.html b/src/baby_monitor/static/log-diaper.html index 2b2813a..146a2c1 100644 --- a/src/baby_monitor/static/log-diaper.html +++ b/src/baby_monitor/static/log-diaper.html @@ -336,6 +336,29 @@ lastDiaperChange.child_id; } } + + // Prepopulate poop and pee fields from most recent entry + try { + const response = await fetch("/api/diaper-changes", { + headers: { Authorization: `Bearer ${token}` }, + }); + if (response.ok) { + const changes = await response.json(); + if (changes.length > 0) { + const last = changes[0]; + document.getElementById("poopAmount").value = + last.poop_amount || ""; + document.getElementById("poopColor").value = + last.poop_color || ""; + document.getElementById("peeAmount").value = + last.pee_amount || ""; + document.getElementById("peeColor").value = + last.pee_color || ""; + } + } + } catch (error) { + // Ignore error, just use default + } } } else { showMessage("Failed to load children", "error"); diff --git a/src/baby_monitor/static/log-feeding.html b/src/baby_monitor/static/log-feeding.html index c1a8fb9..05a45ce 100644 --- a/src/baby_monitor/static/log-feeding.html +++ b/src/baby_monitor/static/log-feeding.html @@ -303,6 +303,22 @@ // If editing, load the feeding data if (isEditMode) { loadFeedingData(); + } else { + // Set default feeding type to most recent log entry + try { + const response = await fetch("/api/feedings", { + headers: { Authorization: `Bearer ${token}` }, + }); + if (response.ok) { + const feedings = await response.json(); + if (feedings.length > 0) { + document.getElementById("feedingType").value = + feedings[0].feeding_type; + } + } + } catch (error) { + // Ignore error, just use default + } } } else { showMessage("Failed to load children", "error"); diff --git a/src/baby_monitor/static/sleep.html b/src/baby_monitor/static/sleep.html index 3d33504..31f4174 100644 --- a/src/baby_monitor/static/sleep.html +++ b/src/baby_monitor/static/sleep.html @@ -390,7 +390,7 @@ readonly style="background-color: #f5f5f5; cursor: default; padding: 8px; border: 1px solid #ddd; border-radius: 4px; font-size: 14px;" /> - +