Changeset 43c9090 for src/main/resources/static/js/admin-terms.js
- Timestamp:
- 10/12/24 21:32:15 (5 weeks ago)
- Branches:
- master
- Parents:
- 743de55
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
src/main/resources/static/js/admin-terms.js
r743de55 r43c9090 1 1 import { deleteAppointment, confirmCarriedOut, getUsersByTermExcept, removeRequestAndUpdateUser, removeAppointment, makeReservation ,displayDiv} from './shared.js'; 2 2 3 let lastClickedItem=null; 3 4 let calendar = document.querySelector('.calendar') 4 5 let importantDate; … … 109 110 })); 110 111 111 await fetch(`/api/appointments/create`, {112 const response=await fetch(`/api/appointments/create`, { 112 113 method: 'POST', 113 114 headers: { 114 115 'Content-Type': 'application/json', 115 116 }, 116 body: JSON.stringify(requestBody) // Send all appointments in one request117 body: JSON.stringify(requestBody) 117 118 }); 119 if(response.ok){ 120 location.reload(); 121 } 122 118 123 } 119 124 document.getElementById('create-appointments').addEventListener('click', async function () { … … 124 129 const interval = parseInt(document.getElementById('time-interval').value); 125 130 126 if (!startDate || !endDate || !startTime || !endTime || !interval) {131 if (!startDate || !endDate || !startTime || !endTime || isNaN(interval)) { 127 132 alert("Please fill out all the fields."); 128 133 return; … … 142 147 const existingTimes = existingMapped.get(date); 143 148 if (checkOverlap(existingTimes, time)) { 144 conflictingAppointments.push(newAppointment); // Add to conflict list if overlaps149 conflictingAppointments.push(newAppointment); 145 150 } else { 146 151 successfulAppointments.push(newAppointment); … … 240 245 requestedRow.appendChild(couponCodeTd); 241 246 requestedElement.appendChild(requestedRow); 242 displayDiv(dateTime);243 247 }) 248 displayDiv(dateTime); 244 249 } 245 250 function getAllRequests(dateTime,containerId){ … … 277 282 278 283 itemDiv.addEventListener('click', async () => { 284 document.getElementById("summary").style.display='none'; 279 285 try{ 280 286 if(lastClickedItem){ 287 lastClickedItem.style.backgroundColor="#f9f9f9"; 288 } 289 lastClickedItem=itemDiv; 290 itemDiv.style.backgroundColor="grey"; 281 291 const isReserved=await isAppointmentReserved(item.localDateTime); 282 292 const isEmpty=await isAppointmentEmpty(item.localDateTime); … … 285 295 cleanData("requested") 286 296 if (isReserved) { 297 document.getElementById("summary").style.display='block'; 287 298 document.getElementById("approved-table").style.display = 'block'; 288 299 document.getElementById("requested-table").style.display = 'none'; … … 292 303 deleteBtn.setAttribute("term",item.localDateTime); 293 304 deleteBtn.setAttribute("type","cancelledAppointmentByAdmin"); 294 //da go isprogramirash delete-approval295 305 document.getElementById("delete-approval").addEventListener('click', function() { 296 306 removeAppointment(item.localDateTime,"cancelledAppointmentByAdmin"); … … 307 317 } 308 318 else if(!isEmpty){ 319 document.getElementById("summary").style.display='block'; 309 320 document.getElementById("approved-table").style.display = 'none'; 310 321 document.getElementById("requested-table").style.display = 'block'; … … 316 327 } 317 328 else{ 329 document.getElementById("summary").style.display='none'; 318 330 document.getElementById("approved-table").style.display = 'none'; 319 331 document.getElementById("requested-table").style.display = 'none'; … … 365 377 let currDate = new Date() 366 378 367 // if (!month) month = currDate.getMonth()368 379 console.log(month); 369 380 if (typeof month !== 'number') month = currDate.getMonth(); … … 374 385 calendar_header_year.innerHTML = year 375 386 376 // get first day of month377 387 378 388 let first_day = new Date(year, month, 1) … … 395 405 } 396 406 day.addEventListener('click', () => { 407 document.getElementById("summary").style.display='none'; 397 408 let temp=document.getElementsByClassName('curr-date'); 398 409 Array.from(temp).forEach(element => { … … 458 469 const otherPickersInterval = 30; 459 470 460 for (let hour = 7; hour < 22; hour++) { // 0 to 23 for 24-hour format471 for (let hour = 7; hour < 22; hour++) { 461 472 for (let minutes = 0; minutes < 60; minutes++) { 462 473 const formattedHour = hour.toString().padStart(2, '0'); … … 504 515 .then(data => { 505 516 console.log(data.message); 517 location.reload(); 506 518 }) 507 519 .catch(error => { … … 525 537 if (response.ok) { 526 538 alert("Free appointments for the selected date range were deleted."); 539 location.reload(); 527 540 } else { 528 541 alert("An error occurred while trying to delete the appointments.");
Note:
See TracChangeset
for help on using the changeset viewer.