From cab7c3bdfd5281a5bd176e6a8d49a92b4445044e Mon Sep 17 00:00:00 2001 From: Imbus <> Date: Sun, 17 Mar 2024 14:44:25 +0100 Subject: [PATCH] Formatting and typing to make linter happy --- frontend/src/API/API.ts | 49 ++++++++++++++++++++++++++++------------- 1 file changed, 34 insertions(+), 15 deletions(-) diff --git a/frontend/src/API/API.ts b/frontend/src/API/API.ts index ed64f71..2769650 100644 --- a/frontend/src/API/API.ts +++ b/frontend/src/API/API.ts @@ -22,12 +22,17 @@ interface API { token: string, ): Promise>; /** Submit a weekly report */ - submitWeeklyReport(project: NewWeeklyReport, token: string): Promise>; + submitWeeklyReport( + project: NewWeeklyReport, + token: string, + ): Promise>; /** Renew the token */ renewToken(token: string): Promise>; /** Gets all the projects of a user*/ - getUserProjects(username: string, token: string): Promise>; - + getUserProjects( + username: string, + token: string, + ): Promise>; } // Export an instance of the API @@ -55,7 +60,7 @@ export const api: API = { async removeUser( username: string, - token: string + token: string, ): Promise> { try { const response = await fetch("/api/userdelete", { @@ -80,7 +85,7 @@ export const api: API = { async createProject( project: NewProject, - token: string + token: string, ): Promise> { try { const response = await fetch("/api/project", { @@ -135,18 +140,26 @@ export const api: API = { }); if (!response.ok) { - return Promise.resolve({ success: false, message: "Failed to get user projects" }); + return Promise.resolve({ + success: false, + message: "Failed to get user projects", + }); } else { const data = (await response.json()) as Project[]; return Promise.resolve({ success: true, data }); } - } - catch (e) { - return Promise.resolve({ success: false, message: "Failed to get user projects" }); + } catch (e) { + return Promise.resolve({ + success: false, + message: "Failed to get user projects", + }); } }, - - submitWeeklyReport: function (project: NewWeeklyReport, token: string): Promise> { + + submitWeeklyReport: function ( + project: NewWeeklyReport, + token: string, + ): Promise> { try { return fetch("/api/submitWeeklyReport", { method: "POST", @@ -158,16 +171,22 @@ export const api: API = { }) .then((response) => { if (!response.ok) { - return { success: false, message: "Failed to submit weekly report" }; + return { + success: false, + message: "Failed to submit weekly report", + }; } else { return response.json(); } }) - .then((data) => { + .then((data: Project) => { return { success: true, data }; }); } catch (e) { - return Promise.resolve({ success: false, message: "Failed to submit weekly report" }); + return Promise.resolve({ + success: false, + message: "Failed to submit weekly report", + }); } - } + }, };