formatting fixes
This commit is contained in:
@@ -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
|
||||
|
||||
Reference in New Issue
Block a user