Add WeeklyReport type and update getWeeklyReportsForProject method
This commit is contained in:
		
							parent
							
								
									ffaa661628
								
							
						
					
					
						commit
						863a14c316
					
				
					 1 changed files with 12 additions and 6 deletions
				
			
		|  | @ -4,6 +4,7 @@ import { | |||
|   User, | ||||
|   Project, | ||||
|   NewProject, | ||||
|   WeeklyReport, | ||||
| } from "../Types/goTypes"; | ||||
| 
 | ||||
| // This type of pattern should be hard to misuse
 | ||||
|  | @ -49,9 +50,10 @@ interface API { | |||
|     token: string, | ||||
|   ): Promise<APIResponse<NewWeeklyReport>>; | ||||
|   getWeeklyReportsForProject( | ||||
|     username: string, | ||||
|     projectName: string, | ||||
|     token: string, | ||||
|   ): Promise<APIResponse<NewWeeklyReport[]>>; | ||||
|   ): Promise<APIResponse<WeeklyReport[]>>; | ||||
|   /** Gets all the projects of a user*/ | ||||
|   getUserProjects(token: string): Promise<APIResponse<Project[]>>; | ||||
|   /** Gets a project from id*/ | ||||
|  | @ -272,15 +274,19 @@ export const api: API = { | |||
|     } | ||||
|   }, | ||||
| 
 | ||||
|   async getWeeklyReportsForProject(projectName: string, token: string) { | ||||
|   async getWeeklyReportsForProject( | ||||
|     username: string, | ||||
|     projectName: string, | ||||
|     token: string, | ||||
|   ) { | ||||
|     try { | ||||
|       const response = await fetch("/api/getWeeklyReportsForProject", { | ||||
|       const response = await fetch("/api/getWeeklyReportsUser", { | ||||
|         method: "GET", | ||||
|         headers: { | ||||
|           "Content-Type": "application/json", | ||||
|           Authorization: "Bearer " + token, | ||||
|         }, | ||||
|         body: JSON.stringify({ projectName }), | ||||
|         body: JSON.stringify({ username, projectName }), | ||||
|       }); | ||||
| 
 | ||||
|       if (!response.ok) { | ||||
|  | @ -289,13 +295,13 @@ export const api: API = { | |||
|           message: "Failed to get weekly reports for project", | ||||
|         }; | ||||
|       } else { | ||||
|         const data = (await response.json()) as NewWeeklyReport[]; | ||||
|         const data = (await response.json()) as WeeklyReport[]; | ||||
|         return { success: true, data }; | ||||
|       } | ||||
|     } catch (e) { | ||||
|       return { | ||||
|         success: false, | ||||
|         message: "Failed to get weekly reports for project", | ||||
|         message: "fuck", | ||||
|       }; | ||||
|     } | ||||
|   }, | ||||
|  |  | |||
		Loading…
	
	Add table
		Add a link
		
	
		Reference in a new issue
	
	 Davenludd
						Davenludd