From 95c2bf67448c14182aa2945cfdd8d5514281a5b3 Mon Sep 17 00:00:00 2001 From: Brian Bjarke Jensen Date: Wed, 3 Dec 2025 19:45:03 +0100 Subject: [PATCH] added peopulation of field values based on most recent entry --- src/baby_monitor/static/log-diaper.html | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+) diff --git a/src/baby_monitor/static/log-diaper.html b/src/baby_monitor/static/log-diaper.html index 2b2813a..55c013d 100644 --- a/src/baby_monitor/static/log-diaper.html +++ b/src/baby_monitor/static/log-diaper.html @@ -336,6 +336,25 @@ 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");