Skip to content

Commit

Permalink
Stop getting user if it doesn't exist
Browse files Browse the repository at this point in the history
  • Loading branch information
Mstiekema authored and Merijn Stiekema committed Dec 12, 2023
1 parent 9b3f11d commit c3b068f
Showing 1 changed file with 8 additions and 2 deletions.
10 changes: 8 additions & 2 deletions admin_board_view/static/AdminBoardView/script.js
Original file line number Diff line number Diff line change
Expand Up @@ -38,8 +38,14 @@ const showUser = document.getElementById("show-user");
if (showUser) {
document.getElementById("show-user").addEventListener("click", e => {
const name = document.getElementById("user").value;
const userId = document.getElementById("userOptions").querySelector(`[value='${name}']`).id;
window.location = `/users/${userId}`;
const user_options = document.getElementById("userOptions");
const selected_user = user_options.querySelector(`[value='${name}']`);
if (!selected_user) {
showToast("Show user - Failed", "User not found");
} else {
const userId = selected_user.id;
window.location = `/users/${userId}`;
}
});
}

Expand Down

0 comments on commit c3b068f

Please sign in to comment.