Skip to content
Snippets Groups Projects
Commit f82a6ebe authored by Hidayatullah Wildan Ghaly Buchary's avatar Hidayatullah Wildan Ghaly Buchary
Browse files

Merge branch 'Achievement-Bug-Fixer' into 'main'

fix: bug when user spamming button

See merge request if3110-2023-01-j/if-3110-2023-01-j!39
parents 4b39ac04 42c2a7fd
Branches
Tags
No related merge requests found
...@@ -106,12 +106,14 @@ if ($page < $pages){ ...@@ -106,12 +106,14 @@ if ($page < $pages){
} }
$paginationButtons .= '</ul>'; $paginationButtons .= '</ul>';
$isAdmin = $_SESSION['isAdmin'];
$response = [ $response = [
'achievementList' => $achievementList, 'achievementList' => $achievementList,
'paginationButtons' => $paginationButtons, 'paginationButtons' => $paginationButtons,
'query1' => $sql1, 'query1' => $sql1,
'query2' => $sql2, 'query2' => $sql2,
'isAdmin' => $isAdmin,
]; ];
......
...@@ -20,7 +20,7 @@ if (!isset($_SESSION['username'])) { ...@@ -20,7 +20,7 @@ if (!isset($_SESSION['username'])) {
<div class="achievement-container"> <div class="achievement-container">
<h1><b>MY-ACHIEVEMENT</b></h1> <h1><b>MY-ACHIEVEMENT</b></h1>
<br> <br>
<button class="btn" onclick="window.location.href='../admin-achievement'"><b>ADMIN</b></button> <button id="btn-admin" class="btn-admin" onclick="window.location.href='../admin-achievement'"><b>ADMIN</b></button>
<button class="btn" onclick="window.location.href='../achievement'"><b>ACHIEVEMENT</b></button> <button class="btn" onclick="window.location.href='../achievement'"><b>ACHIEVEMENT</b></button>
<br><br> <br><br>
<div class="search-container"> <div class="search-container">
......
...@@ -235,6 +235,10 @@ body { ...@@ -235,6 +235,10 @@ body {
background-color: rgb(127, 0, 25); background-color: rgb(127, 0, 25);
} }
.btn-admin {
display: none;
}
button { button {
align-items: center; align-items: center;
appearance: none; appearance: none;
......
...@@ -57,8 +57,8 @@ document.addEventListener('DOMContentLoaded', function () { ...@@ -57,8 +57,8 @@ document.addEventListener('DOMContentLoaded', function () {
const response = JSON.parse(xhr.responseText); const response = JSON.parse(xhr.responseText);
achievementList.innerHTML = response.achievementList; achievementList.innerHTML = response.achievementList;
paginationButtons.innerHTML = response.paginationButtons; paginationButtons.innerHTML = response.paginationButtons;
if (response.isAdmin === "0" || response.isAdmin === 0 || response.isAdmin === false || response.isAdmin === "false" || response.isAdmin === null || response.isAdmin === "null" || response.isAdmin === undefined || response.isAdmin === "undefined") { if (!(response.isAdmin === "0" || response.isAdmin === 0 || response.isAdmin === false || response.isAdmin === "false" || response.isAdmin === null || response.isAdmin === "null" || response.isAdmin === undefined || response.isAdmin === "undefined")) {
document.getElementById("btn-admin").style.display = "none"; document.getElementById("btn-admin").style.display = "inline-flex";
} }
} }
}; };
......
...@@ -55,6 +55,9 @@ document.addEventListener('DOMContentLoaded', function () { ...@@ -55,6 +55,9 @@ document.addEventListener('DOMContentLoaded', function () {
const response = JSON.parse(xhr.responseText); const response = JSON.parse(xhr.responseText);
achievementList.innerHTML = response.achievementList; achievementList.innerHTML = response.achievementList;
paginationButtons.innerHTML = response.paginationButtons; paginationButtons.innerHTML = response.paginationButtons;
if (!(response.isAdmin === "0" || response.isAdmin === 0 || response.isAdmin === false || response.isAdmin === "false" || response.isAdmin === null || response.isAdmin === "null" || response.isAdmin === undefined || response.isAdmin === "undefined")) {
document.getElementById("btn-admin").style.display = "inline-flex";
}
} }
}; };
xhr.send(); xhr.send();
......
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment