Before fuck up
This commit is contained in:
		
							parent
							
								
									2b41085865
								
							
						
					
					
						commit
						74285dc1cf
					
				
					 1 changed files with 33 additions and 0 deletions
				
			
		|  | @ -24,6 +24,7 @@ interface API { | |||
|   login(NewUser: NewUser): Promise<APIResponse<string>>; | ||||
|   /** Renew the token */ | ||||
|   renewToken(token: string): Promise<APIResponse<string>>; | ||||
|   /** Promote user to admin */ | ||||
|   /** Create a project */ | ||||
|   createProject( | ||||
|     project: NewProject, | ||||
|  | @ -41,6 +42,10 @@ interface API { | |||
|     week: string, | ||||
|     token: string, | ||||
|   ): Promise<APIResponse<NewWeeklyReport>>; | ||||
|   getWeeklyReportsForProject( | ||||
|     projectName: string, | ||||
|     token: string, | ||||
|   ): Promise<APIResponse<NewWeeklyReport[]>>; | ||||
|   /** Gets all the projects of a user*/ | ||||
|   getUserProjects(token: string): Promise<APIResponse<Project[]>>; | ||||
|   /** Gets a project from id*/ | ||||
|  | @ -232,6 +237,34 @@ export const api: API = { | |||
|     } | ||||
|   }, | ||||
| 
 | ||||
|   async getWeeklyReportsForProject(projectName: string, token: string) { | ||||
|     try { | ||||
|       const response = await fetch("/api/getWeeklyReportsForProject", { | ||||
|         method: "GET", | ||||
|         headers: { | ||||
|           "Content-Type": "application/json", | ||||
|           Authorization: "Bearer " + token, | ||||
|         }, | ||||
|         body: JSON.stringify({ projectName }), | ||||
|       }); | ||||
| 
 | ||||
|       if (!response.ok) { | ||||
|         return { | ||||
|           success: false, | ||||
|           message: "Failed to get weekly reports for project", | ||||
|         }; | ||||
|       } else { | ||||
|         const data = (await response.json()) as NewWeeklyReport[]; | ||||
|         return { success: true, data }; | ||||
|       } | ||||
|     } catch (e) { | ||||
|       return { | ||||
|         success: false, | ||||
|         message: "Failed to get weekly reports for project", | ||||
|       }; | ||||
|     } | ||||
|   }, | ||||
| 
 | ||||
|   async login(NewUser: NewUser): Promise<APIResponse<string>> { | ||||
|     try { | ||||
|       const response = await fetch("/api/login", { | ||||
|  |  | |||
		Loading…
	
	Add table
		Add a link
		
	
		Reference in a new issue
	
	 al8763be
						al8763be