added peopulation of field values based on most recent entry
This commit is contained in:
@@ -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");
|
||||
|
||||
Reference in New Issue
Block a user