Skip to content

Commit

Permalink
Improve user modal error alert
Browse files Browse the repository at this point in the history
  • Loading branch information
leepeuker committed Apr 12, 2023
1 parent f1f0f72 commit d8c667c
Showing 1 changed file with 7 additions and 7 deletions.
14 changes: 7 additions & 7 deletions public/js/settings-users.js
Original file line number Diff line number Diff line change
Expand Up @@ -139,8 +139,7 @@ document.getElementById('createUserButton').addEventListener('click', async () =
})

if (response.status !== 200) {
document.getElementById('userModalAlerts').innerHTML = '<div class="alert alert-danger" role="alert">Server error.</div>'

setUserModalAlertServerError()
return
}

Expand All @@ -150,6 +149,10 @@ document.getElementById('createUserButton').addEventListener('click', async () =
userModal.hide()
})

function setUserModalAlertServerError() {
document.getElementById('userModalAlerts').innerHTML = '<div class="alert alert-danger alert-dismissible" role="alert">Server error, please try again.<button type="button" class="btn-close" data-bs-dismiss="alert" aria-label="Close"></button></div>'
}

document.getElementById('updateUserButton').addEventListener('click', async () => {
if (validateCreateUserInput() === true) {
return;
Expand All @@ -174,12 +177,10 @@ document.getElementById('updateUserButton').addEventListener('click', async () =
})

if (response.status !== 200) {
document.getElementById('userModalAlerts').innerHTML = '<div class="alert alert-danger" role="alert">Server error.</div>'

setUserModalAlertServerError()
return
}


setUserManagementAlert('User was updated: ' + document.getElementById('userModalNameInput').value)

reloadTable()
Expand All @@ -196,8 +197,7 @@ document.getElementById('deleteUserButton').addEventListener('click', async () =
});

if (response.status !== 200) {
document.getElementById('userModalAlerts').innerHTML = '<div class="alert alert-danger" role="alert">Server error.</div>'

setUserModalAlertServerError()
return
}

Expand Down

0 comments on commit d8c667c

Please sign in to comment.