Add username parameter and error alerts in GetOtherUsersReport component
This commit is contained in:
		
							parent
							
								
									a6f3fc4a1c
								
							
						
					
					
						commit
						91bccba871
					
				
					 1 changed files with 19 additions and 10 deletions
				
			
		|  | @ -31,8 +31,9 @@ export default function GetOtherUsersReport(): JSX.Element { | ||||||
|         projectName ?? "", |         projectName ?? "", | ||||||
|         fetchedWeek?.toString() ?? "0", |         fetchedWeek?.toString() ?? "0", | ||||||
|         token, |         token, | ||||||
|  |         username ?? "", | ||||||
|       ); |       ); | ||||||
| 
 |       console.log(response); | ||||||
|       if (response.success) { |       if (response.success) { | ||||||
|         const report: WeeklyReport = response.data ?? { |         const report: WeeklyReport = response.data ?? { | ||||||
|           reportId: 0, |           reportId: 0, | ||||||
|  | @ -62,25 +63,33 @@ export default function GetOtherUsersReport(): JSX.Element { | ||||||
|     void fetchUsersWeeklyReport(); |     void fetchUsersWeeklyReport(); | ||||||
|   }); |   }); | ||||||
| 
 | 
 | ||||||
|   const handleSignWeeklyReport = async (): Promise<void> => { |   const handleSignWeeklyReport = async (): Promise<boolean> => { | ||||||
|     await api.signReport(reportId, token); |     const response = await api.signReport(reportId, token); | ||||||
|  |     if (response.success) { | ||||||
|  |       return true; | ||||||
|  |     } else { | ||||||
|  |       return false; | ||||||
|  |     } | ||||||
|   }; |   }; | ||||||
| 
 | 
 | ||||||
|   const navigate = useNavigate(); |   const navigate = useNavigate(); | ||||||
| 
 | 
 | ||||||
|   return ( |   return ( | ||||||
|     <> |     <> | ||||||
|       <h1 className="text-[30px] font-bold"> |       <h1 className="text-[30px] font-bold"> {username}'s Report</h1> | ||||||
|         {" "} |  | ||||||
|         UserId: {username}'s Report |  | ||||||
|       </h1> |  | ||||||
|       <div className="border-4 border-black bg-white flex flex-col justify-start min-h-[65vh] h-fit w-[50vw] rounded-3xl overflow-scroll space-y-[2vh] p-[30px] items-center"> |       <div className="border-4 border-black bg-white flex flex-col justify-start min-h-[65vh] h-fit w-[50vw] rounded-3xl overflow-scroll space-y-[2vh] p-[30px] items-center"> | ||||||
|         <form |         <form | ||||||
|           onSubmit={(e) => { |           onSubmit={(e) => { | ||||||
|             e.preventDefault(); |             e.preventDefault(); | ||||||
|             void handleSignWeeklyReport(); |             void (async (): Promise<void> => { | ||||||
|  |               const success = await handleSignWeeklyReport(); | ||||||
|  |               if (!success) { | ||||||
|  |                 alert("Failed to sign report!"); | ||||||
|  |                 return; | ||||||
|  |               } | ||||||
|               alert("Report successfully signed!"); |               alert("Report successfully signed!"); | ||||||
|               navigate(-1); |               navigate(-1); | ||||||
|  |             })(); | ||||||
|           }} |           }} | ||||||
|         > |         > | ||||||
|           <div className="flex flex-col items-center"> |           <div className="flex flex-col items-center"> | ||||||
|  |  | ||||||
		Loading…
	
	Add table
		Add a link
		
	
		Reference in a new issue
	
	 Davenludd
						Davenludd