Skip to content

Commit

Permalink
kao-logic: Properly close loading modal while error happens
Browse files Browse the repository at this point in the history
Signed-off-by: Dicky Herlambang (花) <herlambangdicky5@gmail.com>
  • Loading branch information
Nicklas373 committed May 12, 2024
1 parent 67d7ef7 commit b336cfe
Showing 1 changed file with 6 additions and 1 deletion.
7 changes: 6 additions & 1 deletion resources/js/kao-logic.js
Original file line number Diff line number Diff line change
Expand Up @@ -1061,13 +1061,15 @@ function sendToAPI(files, proc, action) {
`
document.getElementById("scsMsgLink").href = apiUrl+xhrReturn.fileSource
document.getElementById("scsMsgLink").innerText = "Download PDF"
resolve()
} else {
document.getElementById("alert-scs").classList.remove("hidden","opacity-0")
document.getElementById("alert-err").classList.add("hidden","opacity-0")
document.getElementById("scsMsgTitle").innerText = `HANA PDF Process completed !`
document.getElementById("scsMsgResult").innerText = `Download the file or PDF below.`
document.getElementById("scsMsgLink").href = apiUrl+xhrReturn.fileSource
document.getElementById("scsMsgLink").innerText = "Download PDF"
resolve()
}
} else {
document.getElementById("alert-scs").classList.add("hidden","opacity-0")
Expand All @@ -1076,6 +1078,7 @@ function sendToAPI(files, proc, action) {
document.getElementById("errMsg").innerText = xhrReturn.message
document.getElementById("errProcMain").classList.remove("hidden")
document.getElementById("errProcId").innerText = xhrReturn.processId
reject(new Error('API response: '+xhrReturn.errors+' !')) //Force stop loadingModal while return error !
}
} else {
document.getElementById("alert-scs").classList.add("hidden","opacity-0")
Expand All @@ -1084,15 +1087,16 @@ function sendToAPI(files, proc, action) {
document.getElementById("errMsg").innerText = xhrReturn.message
document.getElementById("errProcMain").classList.remove("hidden")
document.getElementById("errProcId").innerText = xhrReturn.processId
reject(new Error('API response: '+xhrReturn.status+' !')) //Force stop loadingModal while return error !
}
resolve()
} else {
document.getElementById("alert-scs").classList.add("hidden","opacity-0")
document.getElementById("alert-err").classList.remove("hidden","opacity-0")
document.getElementById("errMsgTitle").innerText = "HANA PDF Process failed !"
document.getElementById("errMsg").innerText = xhrReturn.message
document.getElementById("errProcMain").classList.remove("hidden")
document.getElementById("errProcId").innerText = xhrReturn.processId
reject(new Error('API response: '+xhr.status+' !')) //Force stop loadingModal while return error !
}
}
} else {
Expand All @@ -1102,6 +1106,7 @@ function sendToAPI(files, proc, action) {
document.getElementById("errMsg").innerText = "There was unexpected error !, please try again later."
document.getElementById("errProcMain").classList.add("hidden")
reject(new Error('API response error !'))
loadingModal.hide() //Force stop loadingModal while return error !
}
}
xhr.send(formData)
Expand Down

0 comments on commit b336cfe

Please sign in to comment.