Added checkIfProjectManager, hope it works

This commit is contained in:
al8763be 2024-03-19 20:25:26 +01:00
parent 382ea38558
commit e48bf5d98c

View file

@ -20,6 +20,12 @@ interface API {
registerUser(user: NewUser): Promise<APIResponse<User>>;
/** Remove a user */
removeUser(username: string, token: string): Promise<APIResponse<User>>;
/** Check if user is project manager */
checkIfProjectManager(
username: string,
projectName: string,
token: string,
): Promise<APIResponse<boolean>>;
/** Login */
login(NewUser: NewUser): Promise<APIResponse<string>>;
/** Renew the token */
@ -106,6 +112,30 @@ export const api: API = {
}
},
async checkIfProjectManager(token: string): Promise<APIResponse<boolean>> {
try {
const response = await fetch("/api/checkIfProjectManager", {
method: "GET",
headers: {
"Content-Type": "application/json",
Authorization: "Bearer " + token,
},
});
if (!response.ok) {
return {
success: false,
message: "Failed to check if project manager",
};
} else {
const data = (await response.json()) as boolean;
return { success: true, data };
}
} catch (e) {
return { success: false, message: "fuck" };
}
},
async createProject(
project: NewProject,
token: string,