From 93659a72dc1d708ca7d1624c0882cc9239ca7413 Mon Sep 17 00:00:00 2001 From: Mattias Date: Tue, 2 Apr 2024 17:05:46 +0200 Subject: [PATCH] Add getUnsignedReportsInProject API method --- frontend/src/API/API.ts | 38 ++++++++++++++++++++++++++++++++++++++ 1 file changed, 38 insertions(+) diff --git a/frontend/src/API/API.ts b/frontend/src/API/API.ts index 553f943..aa14183 100644 --- a/frontend/src/API/API.ts +++ b/frontend/src/API/API.ts @@ -159,6 +159,12 @@ interface API { projectName: string, token: string, ): Promise>; + + getUnsignedReportsInProject( + projectName: string, + token: string, + ): Promise>; + /** * Changes the username of a user in the database. * @param {StrNameChange} data The object containing the previous and new username. @@ -664,6 +670,38 @@ export const api: API = { } }, + async getUnsignedReportsInProject( + projectName: string, + token: string, + ): Promise> { + try { + const response = await fetch(`/api/getUnsignedReports/${projectName}`, { + method: "GET", + headers: { + "Content-Type": "application/json", + Authorization: "Bearer " + token, + }, + }); + + if (!response.ok) { + return { + success: false, + message: + "Failed to get unsigned reports for project: Response code " + + response.status, + }; + } else { + const data = (await response.json()) as WeeklyReport[]; + return { success: true, data }; + } + } catch (e) { + return { + success: false, + message: "Failed to get unsigned reports for project, unknown error", + }; + } + }, + async changeUserName( data: StrNameChange, token: string,