|
|
@@ -17,6 +17,8 @@ window.addEventListener("load", async function() {
|
|
|
if (appointment) {
|
|
|
// load appointment data
|
|
|
await loadAppointment(appointment);
|
|
|
+ document.getElementById("appointment-btn").innerText = "Edit Appointment";
|
|
|
+ document.getElementById("form-title").innerText = "Edit Appointment";
|
|
|
}
|
|
|
|
|
|
document.getElementById("appointment-btn").addEventListener('click', async () => {
|
|
|
@@ -24,6 +26,7 @@ window.addEventListener("load", async function() {
|
|
|
await createAppointment();
|
|
|
} else {
|
|
|
// modify appointment
|
|
|
+ // TODO Add a modify appointment function
|
|
|
}
|
|
|
})
|
|
|
console.log(titleInput.value);
|
|
|
@@ -40,13 +43,10 @@ async function fetchWithToken(url, options) {
|
|
|
async function displayAppointment(data) {
|
|
|
titleInput.value = data.title;
|
|
|
descriptionInput.value = data.description;
|
|
|
- dueDateInput.value = data.dueDate;
|
|
|
- startDateInput.value = data.startDate;
|
|
|
- endDateInput.value = data.endDate;
|
|
|
+ dueDateInput.value = new Date(data.dueDate).toISOString().split('T')[0];
|
|
|
+ startDateInput.value = new Date(data.startDate).toISOString().slice(0, 16);
|
|
|
+ endDateInput.value = new Date(data.endDate).toISOString().slice(0, 16);
|
|
|
placeInput.value = data.place;
|
|
|
- console.log(data.dueDate);
|
|
|
- console.log(data.startDate);
|
|
|
- console.log(data.endDate);
|
|
|
}
|
|
|
|
|
|
async function loadAppointment(appointment) {
|