Changeset 43c9090 for src/main/resources/static/js/editUser.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/editUser.js
r743de55 r43c9090 3 3 import { verificationCheck } from './authentication-shared.js'; 4 4 5 let loggedPerson ;5 let loggedPerson,checkDifferent; 6 6 const modal = document.getElementById('popupModal'); 7 7 const cancelBtn = document.getElementById('cancelBtn'); … … 71 71 counter= user.carriedOut.length; 72 72 } 73 console.log(counter);74 73 return counter; 75 74 } … … 122 121 buttonCell.appendChild(button1); 123 122 button2.textContent = "Потврди одржан"; 124 button 2.addEventListener('click',()=>125 function(){123 buttonCell.appendChild(button2); 124 button2.addEventListener('click',()=> { 126 125 modal.style.display='flex'; 127 approveBtn.addEventListener('click', () => { 128 const userInput = document.getElementById('userInput').value; 129 confirmCarriedOut(request.term,userInput); 130 modal.style.display = 'none'; // Close the modal after approval 131 }); 126 document.getElementById("userInput").disabled=false; 132 127 }); 133 buttonCell.appendChild(button2); 128 approveBtn.addEventListener('click', () => { 129 const userInput = document.getElementById('userInput').value; 130 confirmCarriedOut(request.term,userInput); 131 modal.style.display = 'none'; 132 }); 133 134 134 } 135 135 … … 146 146 if(selectedValue==="requests"){ 147 147 url=`/api/requests/listAll?username=${loggedPerson.username}`; 148 tHeadArray=["Термин", 148 tHeadArray=["Термин","Медицинска состојба","Опции"]; 149 149 createHeader(tHeadArray); 150 150 getAll(url); … … 153 153 let testTemp="RESERVED"; 154 154 url=`/api/appointments/listAll?username=${loggedPerson.username}&status=${testTemp}`; 155 tHeadArray=["Термин", "Опции"];155 tHeadArray=["Термин","Медицинска состојба", "Опции"]; 156 156 createHeader(tHeadArray); 157 157 getAll(url); … … 230 230 .catch(error => { 231 231 console.error('Error fetching user data:', error); 232 return { name: '', surname: '' }; // return empty values on error232 return { name: '', surname: '' }; 233 233 }); 234 234 } … … 267 267 if (cookieUsername) { 268 268 fetchUserData(cookieUsername,"USER").then(userData => { 269 const fullName = `${userData.name} ${userData.surname}`; 270 document.getElementById('cookie-name').innerHTML = fullName; 269 console.log("success") 271 270 }); 272 } else {273 document.getElementById('cookie-name').textContent = 'Default Name';274 271 } 275 272 } … … 277 274 function saveProfileChanges() { 278 275 const userName = document.querySelector('input[name="username"]').value; 279 console.log(userName); 276 const phoneNum=document.querySelector('input[name="phone"]').value.replace(/-/g,"") 277 console.log(phoneNum); 280 278 const updatedData = { 281 279 username: userName, 282 280 name: document.querySelector('input[name="firstName"]').value, 283 281 surname: document.querySelector('input[name="lastName"]').value, 284 phone: document.querySelector('input[name="phone"]').value,282 phone: phoneNum, 285 283 age: document.querySelector('input[name="age"]').value 286 284 }; 287 if(!verificationCheck(updatedData )){285 if(!verificationCheck(updatedData,checkDifferent)){ 288 286 return; 289 287 } … … 299 297 .then(data => { 300 298 alert('Profile updated successfully!'); 301 toggleEditing(false); // Disable fields after saving changes299 toggleEditing(false); 302 300 updateCookieUsername(userName); 303 301 }) … … 313 311 }; 314 312 } 313 function removeOptions(){ 314 if(getRoleFromCookie()!=="ADMIN"){ 315 let temp=this; 316 temp.removeChild(document.getElementById("requests")); 317 temp.removeChild(document.getElementById("appointments")) 318 } 319 } 315 320 316 321 function toggleEditing(isEnabled) { … … 322 327 323 328 window.onload = function(){ 329 checkDifferent=true; 324 330 updateProfile(); 325 331 toggleEditing(false); 326 332 document.getElementById('edit-profile').addEventListener('click', function() { 327 333 const role=getQueryParams(); 328 if(role.param1 ==='ADMIN') 329 toggleEditing(true); 334 if(role.param1 ==='ADMIN'){ 335 toggleEditing(true); 336 checkDifferent=false; 337 } 338 330 339 }); 331 340 document.getElementById('saveChanges').addEventListener('click', saveProfileChanges); 332 341 document.getElementById("statusDropdown").addEventListener('change',createRowsBasedOnType); 333 334 } 342 document.getElementById("statusDropdown").addEventListener('click',removeOptions); 343 }
Note:
See TracChangeset
for help on using the changeset viewer.