From e48bf5d98cdbb468690473a06f0dca364d668a19 Mon Sep 17 00:00:00 2001 From: al8763be Date: Tue, 19 Mar 2024 20:25:26 +0100 Subject: [PATCH] Added checkIfProjectManager, hope it works --- frontend/src/API/API.ts | 30 ++++++++++++++++++++++++++++++ 1 file changed, 30 insertions(+) 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,