forked from v4l3n71n/covas-bo
add function disable, cancel removing and remove user
This commit is contained in:
parent
39010a92f3
commit
d58f386aae
@ -41,13 +41,55 @@ if(id.length > 0){
|
||||
|
||||
}
|
||||
if(buttonUser.length > 0){
|
||||
console.log(disableUser);
|
||||
document.getElementById(buttonUser).classList.remove("hidden");
|
||||
}
|
||||
|
||||
var listModalButton = ["disable", "enable", "cancel", "remove"];
|
||||
|
||||
for (var i=0; i<listModalButton.length; i++){
|
||||
document.getElementById(listModalButton[i]+"UserButton").addEventListener("click", function(e){
|
||||
var httpMethod = ""
|
||||
var httpUrl = "";
|
||||
var idInput = document.getElementById("idUpdateInput").value;
|
||||
switch(e.currentTarget.id){
|
||||
case "disableUserButton":
|
||||
httpMethod = "delete";
|
||||
httpUrl = "users/disable/"+idInput;
|
||||
break;
|
||||
case "removeUserButton":
|
||||
httpMethod = "delete";
|
||||
httpUrl = "users/"+idInput;
|
||||
break;
|
||||
default:
|
||||
httpMethod = "patch";
|
||||
httpUrl = "users/enable/"+idInput;
|
||||
break;
|
||||
}
|
||||
instance({
|
||||
method: httpMethod,
|
||||
url: httpUrl,
|
||||
withCredentials: true
|
||||
})
|
||||
.then(function(response){
|
||||
if(response.status == 200){
|
||||
location.href="/html/user.html?id="+idInput;
|
||||
}
|
||||
})
|
||||
.catch(function(error){
|
||||
console.log(error);
|
||||
});
|
||||
|
||||
});
|
||||
}
|
||||
|
||||
|
||||
})
|
||||
.catch(function(error){
|
||||
console.log(error);
|
||||
|
||||
});
|
||||
|
||||
|
||||
|
||||
|
||||
}
|
Loading…
x
Reference in New Issue
Block a user