feeding type dropdown now defaults to last entry feeding type
This commit is contained in:
@@ -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");
|
||||||
|
|||||||
Reference in New Issue
Block a user