Formatting and typing to make linter happy
This commit is contained in:
		
							parent
							
								
									8d0da111eb
								
							
						
					
					
						commit
						cab7c3bdfd
					
				
					 1 changed files with 34 additions and 15 deletions
				
			
		|  | @ -22,12 +22,17 @@ interface API { | |||
|     token: string, | ||||
|   ): Promise<APIResponse<Project>>; | ||||
|   /** Submit a weekly report */ | ||||
|   submitWeeklyReport(project: NewWeeklyReport, token: string): Promise<APIResponse<Project>>; | ||||
|   submitWeeklyReport( | ||||
|     project: NewWeeklyReport, | ||||
|     token: string, | ||||
|   ): Promise<APIResponse<Project>>; | ||||
|   /** Renew the token */ | ||||
|   renewToken(token: string): Promise<APIResponse<string>>; | ||||
|   /** Gets all the projects of a user*/ | ||||
|   getUserProjects(username: string, token: string): Promise<APIResponse<Project[]>>; | ||||
|    | ||||
|   getUserProjects( | ||||
|     username: string, | ||||
|     token: string, | ||||
|   ): Promise<APIResponse<Project[]>>; | ||||
| } | ||||
| 
 | ||||
| // Export an instance of the API
 | ||||
|  | @ -55,7 +60,7 @@ export const api: API = { | |||
| 
 | ||||
|   async removeUser( | ||||
|     username: string, | ||||
|     token: string | ||||
|     token: string, | ||||
|   ): Promise<APIResponse<User>> { | ||||
|     try { | ||||
|       const response = await fetch("/api/userdelete", { | ||||
|  | @ -80,7 +85,7 @@ export const api: API = { | |||
| 
 | ||||
|   async createProject( | ||||
|     project: NewProject, | ||||
|     token: string | ||||
|     token: string, | ||||
|   ): Promise<APIResponse<Project>> { | ||||
|     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<APIResponse<Project>> { | ||||
| 
 | ||||
|   submitWeeklyReport: function ( | ||||
|     project: NewWeeklyReport, | ||||
|     token: string, | ||||
|   ): Promise<APIResponse<Project>> { | ||||
|     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", | ||||
|       }); | ||||
|     } | ||||
|   } | ||||
|   }, | ||||
| }; | ||||
|  |  | |||
		Loading…
	
	Add table
		Add a link
		
	
		Reference in a new issue
	
	 Imbus
						Imbus