var roleUpdate = document.querySelectorAll('.roleUpdate');
for (var i = 0; i < roleUpdate.length; i++) {
roleUpdate[i].addEventListener('click', function () {
var permissionUserId = this.getAttribute('data-user-id');
var permissionCodeId = this.getAttribute('data-role-code');
const requestData = {
UserId: permissionUserId,
RoleId: permissionCodeId
};
//alert(JSON.stringify(requestData));
fetch(`${window.location.origin}/api/users/updaterole`, {
method: 'POST',
headers: {
'Content-Type': 'application/json'
},
body: JSON.stringify(requestData)
})
.then((response) => {
if (response.ok) {
return response.json();
} else {
throw new Error(`Error: ${response.status}`);
}
})
.then((data) => {
toastr.success('Update User Roles Success');
// alert(data.msg);
})
.catch((error) => {
// alert(error.message);
toastr.error('Update Failed');
});
});
}
// User Active Inactive status update
var userStatus = document.getElementById("userStatus");
userStatus.addEventListener('click', function () {
var puserStatusId = this.getAttribute('data-user-id');
alert(puserStatusId);
const requestData = {
UserId: puserStatusId,
};
//alert(JSON.stringify(requestData));
fetch(`${window.location.origin}/api/users/updaterole`, {
method: 'POST',
headers: {
'Content-Type': 'application/json'
},
body: JSON.stringify(requestData)
})
.then((response) => {
if (response.ok) {
return response.json();
} else {
throw new Error(`Error: ${response.status}`);
}
})
.then((data) => {
toastr.success('Update User Status Success');
// alert(data.msg);
})
.catch((error) => {
// alert(error.message);
toastr.error('Update Failed');
});
});
No comments:
Post a Comment