Skip to content
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

Open
wants to merge 8 commits into
base: truth-redefined-again
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions src/App.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ import PastProgramsPage from "./pages/PastProgramsPage";
import StudentDashboard from "./pages/StudentDashboard";
import RegistrationForm from "./pages/RegistrationForm";
import NotFoundPage from "./pages/404";
import ProjectStats from "./pages/ProjectStat";

function App() {
return (
Expand Down Expand Up @@ -61,6 +62,10 @@ function App() {
path={ROUTER_PATHS.PASTPROGRAMS}
element={<PastProgramsPage />}
/>
<Route
path={ROUTER_PATHS.ALL_PROJECT_STATS}
element={<ProjectStats />}
/>
<Route path="*" element={<NotFoundPage />} />
</Routes>
</AuthProvider>
Expand Down
1 change: 1 addition & 0 deletions src/components/Navbar.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ const LINKS = [
{ name: "PROJECTS", link: ROUTER_PATHS.PROJECTS_LIST },
// { name: "TESTIMONIALS", link: ROUTER_PATHS.TESTIMONIALS },
{ name: "FAQs", link: ROUTER_PATHS.FAQ },
{ name: "PROJECT STATS", link: ROUTER_PATHS.ALL_PROJECT_STATS },
];

function BrandLogo() {
Expand Down
72 changes: 72 additions & 0 deletions src/pages/ProjectStat.tsx
Copy link
Member

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?

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)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
// ... (imports)


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>
Copy link
Member

Choose a reason for hiding this comment

The 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>
Copy link
Member

Choose a reason for hiding this comment

The 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;
12 changes: 12 additions & 0 deletions src/util/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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[];
Copy link
Member

Choose a reason for hiding this comment

The 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;
Expand Down