formatting fixes
Build and Push Docker Image / build-and-push (pull_request) Successful in 58s
Python Code Quality / python-code-quality (pull_request) Successful in 10s
Python Test / python-test (pull_request) Successful in 18s

This commit is contained in:
Brian Bjarke Jensen
2025-11-10 21:19:13 +01:00
parent cd3db4fb86
commit 6c3d301027
6 changed files with 268 additions and 169 deletions
+29 -16
View File
@@ -232,7 +232,11 @@
<button type="submit" class="button" id="submitBtn">
Log Diaper Change
</button>
<button type="button" class="button secondary" onclick="window.location.href='/'">
<button
type="button"
class="button secondary"
onclick="window.location.href='/'"
>
Cancel
</button>
</form>
@@ -252,8 +256,10 @@
// Update UI for edit mode
if (isEditMode) {
document.getElementById("pageTitle").textContent = "🧷 Edit Diaper Change";
document.getElementById("submitBtn").textContent = "Update Diaper Change";
document.getElementById("pageTitle").textContent =
"🧷 Edit Diaper Change";
document.getElementById("submitBtn").textContent =
"Update Diaper Change";
}
let children = [];
@@ -291,7 +297,7 @@
// Load last used child from localStorage
const lastDiaperChange = JSON.parse(
localStorage.getItem("lastDiaperChange") || "{}"
localStorage.getItem("lastDiaperChange") || "{}",
);
if (lastDiaperChange.child_id) {
@@ -311,22 +317,26 @@
// Load diaper change data for editing
async function loadDiaperChangeData() {
try {
const response = await fetch(`/api/diaper-changes/${diaperChangeId}`, {
headers: {
Authorization: `Bearer ${token}`,
const response = await fetch(
`/api/diaper-changes/${diaperChangeId}`,
{
headers: {
Authorization: `Bearer ${token}`,
},
},
});
);
if (response.ok) {
const diaperChange = await response.json();
// Populate form fields
document.getElementById("childSelect").value = diaperChange.child_id;
document.getElementById("childSelect").value =
diaperChange.child_id;
// Convert UTC time to local datetime-local format
const changeTime = new Date(diaperChange.change_time);
changeTime.setMinutes(
changeTime.getMinutes() - changeTime.getTimezoneOffset()
changeTime.getMinutes() - changeTime.getTimezoneOffset(),
);
document.getElementById("changeTime").value = changeTime
.toISOString()
@@ -355,11 +365,14 @@
.addEventListener("submit", async (e) => {
e.preventDefault();
const childId = parseInt(document.getElementById("childSelect").value);
const childId = parseInt(
document.getElementById("childSelect").value,
);
const changeTime = new Date(
document.getElementById("changeTime").value
document.getElementById("changeTime").value,
).toISOString();
const poopAmount = document.getElementById("poopAmount").value || null;
const poopAmount =
document.getElementById("poopAmount").value || null;
const poopColor = document.getElementById("poopColor").value || null;
const peeAmount = document.getElementById("peeAmount").value || null;
const peeColor = document.getElementById("peeColor").value || null;
@@ -407,7 +420,7 @@
"lastDiaperChange",
JSON.stringify({
child_id: childId,
})
}),
);
}
@@ -415,7 +428,7 @@
isEditMode
? "Diaper change updated successfully!"
: "Diaper change logged successfully!",
"success"
"success",
);
setTimeout(() => {
window.location.href = "/";
@@ -424,7 +437,7 @@
const errorData = await response.json();
showMessage(
errorData.detail || "Failed to log diaper change",
"error"
"error",
);
submitBtn.disabled = false;
submitBtn.textContent = isEditMode