Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- if (capacityActive === true) {
- const selectedDates = dateList.map(x => x.value).filter(x => !!x)
- if (officeCapacity.includes(values.office) && selectedDates.length && JSON.stringify(selectedDates) !== selectedDatesGlobal) {
- fetch(`https://freshservicecounter.ringteam.com/getcapacity?office=${values.office}&dates=${JSON.stringify(selectedDates)}`)
- .then(res => {
- return res.json()
- })
- .then(res => {
- console.log(res)
- capacityDisplay.innerHTML = ""
- const office = document.createElement("div")
- office.innerHTML = `<b>Office:</b> ${res.office}`
- const limit = document.createElement("div")
- limit.innerHTML = `<b>Limit:</b> ${res.limit}`
- limit.style.borderBottom = "1px dotted grey"
- capacityDisplay.appendChild(office)
- capacityDisplay.appendChild(limit)
- var capacityDataArray = []
- for (let date in res.capacity) {
- capacityDataArray.push({ date: date, capacity: res.capacity[date] })
- }
- capacityDataArray.sort((x,y) => { return x.date > y.date ? 1 : -1 })
- console.log(capacityDataArray)
- capacityDataArray.forEach(obj => {
- const dateElem = document.createElement("div")
- dateElem.innerHTML = `<b>${obj.date}:</b> ${obj.capacity}`
- capacityDisplay.appendChild(dateElem)
- })
- capacityDisplay.hidden = false
- })
- } else {
- //capacityDisplay.innerHTML = ""
- if (!officeCapacity.includes(values.office)) capacityDisplay.hidden = true
- }
- selectedDatesGlobal = JSON.stringify(selectedDates)
- }
Add Comment
Please, Sign In to add comment