Advertisement
VladislavNechepaev

Untitled

Mar 5th, 2021
109
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. jQuery("input[type=\"submit\"]").each((index, elem) => {
  2.         elem.onclick = async function(e){
  3.           if (checkBrowser()) {
  4.             if (!capacityCheckMain || !capacityCheckAdditional || !parkingCheck) {
  5.               e.stopImmediatePropagation()
  6.               e.preventDefault()
  7.               renderController(true)
  8.               alert("Please check the capactiy for selected dates")                     //поменять нотифай если нужно!//  
  9.             }
  10.           } else {
  11.             const mainOffice = fsNative.office.value
  12.             const addLocInfo = JSON.parse(fsNative.addloc.innerHTML)
  13.             console.log(mainOffice, addLocInfo)
  14.             const data = await fetch(`https://freshservicecounter.ringteam.com/v2/getcapacity?office=${JSON.stringify(officeCapacity)}&dates=${selectedDatesGlobal}${parkingActive ? "&getparking=true" : ""}`)
  15.                                    //const data = await fetch(`http://localhost:5000/v2/getcapacity?office=${JSON.stringify(officeCapacity)}&dates=${selectedDatesGlobal}${parkingActive ? "&getparking=true" : ""}`)
  16.             const json = await data.json()
  17.             console.log('GOT DATA ON CHECK')
  18.             console.log(json)
  19.             var immediateCapacityCheck = true
  20.             for (let office in json) {
  21.               for (let date in json[office].capacity) {
  22.                 if (json[office].capacity[date] >= json[office].limit && (office === mainOffice || (addLocInfo[date] && addLocInfo[date].includes(office)))) immediateCapacityCheck = false
  23.               }
  24.             }
  25.             console.log(capacityCheckMain, capacityCheckAdditional, parkingCheck, immediateCapacityCheck)
  26.             if (!capacityCheckMain || !capacityCheckAdditional || !parkingCheck || !immediateCapacityCheck) {
  27.               e.stopImmediatePropagation()
  28.               e.preventDefault()
  29.               renderController(true)
  30.               alert("Please check the capactiy for selected dates")                     //поменять нотифай если нужно!//  
  31.             }
  32.           }
  33.         }
  34.       })
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement