-
Notifications
You must be signed in to change notification settings - Fork 45
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
#195 Issue:Project Stats Page #231
base: truth-redefined-again
Are you sure you want to change the base?
Changes from all commits
85d46c1
1588570
ec47609
219f936
4aebed9
e94b2b7
6df33a4
6e6ef98
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change | ||
---|---|---|---|---|
@@ -0,0 +1,72 @@ | ||||
import { useEffect, useState } from "react"; | ||||
import { makeRequest } from "../util/backend"; | ||||
import { IEndpointTypes } from "../util/types"; | ||||
import { useAuthContext } from "../util/auth"; | ||||
|
||||
// ... (imports) | ||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Suggested change
|
||||
|
||||
function ProjectStats() { | ||||
const authContext = useAuthContext(); | ||||
const [projectStats, setProjectStats] = useState< | ||||
IEndpointTypes["stats/projects"]["response"] | null | ||||
>(null); | ||||
const [error, setError] = useState<string | null>(null); | ||||
|
||||
useEffect(() => { | ||||
makeRequest("stats/projects", "get", null, authContext.jwt) | ||||
.then((response) => { | ||||
if (response.is_ok) { | ||||
setProjectStats(response.response); | ||||
} else { | ||||
setError("Error fetching project stats."); | ||||
console.log(response.response); | ||||
} | ||||
}) | ||||
.catch((e) => { | ||||
setError("Error fetching project stats."); | ||||
console.log(e); | ||||
}); | ||||
}, []); | ||||
|
||||
return ( | ||||
<div className="flex flex-col items-center pt-28"> | ||||
<h1 className="font-display text-5xl md:text-7xl font-bold text-center"> | ||||
Project Stats | ||||
</h1> | ||||
{error !== null ? ( | ||||
<p className="text-center text-red-500">{error}</p> | ||||
) : projectStats !== null ? ( | ||||
<div className="max-w-7xl px-8 py-4"> | ||||
<table className="min-w-full"> | ||||
<thead> | ||||
<tr> | ||||
<th>Project Name</th> | ||||
<th>Repository Link</th> | ||||
<th>Commit Count</th> | ||||
<th>Pull Count</th> | ||||
<th>Lines Added</th> | ||||
<th>Lines Removed</th> | ||||
<th>Languages Used</th> | ||||
</tr> | ||||
</thead> | ||||
<tbody> | ||||
{projectStats.map((project) => ( | ||||
<tr key={project.repo_link}> | ||||
<td>{project.name}</td> | ||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. It would be good to display the name as a link to the repo. |
||||
<td>{project.repo_link}</td> | ||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This field won't be required. |
||||
<td>{project.commit_count}</td> | ||||
<td>{project.pull_count}</td> | ||||
<td>{project.lines_added}</td> | ||||
<td>{project.lines_removed}</td> | ||||
<td>{project.languages_used.join(", ")}</td> | ||||
</tr> | ||||
))} | ||||
</tbody> | ||||
</table> | ||||
</div> | ||||
) : null} | ||||
</div> | ||||
); | ||||
} | ||||
|
||||
export default ProjectStats; |
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -78,6 +78,18 @@ export interface IEndpointTypes { | |
students: IStudentInfo[]; | ||
}; | ||
}; | ||
"stats/projects": { | ||
request: null; | ||
response: { | ||
harshkhandeparkar marked this conversation as resolved.
Show resolved
Hide resolved
|
||
name: string; | ||
repo_link: string; | ||
commit_count: number; | ||
pull_count: number; | ||
lines_added: number; | ||
lines_removed: number; | ||
languages_used: string[]; | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This is not returned by the endpoint. |
||
}[]; | ||
}; | ||
[route: `project/${number}`]: { | ||
request: null; | ||
response: IProject; | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can you rename the file to
ProjectStats.tsx
?