feeding type dropdown now defaults to last entry feeding type

This commit is contained in:
Brian Bjarke Jensen
2025-12-03 19:23:26 +01:00
parent 1bac464268
commit fdcfb3c8a5
+15
View File
@@ -303,6 +303,21 @@
// If editing, load the feeding data // If editing, load the feeding data
if (isEditMode) { if (isEditMode) {
loadFeedingData(); 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 { } else {
showMessage("Failed to load children", "error"); showMessage("Failed to load children", "error");