Browse Source

appointment creator editor loading current appointment data

Liontix 11 months ago
parent
commit
5f1db3d02d

+ 1 - 1
public/html/appointmentscreator.html

@@ -21,7 +21,7 @@
 </nav>
 <div class="content">
     <div class="container">
-        <h2>Create Appointment</h2>
+        <h2 id="form-title">Create Appointment</h2>
         <div id="appointment-form">
             <div class="input-group">
                 <label for="title">Title</label>

+ 6 - 6
public/javascripts/creator-appointments.js

@@ -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) {