feat: change global role on administration page (#61)

* feat: change global role on administration page

* feat: change global role on administration page test code todo

* feat: change global role on administration page test code

* feat: change global role on administration page

* feat: change global role on administration page

* feat: change global role on administration page

* feat: change global role on administration page

* feat: change global role on administration page
This commit is contained in:
Takeshi Kimata
2024-09-29 20:26:18 +09:00
committed by GitHub
parent d0fcd5e77b
commit f7cc3d918f
13 changed files with 2746 additions and 30 deletions

View File

@@ -47,4 +47,32 @@ async function searchUsers(jwt: string, projectId: number, searchText: string) {
}
}
export { findUser, searchUsers };
async function updateUserRole(jwt: string, userId: number, newRole: number) {
const updateUserData = {
newRole,
};
const fetchOptions = {
method: 'PUT',
headers: {
'Content-Type': 'application/json',
Authorization: `Bearer ${jwt}`,
},
body: JSON.stringify(updateUserData),
};
const url = `${apiServer}/users/${userId}`;
try {
const response = await fetch(url, fetchOptions);
if (!response.ok) {
throw new Error(`HTTP error! Status: ${response.status}`);
}
const data = await response.json();
return data;
} catch (error: any) {
console.error('Error fetching data:', error.message);
}
}
export { findUser, searchUsers, updateUserRole };