feat: delete user button added to admin page

This commit is contained in:
Timothy J. Baek 2023-12-28 23:12:58 -08:00
parent ad1cb5fc25
commit 7fade0bb2f
2 changed files with 68 additions and 9 deletions

View file

@ -45,8 +45,9 @@ export const getUsers = async (token: string) => {
if (!res.ok) throw await res.json();
return res.json();
})
.catch((error) => {
console.log(error);
.catch((err) => {
console.log(err);
error = err.detail;
return null;
});
@ -56,3 +57,30 @@ export const getUsers = async (token: string) => {
return res ? res : [];
};
export const deleteUserById = async (token: string, userId: string) => {
let error = null;
const res = await fetch(`${WEBUI_API_BASE_URL}/users/${userId}`, {
method: 'DELETE',
headers: {
'Content-Type': 'application/json',
Authorization: `Bearer ${token}`
}
})
.then(async (res) => {
if (!res.ok) throw await res.json();
return res.json();
})
.catch((err) => {
console.log(err);
error = err.detail;
return null;
});
if (error) {
throw error;
}
return res;
};