diff --git a/frontend/src/API/API.ts b/frontend/src/API/API.ts index 0fc29a0..a1ecfde 100644 --- a/frontend/src/API/API.ts +++ b/frontend/src/API/API.ts @@ -20,6 +20,12 @@ interface API { registerUser(user: NewUser): Promise>; /** Remove a user */ removeUser(username: string, token: string): Promise>; + /** Check if user is project manager */ + checkIfProjectManager( + username: string, + projectName: string, + token: string, + ): Promise>; /** Login */ login(NewUser: NewUser): Promise>; /** Renew the token */ @@ -106,6 +112,30 @@ export const api: API = { } }, + async checkIfProjectManager(token: string): Promise> { + 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,