From f908a66c77f33408c26bc2a0e1f0e0b757cd894a Mon Sep 17 00:00:00 2001 From: Chetna Singh Date: Fri, 25 Jul 2025 13:26:05 +0530 Subject: [PATCH 1/2] Added UserProfile component and integrated it with contributor PR links --- src/pages/UserProfile/UserProfile.tsx | 57 +++++++++++++++++++++++++++ 1 file changed, 57 insertions(+) create mode 100644 src/pages/UserProfile/UserProfile.tsx diff --git a/src/pages/UserProfile/UserProfile.tsx b/src/pages/UserProfile/UserProfile.tsx new file mode 100644 index 0000000..abf9791 --- /dev/null +++ b/src/pages/UserProfile/UserProfile.tsx @@ -0,0 +1,57 @@ +import { useParams } from "react-router-dom"; +import { useEffect, useState } from "react"; + +type PR = { + title: string; + html_url: string; + repository_url: string; +}; + +export default function UserProfile() { + const { username } = useParams(); + const [profile, setProfile] = useState(null); + const [prs, setPRs] = useState([]); + const [loading, setLoading] = useState(true); + + useEffect(() => { + async function fetchData() { + if (!username) return; + + const userRes = await fetch(`https://api.github.com/users/${username}`); + const userData = await userRes.json(); + setProfile(userData); + + const prsRes = await fetch(`https://api.github.com/search/issues?q=author:${username}+type:pr`); + const prsData = await prsRes.json(); + setPRs(prsData.items); + setLoading(false); + } + + fetchData(); + }, [username]); + + if (loading) return
Loading...
; + + return ( +
+ {profile && ( +
+ +

{profile.login}

+

{profile.bio}

+
+ )} + +

Pull Requests

+ +
+ ); +} From 6c76aeafb928f5632e69bde143b84b903f67b37d Mon Sep 17 00:00:00 2001 From: Chetna Singh Date: Fri, 25 Jul 2025 13:27:57 +0530 Subject: [PATCH 2/2] Linked UserProfile in routing and added navigation from Contributors section --- src/App.tsx | 1 - src/Routes/Router.tsx | 3 +- src/pages/Contributors/Contributors.tsx | 135 +++++++++++++----------- 3 files changed, 74 insertions(+), 65 deletions(-) diff --git a/src/App.tsx b/src/App.tsx index a49da65..e9adacf 100644 --- a/src/App.tsx +++ b/src/App.tsx @@ -1,4 +1,3 @@ - import Navbar from "./components/Navbar"; import Footer from "./components/Footer"; import ScrollProgressBar from './components/ScrollProgressBar'; diff --git a/src/Routes/Router.tsx b/src/Routes/Router.tsx index b6bce37..007d11d 100644 --- a/src/Routes/Router.tsx +++ b/src/Routes/Router.tsx @@ -6,7 +6,7 @@ import Contact from "../pages/Contact/Contact"; // Import the Contact component import Contributors from "../pages/Contributors/Contributors"; import Signup from "../pages/Signup/Signup.tsx"; import Login from "../pages/Login/Login.tsx"; - +import UserProfile from "../pages/UserProfile/UserProfile.tsx"; const Router = () => { return ( @@ -19,6 +19,7 @@ const Router = () => { } /> } /> } /> + } /> ); }; diff --git a/src/pages/Contributors/Contributors.tsx b/src/pages/Contributors/Contributors.tsx index c72de46..ab9de23 100644 --- a/src/pages/Contributors/Contributors.tsx +++ b/src/pages/Contributors/Contributors.tsx @@ -13,6 +13,7 @@ import { } from "@mui/material"; import { FaGithub } from "react-icons/fa"; import axios from "axios"; +import { Link } from "react-router-dom"; // ✅ Added interface Contributor { id: number; @@ -30,7 +31,8 @@ const ContributorsPage = () => { useEffect(() => { const fetchContributors = async () => { try { - const response = await axios.get("https://api.github.com/repos/GitMetricsLab/github_tracker/contributors", + const response = await axios.get( + "https://api.github.com/repos/GitMetricsLab/github_tracker/contributors", { withCredentials: false } ); setContributors(response.data); @@ -84,76 +86,83 @@ const ContributorsPage = () => { {contributors.map((contributor) => ( - - - - + - {contributor.login} - - - {contributor.contributions} Contributions - - - Thank you for your valuable contributions! - - - - - - + {contributor.login} + + + {contributor.contributions} Contributions + + + Thank you for your valuable contributions! + + + + + + + ))}