2022-08-06 21:48:41 +02:00
|
|
|
checkToken();
|
|
|
|
signOut();
|
|
|
|
var id = getQuery("id");
|
|
|
|
|
|
|
|
if(id.length > 0){
|
|
|
|
instance.get("users/"+id, {withCredentials: true})
|
|
|
|
.then(function(response){
|
|
|
|
var listValue = [ "id", "pseudo", "name", "firstName", "email", "birth"];
|
|
|
|
for (var i=0; i<listValue.length; i++){
|
|
|
|
document.getElementById(listValue[i]+"UpdateInput").value=response.data[listValue[i]];
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
var listSelector = ["roles", "status"];
|
|
|
|
for (var i=0; i<listSelector.length; i++){
|
|
|
|
var select = document.getElementById(listSelector[i]+"Selector").querySelectorAll("option");
|
|
|
|
for (var j=0; j<select.length; j++){
|
|
|
|
if(select[j].value == response.data[listSelector[i]]){
|
|
|
|
select[j].setAttribute("selected", true);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
2022-08-06 22:48:00 +02:00
|
|
|
|
|
|
|
var buttonUser = "";
|
|
|
|
switch(response.data.status){
|
|
|
|
case 1:
|
|
|
|
buttonUser = "disableUser";
|
|
|
|
break;
|
|
|
|
case 2:
|
|
|
|
buttonUser = "enableUser";
|
|
|
|
break;
|
|
|
|
case -1:
|
|
|
|
buttonUser = "cancelUser";
|
|
|
|
document.getElementById("removeUser").classList.add("hidden");
|
|
|
|
break;
|
|
|
|
case 0:
|
|
|
|
buttonUser = "enableUser";
|
|
|
|
break;
|
|
|
|
default:
|
|
|
|
break;
|
|
|
|
|
|
|
|
}
|
|
|
|
if(buttonUser.length > 0){
|
|
|
|
console.log(disableUser);
|
|
|
|
document.getElementById(buttonUser).classList.remove("hidden");
|
|
|
|
}
|
2022-08-06 21:48:41 +02:00
|
|
|
|
|
|
|
})
|
|
|
|
.catch(function(error){
|
|
|
|
console.log(error);
|
|
|
|
|
|
|
|
});
|
|
|
|
}
|