2024-08-23 12:26:12 +00:00
|
|
|
export function showUsers(api) {
|
|
|
|
const tbody = document.getElementById("user-table").getElementsByTagName("tbody")[0];
|
|
|
|
const token = localStorage.getItem("token");
|
|
|
|
|
|
|
|
const requestOptions = {
|
|
|
|
method: 'post',
|
|
|
|
headers: {
|
|
|
|
'Accept': `application/json`,
|
|
|
|
'Content-Type': 'application/json',
|
|
|
|
'Authorization': 'Bearer ' + token,
|
|
|
|
},
|
|
|
|
};
|
|
|
|
|
|
|
|
fetch(api + "/api/admin/all-users", requestOptions)
|
|
|
|
.then(response => response.json())
|
|
|
|
.then(function (data) {
|
|
|
|
if (data) {
|
|
|
|
data.forEach(i => {
|
|
|
|
let newRow = tbody.insertRow();
|
|
|
|
let newCell = newRow.insertCell();
|
|
|
|
|
|
|
|
newCell.innerHTML = `<a href="/admin/all-users/${i.id}">${i.last_name}, ${i.first_name}</a>`;
|
|
|
|
|
|
|
|
newCell = newRow.insertCell();
|
|
|
|
let item = document.createTextNode(i.email);
|
|
|
|
newCell.appendChild(item);
|
|
|
|
});
|
|
|
|
} else {
|
|
|
|
let newRow = tbody.insertRow();
|
|
|
|
let newCell = newRow.insertCell();
|
|
|
|
newCell.setAttribute("colspan", "2");
|
|
|
|
newCell.innerHTML = "no data available";
|
|
|
|
}
|
|
|
|
});
|
|
|
|
}
|
2024-08-23 19:07:13 +00:00
|
|
|
|
|
|
|
export function showUser(api) {
|
|
|
|
const token = localStorage.getItem("token");
|
|
|
|
let id = window.location.pathname.split("/").pop();
|
|
|
|
|
|
|
|
const requestOptions = {
|
|
|
|
method: 'post',
|
|
|
|
headers: {
|
|
|
|
'Accept': `application/json`,
|
|
|
|
'Content-Type': 'application/json',
|
|
|
|
'Authorization': 'Bearer ' + token,
|
|
|
|
},
|
|
|
|
};
|
|
|
|
|
|
|
|
fetch(api + `/api/admin/all-users/${id}`, requestOptions)
|
|
|
|
.then(response => response.json())
|
|
|
|
.then(function (data) {
|
|
|
|
console.log(data);
|
|
|
|
});
|
|
|
|
|
|
|
|
}
|